The Elk Code
genephmat.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 
6 subroutine genephmat(iq,ik,de,a,dvmt,dvir,ephmat)
7 use modmain
8 use modphonon
9 implicit none
10 ! arguments
11 integer, intent(in) :: iq,ik
12 real(8), intent(in) :: de
13 complex(8), intent(in) :: a(nbph,nbph)
14 complex(8), intent(in) :: dvmt(npcmtmax,natmtot,nbph),dvir(ngtc,nbph)
15 complex(8), intent(out) :: ephmat(nstsv,nstsv,nbph)
16 ! local variables
17 integer jk,jkq,isym,ld
18 integer nst,nstq,ist,jst
19 integer ispn,jspn,is,ias
20 integer npc,nq,igp,i,j,l
21 real(8) vpql(3)
22 ! automatic arrays
23 integer idx(nstsv),idxq(nstsv)
24 integer ngp(nspnfv),ngpq(nspnfv)
25 complex(4) cfmt1(npcmtmax),cfmt2(npcmtmax),c(ngkmax)
26 complex(8) x(nbph)
27 ! allocatable arrays
28 integer, allocatable :: igpig(:,:),igpqig(:,:)
29 complex(4), allocatable :: wfmt(:,:,:,:),wfgp(:,:,:)
30 complex(4), allocatable :: wfmtq(:,:,:,:),wfgpq(:,:,:)
31 complex(4), allocatable :: wfir1(:),wfir2(:)
32 ! equivalent reduced k-point
33 jk=ivkik(ivk(1,ik),ivk(2,ik),ivk(3,ik))
34 ! k+q-vector in lattice coordinates
35 vpql(1:3)=vkl(1:3,ik)+vql(1:3,iq)
36 ! find reduced k-point index corresponding to k+q
37 call findkpt(vpql,isym,jkq)
38 ! index to states in energy window around Fermi energy
39 nst=0
40 do ist=1,nstsv
41  if (abs(evalsv(ist,jk)-efermi) > de) cycle
42  nst=nst+1
43  idx(nst)=ist
44 end do
45 nstq=0
46 do ist=1,nstsv
47  if (abs(evalsv(ist,jkq)-efermi) > de) cycle
48  nstq=nstq+1
49  idxq(nstq)=ist
50 end do
51 ! generate the second-variational wavefunctions for all states at k and k+q
52 allocate(igpig(ngkmax,nspnfv))
53 allocate(wfmt(npcmtmax,natmtot,nspinor,nst),wfgp(ngkmax,nspinor,nst))
54 call genwfsvp_sp(.false.,.true.,nst,idx,ngridg,igfft,vkl(:,ik),ngp,igpig,wfmt, &
55  ngkmax,wfgp)
56 allocate(igpqig(ngkmax,nspnfv))
57 allocate(wfmtq(npcmtmax,natmtot,nspinor,nstq),wfgpq(ngkmax,nspinor,nstq))
58 call genwfsvp_sp(.false.,.true.,nstq,idxq,ngridg,igfft,vpql,ngpq,igpqig,wfmtq, &
59  ngkmax,wfgpq)
60 ! zero the electron-phonon coupling matrix elements
61 ephmat(1:nstsv,1:nstsv,1:nbph)=0.d0
62 !-------------------------!
63 ! muffin-tin part !
64 !-------------------------!
65 do j=1,nst
66  jst=idx(j)
67  do i=1,nstq
68  ist=idxq(i)
69  do ias=1,natmtot
70  is=idxis(ias)
71  npc=npcmt(is)
72  if (spinpol) then
73  cfmt1(1:npc)=wfmtq(1:npc,ias,1,i)*conjg(wfmt(1:npc,ias,1,j)) &
74  +wfmtq(1:npc,ias,2,i)*conjg(wfmt(1:npc,ias,2,j))
75  else
76  cfmt1(1:npc)=wfmtq(1:npc,ias,1,i)*conjg(wfmt(1:npc,ias,1,j))
77  end if
78  call cfsht(nrcmt(is),nrcmti(is),cfmt1,cfmt2)
79  do l=1,nbph
80  ephmat(ist,jst,l)=ephmat(ist,jst,l) &
81  +dot_product(cfmt2(1:npc),dvmt(1:npc,ias,l))
82  end do
83  end do
84  end do
85 end do
86 deallocate(wfmt,wfmtq)
87 !---------------------------!
88 ! interstitial part !
89 !---------------------------!
90 allocate(wfir1(ngtc),wfir2(ngtc))
91 do j=1,nst
92  jst=idx(j)
93  do ispn=1,nspinor
94  jspn=jspnfv(ispn)
95  nq=ngpq(jspn)
96 ! Fourier transform wavefunction to real-space
97  wfir1(1:ngtc)=0.e0
98  do igp=1,ngp(jspn)
99  wfir1(igfc(igpig(igp,jspn)))=wfgp(igp,ispn,j)
100  end do
101  call cfftifc(3,ngdgc,1,wfir1)
102  do l=1,nbph
103 ! apply potential derivative to wavefunction
104  wfir2(1:ngtc)=dvir(1:ngtc,l)*wfir1(1:ngtc)
105 ! Fourier transform to G+p+q-space
106  call cfftifc(3,ngdgc,-1,wfir2)
107  do igp=1,nq
108  c(igp)=wfir2(igfc(igpqig(igp,jspn)))
109  end do
110  do i=1,nstq
111  ist=idxq(i)
112 ! compute inner product
113  ephmat(ist,jst,l)=ephmat(ist,jst,l) &
114  +dot_product(wfgpq(1:nq,ispn,i),c(1:nq))
115  end do
116  end do
117  end do
118 end do
119 deallocate(wfir1,wfir2)
120 ! convert to phonon coordinates
121 ld=nstsv**2
122 do i=1,nstq
123  ist=idxq(i)
124  do j=1,nst
125  jst=idx(j)
126  x(1:nbph)=ephmat(ist,jst,1:nbph)
127  call zgemv('T',nbph,nbph,zone,a,nbph,x,1,zzero,ephmat(ist,jst,1),ld)
128  end do
129 end do
130 deallocate(igpig,igpqig,wfgp,wfgpq)
131 end subroutine
132 
real(8) efermi
Definition: modmain.f90:907
integer, dimension(maxspecies) npcmt
Definition: modmain.f90:214
integer, dimension(3) ngridg
Definition: modmain.f90:386
real(8), dimension(:,:), allocatable evalsv
Definition: modmain.f90:921
logical spinpol
Definition: modmain.f90:228
subroutine genwfsvp_sp(tsh, tgp, nst, idx, ngridg_, igfft_, vpl, ngp, igpig, wfmt, ld, wfir)
Definition: genwfsvp_sp.f90:8
integer, dimension(:,:,:), allocatable ivkik
Definition: modmain.f90:467
complex(8), parameter zone
Definition: modmain.f90:1240
subroutine genephmat(iq, ik, de, a, dvmt, dvir, ephmat)
Definition: genephmat.f90:7
subroutine cfsht(nr, nri, cfmt1, cfmt2)
Definition: cfsht.f90:7
subroutine cfftifc(nd, n, sgn, c)
Definition: cfftifc_fftw.f90:7
integer, dimension(:), allocatable igfft
Definition: modmain.f90:406
integer, dimension(:), allocatable igfc
Definition: modmain.f90:410
real(8), dimension(:,:), allocatable vql
Definition: modmain.f90:545
integer nspinor
Definition: modmain.f90:267
complex(8), parameter zzero
Definition: modmain.f90:1240
real(8), dimension(:,:), allocatable vkl
Definition: modmain.f90:471
integer, dimension(maxatoms *maxspecies) idxis
Definition: modmain.f90:44
integer, dimension(3) ngdgc
Definition: modmain.f90:388
integer, dimension(maxspecies) nrcmt
Definition: modmain.f90:173
integer, dimension(maxspecies) nrcmti
Definition: modmain.f90:211
subroutine findkpt(vpl, isym, ik)
Definition: findkpt.f90:7
integer, dimension(2) jspnfv
Definition: modmain.f90:291
integer, dimension(:,:), allocatable ivk
Definition: modmain.f90:465