-
Notifications
You must be signed in to change notification settings - Fork 1
/
VCA_OMEGA.f90
332 lines (287 loc) · 10.1 KB
/
VCA_OMEGA.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
MODULE VCA_OMEGA
!
USE VCA_GF_SHARED
USE VCA_BATH_FUNCTIONS
USE VCA_GF_NORMAL
USE SF_INTEGRATE
USE SF_LINALG
USE SF_IOTOOLS, only: splot
!
implicit none
private
public :: sum_kmesh
public :: frequency_integration
public :: frequency_integration_finite_t
public :: reconstruct_g
public :: test_g
!public :: frequency_integration_sample
!public :: test_ksum
complex(8),allocatable,dimension(:,:,:,:,:,:) :: gfprime ![Nlat][Nlat][Nspin][Nspin][Norb][Norb]
complex(8),allocatable,dimension(:,:,:,:,:,:,:) :: gftest ![Nlat][Nlat][Nspin][Nspin][Norb][Norb]
real(8) :: integrationR
contains
!+------------------------------------------------------------------+
!PURPOSE : Function that does the k-sum in the RBZ of the VCA variational function(al)
!+------------------------------------------------------------------+
function sum_kmesh(omega) result(out_1)
integer :: ii,jj,kk
complex(8) :: omega
real(8) :: out_1
complex(8),allocatable,dimension(:,:) :: tmp_mat
complex(8),allocatable,dimension(:,:,:,:,:,:) :: deltamat
!
out_1=0.d0
!
!
if(allocated(tmp_mat))deallocate(tmp_mat)
if(allocated(gfprime))deallocate(gfprime)
if(allocated(deltamat))deallocate(deltamat)
!
allocate(tmp_mat(Nlat*Nspin*Norb,Nlat*Nspin*Norb))
allocate(deltamat(Nlat,Nlat,Nspin,Nspin,Norb,Norb))
allocate(gfprime(Nlat,Nlat,Nspin,Nspin,Norb,Norb))
!
tmp_mat=zero
gfprime=zero
deltamat=zero
!
!
call vca_gf_cluster(omega,gfprime)
if(Nlat_bath>0.and.Norb_bath>0)then
deltamat=delta_bath_freq(omega,vca_bath)
endif
!
do ii=1,size(impHk,7)
tmp_mat=eye(Nlat*Nspin*Norb)+matmul(vca_nnn2lso_reshape(deltamat+impHloc-impHk(:,:,:,:,:,:,ii),Nlat,Nspin,Norb),vca_nnn2lso_reshape(gfprime,Nlat,Nspin,Norb))
out_1=out_1+log(abs(det(tmp_mat)))
enddo
out_1=out_1/size(impHk,7)
!
deallocate(tmp_mat)
deallocate(gfprime)
return
!
end function sum_kmesh
function sum_kmesh_complex(omega) result(out_1)
integer :: ii,jj,kk
complex(8) :: omega
complex(8) :: out_1
complex(8),allocatable,dimension(:,:) :: tmp_mat
complex(8),allocatable,dimension(:,:,:,:,:,:) :: deltamat
!
out_1=0.d0
!
!
if(allocated(tmp_mat))deallocate(tmp_mat)
if(allocated(gfprime))deallocate(gfprime)
if(allocated(deltamat))deallocate(deltamat)
!
allocate(tmp_mat(Nlat*Nspin*Norb,Nlat*Nspin*Norb))
allocate(deltamat(Nlat,Nlat,Nspin,Nspin,Norb,Norb))
allocate(gfprime(Nlat,Nlat,Nspin,Nspin,Norb,Norb))
!
tmp_mat=zero
gfprime=zero
deltamat=zero
!
!
call vca_gf_cluster(omega,gfprime)
if(Nlat_bath>0.and.Norb_bath>0)then
deltamat=delta_bath_freq(omega,vca_bath)
endif
!
do ii=1,size(impHk,7)
tmp_mat=eye(Nlat*Nspin*Norb)+matmul(vca_nnn2lso_reshape(deltamat+impHloc-impHk(:,:,:,:,:,:,ii),Nlat,Nspin,Norb),vca_nnn2lso_reshape(gfprime,Nlat,Nspin,Norb))
out_1=out_1+log(det(tmp_mat))
enddo
out_1=out_1/size(impHk,7)
!
deallocate(tmp_mat)
deallocate(gfprime)
return
!
end function sum_kmesh_complex
!+------------------------------------------------------------------+
!PURPOSE : Do the frequency sum at zero T
!+------------------------------------------------------------------+
function frequency_integration() result(out_2)
integer :: inf
real(8) :: out_2,spin_multiplicity
!
out_2=0.d0
spin_multiplicity=3.d0-Nspin
!
!
write(LOGfile,"(A)")"Calculating Omega"
call quad(imaginary_axis,a=0.0d0,inf=1,verbose=(verbose>=3),result=out_2,strict=.false.)
!
out_2=spin_multiplicity*out_2/pi
return
end function frequency_integration
function imaginary_axis(zeta) result(f)
real(8) :: zeta,f
complex(8) :: w
!
w=xi*zeta
!
f=sum_kmesh(w)
end function imaginary_axis
!+------------------------------------------------------------------+
!PURPOSE : Do the frequency sum at finite T
!+------------------------------------------------------------------+
function frequency_integration_finite_t() result(out_2)
integer :: inf,Nmax,ii
real(8) :: out_2,spin_multiplicity,omegamax,integralpart
!
!1) Find the real omegamax
nmax=int(2*(abs(max_exc)+bandwidth)*beta/pi)
if (mod(nmax,2)==0)then
nmax=nmax/2
else
nmax=(nmax+1)/2
endif
integrationR=2*(nmax+1)*pi/beta
print*,"NMAX=",nmax
print*,"INTEGRATION R=",integrationR
!2) Evaluate discrete sum
!
out_2=0.d0
do ii=0,Nmax
out_2=out_2+dreal(sum_kmesh_complex(xi*(2*ii+1)*pi/beta))
enddo
!
out_2=2.d0*(1/beta)*out_2
print*,"SUM PART = ",out_2
!
!3) Evaluate integral part
integralpart=0.d0
call quad(integral_contour,a=0.0d0,b=pi,verbose=(verbose>=3),key=6,result=integralpart,strict=.false.)
!
print*,"INTEGRAL PART = ",integralpart
!4) Sum all
out_2=out_2+integralpart
!5) Spin trick
spin_multiplicity=3.d0-Nspin
out_2=spin_multiplicity*out_2
return
end function frequency_integration_finite_t
function integral_contour(zeta) result(f)
real(8) :: zeta,f
complex(8) :: w,fermi
!
w=integrationR*exp(xi*zeta)
if(dreal((w-XMU)*beta)>= 100)then
fermi=0.d0
else
fermi=(1/(exp(beta*(w-XMU))+1))
endif
!
f=dreal((1/pi)*w*fermi*sum_kmesh_complex(w))
!print*,zeta,f,fermi,sum_kmesh(w)
end function integral_contour
!+------------------------------------------------------------------+
!PURPOSE : DEBUG
!+------------------------------------------------------------------+
subroutine reconstruct_g
complex(8),allocatable,dimension(:,:) :: tmp_mat
character(len=64) :: suffix
integer :: ilat,jlat,iorb,jorb,ispin,ifreq
!
allocate(gftest(Nlat,Nlat,Nspin,Nspin,Norb,Norb,Lmats))
gftest=0
!
!
if(.not.allocated(wm))allocate(wm(Lmats))
wm = pi/beta*real(2*arange(1,Lmats)-1,8)
!
do ifreq=1,size(wm)
call vca_gf_cluster(xi*wm(ifreq),gftest(:,:,:,:,:,:,ifreq))
enddo
!
do ilat=1,Nlat
do jlat=1,Nlat
do iorb=1,Norb
do jorb=1,Norb
do ispin=1,Nspin
suffix="_Isite"//str(ilat,4)//"_Jsite"//str(jlat,4)//"_l"//str(iorb)//str(jorb)//"_s"//str(ispin)
call splot("Gtest"//reg(suffix)//"_iw"//reg(file_suffix)//".vca" ,wm,gftest(ilat,jlat,ispin,ispin,iorb,jorb,:))
enddo
enddo
enddo
enddo
enddo
!
if(allocated(wm))deallocate(wm)
if(allocated(gftest))deallocate(gftest)
!
end subroutine reconstruct_g
subroutine test_g
complex(8),allocatable,dimension(:,:) :: tmp_mat
character(len=64) :: suffix
integer :: ilat,jlat,iorb,ispin,ifreq
!
allocate(gftest(Nlat,Nlat,Nspin,Nspin,Norb,Norb,Lmats))
gftest=0
!
!
call vca_gf_cluster(xi*0.5d0,gftest(:,:,:,:,:,:,1))
if(allocated(gftest))deallocate(gftest)
!
end subroutine test_g
!subroutine test_ksum
! integer :: ii,jj,kk
! real(8) :: omega
! real(8) :: out_1
! complex(8),allocatable,dimension(:,:) :: tmp_mat
! !
! out_1=0.d0
! omega=1.0d0
! !
! !
! if(allocated(tmp_mat))deallocate(tmp_mat)
! if(allocated(gfprime))deallocate(gfprime)
! !
! allocate(tmp_mat(Nlat*Nspin*Norb,Nlat*Nspin*Norb))
! allocate(gfprime(Nlat,Nlat,Nspin,Nspin,Norb,Norb))
! !
! tmp_mat=zero
! gfprime=zero
! !
! call vca_gf_cluster(xi*omega,gfprime)
! do ii=1,size(impHk,7)
! print*,"ITERATION",ii
! !print*,"OMEGA",xi*omega
! !print*,"AAAAAAAAA",matmul(vca_nnn2lso_reshape(impHk(:,:,:,:,:,:,ii)-impHloc,Nlat,Nspin,Norb),vca_nnn2lso_reshape(gfprime,Nlat,Nspin,Norb))
! !print*,"BBBBBBBBB",vca_nnn2lso_reshape(impHk(:,:,:,:,:,:,ii)-impHloc,Nlat,Nspin,Norb)
! tmp_mat=eye(Nlat*Nspin*Norb)+matmul(vca_nnn2lso_reshape(impHk(:,:,:,:,:,:,ii)-impHloc,Nlat,Nspin,Norb),vca_nnn2lso_reshape(gfprime,Nlat,Nspin,Norb))
! out_1=out_1+log(abs(REAL(det(tmp_mat))))
! print*,"CCCCCCCCC",(vca_nnn2lso_reshape(impHk(:,:,:,:,:,:,ii)-impHloc,Nlat,Nspin,Norb))
! enddo
! out_1=out_1/size(impHk,7) !*(pi**Ndim)
! !
! deallocate(tmp_mat)
! deallocate(gfprime)
! return
! !
!end subroutine test_ksum
!function frequency_integration_sample() result(out_2)
! integer :: N,i
! real(8),dimension(:),allocatable :: x,func
! real(8) :: out_2,a,b,spin_multiplicity
! !
! a=0.0001d0
! b=99999.d0
! N=1000
! out_2=0.d0
! spin_multiplicity=2.d0
! allocate(x(N),func(N))
! x = linspace(a,b,N)
! do i=1,N
! func(i) = sum_kmesh(xi*x(i))
! enddo
! call quad(func,a,b,Ninterp=3,key=6,epsabs=0d0,epsrel=1d-4,verbose=.true.,result=out_2)
! out_2=spin_multiplicity*out_2/pi
! deallocate(x,func)
! return
!end function frequency_integration_sample
end MODULE VCA_OMEGA