2 ! Copyright (C) 2002-2007 J. K. Dewhurst, S. Sharma and C. Ambrosch-Draxl.
3 ! This file is distributed under the terms of the GNU General Public License.
4 ! See the file COPYING for license details.
10 integer ik
,ispn
,jspn
,i
,j
,kst
11 integer is
,ia
,ias
,ist
,irc
,n
12 real(8) xl(3),xs(3),xj(3),wo
15 logical, allocatable
:: done(:,:)
16 real(8), allocatable
:: xlt(:,:),xst(:,:),xjt(:,:)
17 complex(8), allocatable
:: apwalm(:,:,:,:,:)
18 complex(8), allocatable
:: evecfv(:,:,:)
19 complex(8), allocatable
:: evecsv(:,:)
20 complex(8), allocatable
:: wfmt1(:,:,:,:)
21 complex(8), allocatable
:: wfmt2(:,:,:)
22 complex(8), allocatable
:: wfmt3(:,:,:,:)
23 complex(8), allocatable
:: wfmt4(:,:,:,:)
24 complex(8), allocatable
:: zlflm(:,:)
28 ! initialise universal variables
31 allocate(done(nstfv
,nspnfv
))
32 allocate(xlt(3,natmtot
),xst(3,natmtot
),xjt(3,natmtot
))
33 allocate(apwalm(ngkmax
,apwordmax
,lmmaxapw
,natmtot
,nspnfv
))
34 allocate(evecfv(nmatmax
,nstfv
,nspnfv
))
35 allocate(evecsv(nstsv
,nstsv
))
36 allocate(wfmt1(lmmaxapw
,nrcmtmax
,nstfv
,nspnfv
))
37 allocate(wfmt2(lmmaxapw
,nrcmtmax
,2))
38 allocate(wfmt3(lmmaxapw
,nrcmtmax
,2,3))
39 allocate(wfmt4(lmmaxapw
,nrcmtmax
,2,3))
40 allocate(zlflm(lmmaxapw
,3))
41 ! read density and potentials from file
43 ! find the new linearisation energies
45 ! generate the APW radial functions
47 ! generate the local-orbital radial functions
50 ! get the occupancies from file
52 call getoccsv(vkl(1,ik
),occsv(1,ik
))
55 ! flag the occupancies for the k-points and states in kstlist
60 if ((ik
.le
.0).or
.(ik
.gt
.nkpt
)) then
62 write(*,'("Error(writelsj): k-point out of range : ",I8)') ik
66 if ((j
.le
.0).or
.(j
.gt
.nstsv
)) then
68 write(*,'("Error(writelsj): state out of range : ",I8)') j
76 open(50,file
='LSJ.OUT',action
='WRITE',form
='FORMATTED')
78 open(50,file
='LSJ_KST.OUT',action
='WRITE',form
='FORMATTED')
81 write(50,'("Expectation values are computed only over the muffin-tin")')
82 ! zero the total expection values
86 ! begin loop over k-point and state list
88 ! get the eigenvectors from file
89 call getevecfv(vkl(1,ik
),vgkl(1,1,ik
,1),evecfv
)
90 call getevecsv(vkl(1,ik
),evecsv
)
91 ! find the matching coefficients
93 call match(ngk(ik
,ispn
),gkc(1,ik
,ispn
),tpgkc(1,1,ik
,ispn
), &
94 sfacgk(1,1,ik
,ispn
),apwalm(1,1,1,1,ispn
))
96 ! begin loop over atoms and species
102 ! begin loop over second-variational states
104 wo
=wkpt(ik
)*occsv(j
,ik
)
105 if (abs(wo
).gt
.epsocc
) then
107 ! generate spinor wavefunction from second-variational eigenvectors
119 if (abs(dble(zt1
))+abs(aimag(zt1
)).gt
.epsocc
) then
120 if (.not
.done(ist
,jspn
)) then
121 call wavefmt(lradstp
,lmaxapw
,is
,ia
,ngk(ik
,jspn
), &
122 apwalm(1,1,1,1,jspn
),evecfv(1,ist
,jspn
),lmmaxapw
, &
124 done(ist
,jspn
)=.true
.
126 ! add to spinor wavefunction
127 call zaxpy(n
,zt1
,wfmt1(1,1,ist
,jspn
),1,wfmt2(1,1,ispn
),1)
132 ! spin-unpolarised wavefunction
133 call wavefmt(lradstp
,lmaxapw
,is
,ia
,ngk(ik
,1),apwalm
,evecfv(1,j
,1), &
136 ! apply the L operator
139 call lopzflm(lmaxapw
,wfmt2(1,irc
,ispn
),lmmaxapw
,zlflm
)
141 wfmt3(:,irc
,ispn
,i
)=zlflm(:,i
)
145 ! compute the expectation value of L
149 zt1
=zfmtinp(.true
.,lmaxapw
,nrcmt(is
),rcmt(1,is
),lmmaxapw
, &
150 wfmt2(1,1,ispn
),wfmt3(1,1,ispn
,i
))
151 xl(i
)=xl(i
)+dble(zt1
)
154 ! compute the expecations value of S
156 ! apply the S operator
159 wfmt4(:,irc
,1,1)=0.5d0*wfmt2(:,irc
,2)
160 wfmt4(:,irc
,2,1)=0.5d0*wfmt2(:,irc
,1)
162 wfmt4(:,irc
,1,2)=-0.5d0*zi
*wfmt2(:,irc
,2)
163 wfmt4(:,irc
,2,2)=0.5d0*zi
*wfmt2(:,irc
,1)
165 wfmt4(:,irc
,1,3)=0.5d0*wfmt2(:,irc
,1)
166 wfmt4(:,irc
,2,3)=-0.5d0*wfmt2(:,irc
,2)
171 zt1
=zfmtinp(.true
.,lmaxapw
,nrcmt(is
),rcmt(1,is
),lmmaxapw
, &
172 wfmt2(1,1,ispn
),wfmt4(1,1,ispn
,i
))
173 xs(i
)=xs(i
)+dble(zt1
)
177 ! spin-unpolarised case
180 ! expectation value of J
183 xlt(:,ias
)=xlt(:,ias
)+wo
*xl(:)
184 xst(:,ias
)=xst(:,ias
)+wo
*xs(:)
185 xjt(:,ias
)=xjt(:,ias
)+wo
*xj(:)
186 ! write the particular L, S and J to file
189 write(50,'("k-point : ",I6,3G18.10)') ik
,vkl(:,ik
)
190 write(50,'("state : ",I6)') j
191 write(50,'("species : ",I4," (",A,"), atom : ",I4)') is
, &
193 write(50,'(" L : ",3G18.10)') xl
194 write(50,'(" S : ",3G18.10)') xs
195 write(50,'(" J : ",3G18.10)') xj
198 ! end loop over states
200 ! end loops over atoms and species
203 ! end loop over k-points
205 ! write the total L, S and J to file if required
211 write(50,'("Species : ",I4," (",A,"), atom : ",I4)') is
, &
213 write(50,'(" L : ",3G18.10)') xlt(:,ias
)
214 write(50,'(" S : ",3G18.10)') xst(:,ias
)
215 write(50,'(" J : ",3G18.10)') xjt(:,ias
)
221 write(*,'("Info(writelsj):")')
223 write(*,'(" total L, S and J expectation values written to LSJ.OUT")')
225 write(*,'(" L, S and J expectation values for each k-point and state")')
226 write(*,'(" in kstlist written to LSJ_KST.OUT")')
229 deallocate(done
,xlt
,xst
,xjt
)
230 deallocate(apwalm
,evecfv
,evecsv
)
231 deallocate(wfmt1
,wfmt2
,wfmt3
,wfmt4
,zlflm
)