36 REAL(
dp),
INTENT(IN) :: gvecs(:, :), position(3), volume
37 COMPLEX(dp),
INTENT(OUT) :: density(:)
38 COMPLEX(dp),
INTENT(OUT),
OPTIONAL :: dposition(:, :), dg(:, :)
42 REAL(
dp) :: norm_g, radial, slope
43 REAL(
dp),
ALLOCATABLE :: weighted(:)
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)))
51 cpassert(all(shape(dg) == shape(gvecs)))
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))
59 cpassert(
SIZE(pot%rho_nlcc) == nr)
60 ALLOCATE (weighted(nr))
64 IF (weighted(nr) /= 0.0_dp)
EXIT
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)
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
subroutine, public upf_core_fourier(pot, gvecs, position, volume, density, dposition, dg)
Integrate the supplied true spherical density with the original radial quadrature....