The Elk Code
 
Loading...
Searching...
No Matches
bandstr.f90
Go to the documentation of this file.
1
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.
5
6!BOP
7! !ROUTINE: bandstr
8! !INTERFACE:
9subroutine bandstr
10! !USES:
11use modmain
12use modomp
13! !DESCRIPTION:
14! Produces a band structure along the path in reciprocal space which connects
15! the vertices in the array {\tt vvlp1d}. The band structure is obtained from
16! the second-variational eigenvalues and is written to the file {\tt BAND.OUT}
17! with the Fermi energy set to zero. If required, band structures are plotted
18! to files {\tt BAND\_Sss\_Aaaaa.OUT} for atom {\tt aaaa} of species {\tt ss},
19! which include the band characters for each $l$ component of that atom in
20! columns 4 onwards. Column 3 contains the sum over $l$ of the characters.
21! Vertex location lines are written to {\tt BANDLINES.OUT}.
22!
23! !REVISION HISTORY:
24! Created June 2003 (JKD)
25!EOP
26!BOC
27implicit none
28! local variables
29integer ik,ist,ispn,is,ia,ias
30integer lmax,lmmax,l,m,lm,iv,nthd
31real(8) emin,emax,sm,t1
32character(256) fname
33! allocatable arrays
34real(8), allocatable :: evalfv(:,:)
35! low precision for band character array saves memory
36real(4), allocatable :: bc(:,:,:,:)
37complex(8), allocatable :: dmat(:,:,:,:,:),apwalm(:,:,:,:,:)
38complex(8), allocatable :: evecfv(:,:,:),evecsv(:,:)
39! initialise universal variables
40call init0
41call init1
42! maximum angular momentum for band character
43lmax=min(3,lmaxo)
44lmmax=(lmax+1)**2
45if (task == 21) then
46 allocate(bc(0:lmax,natmtot,nstsv,nkpt))
47else if (task == 22) then
48 allocate(bc(lmmax,natmtot,nstsv,nkpt))
49else if (task == 23) then
50 allocate(bc(nspinor,natmtot,nstsv,nkpt))
51end if
52! read density and potentials from file
53call readstate
54! Fourier transform Kohn-Sham potential to G-space
55call genvsig
56! find the new linearisation energies
57call linengy
58! generate the APW and local-orbital radial functions and integrals
59call genapwlofr
60! generate the spin-orbit coupling radial functions
61call gensocfr
62! begin parallel loop over k-points
63call holdthd(nkpt,nthd)
64!$OMP PARALLEL DEFAULT(SHARED) &
65!$OMP PRIVATE(evalfv,evecfv,evecsv) &
66!$OMP PRIVATE(dmat,apwalm,ist,ispn) &
67!$OMP PRIVATE(ias,l,m,lm,sm) &
68!$OMP NUM_THREADS(nthd)
69allocate(evalfv(nstfv,nspnfv))
70allocate(evecfv(nmatmax,nstfv,nspnfv),evecsv(nstsv,nstsv))
71if (task >= 21) then
72 allocate(dmat(lmmax,nspinor,lmmax,nspinor,nstsv))
73 allocate(apwalm(ngkmax,apwordmax,lmmaxapw,natmtot,nspnfv))
74end if
75!$OMP DO SCHEDULE(DYNAMIC)
76do ik=1,nkpt
77!$OMP CRITICAL(bandstr_)
78 write(*,'("Info(bandstr): ",I6," of ",I6," k-points")') ik,nkpt
79!$OMP END CRITICAL(bandstr_)
80! solve the first- and second-variational eigenvalue equations
81 call eveqn(ik,evalfv,evecfv,evecsv)
82! compute the band characters if required
83 if (task >= 21) then
84! find the matching coefficients
85 do ispn=1,nspnfv
86 call match(ngk(ispn,ik),vgkc(:,:,ispn,ik),gkc(:,ispn,ik), &
87 sfacgk(:,:,ispn,ik),apwalm(:,:,:,:,ispn))
88 end do
89! average band character over spin and m for all atoms
90 do ias=1,natmtot
91! generate the diagonal of the density matrix
92 call gendmatk(.true.,.true.,0,lmax,ias,nstsv,[0],ngk(:,ik),apwalm,evecfv,&
93 evecsv,lmmax,dmat)
94 do ist=1,nstsv
95 if (task == 21) then
96! l character of band
97 lm=0
98 do l=0,lmax
99 sm=0.d0
100 do m=-l,l
101 lm=lm+1
102 do ispn=1,nspinor
103 sm=sm+dble(dmat(lm,ispn,lm,ispn,ist))
104 end do
105 end do
106 bc(l,ias,ist,ik)=real(sm)
107 end do
108 else if (task == 22) then
109! (l,m) character of band
110 lm=0
111 do l=0,lmax
112 do m=-l,l
113 lm=lm+1
114 sm=0.d0
115 do ispn=1,nspinor
116 sm=sm+dble(dmat(lm,ispn,lm,ispn,ist))
117 end do
118 bc(lm,ias,ist,ik)=real(sm)
119 end do
120 end do
121 else
122! spin character of band
123 do ispn=1,nspinor
124 sm=0.d0
125 lm=0
126 do l=0,lmax
127 do m=-l,l
128 lm=lm+1
129 sm=sm+dble(dmat(lm,ispn,lm,ispn,ist))
130 end do
131 end do
132 bc(ispn,ias,ist,ik)=real(sm)
133 end do
134 end if
135 end do
136 end do
137 end if
138! end loop over k-points
139end do
140!$OMP END DO
141deallocate(evalfv,evecfv,evecsv)
142if (task >= 21) deallocate(dmat,apwalm)
143!$OMP END PARALLEL
144call freethd(nthd)
145! subtract the Fermi energy
146evalsv(:,:)=evalsv(:,:)-efermi
147! find the minimum and maximum eigenvalues
148emin=minval(evalsv(:,:))
149emax=maxval(evalsv(:,:))
150t1=(emax-emin)*0.5d0
151emin=emin-t1
152emax=emax+t1
153! output the band structure
154if (task == 20) then
155 open(50,file='BAND.OUT',form='FORMATTED',action='WRITE')
156 do ist=1,nstsv
157 do ik=1,nkpt
158 write(50,'(2G18.10)') dpp1d(ik),evalsv(ist,ik)
159 end do
160 write(50,*)
161 end do
162 close(50)
163 write(*,*)
164 write(*,'("Info(bandstr):")')
165 write(*,'(" Band structure plot written to BAND.OUT")')
166else
167 do is=1,nspecies
168 do ia=1,natoms(is)
169 ias=idxas(ia,is)
170 write(fname,'("BAND_S",I2.2,"_A",I4.4,".OUT")') is,ia
171 open(50,file=trim(fname),form='FORMATTED',action='WRITE')
172 do ist=1,nstsv
173 do ik=1,nkpt
174 if (task == 21) then
175! sum band character over l to find total atomic character
176 sm=0.d0
177 do l=0,lmax
178 sm=sm+bc(l,ias,ist,ik)
179 end do
180 write(50,'(2G18.10,5F12.6)') dpp1d(ik),evalsv(ist,ik),sm, &
181 (bc(l,ias,ist,ik),l=0,lmax)
182 else if (task == 22) then
183 write(50,'(2G18.10,16F12.6)') dpp1d(ik),evalsv(ist,ik), &
184 (bc(lm,ias,ist,ik),lm=1,lmmax)
185 else
186 write(50,'(2G18.10,2F12.6)') dpp1d(ik),evalsv(ist,ik), &
187 (bc(ispn,ias,ist,ik),ispn=1,nspinor)
188 end if
189 end do
190 write(50,*)
191 end do
192 close(50)
193 end do
194 end do
195 write(*,*)
196 write(*,'("Info(bandstr):")')
197 write(*,'(" Band structure plot written to BAND_Sss_Aaaaa.OUT")')
198 write(*,'(" for all species and atoms")')
199 write(*,*)
200 write(*,'(" Columns in the file are :")')
201 if (task == 21) then
202 write(*,'(" distance, eigenvalue, total atomic character, l character &
203 &(l = 0...",I1,")")') lmax
204 else if (task == 22) then
205 write(*,'(" distance, eigenvalue, (l,m) character &
206 &(l = 0...",I1,", m = -l...l)")') lmax
207 else
208 write(*,'(" distance, eigenvalue, spin-up and spin-down characters")')
209 end if
210end if
211write(*,*)
212write(*,'(" Fermi energy is at zero in plot")')
213! output the vertex location lines
214open(50,file='BANDLINES.OUT',form='FORMATTED',action='WRITE')
215do iv=1,nvp1d
216 write(50,'(2G18.10)') dvp1d(iv),emin
217 write(50,'(2G18.10)') dvp1d(iv),emax
218 write(50,*)
219end do
220close(50)
221write(*,*)
222write(*,'(" Vertex location lines written to BANDLINES.OUT")')
223if (task >= 21) deallocate(bc)
224end subroutine
225!EOC
226
subroutine bandstr
Definition bandstr.f90:10
subroutine eveqn(ik, evalfv, evecfv, evecsv)
Definition eveqn.f90:10
subroutine genapwlofr
Definition genapwlofr.f90:7
subroutine gendmatk(tspndg, tlmdg, lmin, lmax, ias, nst, idx, ngp, apwalm, evecfv, evecsv, ld, dmat)
Definition gendmatk.f90:8
subroutine gensocfr
Definition gensocfr.f90:7
subroutine genvsig
Definition genvsig.f90:10
subroutine init0
Definition init0.f90:10
subroutine init1
Definition init1.f90:10
subroutine linengy
Definition linengy.f90:10
subroutine match(ngp, vgpc, gpc, sfacgp, apwalm)
Definition match.f90:10
real(8), dimension(:,:,:,:), allocatable vgkc
Definition modmain.f90:505
real(8), dimension(:,:,:), allocatable gkc
Definition modmain.f90:507
real(8) efermi
Definition modmain.f90:904
integer nspinor
Definition modmain.f90:267
integer nvp1d
Definition modmain.f90:1111
integer, dimension(maxspecies) natoms
Definition modmain.f90:36
integer, dimension(maxatoms, maxspecies) idxas
Definition modmain.f90:42
integer, dimension(:,:), allocatable ngk
Definition modmain.f90:497
integer lmmaxapw
Definition modmain.f90:199
integer apwordmax
Definition modmain.f90:760
integer nkpt
Definition modmain.f90:461
integer natmtot
Definition modmain.f90:40
integer nspnfv
Definition modmain.f90:289
real(8), dimension(:), allocatable dvp1d
Definition modmain.f90:1119
integer nmatmax
Definition modmain.f90:848
integer task
Definition modmain.f90:1298
integer nstsv
Definition modmain.f90:886
real(8), dimension(:), allocatable dpp1d
Definition modmain.f90:1123
integer lmaxo
Definition modmain.f90:201
integer ngkmax
Definition modmain.f90:499
integer nstfv
Definition modmain.f90:884
complex(8), dimension(:,:,:,:), allocatable sfacgk
Definition modmain.f90:509
integer nspecies
Definition modmain.f90:34
real(8), dimension(:,:), allocatable evalsv
Definition modmain.f90:918
subroutine holdthd(nloop, nthd)
Definition modomp.f90:78
subroutine freethd(nthd)
Definition modomp.f90:106
subroutine readstate
Definition readstate.f90:10