The Elk Code
 
Loading...
Searching...
No Matches
ephcouple.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 ephcouple
7use modmain
8use modphonon
9use modmpi
10use modomp
11implicit none
12! local variables
13integer iq,ik,jk,jkq
14integer ist,jst,isym,ip
15integer is,ia,ias,js,jas
16integer nr,nri,np,i,n,nthd
17real(8) vl(3),de,x
18real(8) t1,t2,t3,t4
19! allocatable arrays
20real(8), allocatable :: gq(:,:),y(:)
21complex(8), allocatable :: ev(:,:),a(:,:)
22complex(8), allocatable :: dvmt(:,:,:),dvir(:,:)
23complex(8), allocatable :: zfmt(:),gzfmt(:,:,:)
24complex(8), allocatable :: ephmat(:,:,:)
25! external functions
26real(8), external :: sdelta
27! increase the angular momentum cut-off on the inner part of the muffin-tin
29lmaxi=max(lmaxi,4)
30! initialise universal variables
31call init0
32call init1
33call init2
34call initph
35! allocate global arrays
36if (allocated(dvsbs)) deallocate(dvsbs)
38allocate(dvsbs(n))
39dvsmt(1:npmtmax,1:natmtot) => dvsbs(1:)
40if (allocated(dvsir)) deallocate(dvsir)
41allocate(dvsir(ngtot))
42! allocate local arrays
43allocate(gq(nbph,nqpt),y(nbph))
44allocate(ev(nbph,nbph),a(nbph,nbph))
45allocate(dvmt(npcmtmax,natmtot,nbph),dvir(ngtc,nbph))
46allocate(zfmt(npmtmax),gzfmt(npmtmax,3,natmtot))
47! read in the density and potentials from file
48call readstate
49! Fourier transform Kohn-Sham potential to G-space
50call genvsig
51! set the speed of light >> 1 (non-relativistic approximation)
52solsc=sol*100.d0
53! new file extension for eigenvector files with c >> 1
54filext='_EPH.OUT'
55! generate the first- and second-variational eigenvectors and eigenvalues
56call linengy
57call genapwlofr
58call gensocfr
59call genevfsv
60! precise determination of the Fermi energy
62swidth=1.d-5
63call occupy
65! restore the speed of light
67! compute the gradients of the Kohn-Sham potential for the rigid-ion term
68do ias=1,natmtot
69 is=idxis(ias)
70 nr=nrmt(is)
71 nri=nrmti(is)
72 call rtozfmt(nr,nri,vsmt(:,ias),zfmt)
73 call gradzfmt(nr,nri,rlmt(:,-1,is),wcrmt(:,:,is),zfmt,npmtmax,gzfmt(:,:,ias))
74end do
75! energy window for calculating the electron-phonon matrix elements
76if (task == 240) then
77 de=4.d0*swidth
78else
79 de=1.d6
80end if
81! loop over phonon q-points
82do iq=1,nqpt
83 if (mp_mpi) write(*,'("Info(ephcouple): ",I6," of ",I6," q-points")') iq,nqpt
84! diagonalise the dynamical matrix
85 call dynev(dynq(:,:,iq),wphq(:,iq),ev)
86! generate the matrix for converting between Cartesian and phonon coordinates
87 call genmcph(wphq(:,iq),ev,a)
88 i=0
89 do is=1,nspecies
90 nr=nrmt(is)
91 nri=nrmti(is)
92 np=npmt(is)
93 do ia=1,natoms(is)
94 ias=idxas(ia,is)
95 do ip=1,3
96 i=i+1
97! read in the Cartesian change in Kohn-Sham potential
98 call readdvs(iq,is,ia,ip,dvsmt,dvsir)
99! add the rigid-ion term
100 dvsmt(1:np,ias)=dvsmt(1:np,ias)-gzfmt(1:np,ip,ias)
101 do jas=1,natmtot
102 js=idxis(jas)
103! convert to coarse radial mesh
104 call zfmtftoc(nrcmt(js),nrcmti(js),dvsmt(:,jas),dvmt(:,jas,i))
105! apply the radial integration weights
106 call zfmtwr(nrcmt(js),nrcmti(js),wr2cmt(:,js),dvmt(:,jas,i))
107 end do
108! multiply the interstitial potential with the characteristic function and
109! convert to coarse grid
110 call zfirftoc(dvsir,dvir(:,i))
111 end do
112 end do
113 end do
114 y(1:nbph)=0.d0
115 call holdthd(nkptnr/np_mpi,nthd)
116!$OMP PARALLEL DEFAULT(SHARED) &
117!$OMP PRIVATE(ephmat,jk,vl,isym,jkq) &
118!$OMP PRIVATE(t1,t2,t3,t4,ist,jst,x,i) &
119!$OMP REDUCTION(+:y) &
120!$OMP NUM_THREADS(nthd)
121 allocate(ephmat(nstsv,nstsv,nbph))
122!$OMP DO SCHEDULE(DYNAMIC)
123 do ik=1,nkptnr
124! distribute among MPI processes
125 if (mod(ik-1,np_mpi) /= lp_mpi) cycle
126! equivalent reduced k-point
127 jk=ivkik(ivk(1,ik),ivk(2,ik),ivk(3,ik))
128! compute the electron-phonon coupling matrix elements
129 call genephmat(iq,ik,de,a,dvmt,dvir,ephmat)
130! write the matrix elements to file if required
131 if (task == 241) call putephmat(iq,ik,ephmat)
132! k+q-vector in lattice coordinates
133 vl(1:3)=vkl(1:3,ik)+vql(1:3,iq)
134! index to k+q-vector
135 call findkpt(vl,isym,jkq)
136 t1=pi*wkptnr*occmax
137! loop over second-variational states
138 do ist=1,nstsv
139 x=(evalsv(ist,jkq)-efermi)/swidth
140 t2=t1*sdelta(stype,x)/swidth
141 do jst=1,nstsv
142! loop over phonon branches
143 do i=1,nbph
144 x=(wphq(i,iq)+evalsv(jst,jk)-evalsv(ist,jkq))/swidth
145 t3=t2*sdelta(stype,x)/swidth
146 t4=dble(ephmat(ist,jst,i))**2+aimag(ephmat(ist,jst,i))**2
147 y(i)=y(i)+wphq(i,iq)*t3*t4
148 end do
149 end do
150 end do
151! end loop over k-points
152 end do
153!$OMP END DO
154 deallocate(ephmat)
155!$OMP END PARALLEL
156 call freethd(nthd)
157! store in phonon linewidths array
158 gq(1:nbph,iq)=y(1:nbph)
159! end loop over phonon q-points
160end do
161! add gq from each MPI process
162if (np_mpi > 1) then
163 n=nbph*nqpt
164 call mpi_allreduce(mpi_in_place,gq,n,mpi_double_precision,mpi_sum,mpicom, &
165 ierror)
166end if
167! restore the default file extension
168filext='.OUT'
169if (mp_mpi) then
170! write the phonon linewidths to file
171 call writegamma(gq)
172! write electron-phonon coupling constants to file
173 call writelambda(gq)
174 if (task == 241) then
175 write(*,*)
176 write(*,'("Info(ephcouple):")')
177 write(*,'(" wrote electron-phonon matrix elements to EPHMAT.OUT")')
178 end if
179end if
180! deallocate global arrays
181deallocate(dvsbs)
182! deallocate local arrays
183deallocate(gq,y,ev,a,dvmt,dvir,zfmt,gzfmt)
184! restore original input parameters
186end subroutine
187
subroutine dynev(dq, wq, ev)
Definition dynev.f90:7
subroutine ephcouple
Definition ephcouple.f90:7
subroutine findkpt(vpl, isym, ik)
Definition findkpt.f90:7
subroutine genapwlofr
Definition genapwlofr.f90:7
subroutine genephmat(iq, ik, de, a, dvmt, dvir, ephmat)
Definition genephmat.f90:7
subroutine genevfsv
Definition genevfsv.f90:7
pure subroutine genmcph(wq, ev, a)
Definition genmcph.f90:7
subroutine gensocfr
Definition gensocfr.f90:7
subroutine genvsig
Definition genvsig.f90:10
subroutine gradzfmt(nr, nri, ri, wcr, zfmt, ld, gzfmt)
Definition gradzfmt.f90:10
subroutine init0
Definition init0.f90:10
subroutine init1
Definition init1.f90:10
subroutine init2
Definition init2.f90:7
subroutine initph
Definition initph.f90:7
subroutine linengy
Definition linengy.f90:10
integer, dimension(maxspecies) nrmti
Definition modmain.f90:211
real(8), dimension(:,:,:), allocatable wcrmt
Definition modmain.f90:187
integer lmaxi0
Definition modmain.f90:205
integer ngtot
Definition modmain.f90:390
real(8) swidth0
Definition modmain.f90:892
real(8) efermi
Definition modmain.f90:904
integer nkptnr
Definition modmain.f90:463
real(8), parameter pi
Definition modmain.f90:1229
integer, dimension(maxspecies) nrmt
Definition modmain.f90:150
integer, dimension(maxspecies) natoms
Definition modmain.f90:36
character(256) filext
Definition modmain.f90:1300
integer, dimension(maxatoms, maxspecies) idxas
Definition modmain.f90:42
real(8), parameter sol
Definition modmain.f90:1250
integer, dimension(maxspecies) nrcmt
Definition modmain.f90:173
integer, dimension(:,:), allocatable ivk
Definition modmain.f90:465
integer, dimension(maxatoms *maxspecies) idxis
Definition modmain.f90:44
integer ngtc
Definition modmain.f90:392
real(8) swidth
Definition modmain.f90:892
integer nqpt
Definition modmain.f90:525
real(8), dimension(:,:), allocatable wr2cmt
Definition modmain.f90:189
integer natmtot
Definition modmain.f90:40
real(8), dimension(:,:), allocatable vql
Definition modmain.f90:545
integer npcmtmax
Definition modmain.f90:216
integer task
Definition modmain.f90:1298
integer nstsv
Definition modmain.f90:886
integer npmtmax
Definition modmain.f90:216
real(8), dimension(:,:), pointer, contiguous vsmt
Definition modmain.f90:649
integer, dimension(maxspecies) npmt
Definition modmain.f90:213
real(8) solsc
Definition modmain.f90:1252
real(8), dimension(:,:), allocatable vkl
Definition modmain.f90:471
real(8) occmax
Definition modmain.f90:898
integer lmaxi
Definition modmain.f90:205
integer, dimension(:,:,:), allocatable ivkik
Definition modmain.f90:467
integer stype
Definition modmain.f90:888
integer, dimension(maxspecies) nrcmti
Definition modmain.f90:211
integer nspecies
Definition modmain.f90:34
real(8), dimension(:,:,:), allocatable rlmt
Definition modmain.f90:179
real(8) wkptnr
Definition modmain.f90:477
real(8), dimension(:,:), allocatable evalsv
Definition modmain.f90:918
integer lp_mpi
Definition modmpi.f90:15
integer ierror
Definition modmpi.f90:19
integer mpicom
Definition modmpi.f90:11
integer np_mpi
Definition modmpi.f90:13
logical mp_mpi
Definition modmpi.f90:17
subroutine holdthd(nloop, nthd)
Definition modomp.f90:78
subroutine freethd(nthd)
Definition modomp.f90:106
integer nbph
Definition modphonon.f90:13
complex(8), dimension(:), allocatable dvsir
complex(8), dimension(:,:), pointer, contiguous dvsmt
complex(8), dimension(:,:,:), allocatable dynq
Definition modphonon.f90:27
complex(8), dimension(:), allocatable, target dvsbs
real(8), dimension(:,:), allocatable wphq
Definition modphonon.f90:31
subroutine occupy
Definition occupy.f90:10
subroutine putephmat(iq, ik, ephmat)
Definition putephmat.f90:7
subroutine readdvs(iq, is, ia, ip, dvsmt, dvsir)
Definition readdvs.f90:7
subroutine readstate
Definition readstate.f90:10
pure subroutine rtozfmt(nr, nri, rfmt, zfmt)
Definition rtozfmt.f90:7
real(8) function sdelta(stype, x)
Definition sdelta.f90:10
subroutine writegamma(gq)
Definition writegamma.f90:7
subroutine writelambda(gq)
subroutine zfirftoc(zfir, zfirc)
Definition zfirftoc.f90:7
pure subroutine zfmtftoc(nrc, nrci, zfmt, zfcmt)
Definition zfmtftoc.f90:7
pure subroutine zfmtwr(nr, nri, wr, zfmt)
Definition zfmtwr.f90:7