(git:3d5d2e5)
Loading...
Searching...
No Matches
upf_core.F
Go to the documentation of this file.
1!--------------------------------------------------------------------------------------------------!
2! CP2K: A general program to perform molecular dynamics simulations !
3! Copyright 2000-2026 CP2K developers group <https://cp2k.org> !
4! !
5! SPDX-License-Identifier: GPL-2.0-or-later !
6!--------------------------------------------------------------------------------------------------!
7!> \brief Fourier coefficients and geometry derivatives of the original UPF partial core density.
8MODULE upf_core
9 USE bessel_lib, ONLY: bessel0
10 USE kinds, ONLY: dp
11 USE mathconstants, ONLY: fourpi
12 USE upf_types, ONLY: atom_upfpot_type,&
14#include "../base/base_uses.f90"
15
16 IMPLICIT NONE
17 PRIVATE
18 PUBLIC :: upf_core_fourier
19
20CONTAINS
21
22! **************************************************************************************************
23!> \brief Integrate the supplied true spherical density with the original radial quadrature.
24!> The finite tabulated integration domain is retained, including its endpoint rule.
25!> This field contributes to XC only, not the valence charge or orbital metric.
26!> \param pot Original scalar UPF dataset.
27!> \param gvecs Native reciprocal vectors in Cartesian inverse bohr.
28!> \param position Physical atom position in bohr.
29!> \param volume Physical cell volume in cubic bohr.
30!> \param density Fourier density coefficients, including 1/volume.
31!> \param dposition Optional Cartesian center derivatives, axis first.
32!> \param dg Optional reciprocal-vector derivatives at fixed center and volume, axis first.
33! **************************************************************************************************
34 SUBROUTINE upf_core_fourier(pot, gvecs, position, volume, density, dposition, dg)
35 TYPE(atom_upfpot_type), INTENT(IN) :: pot
36 REAL(dp), INTENT(IN) :: gvecs(:, :), position(3), volume
37 COMPLEX(dp), INTENT(OUT) :: density(:)
38 COMPLEX(dp), INTENT(OUT), OPTIONAL :: dposition(:, :), dg(:, :)
39
40 COMPLEX(dp) :: phase
41 INTEGER :: ig, nr
42 REAL(dp) :: norm_g, radial, slope
43 REAL(dp), ALLOCATABLE :: weighted(:)
44
45 cpassert(volume > 0.0_dp)
46 cpassert(SIZE(gvecs, 1) == 3 .AND. SIZE(gvecs, 2) == SIZE(density))
47 IF (PRESENT(dposition)) THEN
48 cpassert(all(shape(dposition) == shape(gvecs)))
49 END IF
50 IF (PRESENT(dg)) THEN
51 cpassert(all(shape(dg) == shape(gvecs)))
52 END IF
53 density = cmplx(0.0_dp, 0.0_dp, dp)
54 IF (PRESENT(dposition)) dposition = cmplx(0.0_dp, 0.0_dp, dp)
55 IF (PRESENT(dg)) dg = cmplx(0.0_dp, 0.0_dp, dp)
56 IF (.NOT. pot%core_correction) RETURN
57 cpassert(ALLOCATED(pot%rho_nlcc))
58 nr = SIZE(pot%r)
59 cpassert(SIZE(pot%rho_nlcc) == nr)
60 ALLOCATE (weighted(nr))
61 weighted(:) = fourpi*upf_radial_weights(pot)*pot%r**2*pot%rho_nlcc
62 ! Form weights before omitting an exact zero suffix.
63 DO WHILE (nr > 0)
64 IF (weighted(nr) /= 0.0_dp) EXIT
65 nr = nr - 1
66 END DO
67 IF (nr == 0) RETURN
68 DO ig = 1, SIZE(density)
69 norm_g = sqrt(sum(gvecs(:, ig)**2))
70 phase = exp(cmplx(0.0_dp, -dot_product(gvecs(:, ig), position), dp))/volume
71 radial = sum(weighted(:nr)*bessel0(norm_g*pot%r(:nr), 0))
72 density(ig) = phase*radial
73 IF (PRESENT(dposition)) dposition(:, ig) = cmplx(0.0_dp, -gvecs(:, ig), dp)*density(ig)
74 IF (PRESENT(dg)) THEN
75 dg(:, ig) = cmplx(0.0_dp, -position, dp)*density(ig)
76 IF (norm_g > 0.0_dp) THEN
77 slope = -sum(weighted(:nr)*pot%r(:nr)*bessel0(norm_g*pot%r(:nr), 1))
78 dg(:, ig) = dg(:, ig) + phase*slope*gvecs(:, ig)/norm_g
79 END IF
80 END IF
81 END DO
82 END SUBROUTINE upf_core_fourier
83
84END MODULE upf_core
Calculates Bessel functions.
Definition bessel_lib.F:16
elemental impure real(kind=dp) function, public bessel0(x, l)
...
Definition bessel_lib.F:161
Defines the basic variable types.
Definition kinds.F:23
integer, parameter, public dp
Definition kinds.F:34
Definition of mathematical constants and functions.
real(kind=dp), parameter, public fourpi
Fourier coefficients and geometry derivatives of the original UPF partial core density.
Definition upf_core.F:8
subroutine, public upf_core_fourier(pot, gvecs, position, volume, density, dposition, dg)
Integrate the supplied true spherical density with the original radial quadrature....
Definition upf_core.F:35
Owned UPF dataset and radial conventions shared by ATOM and Quickstep. Dataset availability does not ...
Definition upf_types.F:12
real(dp) function, dimension(size(pot%r)), public upf_radial_weights(pot)
Composite Simpson weights for dr on the supplied UPF mesh index.
Definition upf_types.F:189