The Elk Code
getevecfv.f90
Go to the documentation of this file.
1 
2 ! Copyright (C) 2007-2008 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: getevecfv
8 ! !INTERFACE:
9 subroutine getevecfv(fext,ikp,vpl,vgpl,evecfv)
10 ! !USES:
11 use modmain
12 use modramdisk
13 ! !INPUT/OUTPUT PARAMETERS:
14 ! fext : filename extension (in,character(*))
15 ! ikp : p-point vector index (in,integer)
16 ! vpl : p-point vector in lattice coordinates (in,real(3))
17 ! vgpl : G+p-vectors in lattice coordinates (out,real(3,ngkmax,nspnfv))
18 ! evecfv : first-variational eigenvectors (out,complex(nmatmax,nstfv,nspnfv))
19 ! !DESCRIPTION:
20 ! Reads in a first-variational eigenvector from file. If the input $k$-point,
21 ! ${\bf p}$, is not in the reduced set, then the eigenvector of the equivalent
22 ! point is read in and the required rotation/translation operations applied.
23 !
24 ! !REVISION HISTORY:
25 ! Created Feburary 2007 (JKD)
26 ! Fixed transformation error, October 2007 (JKD, Anton Kozhevnikov)
27 ! Fixed l.o. rotation, June 2010 (A. Kozhevnikov)
28 !EOP
29 !BOC
30 implicit none
31 ! arguments
32 character(*), intent(in) :: fext
33 integer, intent(in) :: ikp
34 real(8), intent(in) :: vpl(3),vgpl(3,ngkmax,nspnfv)
35 complex(8), intent(out) :: evecfv(nmatmax,nstfv,nspnfv)
36 ! local variables
37 logical tgs
38 integer isym,lspl,ilspl
39 integer jspn,ilo,l,lm,i,j
40 integer ik,ngk_,igp,igk,ig
41 integer is,ia,ja,ias,jas
42 integer recl,nmatmax_,nstfv_,nspnfv_
43 real(8) vkl_(3),v(3),si(3,3),t1
44 complex(8) z1
45 character(256) fname
46 if (ikp > 0) then
47  ik=ikp
48 else
49 ! find the equivalent k-point number and crystal symmetry element
50  call findkpt(vpl,isym,ik)
51 end if
52 ! construct the filename
53 fname=trim(scrpath)//'EVECFV'//trim(fext)
54 !$OMP CRITICAL(u202)
55 ! read from RAM disk if required
56 if (ramdisk) then
57  call getrd(fname,ik,tgs,v1=vkl_,n1=nmatmax_,n2=nstfv_,n3=nspnfv_, &
58  nzv=nmatmax*nstfv*nspnfv,zva=evecfv)
59  if (tgs) goto 10
60 end if
61 ! find the record length
62 inquire(iolength=recl) vkl_,nmatmax_,nstfv_,nspnfv_,evecfv
63 open(202,file=fname,form='UNFORMATTED',access='DIRECT',recl=recl)
64 read(202,rec=ik) vkl_,nmatmax_,nstfv_,nspnfv_,evecfv
65 close(202)
66 10 continue
67 !$OMP END CRITICAL(u202)
68 t1=abs(vkl(1,ik)-vkl_(1))+abs(vkl(2,ik)-vkl_(2))+abs(vkl(3,ik)-vkl_(3))
69 if (t1 > epslat) then
70  write(*,*)
71  write(*,'("Error(getevecfv): differing vectors for k-point ",I0)') ik
72  write(*,'(" current : ",3G18.10)') vkl(:,ik)
73  write(*,'(" EVECFV.OUT : ",3G18.10)') vkl_
74  write(*,*)
75  stop
76 end if
77 if (nmatmax /= nmatmax_) then
78  write(*,*)
79  write(*,'("Error(getevecfv): differing nmatmax for k-point ",I0)') ik
80  write(*,'(" current : ",I0)') nmatmax
81  write(*,'(" EVECFV.OUT : ",I0)') nmatmax_
82  write(*,*)
83  stop
84 end if
85 if (nstfv /= nstfv_) then
86  write(*,*)
87  write(*,'("Error(getevecfv): differing nstfv for k-point ",I0)') ik
88  write(*,'(" current : ",I0)') nstfv
89  write(*,'(" EVECFV.OUT : ",I0)') nstfv_
90  write(*,*)
91  stop
92 end if
93 if (nspnfv /= nspnfv_) then
94  write(*,*)
95  write(*,'("Error(getevecfv): differing nspnfv for k-point ",I0)') ik
96  write(*,'(" current : ",I0)') nspnfv
97  write(*,'(" EVECFV.OUT : ",I0)') nspnfv_
98  write(*,*)
99  stop
100 end if
101 ! if p = k then return
102 if (ikp > 0) return
103 t1=abs(vpl(1)-vkl(1,ik))+abs(vpl(2)-vkl(2,ik))+abs(vpl(3)-vkl(3,ik))
104 if (t1 < epslat) return
105 block
106 logical done(ngkmax)
107 complex(8) evecfv_(nmatmax,nstfv)
108 ! index to spatial rotation in lattice point group
109 lspl=lsplsymc(isym)
110 ! the inverse of the spatial symmetry rotates k into p
111 ilspl=isymlat(lspl)
112 si(1:3,1:3)=dble(symlat(1:3,1:3,ilspl))
113 !-----------------------------------------------!
114 ! translate and rotate APW coefficients !
115 !-----------------------------------------------!
116 ! loop over the first-variational spins
117 do jspn=1,nspnfv
118  ngk_=ngk(jspn,ik)
119  if (tv0symc(isym)) then
120 ! translation vector is zero
121  evecfv_(1:ngk_,1:nstfv)=evecfv(1:ngk_,1:nstfv,jspn)
122  else
123 ! non-zero translation vector gives a phase factor
124  v(1:3)=vtcsymc(1:3,isym)
125  do igk=1,ngk_
126  ig=igkig(igk,jspn,ik)
127  t1=vgc(1,ig)*v(1)+vgc(2,ig)*v(2)+vgc(3,ig)*v(3)
128  z1=cmplx(cos(t1),-sin(t1),8)
129  evecfv_(igk,1:nstfv)=z1*evecfv(igk,1:nstfv,jspn)
130  end do
131  end if
132 ! apply spatial rotation operation (passive transformation)
133  done(1:ngk_)=.false.
134  i=1
135  do igk=1,ngk_
136  call r3mtv(si,vgkl(:,igk,jspn,ik),v)
137  j=0
138  do igp=i,ngk_
139  if (done(igp)) cycle
140  if (j == 0) j=igp
141  t1=abs(v(1)-vgpl(1,igp,jspn)) &
142  +abs(v(2)-vgpl(2,igp,jspn)) &
143  +abs(v(3)-vgpl(3,igp,jspn))
144  if (t1 < epslat) then
145  evecfv(igp,1:nstfv,jspn)=evecfv_(igk,1:nstfv)
146  done(igp)=.true.
147  if (igp == j) j=j+1
148  exit
149  end if
150  end do
151  if (j > 0) i=j
152  end do
153 end do
154 !---------------------------------------------------------!
155 ! translate and rotate local-orbital coefficients !
156 !---------------------------------------------------------!
157 if (nlotot > 0) then
158 ! rotate k-point by inverse symmetry matrix
159  call r3mtv(si,vkl(:,ik),v)
160 ! loop over the first-variational spins
161  do jspn=1,nspnfv
162  ngk_=ngk(jspn,ik)
163 ! make a copy of the local-orbital coefficients
164  do i=ngk_+1,nmat(jspn,ik)
165  evecfv_(i,1:nstfv)=evecfv(i,1:nstfv,jspn)
166  end do
167  do is=1,nspecies
168  do ia=1,natoms(is)
169  ias=idxas(ia,is)
170 ! equivalent atom for this symmetry
171  ja=ieqatom(ia,is,isym)
172  jas=idxas(ja,is)
173 ! phase factor from translation
174  t1=-twopi*dot_product(vkl(1:3,ik),atposl(1:3,ja,is))
175  z1=cmplx(cos(t1),sin(t1),8)
176  t1=twopi*dot_product(v(1:3),atposl(1:3,ia,is))
177  z1=z1*cmplx(cos(t1),sin(t1),8)
178 ! rotate local-orbitals (active transformation)
179  do ilo=1,nlorb(is)
180  l=lorbl(ilo,is)
181  lm=l**2+1
182  i=ngk_+idxlo(lm,ilo,ias)
183  j=ngk_+idxlo(lm,ilo,jas)
184  call rotzflm(symlatc(:,:,lspl),l,l,lolmmax,nstfv,nmatmax, &
185  evecfv_(j,1),evecfv(i,1,jspn))
186  evecfv(i:i+2*l,1:nstfv,jspn)=z1*evecfv(i:i+2*l,1:nstfv,jspn)
187  end do
188  end do
189  end do
190  end do
191 end if
192 end block
193 end subroutine
194 !EOC
195 
character(256) scrpath
Definition: modmain.f90:1295
pure subroutine r3mtv(a, x, y)
Definition: r3mtv.f90:10
real(8), parameter twopi
Definition: modmain.f90:1225
integer, dimension(maxspecies) nlorb
Definition: modmain.f90:784
integer, dimension(:,:,:), allocatable idxlo
Definition: modmain.f90:851
integer, dimension(maxatoms, maxspecies) idxas
Definition: modmain.f90:42
logical ramdisk
Definition: modramdisk.f90:9
integer nlotot
Definition: modmain.f90:788
subroutine getevecfv(fext, ikp, vpl, vgpl, evecfv)
Definition: getevecfv.f90:10
integer, dimension(48) isymlat
Definition: modmain.f90:348
type(file_t), dimension(:), allocatable, private file
Definition: modramdisk.f90:29
integer, dimension(3, 3, 48) symlat
Definition: modmain.f90:344
integer, dimension(:,:,:), allocatable ieqatom
Definition: modmain.f90:368
logical, dimension(maxsymcrys) tv0symc
Definition: modmain.f90:362
subroutine getrd(fname, irec, tgs, n1, n2, n3, v1, v2, nrv, rva, nzv, zva)
Definition: modramdisk.f90:212
real(8), dimension(:,:), allocatable vgc
Definition: modmain.f90:420
integer, dimension(:,:), allocatable nmat
Definition: modmain.f90:847
integer, dimension(:,:), allocatable ngk
Definition: modmain.f90:497
real(8), dimension(3, maxatoms, maxspecies) atposl
Definition: modmain.f90:51
integer, dimension(maxsymcrys) lsplsymc
Definition: modmain.f90:364
real(8), dimension(:,:,:,:), allocatable vgkl
Definition: modmain.f90:503
real(8), dimension(3, 3, 48) symlatc
Definition: modmain.f90:350
real(8), dimension(:,:), allocatable vkl
Definition: modmain.f90:471
integer, dimension(maxspecies) natoms
Definition: modmain.f90:36
real(8) epslat
Definition: modmain.f90:24
integer lolmmax
Definition: modmain.f90:798
integer nspecies
Definition: modmain.f90:34
subroutine findkpt(vpl, isym, ik)
Definition: findkpt.f90:7
integer, dimension(maxlorb, maxspecies) lorbl
Definition: modmain.f90:794
integer, dimension(:,:,:), allocatable igkig
Definition: modmain.f90:501
subroutine rotzflm(rot, lmin, lmax, lmmax, n, ld, zflm1, zflm2)
Definition: rotzflm.f90:10
real(8), dimension(3, maxsymcrys) vtcsymc
Definition: modmain.f90:360