37 write(*,*)
" Energy per u.c. [eV]"
45 write(*,*)
" Total energy : ", etot*
htr2ev
58 real(8),
intent(inout) :: Etot
60 integer :: ik, ibnd, ipw
61 real(8) :: occ(nbnd,nk), kgv(3), gg05(g_wf%npw), Ekin
71 kgv(1:3) =
kvec(1:3,ik) + matmul(
bvec(1:3,1:3), dble(g_wf%mill(1:3,g_wf%map(ipw))))
72 gg05(ipw) = 0.5d0 * dot_product(kgv,kgv)
76 ekin = ekin + occ(ibnd,ik) &
77 & * dble(sum(conjg(
evec(1:g_wf%npw,ibnd,ik)) &
78 & *
evec(1:g_wf%npw,ibnd,ik) &
79 & * gg05(1:g_wf%npw ) ))
87 write(*,*)
" Kinetic energy : ", ekin*
htr2ev
100 real(8),
intent(inout) :: Etot
104 complex(8) :: rhog(g_rh%nr)
112 g3(1:3) = matmul(
bvec(1:3,1:3), dble(g_rh%mill(1:3,ir)))
113 eh = eh + 4.0d0 *
pi * dble(conjg(rhog(ir))*rhog(ir)) &
114 & / dot_product(g3(1:3),g3(1:3))
116 eh = eh * 0.5d0 *
vcell
118 write(*,*)
" Hartree energy : ", eh*
htr2ev
130 real(8),
intent(inout) :: Etot
136 write(*,*)
" rho*V : ", eps*
htr2ev
141 subroutine ewald(Etot)
146 real(8),
intent(inout) :: Etot
148 integer :: nmax3(3), iat, jat, i1, i2, i3, ii
149 real(8) :: Eew, eta, cutoff, dtau(3), ZZ, gv(3), g2, phase, norm, rv(3)
155 norm = sqrt(dot_product(
bvec(1:3,ii),
bvec(1:3,ii)))
158 eta = eta / 3.0d0 / sqrt(2.0d0) / sqrt(2.0d0*
pi)
159 write(*,*)
" Ewald eta [Bohr^-1] : ", eta
163 cutoff = 10.0d0 * eta * 2.0d0
165 norm = sqrt(dot_product(
avec(1:3,ii),
avec(1:3,ii)))
166 nmax3(ii) = ceiling(cutoff*norm/(2.0d0*
pi))
169 write(*,*)
" Ewald grid (G) : ", nmax3(1:3)
174 dtau(1:3) =
atm(iat)%pos(1:3) -
atm(jat)%pos(1:3)
177 do i3 = -nmax3(3), nmax3(3)
178 do i2 = -nmax3(2), nmax3(2)
179 do i1 = -nmax3(1), nmax3(1)
181 if(all((/i1,i2,i3/)==0)) cycle
183 gv(1:3) = matmul(
bvec(1:3,1:3), dble((/i1,i2,i3/)))
184 g2 = dot_product(gv,gv)
185 phase = 2.0d0*
pi*dot_product(dtau(1:3), dble((/i1,i2,i3/)))
188 & + 0.5d0 * zz * cos(phase) * 4.0d0 *
pi * exp(-g2/(4.0d0*eta**2)) / (
vcell*g2)
200 cutoff = 10.0d0 / eta
202 norm = sqrt(dot_product(
bvec(1:3,ii),
bvec(1:3,ii)))
203 nmax3(ii) = ceiling(cutoff*norm/(2.0d0*
pi))
206 write(*,*)
" Ewald grid (R) : ", nmax3(1:3)
211 dtau(1:3) =
atm(iat)%pos(1:3) -
atm(jat)%pos(1:3)
214 do i3 = -nmax3(3), nmax3(3)
215 do i2 = -nmax3(2), nmax3(2)
216 do i1 = -nmax3(1), nmax3(1)
218 if(all((/i1,i2,i3/)==0) .and. iat == jat) cycle
220 rv(1:3) = matmul(
avec(1:3,1:3), dtau(1:3) + dble((/i1,i2,i3/)))
221 norm = sqrt(dot_product(rv(1:3), rv(1:3)))
224 & + 0.5d0 * zz * erfc(norm*eta) / norm
231 eew = eew - eta *
spec(
atm(iat)%ityp)%Zion**2 / sqrt(
pi)
235 write(*,*)
" Ewald energy : ", eew*
htr2ev
247 real(8),
intent(inout) :: Etot
250 real(8) :: rs, exc0, Exc
255 if(
rho(ir) > 1.0d-10)
then
257 rs = (3.0d0 / (4.0d0 *
pi *
rho(ir)))**(1.0d0/3.0d0)
260 exc0 = -3.0d0 / (4.0d0*
pi) * (9.0d0*
pi/4)**(1.0d0/3.0d0) / rs &
261 & - 0.0480d0 + 0.031d0*log(rs) - 0.0116d0*rs + 0.0020d0*rs*log(rs)
263 exc0 = -3.0d0 / (4.0d0*
pi) * (9.0d0*
pi/4)**(1.0d0/3.0d0) / rs &
264 & - 0.1423d0 / (1.0d0 + 1.0529d0*sqrt(rs) + 0.3334d0*rs)
267 exc = exc + exc0 *
rho(ir)
274 write(*,*)
" XC energy : ", exc*
htr2ev