2 ! Copyright (C) 2002-2005 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.
13 ! Generates the $k$-point set and then allocates and initialises global
14 ! variables which depend on the $k$-point set.
17 ! Created January 2004 (JKD)
22 integer ik
,is
,ia
,ias
,io
,ilo
23 integer i1
,i2
,i3
,ispn
,iv(3)
24 integer l1
,l2
,l3
,m1
,m2
,m3
,lm1
,lm2
,lm3
25 real(8) vl(3),vc(3),boxl(3,4)
33 !---------------------!
35 !---------------------!
36 ! check if the system is an isolated molecule
42 ! setup the default k-point box
44 boxl(:,1)=vkloff(:)/dble(ngridk(:))
45 boxl(1,2)=1.d0
; boxl(2,3)=1.d0
; boxl(3,4)=1.d0
46 ! k-point set and box for Fermi surface plots
47 if ((task
.eq
.100).or
.(task
.eq
.101)) then
51 if ((task
.eq
.20).or
.(task
.eq
.21)) then
52 ! for band structure plots generate k-points along a line
53 call connect(bvec
,nvp1d
,npp1d
,vvlp1d
,vplp1d
,dvp1d
,dpp1d
)
55 if (allocated(vkl
)) deallocate(vkl
)
57 if (allocated(vkc
)) deallocate(vkc
)
60 vkl(:,ik
)=vplp1d(:,ik
)
61 call r3mv(bvec
,vkl(:,ik
),vkc(:,ik
))
63 else if (task
.eq
.25) then
64 ! effective mass calculation
66 if (allocated(ivk
)) deallocate(ivk
)
68 if (allocated(vkl
)) deallocate(vkl
)
70 if (allocated(vkc
)) deallocate(vkc
)
73 call r3frac(epslat
,vklem
,iv
)
79 ivk(1,ik
)=i1
; ivk(2,ik
)=i2
; ivk(3,ik
)=i3
80 vc(1)=dble(i1
); vc(2)=dble(i2
); vc(3)=dble(i3
)
83 vkl(:,ik
)=vklem(:)+vl(:)
84 call r3mv(bvec
,vkl(:,ik
),vkc(:,ik
))
89 ! determine the k-point grid automatically from radkpt if required
91 ngridk(:)=int(radkpt
/sqrt(avec(1,:)**2+avec(2,:)**2+avec(3,:)**2))+1
93 ! allocate the reduced k-point set arrays
94 if (allocated(ivk
)) deallocate(ivk
)
95 allocate(ivk(3,ngridk(1)*ngridk(2)*ngridk(3)))
96 if (allocated(vkl
)) deallocate(vkl
)
97 allocate(vkl(3,ngridk(1)*ngridk(2)*ngridk(3)))
98 if (allocated(vkc
)) deallocate(vkc
)
99 allocate(vkc(3,ngridk(1)*ngridk(2)*ngridk(3)))
100 if (allocated(wkpt
)) deallocate(wkpt
)
101 allocate(wkpt(ngridk(1)*ngridk(2)*ngridk(3)))
102 if (allocated(ikmap
)) deallocate(ikmap
)
103 allocate(ikmap(0:ngridk(1)-1,0:ngridk(2)-1,0:ngridk(3)-1))
104 ! generate the reduced k-point set
105 call genppts(reducek
,.false
.,ngridk
,boxl
,nkpt
,ikmap
,ivk
,vkl
,vkc
,wkpt
)
106 ! allocate the non-reduced k-point set arrays
107 nkptnr
=ngridk(1)*ngridk(2)*ngridk(3)
108 if (allocated(ivknr
)) deallocate(ivknr
)
109 allocate(ivknr(3,nkptnr
))
110 if (allocated(vklnr
)) deallocate(vklnr
)
111 allocate(vklnr(3,nkptnr
))
112 if (allocated(vkcnr
)) deallocate(vkcnr
)
113 allocate(vkcnr(3,nkptnr
))
114 if (allocated(wkptnr
)) deallocate(wkptnr
)
115 allocate(wkptnr(nkptnr
))
116 if (allocated(ikmapnr
)) deallocate(ikmapnr
)
117 allocate(ikmapnr(0:ngridk(1)-1,0:ngridk(2)-1,0:ngridk(3)-1))
118 ! generate the non-reduced k-point set
119 call genppts(.false
.,.false
.,ngridk
,boxl
,nkptnr
,ikmapnr
,ivknr
,vklnr
,vkcnr
, &
123 !---------------------!
125 !---------------------!
127 if ((isgkmax
.ge
.1).and
.(isgkmax
.le
.nspecies
)) then
128 gkmax
=rgkmax
/rmt(isgkmax
)
132 if (2.d0
*gkmax
.gt
.gmaxvr
+epslat
) then
134 write(*,'("Error(init1): 2*gkmax > gmaxvr ",2G18.10)') 2.d0
*gkmax
,gmaxvr
138 ! find the maximum number of G+k-vectors
140 ! allocate the G+k-vector arrays
141 if (allocated(ngk
)) deallocate(ngk
)
142 allocate(ngk(nspnfv
,nkpt
))
143 if (allocated(igkig
)) deallocate(igkig
)
144 allocate(igkig(ngkmax
,nspnfv
,nkpt
))
145 if (allocated(vgkl
)) deallocate(vgkl
)
146 allocate(vgkl(3,ngkmax
,nspnfv
,nkpt
))
147 if (allocated(vgkc
)) deallocate(vgkc
)
148 allocate(vgkc(3,ngkmax
,nspnfv
,nkpt
))
149 if (allocated(gkc
)) deallocate(gkc
)
150 allocate(gkc(ngkmax
,nspnfv
,nkpt
))
151 if (allocated(tpgkc
)) deallocate(tpgkc
)
152 allocate(tpgkc(2,ngkmax
,nspnfv
,nkpt
))
153 if (allocated(sfacgk
)) deallocate(sfacgk
)
154 allocate(sfacgk(ngkmax
,natmtot
,nspnfv
,nkpt
))
160 vl(:)=vkl(:,ik
)+0.5d0*vqlss(:)
161 vc(:)=vkc(:,ik
)+0.5d0*vqcss(:)
163 vl(:)=vkl(:,ik
)-0.5d0*vqlss(:)
164 vc(:)=vkc(:,ik
)-0.5d0*vqcss(:)
170 ! generate the G+k-vectors
171 call gengpvec(vl
,vc
,ngk(ispn
,ik
),igkig(:,ispn
,ik
),vgkl(:,:,ispn
,ik
), &
172 vgkc(:,:,ispn
,ik
),gkc(:,ispn
,ik
),tpgkc(:,:,ispn
,ik
))
173 ! generate structure factors for G+k-vectors
174 call gensfacgp(ngk(ispn
,ik
),vgkc(:,:,ispn
,ik
),ngkmax
,sfacgk(:,:,ispn
,ik
))
178 !---------------------------------!
179 ! APWs and local-orbitals !
180 !---------------------------------!
181 ! allocate linearisation energy arrays
182 if (allocated(apwe
)) deallocate(apwe
)
183 allocate(apwe(maxapword
,0:lmaxapw
,natmtot
))
184 if (allocated(lorbe
)) deallocate(lorbe
)
185 allocate(lorbe(maxlorbord
,maxlorb
,natmtot
))
190 ! find the maximum APW order
192 apwordmax
=max(apwordmax
,apword(l1
,is
))
194 ! set the APW linearisation energies to the default
198 do io
=1,apword(l1
,is
)
199 apwe(io
,l1
,ias
)=apwe0(io
,l1
,is
)
203 ! find the maximum number of local-orbitals
204 nlomax
=max(nlomax
,nlorb(is
))
205 ! set the local-orbital linearisation energies to the default
209 lolmax
=max(lolmax
,lorbl(ilo
,is
))
210 do io
=1,lorbord(ilo
,is
)
211 lorbe(io
,ilo
,ias
)=lorbe0(io
,ilo
,is
)
216 lolmmax
=(lolmax
+1)**2
217 ! generate the local-orbital index
219 ! allocate radial function arrays
220 if (allocated(apwfr
)) deallocate(apwfr
)
221 allocate(apwfr(nrmtmax
,2,apwordmax
,0:lmaxapw
,natmtot
))
222 if (allocated(apwdfr
)) deallocate(apwdfr
)
223 allocate(apwdfr(apwordmax
,0:lmaxapw
,natmtot
))
224 if (allocated(lofr
)) deallocate(lofr
)
225 allocate(lofr(nrmtmax
,2,nlomax
,natmtot
))
227 !------------------------------------!
228 ! secular equation variables !
229 !------------------------------------!
230 ! number of first-variational states
231 nstfv
=int(chgval
/2.d0
)+nempty
+1
232 ! overlap and Hamiltonian matrix sizes
233 if (allocated(nmat
)) deallocate(nmat
)
234 allocate(nmat(nspnfv
,nkpt
))
235 if (allocated(npmat
)) deallocate(npmat
)
236 allocate(npmat(nspnfv
,nkpt
))
240 nmat(ispn
,ik
)=ngk(ispn
,ik
)+nlotot
241 nmatmax
=max(nmatmax
,nmat(ispn
,ik
))
242 ! packed matrix sizes
243 npmat(ispn
,ik
)=(nmat(ispn
,ik
)*(nmat(ispn
,ik
)+1))/2
244 ! the number of first-variational states should not exceed the matrix size
245 nstfv
=min(nstfv
,nmat(ispn
,ik
))
248 ! number of second-variational states
250 ! allocate second-variational arrays
251 if (allocated(evalsv
)) deallocate(evalsv
)
252 allocate(evalsv(nstsv
,nkpt
))
253 if (allocated(occsv
)) deallocate(occsv
)
254 allocate(occsv(nstsv
,nkpt
))
256 ! allocate overlap and Hamiltonian integral arrays
257 if (allocated(oalo
)) deallocate(oalo
)
258 allocate(oalo(apwordmax
,nlomax
,natmtot
))
259 if (allocated(ololo
)) deallocate(ololo
)
260 allocate(ololo(nlomax
,nlomax
,natmtot
))
261 if (allocated(haa
)) deallocate(haa
)
262 allocate(haa(apwordmax
,0:lmaxmat
,apwordmax
,0:lmaxapw
,lmmaxvr
,natmtot
))
263 if (allocated(hloa
)) deallocate(hloa
)
264 allocate(hloa(nlomax
,apwordmax
,0:lmaxmat
,lmmaxvr
,natmtot
))
265 if (allocated(hlolo
)) deallocate(hlolo
)
266 allocate(hlolo(nlomax
,nlomax
,lmmaxvr
,natmtot
))
267 ! allocate and generate complex Gaunt coefficient array
268 if (allocated(gntyry
)) deallocate(gntyry
)
269 allocate(gntyry(lmmaxmat
,lmmaxvr
,lmmaxapw
))
279 gntyry(lm1
,lm2
,lm3
)=gauntyry(l1
,l2
,l3
,m1
,m2
,m3
)
288 timeinit
=timeinit
+ts1
-ts0