-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathed_lanc_gf_superc.f90
360 lines (334 loc) · 14.1 KB
/
ed_lanc_gf_superc.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
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
!+------------------------------------------------------------------+
!PURPOSE : Evaluate Green's functions using Lanczos algorithm
!+------------------------------------------------------------------+
subroutine lanc_ed_getgf_superc()
integer :: izero,iorb,jorb,ispin,i
integer :: isect0,numstates
real(8) :: norm0
call allocate_grids
allocate(Gaux_mats(3,Lmats),Gaux_real(3,Lreal))
if(.not.allocated(impGmats))allocate(impGmats(Nspin,Nspin,Norb,Norb,Lmats))
if(.not.allocated(impGreal))allocate(impGreal(Nspin,Nspin,Norb,Norb,Lreal))
if(.not.allocated(impFmats))allocate(impFmats(Nspin,Nspin,Norb,Norb,Lmats))
if(.not.allocated(impFreal))allocate(impFreal(Nspin,Nspin,Norb,Norb,Lreal))
impGmats=zero
impGreal=zero
impFmats=zero
impFreal=zero
Gaux_mats=zero
Gaux_real=zero
do ispin=1,Nspin
do iorb=1,Norb
if(ed_verbose<3)write(LOGfile,"(A)")"Get G&F_l"//reg(txtfy(iorb))//"_s"//reg(txtfy(ispin))
call lanc_ed_buildgf_sc_d(iorb,ispin,.false.)
enddo
enddo
!
do ispin=1,Nspin
do iorb=1,Norb
impGmats(ispin,ispin,iorb,iorb,:) = Gaux_mats(1,:)
impGreal(ispin,ispin,iorb,iorb,:) = Gaux_real(1,:)
impFmats(ispin,ispin,iorb,iorb,:) = 0.5d0*(Gaux_mats(3,:)-Gaux_mats(2,:)-Gaux_mats(1,:))
impFreal(ispin,ispin,iorb,iorb,:) = 0.5d0*(Gaux_real(3,:)-Gaux_real(2,:)-Gaux_real(1,:))
enddo
enddo
!
!Print impurity functions:
call print_imp_gf_sc
deallocate(wm,wr,tau,vm)
deallocate(impGmats,impGreal)
deallocate(impFmats,impFreal)
deallocate(Gaux_mats,Gaux_real)
end subroutine lanc_ed_getgf_superc
!+------------------------------------------------------------------+
!PURPOSE : DOUBLE PRECISION
!+------------------------------------------------------------------+
subroutine lanc_ed_buildgf_sc_d(iorb,ispin,iverbose)
real(8),allocatable :: vvinit(:)
real(8),allocatable :: alfa_(:),beta_(:)
integer :: iorb,ispin,isite,isect0,izero
integer :: idim0,jsect0
integer :: jdim0,isz0,jsz0
integer :: ib(Ntot)
integer :: m,i,j,r,numstates
real(8) :: sgn,norm2,norm0
complex(8) :: cnorm2
integer :: Nitermax,Nlanc
logical,optional :: iverbose
logical :: iverbose_
integer,allocatable,dimension(:) :: HImap,HJmap
!
iverbose_=.false.;if(present(iverbose))iverbose_=iverbose
!
Nitermax=lanc_nGFiter
allocate(alfa_(Nitermax),beta_(Nitermax))
!
isite=impIndex(iorb,ispin)
!
numstates=numgs
if(finiteT)numstates=state_list%size
!
if(ed_verbose<2)call start_progress
do izero=1,numstates
if(ed_verbose<1)call progress(izero,numstates)
isect0 = es_return_sector(state_list,izero)
state_e = es_return_energy(state_list,izero)
state_vec => es_return_vector(state_list,izero)
norm0=sqrt(dot_product(state_vec,state_vec))
if(abs(norm0-1.d0)>1.d-9)stop "GS is not normalized"
idim0 = getdim(isect0)
allocate(HImap(idim0))
call build_sector(isect0,HImap)
!APPLY CDG_UP
jsect0 = getCDGsector(1,isect0)
if(jsect0/=0)then
jdim0 = getdim(jsect0)
if(iverbose_)&
write(LOGfile,"(A,I3,I15)")'apply cdg_up:',getsz(jsect0),jdim0
allocate(HJmap(jdim0),vvinit(jdim0))
call build_sector(jsect0,HJmap) !note that here you are doing twice the map building...
vvinit=0.d0
do m=1,idim0 !loop over |gs> components m
i=HImap(m) !map m to Hilbert space state i
call bdecomp(i,ib) !i into binary representation
if(ib(iorb)==0)then !if impurity is empty: proceed
call cdg(iorb,i,r,sgn)
j=binary_search(HJmap,r) !map r back to jsect0
vvinit(j) = sgn*state_vec(m) !build the cdg_up|gs> state
endif
enddo
deallocate(HJmap)
norm2=dot_product(vvinit,vvinit)
vvinit=vvinit/sqrt(norm2)
alfa_=0.d0 ; beta_=0.d0 ; nlanc=nitermax
call ed_buildH_d(jsect0)
call lanczos_plain_set_htimesv_d(lanc_spHtimesV_dd)
call lanczos_plain_tridiag_d(vvinit,alfa_,beta_,nlanc)
call lanczos_plain_delete_htimesv
cnorm2=one*norm2
call add_to_lanczos_gf_sc(cnorm2,state_e,nlanc,alfa_,beta_,1,iorb,iorb,ichan=1)
deallocate(vvinit)
if(spH0%status)call sp_delete_matrix(spH0)
endif
!APPLY C_DW
jsect0 = getCsector(2,isect0)
if(jsect0/=0)then
jdim0 = getdim(jsect0)
if(iverbose_)&
write(LOGfile,"(A,I3,I15)")'apply c_dw:',getsz(jsect0),jdim0
allocate(HJmap(jdim0),vvinit(jdim0))
call build_sector(jsect0,HJmap) !note that here you are doing twice the map building...
vvinit=0.d0
do m=1,idim0 !loop over |gs> components m
i=HImap(m) !map m to Hilbert space state i
call bdecomp(i,ib) !i into binary representation
if(ib(iorb+Ns)==1)then !if impurity is empty: proceed
call c(iorb+Ns,i,r,sgn)
j=binary_search(HJmap,r) !map r back to jsect0
vvinit(j) = sgn*state_vec(m) !build the cdg_up|gs> state
endif
enddo
deallocate(HJmap)
norm2=dot_product(vvinit,vvinit)
vvinit=vvinit/sqrt(norm2)
alfa_=0.d0 ; beta_=0.d0 ; nlanc=nitermax
call ed_buildH_d(jsect0)
call lanczos_plain_set_htimesv_d(lanc_spHtimesV_dd)
call lanczos_plain_tridiag_d(vvinit,alfa_,beta_,nlanc)
call lanczos_plain_delete_htimesv
cnorm2=one*norm2
call add_to_lanczos_gf_sc(cnorm2,state_e,nlanc,alfa_,beta_,1,iorb,iorb,ichan=2)
deallocate(vvinit)
if(spH0%status)call sp_delete_matrix(spH0)
endif
!APPLY CDG_UP + C_DW
isz0 = getsz(isect0)
if(isz0<Ns)then
jsz0 = isz0+1
jsect0 = getsector(jsz0,1)
jdim0 = getdim(jsect0)
if(iverbose_)&
write(LOGfile,"(A,I3,I15)")'apply c_dw:',getsz(jsect0),jdim0
allocate(HJmap(jdim0),vvinit(jdim0))
call build_sector(jsect0,HJmap) !note that here you are doing twice the map building...
vvinit=0.d0
do m=1,idim0 !loop over |gs> components m
i=HImap(m) !map m to Hilbert space state i
call bdecomp(i,ib) !i into binary representation
if(ib(iorb)==0)then !if impurity is empty: proceed
call cdg(iorb,i,r,sgn)
j=binary_search(HJmap,r) !map r back to jsect0
vvinit(j) = sgn*state_vec(m) !build the cdg_up|gs> state
endif
enddo
do m=1,idim0 !loop over |gs> components m
i=HImap(m) !map m to Hilbert space state i
call bdecomp(i,ib) !i into binary representation
if(ib(iorb+Ns)==1)then !if impurity is empty: proceed
call c(iorb+Ns,i,r,sgn)
j=binary_search(HJmap,r) !map r back to jsect0
vvinit(j) = vvinit(j) + sgn*state_vec(m) !build the cdg_up|gs> state
endif
enddo
deallocate(HJmap)
norm2=dot_product(vvinit,vvinit)
vvinit=vvinit/sqrt(norm2)
alfa_=0.d0 ; beta_=0.d0 ; nlanc=nitermax
call ed_buildH_d(jsect0)
call lanczos_plain_set_htimesv_d(lanc_spHtimesV_dd)
call lanczos_plain_tridiag_d(vvinit,alfa_,beta_,nlanc)
call lanczos_plain_delete_htimesv
cnorm2=one*norm2
call add_to_lanczos_gf_sc(cnorm2,state_e,nlanc,alfa_,beta_,1,iorb,iorb,ichan=3)
deallocate(vvinit)
if(spH0%status)call sp_delete_matrix(spH0)
endif
!APPLY C_UP
jsect0 = getCsector(1,isect0)
if(jsect0/=0)then
jdim0 = getdim(jsect0)
if(iverbose_)&
write(LOGfile,"(A,I3,I15)")'apply cdg_up:',getsz(jsect0),jdim0
allocate(HJmap(jdim0),vvinit(jdim0))
call build_sector(jsect0,HJmap) !note that here you are doing twice the map building...
vvinit=0.d0
do m=1,idim0 !loop over |gs> components m
i=HImap(m) !map m to Hilbert space state i
call bdecomp(i,ib) !i into binary representation
if(ib(iorb)==1)then !if impurity is empty: proceed
call c(iorb,i,r,sgn)
j=binary_search(HJmap,r) !map r back to jsect0
vvinit(j) = sgn*state_vec(m) !build the cdg_up|gs> state
endif
enddo
deallocate(HJmap)
norm2=dot_product(vvinit,vvinit)
vvinit=vvinit/sqrt(norm2)
alfa_=0.d0 ; beta_=0.d0 ; nlanc=nitermax
call ed_buildH_d(jsect0)
call lanczos_plain_set_htimesv_d(lanc_spHtimesV_dd)
call lanczos_plain_tridiag_d(vvinit,alfa_,beta_,nlanc)
call lanczos_plain_delete_htimesv
cnorm2=one*norm2
call add_to_lanczos_gf_sc(cnorm2,state_e,nlanc,alfa_,beta_,-1,iorb,iorb,ichan=1)
deallocate(vvinit)
if(spH0%status)call sp_delete_matrix(spH0)
endif
!APPLY CDG_DW
jsect0 = getCDGsector(2,isect0)
if(jsect0/=0)then
jdim0 = getdim(jsect0)
if(iverbose_)&
write(LOGfile,"(A,I3,I15)")'apply c_dw:',getsz(jsect0),jdim0
allocate(HJmap(jdim0),vvinit(jdim0))
call build_sector(jsect0,HJmap) !note that here you are doing twice the map building...
vvinit=0.d0
do m=1,idim0 !loop over |gs> components m
i=HImap(m) !map m to Hilbert space state i
call bdecomp(i,ib) !i into binary representation
if(ib(iorb+Ns)==0)then !if impurity is empty: proceed
call cdg(iorb+Ns,i,r,sgn)
j=binary_search(HJmap,r) !map r back to jsect0
vvinit(j) = sgn*state_vec(m) !build the cdg_up|gs> state
endif
enddo
deallocate(HJmap)
norm2=dot_product(vvinit,vvinit)
vvinit=vvinit/sqrt(norm2)
alfa_=0.d0 ; beta_=0.d0 ; nlanc=nitermax
call ed_buildH_d(jsect0)
call lanczos_plain_set_htimesv_d(lanc_spHtimesV_dd)
call lanczos_plain_tridiag_d(vvinit,alfa_,beta_,nlanc)
call lanczos_plain_delete_htimesv
cnorm2=one*norm2
call add_to_lanczos_gf_sc(cnorm2,state_e,nlanc,alfa_,beta_,-1,iorb,iorb,ichan=2)
deallocate(vvinit)
if(spH0%status)call sp_delete_matrix(spH0)
endif
!APPLY C_UP + CDG_DW
isz0 = getsz(isect0)
if(isz0>-Ns)then
jsz0 = isz0-1
jsect0 = getsector(jsz0,1)
jdim0 = getdim(jsect0)
if(iverbose_)&
write(LOGfile,"(A,I3,I15)")'apply c_dw:',getsz(jsect0),jdim0
allocate(HJmap(jdim0),vvinit(jdim0))
call build_sector(jsect0,HJmap) !note that here you are doing twice the map building...
vvinit=0.d0
do m=1,idim0 !loop over |gs> components m
i=HImap(m) !map m to Hilbert space state i
call bdecomp(i,ib) !i into binary representation
if(ib(iorb)==1)then !if impurity is empty: proceed
call c(iorb,i,r,sgn)
j=binary_search(HJmap,r) !map r back to jsect0
vvinit(j) = sgn*state_vec(m) !build the cdg_up|gs> state
endif
enddo
do m=1,idim0 !loop over |gs> components m
i=HImap(m) !map m to Hilbert space state i
call bdecomp(i,ib) !i into binary representation
if(ib(iorb+Ns)==0)then !if impurity is empty: proceed
call cdg(iorb+Ns,i,r,sgn)
j=binary_search(HJmap,r) !map r back to jsect0
vvinit(j) = vvinit(j) + sgn*state_vec(m) !build the cdg_up|gs> state
endif
enddo
deallocate(HJmap)
norm2=dot_product(vvinit,vvinit)
vvinit=vvinit/sqrt(norm2)
alfa_=0.d0 ; beta_=0.d0 ; nlanc=nitermax
call ed_buildH_d(jsect0)
call lanczos_plain_set_htimesv_d(lanc_spHtimesV_dd)
call lanczos_plain_tridiag_d(vvinit,alfa_,beta_,nlanc)
call lanczos_plain_delete_htimesv
cnorm2=one*norm2
call add_to_lanczos_gf_sc(cnorm2,state_e,nlanc,alfa_,beta_,-1,iorb,iorb,ichan=3)
deallocate(vvinit)
if(spH0%status)call sp_delete_matrix(spH0)
endif
!
nullify(state_vec)
deallocate(HImap)
!
enddo
if(ed_verbose<2)call stop_progress
deallocate(alfa_,beta_)
end subroutine lanc_ed_buildgf_sc_d
!+------------------------------------------------------------------+
!PURPOSE :
!+------------------------------------------------------------------+
subroutine add_to_lanczos_gf_sc(vnorm2,Ei,nlanc,alanc,blanc,isign,iorb,jorb,ichan)
complex(8) :: vnorm2,pesoBZ,peso
real(8) :: Ei,Egs,de
integer :: nlanc
real(8),dimension(nlanc) :: alanc,blanc
integer :: isign,iorb,jorb,ispin,ichan
real(8),dimension(size(alanc),size(alanc)) :: Z
real(8),dimension(size(alanc)) :: diag,subdiag
integer :: i,j,ierr
complex(8) :: iw
!
ispin=1
Egs = state_list%emin !get the gs energy
pesoBZ = vnorm2/zeta_function
if(finiteT)pesoBZ = vnorm2*exp(-beta*(Ei-Egs))/zeta_function
!
diag=0.d0 ; subdiag=0.d0 ; Z=0.d0
forall(i=1:Nlanc)Z(i,i)=1.d0
diag(1:Nlanc) = alanc(1:Nlanc)
subdiag(2:Nlanc) = blanc(2:Nlanc)
call tql2(Nlanc,diag,subdiag,Z,ierr)
do j=1,nlanc
de = diag(j)-Ei
peso = pesoBZ*Z(1,j)*Z(1,j)
do i=1,Lmats
iw=xi*wm(i)
Gaux_mats(ichan,i)=Gaux_mats(ichan,i) + peso/(iw-isign*de)
enddo
do i=1,Lreal
iw=dcmplx(wr(i),eps)
Gaux_real(ichan,i)=Gaux_real(ichan,i) + peso/(iw-isign*de)
enddo
enddo
end subroutine add_to_lanczos_gf_sc