15 integer,
parameter :: maxit=500
23 integer(omp_lock_kind),
allocatable :: lock(:)
24 real(8),
allocatable :: vgqc(:,:),gqc(:),gclgq(:),jlgqr(:,:,:)
25 complex(8),
allocatable :: ylmgq(:,:),sfacgq(:,:)
26 complex(8),
allocatable :: vchi0(:,:,:),vfxc(:,:,:)
27 complex(4),
allocatable :: vchi0_sp(:,:,:)
28 complex(8),
allocatable :: eps0(:,:,:),epsi(:,:,:),epsm(:,:,:)
29 complex(8),
allocatable :: zw(:),a(:,:)
37 v(1:3)=abs(v(1:3)-nint(v(1:3)))
40 write(*,
'("Error(tddftlr): q-vector incommensurate with k-point grid")')
41 write(*,
'(" ngridk : ",3I6)')
ngridk 42 write(*,
'(" vecql : ",3G18.10)')
vecql 84 call omp_init_lock(lock(iw))
87 allocate(vchi0_sp(nm,nm,
nwrf))
88 vchi0_sp(1:nm,1:nm,1:
nwrf)=0.e0
97 write(*,
'("Info(tddftlr): ",I6," of ",I6," k-points")') ik,
nkptnr 100 call genvchi0(.true.,ik,lock,
vecql,gclgq,jlgqr,ylmgq,sfacgq,nm,vchi0_sp)
106 call omp_destroy_lock(lock(iw))
112 call mpi_allreduce(mpi_in_place,vchi0_sp,n,mpi_complex,mpi_sum,
mpicom,
ierror)
115 allocate(vchi0(nm,nm,
nwrf))
116 vchi0(1:nm,1:nm,1:
nwrf)=vchi0_sp(1:nm,1:nm,1:
nwrf)
118 allocate(vfxc(nm,nm,
nwrf),eps0(nm,nm,
nwrf),epsi(nm,nm,
nwrf))
120 eps0(1:nm,1:nm,1:
nwrf)=-vchi0(1:nm,1:nm,1:
nwrf)
122 eps0(i,i,1:
nwrf)=eps0(i,i,1:
nwrf)+1.d0
125 if (any(
fxctype(1) == [210,211]))
then 126 epsi(1:nm,1:nm,1:
nwrf)=vchi0(1:nm,1:nm,1:
nwrf)
128 epsi(i,i,1:
nwrf)=epsi(i,i,1:
nwrf)+1.d0
136 call genvfxc(tq0,.true.,gclgq,nm,vchi0,eps0,epsi,vfxc)
140 a(1:nm,1:nm)=eps0(1:nm,1:nm,iw)-vfxc(1:nm,1:nm,iw)
144 call zgemm(
'N',
'N',nm,nm,nm,
zone,vchi0(:,:,iw),nm,a,nm,
zzero,epsi(:,:,iw),nm)
147 epsi(i,i,iw)=1.d0+epsi(i,i,iw)
155 write(*,
'("Error(tddftlr): bootstrap kernel failed to converge")')
160 if (mod(it,10) == 0)
then 161 write(*,
'("Info(tddftlr): done ",I4," bootstrap iterations")') it
163 write(*,
'(" head of matrix v⁻¹⸍² f_xc v⁻¹⸍² : ",G18.10)') t1
164 write(*,
'(" multiplied by -4π gives α : ",G18.10)') -
fourpi*t1
168 t1=abs(vfxcp)-abs(vfxc(1,1,1))
170 if (abs(t1) > 1.d-8)
goto 10
171 else if (
fxctype(1) == 211)
then 176 deallocate(gclgq,jlgqr,ylmgq,sfacgq,vchi0,vfxc)
179 eps0(1:nm,1:nm,iw)=epsi(1:nm,1:nm,iw)
180 call zminv(nm,eps0(:,:,iw))
188 write(fname,
'("EPSILON_TDDFT_",2I1,".OUT")') i,j
189 open(50,file=trim(fname),form=
'FORMATTED')
190 write(fname,
'("EPSINV_TDDFT_",2I1,".OUT")') i,j
191 open(51,file=trim(fname),form=
'FORMATTED')
193 write(50,
'(2G18.10)') dble(
wrf(iw)),dble(eps0(i,j,iw))
194 write(51,
'(2G18.10)') dble(
wrf(iw)),dble(epsi(i,j,iw))
199 write(50,
'(2G18.10)') dble(
wrf(iw)),aimag(eps0(i,j,iw))
200 write(51,
'(2G18.10)') dble(
wrf(iw)),aimag(epsi(i,j,iw))
206 open(50,file=
'EPSILON_TDDFT.OUT',form=
'FORMATTED')
207 open(51,file=
'EPSINV_TDDFT.OUT',form=
'FORMATTED')
209 write(50,
'(2G18.10)') dble(
wrf(iw)),dble(eps0(1,1,iw))
210 write(51,
'(2G18.10)') dble(
wrf(iw)),dble(epsi(1,1,iw))
215 write(50,
'(2G18.10)') dble(
wrf(iw)),aimag(eps0(1,1,iw))
216 write(51,
'(2G18.10)') dble(
wrf(iw)),aimag(epsi(1,1,iw))
223 allocate(epsm(3,3,
nwrf))
225 epsm(1:3,1:3,iw)=epsi(1:3,1:3,iw)
226 call zminv(3,epsm(:,:,iw))
232 write(fname,
'("EPSM_TDDFT_",2I1,".OUT")') i,j
233 open(50,file=trim(fname),form=
'FORMATTED')
235 write(50,
'(2G18.10)') dble(
wrf(iw)),dble(epsm(i,j,iw))
239 write(50,
'(2G18.10)') dble(
wrf(iw)),aimag(epsm(i,j,iw))
246 zw(iw)=0.5d0*
zi*epsm(1,2,iw)/sqrt(epsm(1,1,iw))
248 open(50,file=
'FARADAY.OUT',form=
'FORMATTED')
250 write(50,
'(2G18.10)') dble(
wrf(iw)),dble(zw(iw))
254 write(50,
'(2G18.10)') dble(
wrf(iw)),aimag(zw(iw))
259 zw(iw)=-epsm(1,2,iw)/(sqrt(epsm(1,1,iw))*(epsm(1,1,iw)-1.d0))
261 open(50,file=
'KERR_TDDFT.OUT',form=
'FORMATTED')
263 write(50,
'(2G18.10)') dble(
wrf(iw)),dble(zw(iw))*180.d0/
pi 267 write(50,
'(2G18.10)') dble(
wrf(iw)),aimag(zw(iw))*180.d0/
pi 275 zw(iw)=t2*epsm(1,2,iw)/((z1-1.d0)*(z1-(t1*(z1+1.d0))))
277 open(50,file=
'MLD.OUT',form=
'FORMATTED')
279 write(50,
'(2G18.10)') dble(
wrf(iw)),dble(zw(iw))
283 write(50,
'(2G18.10)') dble(
wrf(iw)),aimag(zw(iw))
290 call writetest(320,
'inverse ϵ',nv=nm*nm*
nwrf,tol=1.d-2,zva=epsi)
291 deallocate(eps0,epsi,a)
294 write(*,
'("Info(tddftlr):")')
296 write(*,
'(" Dielectric tensor written to EPSILON_TDDFT_ij.OUT")')
297 write(*,
'(" Inverse written to EPSINV_TDDFT_ij.OUT")')
298 write(*,
'(" Macroscopic part written to EPSM_TDDFT_ij.OUT")')
299 write(*,
'(" for components")')
301 write(*,
'(" i = ",I1,", j = ",I1)')
optcomp(1:2,ioc)
304 write(*,
'(" Faraday angle parameters Δδ and Δβ written to FARADAY.OUT")')
305 write(*,
'(" MOKE Kerr angle written to KERR_TDDFT.OUT")')
306 write(*,
'(" Magnetic linear dichroism (MLD) spectrum written to MLD.OUT")')
308 write(*,
'(" Note that the q-vector is zero and therefore the head of the")')
309 write(*,
'(" tensor is a 3 x 3 matrix and the wings are 3 x ngrf matrices")')
311 write(*,
'(" Dielectric tensor written to EPSILON_TDDFT.OUT")')
312 write(*,
'(" Inverse written to EPSINV_TDDFT.OUT")')
313 write(*,
'(" q-vector (lattice coordinates) : ")')
314 write(*,
'(3G18.10)')
vecql 315 write(*,
'(" q-vector length : ",G18.10)') gqc(1)
subroutine writetest(id, descr, nv, iv, iva, tol, rv, rva, zv, zva)
real(8), dimension(:,:), allocatable evalsv
subroutine gengqf(ng, vqpc, vgqc, gqc, jlgqr, ylmgq, sfacgq)
subroutine getevalsv(fext, ikp, vpl, evalsv_)
complex(8), dimension(:), allocatable wrf
complex(8), parameter zone
real(8), dimension(3) vecql
pure subroutine gengclgq(treg, iq, ngq, gqc, gclgq)
subroutine findqpt(vpl, isym, iq)
subroutine genvchi0(t3hw, ik, lock, vqpl, gclgq, jlgqr, ylmgq, sfacgq, nm, vchi0)
integer, dimension(3, 27) optcomp
integer, dimension(3) ngridk
real(8), dimension(:,:), allocatable occsv
complex(8), parameter zzero
real(8), dimension(:,:), allocatable vkl
subroutine getoccsv(fext, ikp, vpl, occsvp)
subroutine holdthd(nloop, nthd)
real(8), parameter fourpi
subroutine genvfxc(tq0, t3hw, gclgq, nm, vchi0, eps0, epsi, vfxc)
integer, dimension(3) fxctype
real(8), dimension(3) vecqc