The Elk Code
genpmatk.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: genpmatk
8 ! !INTERFACE:
9 subroutine genpmatk(ngp,igpig,vgpc,wfmt,wfgp,pmat)
10 ! !USES:
11 use modmain
12 ! !INPUT/OUTPUT PARAMETERS:
13 ! ngp : number of G+p-vectors (in,integer(nspnfv))
14 ! igpig : index from G+p-vectors to G-vectors (in,integer(ngkmax,nspnfv))
15 ! vgpc : G+p-vectors in Cartesian coordinates (in,real(3,ngkmax,nspnfv))
16 ! wfmt : muffin-tin wavefunction in spherical harmonics
17 ! (in,complex(npcmtmax,natmtot,nspinor,nstsv))
18 ! wfgp : interstitial wavefunction in plane wave basis
19 ! (in,complex(ngkmax,nspinor,nstsv))
20 ! pmat : momentum matrix elements (out,complex(nstsv,nstsv,3))
21 ! !DESCRIPTION:
22 ! Calculates the momentum matrix elements
23 ! $$ P_{ij}=\int d^3r\,\Psi_{i{\bf k}}^*({\bf r})\left(-i\nabla
24 ! +\frac{1}{4c^2}\left[\vec{\sigma}\times\nabla V_s({\bf r})\right]\right)
25 ! \Psi_{j{\bf k}}({\bf r}), $$
26 ! where $V_s$ is the Kohn-Sham effective potential. The second term in the
27 ! brackets is only calculated if spin-orbit coupling is enabled. See Rathgen
28 ! and Katsnelson, {\it Physica Scripta} {\bf T109}, 170 (2004).
29 !
30 ! !REVISION HISTORY:
31 ! Created November 2003 (Sharma)
32 ! Fixed bug found by Juergen Spitaler, September 2006 (JKD)
33 ! Added spin-orbit correction, July 2010 (JKD)
34 ! Fixed bug found by Koichi Kitahara, January 2014 (JKD)
35 !EOP
36 !BOC
37 implicit none
38 ! arguments
39 integer, intent(in) :: ngp(nspnfv),igpig(ngkmax,nspnfv)
40 real(8), intent(in) :: vgpc(3,ngkmax,nspnfv)
41 complex(8), intent(in) :: wfmt(npcmtmax,natmtot,nspinor,nstsv)
42 complex(8), intent(in) :: wfgp(ngkmax,nspinor,nstsv)
43 complex(8), intent(out) :: pmat(nstsv,nstsv,3)
44 ! local variables
45 integer ist,jst,ispn,jspn
46 integer is,ia,ias,nrc,nrci,npc
47 integer ld1,ld2,igp,ifg,i
48 real(8) cso
49 complex(8) z1,z2,z11,z12,z21,z22,z31,z32
50 ! automatic arrays
51 real(8) rfmt(npcmtmax)
52 complex(8) gwfmt(npcmtmax,3,nspinor),gvmt(npcmtmax,3)
53 complex(8) zfmt1(npcmtmax,nspinor),zfmt2(npcmtmax,3,nspinor)
54 complex(8) gwfir(ngtc,3),z(ngkmax)
55 ! coefficient of spin-orbit coupling
56 cso=1.d0/(4.d0*solsc**2)
57 ! leading dimensions
58 ld1=npcmtmax*natmtot*nspinor
59 ld2=ngkmax*nspinor
60 ! zero the momentum matrix elements array
61 pmat(1:nstsv,1:nstsv,1:3)=0.d0
62 !---------------------------------!
63 ! muffin-tin contribution !
64 !---------------------------------!
65 do is=1,nspecies
66  nrc=nrcmt(is)
67  nrci=nrcmti(is)
68  npc=npcmt(is)
69  do ia=1,natoms(is)
70  ias=idxas(ia,is)
71 ! compute gradient of potential for spin-orbit correction if required
72  if (spinorb) then
73  call rfmtftoc(nrc,nrci,vsmt(:,ias),rfmt)
74  call rtozfmt(nrc,nrci,rfmt,zfmt1)
75  call gradzfmt(nrc,nrci,rlcmt(:,-1,is),wcrcmt(:,:,is),zfmt1,npcmtmax,gvmt)
76 ! convert to spherical coordinates
77  do i=1,3
78  call zbshtip(nrc,nrci,gvmt(:,i))
79  end do
80  end if
81  do jst=1,nstsv
82  do ispn=1,nspinor
83 ! compute the gradient of the wavefunction
84  call gradzfmt(nrc,nrci,rlcmt(:,-1,is),wcrcmt(:,:,is), &
85  wfmt(:,ias,ispn,jst),npcmtmax,gwfmt(:,:,ispn))
86  end do
87 ! add spin-orbit correction if required
88  if (spinorb) then
89  do ispn=1,nspinor
90 ! convert wavefunction to spherical coordinates
91  call zbsht(nrc,nrci,wfmt(:,ias,ispn,jst),zfmt1(:,ispn))
92  end do
93 ! compute i σ ⨯ (∇ V(r)) φ(r)
94  do i=1,npc
95  z1=cmplx(-zfmt1(i,1)%im,zfmt1(i,1)%re,8)
96  z2=cmplx(-zfmt1(i,2)%im,zfmt1(i,2)%re,8)
97  z11=gvmt(i,1)*z1; z12=gvmt(i,1)*z2
98  z21=gvmt(i,2)*z1; z22=gvmt(i,2)*z2
99  z31=gvmt(i,3)*z1; z32=gvmt(i,3)*z2
100  zfmt2(i,1,1)=cmplx(z32%im,-z32%re,8)-z21
101  zfmt2(i,1,2)=cmplx(-z31%im,z31%re,8)+z22
102  zfmt2(i,2,1)=z11-z32
103  zfmt2(i,2,2)=-z12-z31
104  zfmt2(i,3,1)=cmplx(-z12%im,z12%re,8)+z22
105  zfmt2(i,3,2)=cmplx(z11%im,-z11%re,8)+z21
106  end do
107 ! convert to spherical harmonics and add to wavefunction gradient
108  do ispn=1,nspinor
109  do i=1,3
110  call zfsht(nrc,nrci,zfmt2(:,i,ispn),zfmt1)
111  gwfmt(1:npc,i,ispn)=gwfmt(1:npc,i,ispn)+cso*zfmt1(1:npc,1)
112  end do
113  end do
114  end if
115  do i=1,3
116  do ispn=1,nspinor
117 ! apply the radial integral weights
118  call zfmtwr(nrc,nrci,wr2cmt(:,is),gwfmt(:,i,ispn))
119 ! compute the overlaps
120  call zgemv('C',npc,jst,zone,wfmt(1,ias,ispn,1),ld1,gwfmt(1,i,ispn),1,&
121  zone,pmat(1,jst,i),1)
122  end do
123  end do
124  end do
125  end do
126 end do
127 !-----------------------------------!
128 ! interstitial contribution !
129 !-----------------------------------!
130 do jst=1,nstsv
131  do ispn=1,nspinor
132  jspn=jspnfv(ispn)
133 ! compute the gradient
134  gwfir(1:ngtc,1:3)=0.d0
135  do igp=1,ngp(jspn)
136  ifg=igfc(igpig(igp,jspn))
137  z1=wfgp(igp,ispn,jst)
138  z1=cmplx(-z1%im,z1%re,8)
139  gwfir(ifg,1:3)=vgpc(1:3,igp,jspn)*z1
140  end do
141  do i=1,3
142 ! Fourier transform to real-space
143  call zfftifc(3,ngdgc,1,gwfir(:,i))
144 ! multiply by coarse characteristic function
145  gwfir(1:ngtc,i)=gwfir(1:ngtc,i)*cfrc(1:ngtc)
146 ! Fourier transform back to G-space
147  call zfftifc(3,ngdgc,-1,gwfir(:,i))
148  end do
149 ! find the overlaps
150  do i=1,3
151  do igp=1,ngp(jspn)
152  ifg=igfc(igpig(igp,jspn))
153  z(igp)=gwfir(ifg,i)
154  end do
155  call zgemv('C',ngp(jspn),jst,zone,wfgp(1,ispn,1),ld2,z,1,zone, &
156  pmat(1,jst,i),1)
157  end do
158  end do
159 end do
160 ! multiply by -i and set lower triangular part
161 do i=1,3
162  do jst=1,nstsv
163  do ist=1,jst-1
164  z1=pmat(ist,jst,i)
165  z1=cmplx(z1%im,-z1%re,8)
166  pmat(ist,jst,i)=z1
167  pmat(jst,ist,i)=conjg(z1)
168  end do
169  pmat(jst,jst,i)=aimag(pmat(jst,jst,i))
170  end do
171 end do
172 end subroutine
173 !EOC
174 
integer, dimension(maxspecies) npcmt
Definition: modmain.f90:214
pure subroutine zfmtwr(nr, nri, wr, zfmt)
Definition: zfmtwr.f90:7
integer, dimension(maxatoms, maxspecies) idxas
Definition: modmain.f90:42
subroutine gradzfmt(nr, nri, ri, wcr, zfmt, ld, gzfmt)
Definition: gradzfmt.f90:10
complex(8), parameter zone
Definition: modmain.f90:1240
subroutine zfsht(nr, nri, zfmt1, zfmt2)
Definition: zfsht.f90:10
pure subroutine rtozfmt(nr, nri, rfmt, zfmt)
Definition: rtozfmt.f90:7
subroutine genpmatk(ngp, igpig, vgpc, wfmt, wfgp, pmat)
Definition: genpmatk.f90:10
subroutine zfftifc(nd, n, sgn, z)
Definition: zfftifc_fftw.f90:7
subroutine zbshtip(nr, nri, zfmt)
Definition: zbshtip.f90:7
integer, dimension(:), allocatable igfc
Definition: modmain.f90:410
real(8), dimension(:,:,:), allocatable rlcmt
Definition: modmain.f90:181
real(8) solsc
Definition: modmain.f90:1253
integer, dimension(maxspecies) natoms
Definition: modmain.f90:36
real(8), dimension(:,:), allocatable wr2cmt
Definition: modmain.f90:189
real(8), dimension(:,:,:), allocatable wcrcmt
Definition: modmain.f90:193
subroutine zbsht(nr, nri, zfmt1, zfmt2)
Definition: zbsht.f90:10
integer, dimension(3) ngdgc
Definition: modmain.f90:388
logical spinorb
Definition: modmain.f90:230
integer nspecies
Definition: modmain.f90:34
real(8), dimension(:), allocatable cfrc
Definition: modmain.f90:438
integer, dimension(maxspecies) nrcmt
Definition: modmain.f90:173
integer, dimension(maxspecies) nrcmti
Definition: modmain.f90:211
pure subroutine rfmtftoc(nrc, nrci, rfmt, rfcmt)
Definition: rfmtftoc.f90:7
real(8), dimension(:,:), pointer, contiguous vsmt
Definition: modmain.f90:649
integer, dimension(2) jspnfv
Definition: modmain.f90:291