27 real(8),
allocatable :: &
28 & Vks(:), & !< (g_rh%nr) Kohn-Sham potential [Htr]
29 & Vps(:), & !< (g_rh%nr) Pseudopotential [Htr]
30 & rho(:) !< (g_rh%nr) Charge density
61 integer :: jtyp, iat, nat2, ipw
62 real(8) :: prod(nat), pos2(3,nat), gv(3), ctail, glen, dr, &
64 complex(8) :: strfac(g_rh%nr), VpsG(g_rh%nr)
65 real(8),
allocatable :: sinc(:)
67 vpsg(1:g_rh%nr) = 0.0d0
75 if(
atm(iat)%ityp == jtyp)
then
77 pos2(1:3,nat2) =
atm(iat)%pos(1:3)
82 prod(1:nat2) = matmul(dble(g_rh%mill(1:3,ipw)),pos2(1:3,1:nat2))
83 strfac(ipw) = sum(exp(cmplx(0.0d0, - 2.0d0 *
pi * prod(1:nat2), 8)))
85 strfac(1:g_rh%nr) = strfac(1:g_rh%nr) /
vcell
89 allocate(sinc(
spec(jtyp)%mmax))
90 dr =
spec(jtyp)%psr(
spec(jtyp)%mmax) / dble(
spec(jtyp)%mmax - 1)
94 ctail = 0.5d0 *
spec(jtyp)%Zion *
spec(jtyp)%psr(
spec(jtyp)%mmax)**2
96 sinc(1:
spec(jtyp)%mmax) = dr
98 sinc(
spec(jtyp)%mmax) = dr * 0.5d0
100 frmfac(1) = sum( sinc(1:
spec(jtyp)%mmax) &
101 & *
spec(jtyp)%psr(1:
spec(jtyp)%mmax)**2 &
102 & *
spec(jtyp)%psV(1:
spec(jtyp)%mmax)) &
104 frmfac(1) = 4.0d0 *
pi * frmfac(1)
110 gv(1:3) = matmul(
bvec(1:3,1:3), dble(g_rh%mill(1:3,ipw)))
111 glen = sqrt(dot_product(gv(1:3),gv(1:3)))
112 sinc(1:
spec(jtyp)%mmax) = glen*
spec(jtyp)%psr(1:
spec(jtyp)%mmax)
114 ctail = -
spec(jtyp)%Zion * cos(sinc(
spec(jtyp)%mmax)) / glen**2
116 sinc(2:
spec(jtyp)%mmax) = sin(sinc(2:
spec(jtyp)%mmax)) &
117 & / sinc( 2:
spec(jtyp)%mmax) &
119 sinc(1 ) = dr * 0.5d0
120 sinc(
spec(jtyp)%mmax) = sinc(
spec(jtyp)%mmax) * 0.5d0
122 frmfac(ipw) = sum( sinc(1:
spec(jtyp)%mmax) &
123 & *
spec(jtyp)%psr(1:
spec(jtyp)%mmax)**2 &
124 & *
spec(jtyp)%psV(1:
spec(jtyp)%mmax)) &
126 frmfac(ipw) = 4.0d0 *
pi * frmfac(ipw)
132 vpsg(1:g_rh%nr) = vpsg(1:g_rh%nr) + strfac(1:g_rh%nr) * frmfac(1:g_rh%nr)
149 real(8),
intent(inout) :: Vloc(g_rh%nr)
152 real(8) :: g3(3), VH(g_rh%nr)
153 complex(8) :: rhog(g_rh%nr)
162 g3(1:3) = matmul(
bvec(1:3,1:3), dble(g_rh%mill(1:3,ir)))
163 rhog(ir) = 4.0d0 *
pi * rhog(ir) / dot_product(g3(1:3),g3(1:3))
168 vloc(1:g_rh%nr) = vloc(1:g_rh%nr) + vh(1:g_rh%nr)
179 real(8),
intent(inout) :: Vloc(g_rh%nr)
182 real(8) :: rs, exc, Vxc
186 if(
rho(ir) > 1.0d-10)
then
188 rs = (3.0d0 / (4.0d0 *
pi *
rho(ir)))**(1.0d0/3.0d0)
191 exc = -3.0d0 / (4.0d0*
pi) * (9.0d0*
pi/4)**(1.0d0/3.0d0) / rs &
192 & - 0.0480d0 + 0.031d0*log(rs) - 0.0116d0*rs + 0.0020d0*rs*log(rs)
194 vxc = exc -1.0d0 / (4.0d0*
pi) * (9.0d0*
pi/4)**(1.0d0/3.0d0) / rs**2 &
195 & -0.0096d0*rs + 0.031d0 + 0.002d0*rs*log(rs)
197 exc = -3.0d0 / (4.0d0*
pi) * (9.0d0*
pi/4)**(1.0d0/3.0d0) / rs &
198 & - 0.1423d0 / (1.0d0 + 1.0529d0*sqrt(rs) + 0.3334d0*rs)
200 vxc = exc -1.0d0 / (4.0d0*
pi) * (9.0d0*
pi/4)**(1.0d0/3.0d0) / rs**2 &
201 & - 0.0474333d0*(0.3334d0*rs + 0.52645*sqrt(rs)) &
202 & /(1.0d0 + 1.0529d0*sqrt(rs) + 0.3334d0*rs)**2
205 vloc(ir) = vloc(ir) + vxc