The Elk Code
hmlepha.f90
Go to the documentation of this file.
1 
2 ! Copyright (C) 2020 Chung-Yu Wang, J. K. Dewhurst, S. Sharma and
3 ! E. K. U. Gross. This file is distributed under the terms of the GNU General
4 ! Public License. See the file COPYING for license details.
5 
6 subroutine hmlepha(ik,a)
7 use modmain
8 use modphonon
9 use modbog
10 use modomp
11 implicit none
12 ! arguments
13 integer, intent(in) :: ik
14 complex(8), intent(out) :: a(nstsv,nstsv)
15 ! local variables
16 integer iq,jq,ikq,isym,nthd
17 integer i1,i2,j1,j2,l1,l2
18 real(8) vl(3),t0
19 complex(8) z1,z2
20 ! automatic arrays
21 complex(4) ephmat(nstsv,nstsv,nbph)
22 complex(8) x(nbph,nstsv),y(nstsv,nbph)
23 ! prefactor
24 t0=-2.d0*wqptnr*ephscf(1)**2/dengy
25 a(:,:)=0.d0
26 if (anomalous) goto 10
27 ! parallel loop over non-reduced q-points
28 call holdthd(nqptnr,nthd)
29 !$OMP PARALLEL DO DEFAULT(SHARED) &
30 !$OMP PRIVATE(ephmat,x,y,jq,vl,isym,ikq) &
31 !$OMP PRIVATE(i1,i2,j1,j2,l1,l2,z1,z2) &
32 !$OMP REDUCTION(+:a) &
33 !$OMP SCHEDULE(DYNAMIC) &
34 !$OMP NUM_THREADS(nthd)
35 do iq=1,nqptnr
36 ! equivalent reduced q-point
37  jq=ivqiq(ivq(1,iq),ivq(2,iq),ivq(3,iq))
38 ! k+q-vector in lattice coordinates
39  vl(:)=vkl(:,ik)+vql(:,iq)
40 ! index to reduced k+q-vector
41  call findkpt(vl,isym,ikq)
42 ! read in the electron-phonon matrix elements from file
43  call getephmkq(iq,ik,ephmat)
44 ! perform the contraction
45  do i2=1,nstsv
46  do j2=1,nstsv
47  do l2=1,nbph
48  z1=0.d0
49  do j1=1,nstsv
50 ! swap indices of VV† to get the density matrix at k+q
51  z1=z1+ephmat(j1,i2,l2)*dvv(j2,j1,ikq)
52  end do
53  x(l2,j2)=z1
54  end do
55  end do
56  do l1=1,nbph
57  do j2=1,nstsv
58  z1=0.d0
59  do l2=1,nbph
60  z2=dxx(l2,l1,jq)+dwx(l2,l1,jq)
61  z1=z1+z2*x(l2,j2)
62  end do
63  y(j2,l1)=z1
64  end do
65  end do
66  do i1=1,i2
67  z1=0.d0
68  do l1=1,nbph
69  do j2=1,nstsv
70  z1=z1+conjg(ephmat(j2,i1,l1))*y(j2,l1)
71  end do
72  end do
73  a(i1,i2)=a(i1,i2)+t0*z1
74  end do
75  end do
76 end do
77 !$OMP END PARALLEL DO
78 call freethd(nthd)
79 10 continue
80 ! add the second-variational eigenvalues minus the Fermi energy
81 do i1=1,nstsv
82  a(i1,i1)=dble(a(i1,i1))+evalsv(i1,ik)-efermi
83 end do
84 end subroutine
85 
subroutine hmlepha(ik, a)
Definition: hmlepha.f90:7
real(8) efermi
Definition: modmain.f90:907
real(8), dimension(:,:), allocatable evalsv
Definition: modmain.f90:921
integer, dimension(:,:), allocatable ivq
Definition: modmain.f90:529
real(8) wqptnr
Definition: modmain.f90:551
Definition: modomp.f90:6
complex(8), dimension(:,:,:), pointer, contiguous dwx
Definition: modbog.f90:43
Definition: modbog.f90:6
real(8), dimension(:,:), allocatable vql
Definition: modmain.f90:545
integer, dimension(:,:,:), allocatable ivqiq
Definition: modmain.f90:531
integer nqptnr
Definition: modmain.f90:527
real(8), dimension(:,:), allocatable vkl
Definition: modmain.f90:471
real(8), dimension(2) ephscf
Definition: modphonon.f90:150
real(8) dengy
Definition: modphonon.f90:146
complex(8), dimension(:,:,:), pointer, contiguous dxx
Definition: modbog.f90:43
subroutine freethd(nthd)
Definition: modomp.f90:106
subroutine holdthd(nloop, nthd)
Definition: modomp.f90:78
logical anomalous
Definition: modphonon.f90:153
complex(8), dimension(:,:,:), pointer, contiguous dvv
Definition: modbog.f90:25
subroutine findkpt(vpl, isym, ik)
Definition: findkpt.f90:7
subroutine getephmkq(iqp, ikp, ephmat)
Definition: getephmkq.f90:7