-
Notifications
You must be signed in to change notification settings - Fork 1
/
VCA_OBSERVABLES.f90
621 lines (575 loc) · 22.5 KB
/
VCA_OBSERVABLES.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
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
MODULE VCA_OBSERVABLES
USE VCA_INPUT_VARS
USE VCA_BATH_FUNCTIONS
USE VCA_VARS_GLOBAL
USE VCA_SETUP
USE VCA_DIAG
USE VCA_IO, only:vca_gf_cluster
USE VCA_GF_SHARED, only:max_exc
USE VCA_AUX_FUNX
USE VCA_EIGENSPACE
USE VCA_HAMILTONIAN
!
USE SF_CONSTANTS, only:zero,pi,xi
USE SF_IOTOOLS, only:free_unit,reg,txtfy
USE SF_ARRAYS, only: arange
USE SF_LINALG
USE SF_INTEGRATE
!
implicit none
private
!
interface add_custom_observable
module procedure :: add_custom_observable_local
module procedure :: add_custom_observable_kdep
end interface add_custom_observable
public :: observables_cluster
public :: init_custom_observables
public :: add_custom_observable
public :: get_custom_observables
public :: clear_custom_observables
logical,save :: iolegend=.true.
real(8),dimension(:,:),allocatable :: dens,dens_up,dens_dw
real(8),dimension(:,:),allocatable :: docc
real(8),dimension(:,:),allocatable :: magz
real(8),dimension(:,:,:),allocatable :: sz2
real(8),dimension(:,:,:),allocatable :: zimp,simp
real(8) :: Egs
real(8) :: s2tot
real(8) :: Ei
real(8) :: integrationR
!
integer :: r,m,k,k1,k2,Nkpts
integer :: iup,idw
integer :: jup,jdw
integer :: mup,mdw
real(8) :: sgn,sgn1,sgn2,sg1,sg2
real(8) :: gs_weight
!
real(8) :: peso
real(8) :: norm
!
integer :: i,j,ii
integer :: isector,jsector
integer :: idim,idimUP,idimDW
complex(8),allocatable,dimension(:,:,:,:,:,:,:) :: sij
!
complex(8),dimension(:),allocatable :: state_cvec
logical :: Jcondition
contains
!+---------------------------------------------------------------------------------+
!PURPOSE : Evaluate and print out many interesting physical qties for the cluster
!+---------------------------------------------------------------------------------+
subroutine observables_cluster()
integer :: iorb
write(LOGfile,"(A)")"Get cluster observables:"
call vca_lanc_observables
end subroutine observables_cluster
subroutine init_custom_observables(N,Nktot_)
integer :: N,Nktot_
!
if(MpiMaster)then
custom_o%N_filled=0
custom_o%N_asked=N
allocate(custom_o%item(N))
custom_o%init=.true.
Nkpts=Nktot_
endif
!
end subroutine init_custom_observables
subroutine add_custom_observable_local(o_name,sij)
integer :: i
complex(8),dimension(:,:,:,:,:,:) :: sij
character(len=*) :: o_name
!
if(MpiMaster .and. custom_o%init)then
if(custom_o%N_filled .gt. custom_o%N_asked)then
STOP "add_custom_observable: too many observables given"
call clear_custom_observables
endif
!
custom_o%N_filled=custom_o%N_filled+1
custom_o%item(custom_o%N_filled)%o_name=o_name
custom_o%item(custom_o%N_filled)%o_value=0.d0
!
allocate(custom_o%item(custom_o%N_filled)%sij(Nlat,Nlat,Nspin,Nspin,Norb,Norb,Nkpts))
do i=1,size(custom_o%item(custom_o%N_filled)%sij,7)
custom_o%item(custom_o%N_filled)%sij(:,:,:,:,:,:,i)=sij
enddo
else
STOP "add_custom_observable: custom observables not initialized"
endif
end subroutine add_custom_observable_local
subroutine add_custom_observable_kdep(o_name,sijk)
integer :: i
complex(8),dimension(:,:,:,:,:,:,:) :: sijk
character(len=*) :: o_name
!
if(MpiMaster .and. custom_o%init)then
if(custom_o%N_filled .gt. custom_o%N_asked)then
STOP "add_custom_observable: too many observables given"
call clear_custom_observables
endif
!
custom_o%N_filled=custom_o%N_filled+1
custom_o%item(custom_o%N_filled)%o_name=o_name
custom_o%item(custom_o%N_filled)%o_value=0.d0
!
allocate(custom_o%item(custom_o%N_filled)%sij(Nlat,Nlat,Nspin,Nspin,Norb,Norb,Nkpts))
custom_o%item(custom_o%N_filled)%sij=sijk
else
STOP "add_custom_observable: custom observables not initialized"
endif
end subroutine add_custom_observable_kdep
subroutine get_custom_observables()
integer :: i
!
if(MpiMaster .and. custom_o%init)then
if(custom_o%N_filled .eq. 0)then
write(Logfile,*)"WARNING! Custom observables initialized but none given."
RETURN
endif
!
write(LOGfile,*)"Calculating custom observables"
!
allocate(sij(Nlat,Nlat,Nspin,Nspin,Norb,Norb,Nkpts))
sij=zero
!
do i=1,custom_o%N_filled
sij=custom_o%item(i)%sij
if(finiteT) then
custom_o%item(i)%o_value=calculate_observable_integral_finite_t()
else
custom_o%item(i)%o_value=calculate_observable_integral_zero_t()
endif
write(LOGfile,"(A,10f18.12,A)")reg(custom_o%item(i)%o_name)//" = ",custom_o%item(i)%o_value
enddo
call write_custom_legend()
call write_custom_observables()
deallocate(sij)
endif
!
end subroutine get_custom_observables
subroutine clear_custom_observables()
integer :: i
if(MpiMaster .and. custom_o%init)then
do i=1,custom_o%N_filled
deallocate(custom_o%item(i)%sij)
custom_o%item(i)%o_name=""
custom_o%item(i)%o_value=0.d0
enddo
custom_o%N_asked=0
custom_o%N_filled=0
custom_o%init=.false.
endif
end subroutine clear_custom_observables
!+-------------------------------------------------------------------+
!PURPOSE : Evaluate and print out many interesting physical qties for the cluster
!+-------------------------------------------------------------------+
subroutine vca_lanc_observables()
integer,dimension(Ns) :: IbUp,IbDw ![Ns]
integer,dimension(Ns_Ud,Ns_Orb) :: Nups,Ndws ![1,Ns]-[Norb,1+Nbath]
integer,dimension(2*Ns_Ud) :: Indices,Jndices
integer,dimension(Ns_Ud) :: iDimUps,iDimDws
integer :: i,j,ii
integer :: istate
integer :: isector,jsector
integer :: idim,jdim,ilat
integer :: isz,jsz
integer :: iorb,jorb,ispin,jspin,isite,jsite,ibath
integer :: numstates
integer :: r,m,k
real(8) :: sgn,sgn1,sgn2
real(8) :: weight
real(8) :: Ei
real(8) :: peso
real(8) :: norm
real(8),dimension(Nlat,Norb) :: nup,ndw,Sz,nt
complex(8),dimension(:),allocatable :: state_cvec
type(sector_map) :: Hi(2*Ns_Ud)
!
!LOCAL OBSERVABLES:
allocate(dens(Nlat,Norb),dens_up(Nlat,Norb),dens_dw(Nlat,Norb))
allocate(docc(Nlat,Norb))
allocate(magz(Nlat,Norb),sz2(Nlat,Norb,Norb))
allocate(simp(Nlat,Norb,Nspin),zimp(Nlat,Norb,Nspin))
!
dens = 0.d0
dens_up = 0.d0
dens_dw = 0.d0
docc = 0.d0
magz = 0.d0
sz2 = 0.d0
simp = 0.d0
zimp = 0.d0
nup = 0.d0
ndw = 0.d0
Egs = state_list%emin
!
do istate=1,state_list%size
isector = es_return_sector(state_list,istate)
Ei = es_return_energy(state_list,istate)
!
#ifdef _MPI
if(MpiStatus)then
call es_return_cvector(MpiComm,state_list,istate,state_cvec)
else
call es_return_cvector(state_list,istate,state_cvec)
endif
#else
call es_return_cvector(state_list,istate,state_cvec)
#endif
!
idim = getdim(isector)
call get_DimUp(isector,iDimUps)
call get_DimDw(isector,iDimDws)
iDimUp = product(iDimUps)
iDimDw = product(iDimDws)
!norm=sqrt(dot_product(state_cvec,state_cvec))
!
!if(abs(norm-1.d0)>1.d-9)stop "GS is not normalized"
!
peso = 1.d0 ; if(finiteT)peso=exp(-beta*(Ei-Egs))
peso = peso/zeta_function
!
if(MpiMaster)then
call build_sector(isector,Hi)
do i=1,idim
call state2indices(i,[iDimUps,iDimDws],Indices)
do ii=1,Ns_Ud
mup = HI(ii)%map(Indices(ii))
mdw = HI(ii+Ns_Ud)%map(Indices(ii+Ns_ud))
Nups(ii,:) = Bdecomp(mup,Ns_Orb)
Ndws(ii,:) = Bdecomp(mdw,Ns_Orb)
enddo
IbUp = Breorder(Nups)
IbDw = Breorder(Ndws)
!
gs_weight=peso*abs(state_cvec(i))**2
!
!Get operators:
do ilat=1,Nlat
do iorb=1,Norb
nup(ilat,iorb)= ibup(imp_state_index(ilat,iorb))
ndw(ilat,iorb)= ibdw(imp_state_index(ilat,iorb))
sz(ilat,iorb) = (nup(ilat,iorb) - ndw(ilat,iorb))/2d0
nt(ilat,iorb) = nup(ilat,iorb) + ndw(ilat,iorb)
enddo
enddo
!
!Evaluate averages of observables:
do ilat=1,Nlat
do iorb=1,Norb
dens(ilat,iorb) = dens(ilat,iorb) + nt(ilat,iorb)*gs_weight
dens_up(ilat,iorb) = dens_up(ilat,iorb) + nup(ilat,iorb)*gs_weight
dens_dw(ilat,iorb) = dens_dw(ilat,iorb) + ndw(ilat,iorb)*gs_weight
docc(ilat,iorb) = docc(ilat,iorb) + nup(ilat,iorb)*ndw(ilat,iorb)*gs_weight
magz(ilat,iorb) = magz(ilat,iorb) + (nup(ilat,iorb)-ndw(ilat,iorb))*gs_weight
sz2(ilat,iorb,iorb) = sz2(ilat,iorb,iorb) + (sz(ilat,iorb)*sz(ilat,iorb))*gs_weight
do jorb=iorb+1,Norb
sz2(ilat,iorb,jorb) = sz2(ilat,iorb,jorb) + (sz(ilat,iorb)*sz(ilat,jorb))*gs_weight
sz2(ilat,jorb,iorb) = sz2(ilat,jorb,iorb) + (sz(ilat,jorb)*sz(ilat,iorb))*gs_weight
enddo
enddo
s2tot = s2tot + (sum(sz))**2*gs_weight
enddo
enddo
call delete_sector(isector,HI)
endif
!
if(allocated(state_cvec))deallocate(state_cvec)
!
enddo
if(MPIMASTER)then
call get_szr
if(iolegend)call write_legend
call write_observables()
!
do ilat=1,Nlat
write(LOGfile,"(A,10f18.12,f18.12,A)")"dens site "//str(ilat)//" "//reg(file_suffix)//"=",(dens(ilat,iorb),iorb=1,Norb),sum(dens(ilat,:))
enddo
write(LOGfile,"(A,10f18.12,f18.12,A)")"dens avg "//reg(file_suffix)//" =",(sum(dens(:,iorb))/Nlat,iorb=1,Norb),sum(dens)/Nlat
!
write(LOGfile,"(A,10f18.12,A)")"docc "//reg(file_suffix)//" =",(sum(docc(:,iorb))/Nlat,iorb=1,Norb)
if(Nspin==2)write(LOGfile,"(A,10f18.12,A)") "mag "//reg(file_suffix)//"=",(sum(magz(:,iorb))/Nlat,iorb=1,Norb)
!
imp_dens_up=dens_up
imp_dens_dw=dens_dw
imp_dens =dens
imp_docc =docc
endif
#ifdef _MPI
if(MpiStatus)then
call Bcast_MPI(MpiComm,dens_up)
call Bcast_MPI(MpiComm,dens_dw)
call Bcast_MPI(MpiComm,dens)
call Bcast_MPI(MpiComm,docc)
endif
#endif
deallocate(dens,docc,dens_up,dens_dw,magz,sz2)
deallocate(simp,zimp)
end subroutine vca_lanc_observables
!+---------------------------------------------------------------------------------+
!PURPOSE : Evaluate and print out custom observable
!+---------------------------------------------------------------------------------+
!T=0
function calculate_observable_integral_zero_t() result(out_2)
integer :: inf
real(8) :: out_2,spin_multiplicity
!
out_2=0.d0
spin_multiplicity=3.d0-Nspin
!
call quad(sum_observable_kmesh,a=0.0d0,inf=1,verbose=(VERBOSE>=3),result=out_2,strict=.false.)
!
out_2=spin_multiplicity*out_2/(pi)
return
end function calculate_observable_integral_zero_t
!T finite
function calculate_observable_integral_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
!2) Evaluate discrete sum
!
out_2=0.d0
do ii=0,Nmax
out_2=out_2+dreal(sum_observable_kmesh_complex(xi*(2*ii+1)*pi/beta))
enddo
!
out_2=2.d0*(1/beta)*out_2
!
!3) Evaluate integral part
integralpart=0.d0
call quad(integral_contour,a=-pi,b=pi,verbose=(VERBOSE>=3),key=6,result=integralpart,strict=.false.)
!
!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 calculate_observable_integral_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.d0/pi)*w*fermi*sum_observable_kmesh_complex(w))
end function integral_contour
!+-------------------------------------------------------------------+
!PURPOSE : sum on k-vectors
!+-------------------------------------------------------------------+
function sum_observable_kmesh(omega) result(out_1)
integer :: ii,jj,kk
real(8) :: omega
real(8) :: out_1
complex(8),allocatable,dimension(:,:) :: tmp_mat
complex(8),allocatable,dimension(:,:,:,:,:,:) :: gfprime
complex(8),allocatable,dimension(:,:) :: gfprime_lso
complex(8),allocatable,dimension(:,:) :: Gk_lso
complex(8),allocatable,dimension(:,:,:,:,:,:) :: deltamat
!
out_1=0.d0
!
!
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))
allocate(gfprime_lso(Nlat*Nspin*Norb,Nlat*Nspin*Norb))
allocate(Gk_lso(Nlat*Nspin*Norb,Nlat*Nspin*Norb))
allocate(deltamat(Nlat,Nlat,Nspin,Nspin,Norb,Norb))
!
tmp_mat=zero
gfprime=zero
gfprime_lso=zero
Gk_lso=zero
!
!
call vca_gf_cluster(xi*omega,gfprime)
gfprime_lso=vca_nnn2lso_reshape(gfprime,Nlat,Nspin,Norb)
call inv(gfprime_lso)
!
if(Nlat_bath>0.and.Norb_bath>0)then
deltamat=delta_bath_freq(xi*omega,vca_bath)
endif
!
do ii=1,size(impHk,7)
Gk_lso=vca_nnn2lso_reshape(impHk(:,:,:,:,:,:,ii)-impHloc-deltamat,Nlat,Nspin,Norb)
Gk_lso=gfprime_lso-Gk_lso
call inv(Gk_lso)
out_1=out_1+DREAL(trace(matmul(vca_nnn2lso_reshape(sij(:,:,:,:,:,:,ii),Nlat,Nspin,Norb),Gk_lso))-&
trace(vca_nnn2lso_reshape(sij(:,:,:,:,:,:,ii),Nlat,Nspin,Norb))/(xi*omega-1.1d0))
enddo
out_1=out_1/(size(impHk,7))
!
deallocate(tmp_mat)
deallocate(gfprime)
return
!
end function sum_observable_kmesh
function sum_observable_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(:,:,:,:,:,:) :: gfprime
complex(8),allocatable,dimension(:,:) :: gfprime_lso
complex(8),allocatable,dimension(:,:) :: Gk_lso
complex(8),allocatable,dimension(:,:,:,:,:,:) :: deltamat
!
out_1=0.d0
!
!
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))
allocate(gfprime_lso(Nlat*Nspin*Norb,Nlat*Nspin*Norb))
allocate(Gk_lso(Nlat*Nspin*Norb,Nlat*Nspin*Norb))
allocate(deltamat(Nlat,Nlat,Nspin,Nspin,Norb,Norb))
!
tmp_mat=zero
gfprime=zero
gfprime_lso=zero
Gk_lso=zero
!
!
call vca_gf_cluster(omega,gfprime)
gfprime_lso=vca_nnn2lso_reshape(gfprime,Nlat,Nspin,Norb)
call inv(gfprime_lso)
!
if(Nlat_bath>0.and.Norb_bath>0)then
deltamat=delta_bath_freq(omega,vca_bath)
endif
!
do ii=1,size(impHk,7)
Gk_lso=vca_nnn2lso_reshape(impHk(:,:,:,:,:,:,ii)-impHloc-deltamat,Nlat,Nspin,Norb)
Gk_lso=gfprime_lso-Gk_lso
call inv(Gk_lso)
out_1=out_1+DREAL(trace(matmul(vca_nnn2lso_reshape(sij(:,:,:,:,:,:,ii),Nlat,Nspin,Norb),Gk_lso))) !!FIXME: CHECK
enddo
out_1=out_1/(size(impHk,7))
!
deallocate(tmp_mat)
deallocate(gfprime)
return
!
end function sum_observable_kmesh_complex
!####################################################################
! COMPUTATIONAL ROUTINES
!####################################################################
!+-------------------------------------------------------------------+
!PURPOSE : get scattering rate and renormalization constant Z
!+-------------------------------------------------------------------+
subroutine get_szr()
integer :: ilat,ispin,iorb
real(8) :: wm1,wm2
wm1 = pi/beta ; wm2=3d0*pi/beta
do ilat=1,Nlat
do ispin=1,Nspin
do iorb=1,Norb
simp(ilat,iorb,ispin) = dimag(impSmats(ilat,ilat,ispin,ispin,iorb,iorb,1)) - &
wm1*(dimag(impSmats(ilat,ilat,ispin,ispin,iorb,iorb,2))-&
dimag(impSmats(ilat,ilat,ispin,ispin,iorb,iorb,1)))/(wm2-wm1)
zimp(ilat,iorb,ispin) = 1.d0/( 1.d0 + abs( dimag(impSmats(ilat,ilat,ispin,ispin,iorb,iorb,1))/wm1 ))
enddo
enddo
enddo
end subroutine get_szr
!+-------------------------------------------------------------------+
!PURPOSE : write legend, i.e. info about columns
!+-------------------------------------------------------------------+
subroutine write_legend()
integer :: unit,iorb,jorb,ispin
unit = free_unit()
open(unit,file="observables_info.vca")
write(unit,"(A1,90(A10,6X))")"#",&
(reg(txtfy(iorb))//"dens_"//reg(txtfy(iorb)),iorb=1,Norb),&
(reg(txtfy(Norb+iorb))//"docc_"//reg(txtfy(iorb)),iorb=1,Norb),&
(reg(txtfy(2*Norb+iorb))//"nup_"//reg(txtfy(iorb)),iorb=1,Norb),&
(reg(txtfy(3*Norb+iorb))//"ndw_"//reg(txtfy(iorb)),iorb=1,Norb),&
(reg(txtfy(4*Norb+iorb))//"mag_"//reg(txtfy(iorb)),iorb=1,Norb),&
reg(txtfy(5*Norb+1))//"egs",&
((reg(txtfy(5*Norb+1+(iorb-1)*Norb+jorb))//"sz2_"//reg(txtfy(iorb))//reg(txtfy(jorb)),jorb=1,Norb),iorb=1,Norb),&
((reg(txtfy((6+2*Norb)*Norb+2+(ispin-1)*Nspin+iorb))//"z_"//reg(txtfy(iorb))//"s"//reg(txtfy(ispin)),iorb=1,Norb),ispin=1,Nspin),&
((reg(txtfy((7+2*Norb)*Norb+2+Nspin+(ispin-1)*Nspin+iorb))//"sig_"//reg(txtfy(iorb))//"s"//reg(txtfy(ispin)),iorb=1,Norb),ispin=1,Nspin)
close(unit)
!
unit = free_unit()
open(unit,file="parameters_info.vca")
write(unit,"(A1,90(A14,1X))")"#","1xmu","2beta",&
(reg(txtfy(2+iorb))//"U_"//reg(txtfy(iorb)),iorb=1,Norb),&
reg(txtfy(2+Norb+1))//"U'",reg(txtfy(2+Norb+2))//"Jh"
close(unit)
!
iolegend=.false.
end subroutine write_legend
subroutine write_custom_legend()
integer :: unit,i
unit = free_unit()
open(unit,file="custom_observables_info.vca")
write(unit,"(A1,90(A10,6X))")"#",(reg(txtfy(i))//reg(custom_o%item(i)%o_name),i=1,custom_o%N_filled)
close(unit)
end subroutine write_custom_legend
!+-------------------------------------------------------------------+
!PURPOSE : write observables to file
!+-------------------------------------------------------------------+
subroutine write_observables()
integer :: unit
integer :: ilat,iorb,jorb,ispin
unit = free_unit()
open(unit,file="parameters_last"//reg(file_suffix)//".vca")
write(unit,"(90F15.9)")xmu,beta,(uloc(iorb),iorb=1,Norb),Ust,Jh,Jx,Jp
close(unit)
!
do ilat=1,Nlat
unit = free_unit()
open(unit,file="observables_last"//reg(file_suffix)//"_site"//str(ilat,3)//".vca")
write(unit,"(90(F15.9,1X))")&
(dens(ilat,iorb),iorb=1,Norb),&
(docc(ilat,iorb),iorb=1,Norb),&
(dens_up(ilat,iorb),iorb=1,Norb),&
(dens_dw(ilat,iorb),iorb=1,Norb),&
(magz(ilat,iorb),iorb=1,Norb),&
egs,&
((sz2(ilat,iorb,jorb),jorb=1,Norb),iorb=1,Norb),&
((zimp(ilat,iorb,ispin),iorb=1,Norb),ispin=1,Nspin),&
((simp(ilat,iorb,ispin),iorb=1,Norb),ispin=1,Nspin)
close(unit)
enddo
end subroutine write_observables
subroutine write_custom_observables()
integer :: i
integer :: unit
unit = free_unit()
open(unit,file="custom_observables_all.vca",position='append')
write(unit,"(90(F15.9,1X))")&
(custom_o%item(i)%o_value,i=1,custom_o%N_filled)
close(unit)
!
unit = free_unit()
open(unit,file="custom_observables_last.vca")
write(unit,"(90(F15.9,1X))")&
(custom_o%item(i)%o_value,i=1,custom_o%N_filled)
close(unit)
!
end subroutine write_custom_observables
END MODULE VCA_OBSERVABLES