The Elk Code
 
Loading...
Searching...
No Matches
genexpmat.f90
Go to the documentation of this file.
1
2! Copyright (C) 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
6subroutine genexpmat(vpl,expmt,emat)
7use modmain
8implicit none
9! arguments
10real(8), intent(in) :: vpl(3)
11complex(8), intent(in) :: expmt(npcmtmax,natmtot)
12complex(8), intent(out) :: emat(nstsv,nstsv)
13! local variables
14integer ist,jst,ispn,i,j,k,l
15integer is,ia,ias,nrc,nrci
16integer npc,ngp,ngpq,igp,ifg
17real(8) vpc(3),vpql(3),vpqc(3),t1
18complex(8) z1
19! allocatable arrays
20integer, allocatable :: igpig(:),igpqig(:)
21real(8), allocatable :: vgpl(:,:),vgpc(:,:),gpc(:)
22real(8), allocatable :: vgpql(:,:),vgpqc(:,:),gpqc(:)
23complex(8), allocatable :: sfacgp(:,:),sfacgpq(:,:)
24complex(8), allocatable :: apwalm1(:,:,:,:),apwalm2(:,:,:,:)
25complex(8), allocatable :: evecfv1(:,:),evecfv2(:,:)
26complex(8), allocatable :: evecsv1(:,:),evecsv2(:,:)
27complex(8), allocatable :: wfmt1(:),wfmt2(:,:)
28complex(8), allocatable :: zfir(:),z(:),em(:,:)
29! external functions
30complex(8), external :: zfmtinp,zdotc
31! check if q-vector is zero
32t1=abs(vecql(1))+abs(vecql(2))+abs(vecql(3))
33if (t1 < epslat) then
34 emat(:,:)=0.d0
35 do i=1,nstsv
36 emat(i,i)=1.d0
37 end do
38 return
39end if
40! allocate local arrays
41allocate(igpig(ngkmax),igpqig(ngkmax))
42allocate(vgpl(3,ngkmax),vgpc(3,ngkmax),gpc(ngkmax))
43allocate(vgpql(3,ngkmax),vgpqc(3,ngkmax),gpqc(ngkmax))
44allocate(sfacgp(ngkmax,natmtot),sfacgpq(ngkmax,natmtot))
45allocate(apwalm1(ngkmax,apwordmax,lmmaxapw,natmtot))
46allocate(apwalm2(ngkmax,apwordmax,lmmaxapw,natmtot))
47allocate(evecfv1(nmatmax,nstfv),evecfv2(nmatmax,nstfv))
48if (tevecsv) then
49 allocate(evecsv1(nstsv,nstsv),evecsv2(nstsv,nstsv))
50end if
51allocate(wfmt1(npcmtmax),wfmt2(npcmtmax,nstfv))
52allocate(zfir(ngtot),z(ngkmax),em(nstfv,nstfv))
53! p-vector in Cartesian coordinates
54call r3mv(bvec,vpl,vpc)
55! generate the G+p-vectors
56call gengkvec(ngvc,ivg,vgc,vpl,vpc,gkmax,ngkmax,ngp,igpig,vgpl,vgpc,gpc)
57! generate the structure factors
58call gensfacgp(ngp,vgpc,ngkmax,sfacgp)
59! find the matching coefficients for k-point p
60call match(ngp,vgpc,gpc,sfacgp,apwalm1)
61! get the eigenvectors for k-point p
62call getevecfv(filext,0,vpl,vgpl,evecfv1)
63! p+q-vector in lattice coordinates
64vpql(:)=vpl(:)+vecql(:)
65! p+q-vector in Cartesian coordinates
66call r3mv(bvec,vpql,vpqc)
67! generate the G+p+q-vectors
68call gengkvec(ngvc,ivg,vgc,vpql,vpqc,gkmax,ngkmax,ngpq,igpqig,vgpql,vgpqc,gpqc)
69! generate the structure factors
70call gensfacgp(ngpq,vgpqc,ngkmax,sfacgpq)
71! find the matching coefficients for k-point p+q
72call match(ngpq,vgpqc,gpqc,sfacgpq,apwalm2)
73! get the eigenvectors for k-point p+q
74call getevecfv(filext,0,vpql,vgpql,evecfv2)
75! set the first-variational matrix element array to zero
76em(:,:)=0.d0
77!------------------------------------!
78! muffin-tin matrix elements !
79!------------------------------------!
80do is=1,nspecies
81 nrc=nrcmt(is)
82 nrci=nrcmti(is)
83 npc=npcmt(is)
84 do ia=1,natoms(is)
85 ias=idxas(ia,is)
86 do ist=1,nstfv
87! calculate the wavefunction for k-point p+q
88 call wfmtfv(ias,ngpq,apwalm2(:,:,:,ias),evecfv2(:,ist),wfmt1)
89! convert from spherical harmonics to spherical coordinates
90 call zbsht(nrc,nrci,wfmt1,wfmt2(:,ist))
91! multiply by exp(-iq.r) (conjugate because zfmtinp conjugates first function)
92 wfmt1(1:npc)=conjg(expmt(1:npc,ias))*wfmt2(1:npc,ist)
93! convert from spherical coordinates to spherical harmonics
94 call zfsht(nrc,nrci,wfmt1,wfmt2(:,ist))
95 end do
96 do jst=1,nstfv
97! calculate the wavefunction for k-point p
98 call wfmtfv(ias,ngp,apwalm1(:,:,:,ias),evecfv1(:,jst),wfmt1)
99 do ist=1,nstfv
100 em(ist,jst)=em(ist,jst)+zfmtinp(nrc,nrci,wr2cmt(:,is),wfmt2(:,ist), &
101 wfmt1)
102 end do
103 end do
104! end loops over atoms and species
105 end do
106end do
107!--------------------------------------!
108! interstitial matrix elements !
109!--------------------------------------!
110! compute interstitial wavefunctions for k-point p
111do jst=1,nstfv
112 zfir(:)=0.d0
113 do igp=1,ngp
114 ifg=igfft(igpig(igp))
115 zfir(ifg)=evecfv1(igp,jst)
116 end do
117! Fourier transform wavefunction to real-space
118 call zfftifc(3,ngridg,1,zfir)
119! multiply with the characteristic function
120 zfir(:)=zfir(:)*cfunir(:)
121! Fourier transform back to G-space
122 call zfftifc(3,ngridg,-1,zfir)
123! store as wavefunction with G+p+q index
124 do igp=1,ngpq
125 ifg=igfft(igpqig(igp))
126 z(igp)=zfir(ifg)
127 end do
128! add to the first-variational matrix elements
129 do ist=1,nstfv
130 em(ist,jst)=em(ist,jst)+zdotc(ngpq,evecfv2(:,ist),1,z,1)
131 end do
132end do
133!-------------------------------------------!
134! second-variational matrix elements !
135!-------------------------------------------!
136if (tevecsv) then
137! get the second-variational eigenvectors
138 call getevecsv(filext,0,vpl,evecsv1)
139 call getevecsv(filext,0,vpql,evecsv2)
140 do i=1,nstsv
141 do j=1,nstsv
142 z1=0.d0
143 k=0
144 do ispn=1,nspinor
145 do ist=1,nstfv
146 k=k+1
147 l=(ispn-1)*nstfv
148 do jst=1,nstfv
149 l=l+1
150 z1=z1+em(ist,jst)*conjg(evecsv2(k,i))*evecsv1(l,j)
151 end do
152 end do
153 end do
154 emat(i,j)=z1
155 end do
156 end do
157else
158 emat(:,:)=em(:,:)
159end if
160deallocate(igpig,igpqig,vgpl,vgpc,gpc)
161deallocate(vgpql,vgpqc,gpqc,sfacgp,sfacgpq)
162deallocate(apwalm1,apwalm2,evecfv1,evecfv2)
163if (tevecsv) deallocate(evecsv1,evecsv2)
164deallocate(wfmt1,wfmt2,zfir,z,em)
165end subroutine
166
subroutine genexpmat(vpl, expmt, emat)
Definition genexpmat.f90:7
pure subroutine gengkvec(ngv, ivg, vgc, vkl, vkc, gkmax, ngkmax, ngk, igkig, vgkl, vgkc, gkc)
Definition gengkvec.f90:11
pure subroutine gensfacgp(ngp, vgpc, ld, sfacgp)
Definition gensfacgp.f90:10
subroutine getevecfv(fext, ikp, vpl, vgpl, evecfv)
Definition getevecfv.f90:10
subroutine getevecsv(fext, ikp, vpl, evecsv)
Definition getevecsv.f90:7
subroutine match(ngp, vgpc, gpc, sfacgp, apwalm)
Definition match.f90:10
integer ngtot
Definition modmain.f90:390
integer, dimension(3) ngridg
Definition modmain.f90:386
integer nspinor
Definition modmain.f90:267
integer, dimension(maxspecies) natoms
Definition modmain.f90:36
character(256) filext
Definition modmain.f90:1300
real(8), dimension(3, 3) bvec
Definition modmain.f90:16
integer, dimension(maxatoms, maxspecies) idxas
Definition modmain.f90:42
real(8), dimension(3) vecql
Definition modmain.f90:1101
integer, dimension(maxspecies) nrcmt
Definition modmain.f90:173
real(8) gkmax
Definition modmain.f90:495
integer lmmaxapw
Definition modmain.f90:199
integer apwordmax
Definition modmain.f90:760
real(8) epslat
Definition modmain.f90:24
real(8), dimension(:,:), allocatable wr2cmt
Definition modmain.f90:189
real(8), dimension(:), allocatable cfunir
Definition modmain.f90:436
integer, dimension(maxspecies) npcmt
Definition modmain.f90:214
integer, dimension(:), allocatable igfft
Definition modmain.f90:406
integer nmatmax
Definition modmain.f90:848
integer, dimension(:,:), allocatable ivg
Definition modmain.f90:400
integer ngkmax
Definition modmain.f90:499
real(8), dimension(:,:), allocatable vgc
Definition modmain.f90:420
integer ngvc
Definition modmain.f90:398
integer nstfv
Definition modmain.f90:884
integer, dimension(maxspecies) nrcmti
Definition modmain.f90:211
integer nspecies
Definition modmain.f90:34
logical tevecsv
Definition modmain.f90:920
pure subroutine r3mv(a, x, y)
Definition r3mv.f90:10
subroutine wfmtfv(ias, ngp, apwalm, evecfv, wfmt)
Definition wfmtfv.f90:10
subroutine zbsht(nr, nri, zfmt1, zfmt2)
Definition zbsht.f90:10
subroutine zfftifc(nd, n, sgn, z)
pure complex(8) function zfmtinp(nr, nri, wr, zfmt1, zfmt2)
Definition zfmtinp.f90:10
subroutine zfsht(nr, nri, zfmt1, zfmt2)
Definition zfsht.f90:10