The Elk Code
 
Loading...
Searching...
No Matches
hmldbsek.f90
Go to the documentation of this file.
1
2! Copyright (C) 2010 S. Sharma, J. K. Dewhurst and E. K. U. Gross.
3! This file is distributed under the terms of the GNU General Public License.
4! See the file COPYING for license details.
5
6subroutine hmldbsek(ik2)
7use modmain
8use modomp
9implicit none
10! arguments
11integer, intent(in) :: ik2
12! local variables
13integer ik1,ist1,ist2,jst1,jst2
14integer i1,i2,j1,j2,a1,a2,b1,b2
15integer iv(3),iq,ig,jg,nthd
16real(8) vl(3),vc(3),t0,t1,t2
17complex(8) z1
18! automatic arrays
19integer ngp(nspnfv)
20! allocatable arrays
21integer, allocatable :: igpig(:,:)
22real(8), allocatable :: vgqc(:,:),gqc(:),gclgq(:),jlgqr(:,:,:)
23complex(8), allocatable :: ylmgq(:,:),sfacgq(:,:)
24complex(4), allocatable :: wfmt1(:,:,:,:),wfir1(:,:,:)
25complex(4), allocatable :: wfmt2(:,:,:,:),wfir2(:,:,:)
26complex(4), allocatable :: crhomt(:,:),crhoir(:)
27complex(8), allocatable :: zvv(:,:,:),zcc(:,:,:)
28complex(8), allocatable :: zvc(:,:,:),zcv(:,:,:)
29complex(8), allocatable :: epsi(:,:,:)
30allocate(igpig(ngkmax,nspnfv))
31allocate(vgqc(3,ngrf),gqc(ngrf),gclgq(ngrf))
32allocate(jlgqr(njcmax,nspecies,ngrf))
33allocate(ylmgq(lmmaxo,ngrf),sfacgq(ngrf,natmtot))
34allocate(wfmt1(npcmtmax,natmtot,nspinor,nstsv),wfir1(ngtc,nspinor,nstsv))
35allocate(wfmt2(npcmtmax,natmtot,nspinor,nstsv),wfir2(ngtc,nspinor,nstsv))
36allocate(zvv(ngrf,nvbse,nvbse),zcc(ngrf,ncbse,ncbse))
37allocate(epsi(ngrf,ngrf,nwrf))
38if (bsefull) then
39 allocate(zvc(ngrf,nvbse,ncbse))
40 allocate(zcv(ngrf,ncbse,nvbse))
41end if
42! generate the wavefunctions for all states of k-point ik2
43call genwfsvp_sp(.false.,.false.,nstsv,[0],ngdgc,igfc,vkl(:,ik2),ngp,igpig, &
44 wfmt2,ngtc,wfir2)
45! begin loop over ik1
46do ik1=1,nkptnr
47! generate the wavefunctions for all states of k-point ik1
48 call genwfsvp_sp(.false.,.false.,nstsv,[0],ngdgc,igfc,vkl(:,ik1),ngp,igpig, &
49 wfmt1,ngtc,wfir1)
50! determine equivalent q-vector in first Brillouin zone
51 iv(:)=ivk(:,ik1)-ivk(:,ik2)
52 iv(:)=modulo(iv(:),ngridk(:))
53 iq=ivqiq(iv(1),iv(2),iv(3))
54! q-vector in lattice and Cartesian coordinates
55 vl(:)=vkl(:,ik1)-vkl(:,ik2)
56 vc(:)=vkc(:,ik1)-vkc(:,ik2)
57! generate the G+q-vectors and related functions
58 call gengqf(ngrf,vc,vgqc,gqc,jlgqr,ylmgq,sfacgq)
59! generate the regularised Coulomb Green's function in G+q-space
60 call gengclgq(.true.,iq,ngrf,gqc,gclgq)
61! symmetrise the Coulomb Green's function
62 gclgq(:)=sqrt(gclgq(:))
63! compute the <v|exp(-i(G+q).r)|v'> matrix elements
64 call holdthd(nvbse,nthd)
65!$OMP PARALLEL DEFAULT(SHARED) &
66!$OMP PRIVATE(crhomt,crhoir,ist1,ist2,i2) &
67!$OMP NUM_THREADS(nthd)
68 allocate(crhomt(npcmtmax,natmtot),crhoir(ngtc))
69!$OMP DO SCHEDULE(DYNAMIC)
70 do i1=1,nvbse
71 ist1=istbse(i1,ik1)
72 do i2=1,nvbse
73 ist2=istbse(i2,ik2)
74 call gencrho(.true.,.true.,ngtc,wfmt2(:,:,:,ist2),wfir2(:,:,ist2), &
75 wfmt1(:,:,:,ist1),wfir1(:,:,ist1),crhomt,crhoir)
76 call zftcf(ngrf,jlgqr,ylmgq,ngrf,sfacgq,crhomt,crhoir,zvv(:,i1,i2))
77 end do
78 end do
79!$OMP END DO
80 deallocate(crhomt,crhoir)
81!$OMP END PARALLEL
82 call freethd(nthd)
83! compute the <c|exp(-i(G+q).r)|c'> matrix elements
84 call holdthd(ncbse,nthd)
85!$OMP PARALLEL DEFAULT(SHARED) &
86!$OMP PRIVATE(crhomt,crhoir,jst1,jst2,j2) &
87!$OMP NUM_THREADS(nthd)
88 allocate(crhomt(npcmtmax,natmtot),crhoir(ngtc))
89!$OMP DO SCHEDULE(DYNAMIC)
90 do j1=1,ncbse
91 jst1=jstbse(j1,ik1)
92 do j2=1,ncbse
93 jst2=jstbse(j2,ik2)
94 call gencrho(.true.,.true.,ngtc,wfmt2(:,:,:,jst2),wfir2(:,:,jst2), &
95 wfmt1(:,:,:,jst1),wfir1(:,:,jst1),crhomt,crhoir)
96 call zftcf(ngrf,jlgqr,ylmgq,ngrf,sfacgq,crhomt,crhoir,zcc(:,j1,j2))
97 end do
98 end do
99!$OMP END DO
100 deallocate(crhomt,crhoir)
101!$OMP END PARALLEL
102 call freethd(nthd)
103! matrix elements for full BSE kernel if required
104 if (bsefull) then
105! compute the <v|exp(-i(G+q).r)|c'> matrix elements
106 call holdthd(nvbse,nthd)
107!$OMP PARALLEL DEFAULT(SHARED) &
108!$OMP PRIVATE(crhomt,crhoir,ist1,jst2,j2) &
109!$OMP NUM_THREADS(nthd)
110 allocate(crhomt(npcmtmax,natmtot),crhoir(ngtc))
111!$OMP DO SCHEDULE(DYNAMIC)
112 do i1=1,nvbse
113 ist1=istbse(i1,ik1)
114 do j2=1,ncbse
115 jst2=jstbse(j2,ik2)
116 call gencrho(.true.,.true.,ngtc,wfmt2(:,:,:,jst2),wfir2(:,:,jst2), &
117 wfmt1(:,:,:,ist1),wfir1(:,:,ist1),crhomt,crhoir)
118 call zftcf(ngrf,jlgqr,ylmgq,ngrf,sfacgq,crhomt,crhoir,zvc(:,i1,j2))
119 end do
120 end do
121!$OMP END DO
122 deallocate(crhomt,crhoir)
123!$OMP END PARALLEL
124 call freethd(nthd)
125! compute the <c|exp(-i(G+q).r)|v'> matrix elements
126 call holdthd(ncbse,nthd)
127!$OMP PARALLEL DEFAULT(SHARED) &
128!$OMP PRIVATE(crhomt,crhoir,jst1,ist2,i2) &
129!$OMP NUM_THREADS(nthd)
130 allocate(crhomt(npcmtmax,natmtot),crhoir(ngtc))
131!$OMP DO SCHEDULE(DYNAMIC)
132 do j1=1,ncbse
133 jst1=jstbse(j1,ik1)
134 do i2=1,nvbse
135 ist2=istbse(i2,ik2)
136 call gencrho(.true.,.true.,ngtc,wfmt2(:,:,:,ist2),wfir2(:,:,ist2), &
137 wfmt1(:,:,:,jst1),wfir1(:,:,jst1),crhomt,crhoir)
138 call zftcf(ngrf,jlgqr,ylmgq,ngrf,sfacgq,crhomt,crhoir,zcv(:,j1,i2))
139 end do
140 end do
141!$OMP END DO
142 deallocate(crhomt,crhoir)
143!$OMP END PARALLEL
144 call freethd(nthd)
145 end if
146! get RPA inverse dielectric function from file
147! this is the symmetric version: ϵ⁻¹ = 1 - v¹⸍² χ₀ v¹⸍²
148 call getcfgq('EPSINV.OUT',vl,ngrf,nwrf,epsi)
149 t0=wkptnr*omega
150 do i1=1,nvbse
151 do j1=1,ncbse
152 a1=ijkbse(i1,j1,ik1)
153 do i2=1,nvbse
154 do j2=1,ncbse
155 a2=ijkbse(i2,j2,ik2)
156 z1=0.d0
157 do ig=1,ngrf
158 t1=t0*gclgq(ig)
159 do jg=1,ngrf
160 t2=t1*gclgq(jg)
161 z1=z1+t2*epsi(ig,jg,1)*conjg(zcc(ig,j1,j2))*zvv(jg,i1,i2)
162 end do
163 end do
164 hmlbse(a1,a2)=hmlbse(a1,a2)-z1
165! compute off-diagonal blocks if required
166 if (bsefull) then
167 b1=a1+nbbse
168 b2=a2+nbbse
169 hmlbse(b1,b2)=hmlbse(b1,b2)+conjg(z1)
170 z1=0.d0
171 do ig=1,ngrf
172 t1=t0*gclgq(ig)
173 do jg=1,ngrf
174 t2=t1*gclgq(jg)
175 z1=z1+t2*epsi(ig,jg,1)*conjg(zcv(ig,j1,i2))*zvc(jg,i1,j2)
176 end do
177 end do
178 hmlbse(a1,b2)=hmlbse(a1,b2)-z1
179 hmlbse(b1,a2)=hmlbse(b1,a2)+conjg(z1)
180 end if
181! end loop over i2 and j2
182 end do
183 end do
184! end loop over i1 and j1
185 end do
186 end do
187! end loop over ik1
188end do
189deallocate(igpig,vgqc,gqc,gclgq,jlgqr)
190deallocate(ylmgq,sfacgq)
191deallocate(wfmt1,wfmt2,wfir1,wfir2)
192deallocate(zvv,zcc,epsi)
193if (bsefull) deallocate(zvc,zcv)
194end subroutine
195
subroutine gencrho(tsh, tspc, ngt, wfmt1, wfir1, wfmt2, wfir2, crhomt, crhoir)
Definition gencrho.f90:7
pure subroutine gengclgq(treg, iq, ngq, gqc, gclgq)
Definition gengclgq.f90:7
subroutine gengqf(ng, vqpc, vgqc, gqc, jlgqr, ylmgq, sfacgq)
Definition gengqf.f90:7
subroutine genwfsvp_sp(tsh, tgp, nst, idx, ngridg_, igfft_, vpl, ngp, igpig, wfmt, ld, wfir)
subroutine getcfgq(fname, vpl, ng, m, cf)
Definition getcfgq.f90:7
subroutine hmldbsek(ik2)
Definition hmldbsek.f90:7
logical bsefull
Definition modmain.f90:1203
integer njcmax
Definition modmain.f90:1170
integer nkptnr
Definition modmain.f90:463
integer nspinor
Definition modmain.f90:267
integer, dimension(:,:), allocatable istbse
Definition modmain.f90:1192
integer, dimension(3) ngdgc
Definition modmain.f90:388
integer nbbse
Definition modmain.f90:1188
real(8) omega
Definition modmain.f90:20
integer nwrf
Definition modmain.f90:1165
integer, dimension(:,:), allocatable ivk
Definition modmain.f90:465
complex(8), dimension(:,:), allocatable hmlbse
Definition modmain.f90:1198
integer, dimension(:,:,:), allocatable ivqiq
Definition modmain.f90:531
integer, dimension(:), allocatable igfc
Definition modmain.f90:410
integer ngtc
Definition modmain.f90:392
integer natmtot
Definition modmain.f90:40
integer, dimension(:,:,:), allocatable ijkbse
Definition modmain.f90:1196
integer npcmtmax
Definition modmain.f90:216
integer, dimension(:,:), allocatable jstbse
Definition modmain.f90:1194
integer, dimension(3) ngridk
Definition modmain.f90:448
integer nstsv
Definition modmain.f90:886
integer ngrf
Definition modmain.f90:1161
real(8), dimension(:,:), allocatable vkl
Definition modmain.f90:471
integer ngkmax
Definition modmain.f90:499
real(8), dimension(:,:), allocatable vkc
Definition modmain.f90:473
integer lmmaxo
Definition modmain.f90:203
integer nspecies
Definition modmain.f90:34
real(8) wkptnr
Definition modmain.f90:477
integer ncbse
Definition modmain.f90:1176
integer nvbse
Definition modmain.f90:1176
subroutine holdthd(nloop, nthd)
Definition modomp.f90:78
subroutine freethd(nthd)
Definition modomp.f90:106
subroutine zftcf(ngp, jlgpr, ylmgp, ld, sfacgp, cfmt, cfir, zfgp)
Definition zftcf.f90:7