forked from fkrien/beps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathal_simple.py
1333 lines (1060 loc) · 54.4 KB
/
al_simple.py
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
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Python implementation of the Boson Exchange Parquet Solver (BEPS) for a quantum impurity model (atomic limit), cite as arXiv:2008.04184
# Copyright (C) 2020 by Friedrich Krien <[email protected]>
from __future__ import print_function, division, absolute_import
from future.builtins import (range)
import h5py
import numpy as np
from matplotlib import pyplot as plt
import matplotlib.colors as colors
import csv
from numpy.linalg import inv
import glob
from matplotlib.ticker import FormatStrFormatter
import math
from scipy.optimize import broyden1, broyden2
from numpy import linalg as eigensystem
#from mpltools import color
plt.rcParams["mathtext.fontset"] = "cm"
cmap = plt.get_cmap('bwr')
# set the colormap and centre the colorbar
class MidpointNormalize(colors.Normalize):
def __init__(self, vmin=None, vmax=None, midpoint=None, clip=False):
self.midpoint = midpoint
colors.Normalize.__init__(self, vmin, vmax, clip)
def __call__(self, value, clip=None):
x, y = [self.vmin, self.midpoint, self.vmax], [0, 0.5, 1]
return np.ma.masked_array(np.interp(value, x, y), np.isnan(value))
def minmax_real(matrix_list, nu_min_, nu_max_, om):
lmin = []
lmax = []
for mat in matrix_list:
lmin.append(mat[nu_g4(nu_min_):nu_g4(nu_max_), nu_g4(nu_min_):nu_g4(nu_max_)].real.min())
lmax.append(mat[nu_g4(nu_min_):nu_g4(nu_max_), nu_g4(nu_min_):nu_g4(nu_max_)].real.max())
return (min(lmin), max(lmax))
def plot_vertex_real(vtx, nu_min_, nu_max_, om, elev_min_=0, elev_max_=0, mid_val_zero=True, title='', filename='', notitle=False):
if elev_min_ == 0 and elev_max_ == 0:
elev_min = vtx[nu_g4(nu_min_):nu_g4(nu_max_), nu_g4(nu_min_):nu_g4(nu_max_)].real.min()
elev_max = vtx[nu_g4(nu_min_):nu_g4(nu_max_), nu_g4(nu_min_):nu_g4(nu_max_)].real.max()
else:
elev_min = elev_min_
elev_max = elev_max_
if mid_val_zero == True: mid_val = 0.0
else: mid_val = (elev_min + elev_max)/2.
pdf = plt.figure()
if notitle:
plt.title('')
else:
plt.title(title, fontdict={'fontsize': 40})
X = np.array(list(range(nu_min_, nu_max_+1)))-0.5
Y = np.array(list(range(nu_min_, nu_max_+1)))-0.5
plt.pcolormesh(X, Y, vtx[nu_g4(nu_min_):nu_g4(nu_max_+1), nu_g4(nu_min_):nu_g4(nu_max_+1)].real, cmap=cmap, clim=(elev_min, elev_max), norm=MidpointNormalize(midpoint=mid_val, vmin=elev_min, vmax=elev_max))
cbar = plt.colorbar(format='%.2f')
plt.tick_params(labelsize=20)
cbar.ax.tick_params(labelsize=20)
plt.xticks([-10, 0, 10])
plt.yticks([-10, 0, 10])
plt.show()
if filename == '':
pdf.savefig('W'+str(om)+'_'+title+'.pdf', pad_inches=0, dpi=200)
else:
pdf.savefig('W'+str(om)+'_'+filename+'.pdf', pad_inches=0, dpi=200)
plt.close(pdf)
return (elev_min, elev_max)
#################
U = 1.0 # do
U_ch = +U # not
U_sp = -U # change
U_si = 2.*U # this
beta = 2. # values of U*beta >= 2 are hard and require mixing and many iterations. Large U*beta requires a nonlinear root-finder (Broyden, Pulay, ...)
delta_beta = 0. # parameter for annealing from a higher temperature
#################
# Matsubara cutoffs
N_nu = 24 # fermionic
N_om = 12 # bosonic
nu_min = -N_nu//2
nu_max = +N_nu//2
om_min = 0
om_max = +N_om
om_min_ = 0
om_max_ = N_om/2
om_inc = 1
plot_pause = 0.1
parquet_approximation = False
initial_guess = 0 # 0=non-interacting limit,1=firr,2="guess" the exact solution (can be used to verify that it corresponds to a stable fixed point)
# various flags for consistency checks
check_bse = False # Plot MBE vertices M
check_phi = False # Plot reducible vertices of parquet decomposition
check_mbe = False # Plot reducible vertices of BEPS
check_lambda_firr = False # Plot fully irr. vertex of parquet
check_threeleg_firr = False # Plot threeleg vertex which arises from fully irr. vertex of parquet (+-1 + sum Lambda^firr gg)
check_gamma_consistency = False # Verify the consistency of the exact solution for the vertices
def psum():
return 2. + 2.*math.exp(-beta*U/2.)
def nu_g4(w_): # four-point
return int(w_+N_nu//2)
def om_g4(w_): # four-point
return int(w_)
def nu_m(nu):
return (2.*nu+1.)*math.pi/beta
def om_m(om):
return 2.*om*math.pi/beta
def delta(om):
if om == 0:
return 1.
else:
return 0.
def sigma(nu):
return U/2. + U*U/(4.j*nu_m(nu))
def g(nu):
return 1. / (1.j * nu_m(nu) - U*U / (4.j * nu_m(nu)))
def g0(nu):
return 1. / (1.j * nu_m(nu) + U/2.)
# def g0_semicircle(nu):
# return 1. / ( 1.j * nu_m(nu) + U/2. )
def chi_ch(om):
return -2.*beta*math.exp(-beta*U/2.)*delta(om)/psum()
def chi_sp(om):
return -2.*beta*delta(om)/psum()
def chi_si(om):
return -beta*math.exp(-beta*U/2.)*delta(om)/psum()
def pi_ch(om):
return (chi_ch(om)/2.) / (1. + U_ch * chi_ch(om) / 2.)
def pi_sp(om):
return (chi_sp(om)/2.) / (1. + U_sp * chi_sp(om) / 2.)
def pi_si(om):
return chi_si(om) / (1. + U_si * chi_si(om) / 2.)
#################
#Functor classes#
#################
class w():
def ch(self, om):
return U_ch + U_ch * chi_ch(om) * U_ch/2.
def sp(self, om):
return U_sp + U_sp * chi_sp(om) * U_sp/2.
def si(self, om):
return U_si + U_si * chi_si(om) * U_si/2.
class thunstroem(): # analytical solution for the vertices of the atomic limit, PRB 98, 235107 (2018)
def __init__(self):
self.Acal0 = np.zeros(4, dtype=np.complex_)
self.Bcal0 = np.zeros(4, dtype=np.complex_)
self.Bcal1 = np.zeros(4, dtype=np.complex_)
self.Bcal2 = np.zeros(4, dtype=np.complex_)
self.Alat = np.zeros(4, dtype=np.complex_)
self.Blat = np.zeros(4, dtype=np.complex_)
self.Acal0[0] = 1.
self.Acal0[1] = 1.
self.Acal0[2] = 1./2.
self.Acal0[3] = -1./2.
self.Bcal0[0] = 1.
self.Bcal0[1] = 1.
self.Bcal0[2] = 1./2.
self.Bcal0[3] = -1./2.
self.Bcal1[0] = 1.j
self.Bcal1[1] = 1.
self.Bcal1[2] = 1.j/math.sqrt(2.)
self.Bcal1[3] = 0.
self.Bcal2[0] = 1.
self.Bcal2[1] = 1.j
self.Bcal2[2] = 1./math.sqrt(2.)
self.Bcal2[3] = 0.
self.Alat[0] = +(U/2.) * math.sqrt(3.)
self.Alat[1] = 1.j*U/2.
self.Alat[2] = 0.
self.Alat[3] = 1.j*U/2.
self.Blat[0] = +(U*U/4.) * (3.*math.exp(+U*beta/2.) - 1.) / (math.exp(+U*beta/2.) + 1.) # corresponds to square of B_r in Table 1 of Thunstroem paper!
self.Blat[1] = +(U*U/4.) * (3.*math.exp(-U*beta/2.) - 1.) / (math.exp(-U*beta/2.) + 1.) # corresponds to square of B_r in Table 1 of Thunstroem paper!
self.Blat[2] = +(U*U/4.) * (3.*math.exp(+U*beta/2.) - 1.) / (math.exp(+U*beta/2.) + 1.) # corresponds to square of B_r in Table 1 of Thunstroem paper!
self.Blat[3] = 0.
def Clat(self, om, flavor):
if flavor == 0:
return + delta(om) * (U*beta/2.) / (1. + math.exp(+U*beta/2.))
else:
return - delta(om) * (U*beta/2.) / (1. + math.exp(-U*beta/2.))
def Dlat(self, om, flavor):
return (U*U/4.) * (1. + self.Clat(om, flavor))/(1. - self.Clat(om, flavor))
def a0(self, nu, om, flavor):
return (beta/2.) * (nu_m(nu) * (nu_m(nu) + om_m(om)) - self.Alat[flavor]*self.Alat[flavor]) \
/ ((nu_m(nu)*nu_m(nu) + U*U/4.) * ((nu_m(nu)+om_m(om))*(nu_m(nu)+om_m(om)) + U*U/4.))
def b0(self, nu, om, flavor):
return (beta/2.) * (nu_m(nu) * (nu_m(nu) + om_m(om)) - self.Blat[flavor]) \
/ ((nu_m(nu)*nu_m(nu) + U*U/4.) * ((nu_m(nu)+om_m(om))*(nu_m(nu)+om_m(om)) + U*U/4.))
def b1(self, nu, om, flavor):
return self.Bcal1[flavor] * math.sqrt(U * (1. - self.Clat(om, flavor))) * (nu_m(nu) * (nu_m(nu) + om_m(om)) - self.Dlat(om, flavor)) \
/ ((nu_m(nu)**2 + U*U/4.) * ((nu_m(nu)+om_m(om))**2 + U*U/4.))
def b2(self, nu, om, flavor):
return self.Bcal2[flavor] * math.sqrt(U*U*U/4.) * math.sqrt((U*U / (1. - self.Clat(om, flavor))) + om_m(om)*om_m(om)) \
/ ((nu_m(nu)**2 + U*U/4.) * ((nu_m(nu)+om_m(om))**2 + U*U/4.))
def chi(self, nu1, nu2, om, flavor):
return - self.a0(nu1, om, flavor) * (delta(nu1-nu2) - delta(nu1 + nu2 + om + 1)) \
- self.b0(nu1, om, flavor) * (delta(nu1-nu2) + delta(nu1 + nu2 + om + 1)) \
- self.b1(nu1, om, flavor)*self.b1(nu2, om, flavor) - self.b2(nu1, om, flavor)*self.b2(nu2, om, flavor)
def gamma(self, nu1, nu2, om_in, flavor): # Thunstroem Eq. 19
if (flavor < 2): om = om_in
else: om = -om_in # Thunstroem paper defined pp-channels with a minus sign so they can use the same formulas for ph and pp
if (flavor == 0): flag = +1
if (flavor == 1): flag = -1
if (flavor == 2): flag = +1
if (flavor < 3):
return (
(beta/2.) * (self.Alat[flavor] * self.Alat[flavor] / self.Acal0[flavor]) * (nu_m(nu1)*nu_m(nu1) + U*U/4.) * ((nu_m(nu1)+om_m(om))*(nu_m(nu1)+om_m(om)) + U*U/4.)
* (delta(nu1-nu2) - delta(nu1 + nu2 + om + 1))
/ ((nu_m(nu1) * (nu_m(nu1) + om_m(om)) - self.Alat[flavor]*self.Alat[flavor]) * (nu_m(nu1) * (nu_m(nu1) + om_m(om))))
) \
+ (
(beta/2.) * (self.Blat[flavor] / self.Bcal0[flavor]) * (nu_m(nu1)*nu_m(nu1) + U*U/4.)
* ((nu_m(nu1)+om_m(om))*(nu_m(nu1)+om_m(om)) + U*U/4.)
* (delta(nu1-nu2) + delta(nu1 + nu2 + om + 1))
/ ((nu_m(nu1) * (nu_m(nu1) + om_m(om)) - self.Blat[flavor]) * (nu_m(nu1) * (nu_m(nu1) + om_m(om))))
) \
- (
U*(np.abs(self.Bcal2[flavor])*np.abs(self.Bcal2[flavor])/(self.Bcal0[flavor]*self.Bcal0[flavor]))*(U*U/4.)*((U*U/4.)*(4.*self.Blat[flavor]/(U*U)+1.)*(4.*self.Blat[flavor]/(U*U)+1.)+om_m(om)*om_m(om))
/ (U * np.tan((beta/4.)*(np.sqrt(4.*self.Blat[flavor]+om_m(om)*om_m(om))+om_m(om)))/np.sqrt(4.*self.Blat[flavor]+om_m(om)*om_m(om)) + flag)
/ (nu_m(nu1) * (nu_m(nu1) + om_m(om)) - self.Blat[flavor])
/ (nu_m(nu2) * (nu_m(nu2) + om_m(om)) - self.Blat[flavor])
) \
- (self.Bcal1[flavor]*self.Bcal1[flavor]/(self.Bcal0[flavor]*self.Bcal0[flavor]))*U
else:
return (
(beta/2.) * (self.Alat[flavor] * self.Alat[flavor] / self.Acal0[flavor]) * (nu_m(nu1)*nu_m(nu1) + U*U/4.) * ((nu_m(nu1)+om_m(om))*(nu_m(nu1)+om_m(om)) + U*U/4.)
* (delta(nu1-nu2) - delta(nu1 + nu2 + om + 1))
/ ((nu_m(nu1) * (nu_m(nu1) + om_m(om)) - self.Alat[flavor]*self.Alat[flavor]) * (nu_m(nu1) * (nu_m(nu1) + om_m(om))))
) \
+ (
(beta/2.) * (self.Blat[flavor] / self.Bcal0[flavor]) * (nu_m(nu1)*nu_m(nu1) + U*U/4.)
* ((nu_m(nu1)+om_m(om))*(nu_m(nu1)+om_m(om)) + U*U/4.)
* (delta(nu1-nu2) + delta(nu1 + nu2 + om + 1))
/ ((nu_m(nu1) * (nu_m(nu1) + om_m(om)) - self.Blat[flavor]) * (nu_m(nu1) * (nu_m(nu1) + om_m(om))))
)
def vtx_ph(self, nu1, nu2, om, flavor):
return (self.chi(nu1, nu2, om, flavor) - beta * g(nu1) * g(nu1 + om) * delta(nu1-nu2)) / (g(nu1) * g(nu1 + om) * g(nu2) * g(nu2 + om))
def vtx_pp(self, nu1, nu2, om, flavor):
return (self.vtx_ph(nu1, nu2, om-nu1-nu2-1, 0) - (3. - 4. * delta(flavor-1))*self.vtx_ph(nu1, nu2, om-nu1-nu2-1, 1))/2.
def ch(self, nu1, nu2, om):
return self.vtx_ph(nu1, nu2, om, 0)
def sp(self, nu1, nu2, om):
return self.vtx_ph(nu1, nu2, om, 1)
def si(self, nu1, nu2, om):
return self.vtx_pp(nu1, nu2, om, 0)
def tr(self, nu1, nu2, om):
return self.vtx_pp(nu1, nu2, om, 1)
def firr_ch(self, nu1, nu2, om):
return self.gamma(nu1, nu2, om, 0) - 0.5*self.gamma(nu1, nu1+om, nu2-nu1, 0) - 1.5*self.gamma(nu1, nu1+om, nu2-nu1, 1) \
+ 0.5*self.gamma(nu1, nu2, nu1+nu2+om+1, 2) + 1.5*self.gamma(nu1, nu2, nu1+nu2+om+1, 3) - 2.*self.ch(nu1, nu2, om)
def firr_sp(self, nu1, nu2, om):
return self.gamma(nu1, nu2, om, 1) - 0.5*self.gamma(nu1, nu1+om, nu2-nu1, 0) + 0.5*self.gamma(nu1, nu1+om, nu2-nu1, 1) \
- 0.5*self.gamma(nu1, nu2, nu1+nu2+om+1, 2) + 0.5*self.gamma(nu1, nu2, nu1+nu2+om+1, 3) - 2.*self.sp(nu1, nu2, om)
def firr_si(self, nu1, nu2, om):
return 0.5*self.firr_ch(nu1, nu2, om-nu1-nu2-1) - 1.5*self.firr_sp(nu1, nu2, om-nu1-nu2-1)
def firr_tr(self, nu1, nu2, om):
return 0.5*self.firr_ch(nu1, nu2, om-nu1-nu2-1) + 0.5*self.firr_sp(nu1, nu2, om-nu1-nu2-1)
def phi_ch(self, nu1, nu2, om):
return self.ch(nu1, nu2, om) - self.gamma(nu1, nu2, om, 0)
def phi_sp(self, nu1, nu2, om):
return self.sp(nu1, nu2, om) - self.gamma(nu1, nu2, om, 1)
def phi_si(self, nu1, nu2, om):
return self.si(nu1, nu2, om) - self.gamma(nu1, nu2, om, 2)
def phi_tr(self, nu1, nu2, om):
return self.tr(nu1, nu2, om) - self.gamma(nu1, nu2, om, 3)
class mbe():
def __init__(self, th, nb):
self.nb = nb
self.th = th
def ch(self, nu1, nu2, om):
return self.th.phi_ch(nu1, nu2, om) - self.nb.ch(nu1, nu2, om) + U_ch
def sp(self, nu1, nu2, om):
return self.th.phi_sp(nu1, nu2, om) - self.nb.sp(nu1, nu2, om) + U_sp
def si(self, nu1, nu2, om):
return self.th.phi_si(nu1, nu2, om) - self.nb.si(nu1, nu2, om) + U_si
def tr(self, nu1, nu2, om):
return self.th.phi_tr(nu1, nu2, om)
class hedin():
def dgdnu(self, nu, om):
return (g(nu+om) - g(nu)) / (1.j * om_m(om))
def dgdmu(self, nu):
return -((-beta*U*math.exp(-beta*U/2.) / (-nu_m(nu)*nu_m(nu) - U*U/4.)) + (psum()/2.)/((1.j*nu_m(nu) + U/2.)**2) + (psum()/2.)/((1.j*nu_m(nu) - U/2.)**2)) / psum()
def dgdh(self, nu):
return -((beta*U / (-nu_m(nu)*nu_m(nu) - U*U/4.)) + (psum()/2.)/((1.j*nu_m(nu) + U/2.)**2) + (psum()/2.)/((1.j*nu_m(nu) - U/2.)**2)) / psum()
def g3pp(self, nu, om):
return (-math.exp(-beta*U/2.)/psum()) * \
((math.exp(beta*U/2.) + 1.) * ((1. / ((1.j*nu_m(nu) + U/2.)*(1.j*om_m(om) - 1.j*nu_m(nu) - U/2.)))
+ (1. / ((1.j*nu_m(nu) - U/2.)*(1.j*om_m(om) - 1.j*nu_m(nu) + U/2.))))
+ ((delta(om) * beta * U) / ((1.j*nu_m(nu) + U/2.) * (1.j*nu_m(nu) - U/2.))))
def ch(self, nu, om):
if om == 0:
return -self.dgdmu(nu) / (g(nu) * g(nu) * (1. + U_ch*chi_ch(om)/2.))
else:
return -self.dgdnu(nu, om) / (g(nu) * g(nu+om) * (1. + U_ch*chi_ch(om)/2.))
def sp(self, nu, om):
if om == 0:
return -self.dgdh(nu) / (g(nu) * g(nu) * (1. + U_sp*chi_sp(om)/2.))
else:
return -self.dgdnu(nu, om) / (g(nu) * g(nu+om) * (1. + U_sp*chi_sp(om)/2.))
def si(self, nu, om):
return self.g3pp(nu, om) / (g(nu) * g(om-nu-1) * (1. + U_si*chi_si(om)/2.))
class nabla():
def __init__(self, w, l):
self.w = w
self.l = l
def ch(self, nu1, nu2, om):
# return self.l.ch(nu1,om) * self.w.ch(om) * self.l.ch(nu2,om)
return self.l.ch(nu1, om) * self.w.ch(om) * self.l.ch(nu2+om, -om)
def sp(self, nu1, nu2, om):
# return self.l.sp(nu1,om) * self.w.sp(om) * self.l.sp(nu2,om)
return self.l.sp(nu1, om) * self.w.sp(om) * self.l.sp(nu2+om, -om)
def si(self, nu1, nu2, om):
return self.l.si(nu1, om) * self.w.si(om) * self.l.si(nu2, om)
def vph_ch(self, nu1, nu2, om):
return - (self.ch(nu1, nu1+om, nu2-nu1) + 3.*self.sp(nu1, nu1+om, nu2-nu1)) / 2.
def vph_sp(self, nu1, nu2, om):
return - (self.ch(nu1, nu1+om, nu2-nu1) - self.sp(nu1, nu1+om, nu2-nu1)) / 2.
def pp_ch(self, nu1, nu2, om):
return + self.si(nu1, nu2, om + nu1 + nu2 + 1)/2.
def pp_sp(self, nu1, nu2, om):
return - self.si(nu1, nu2, om + nu1 + nu2 + 1)/2.
def sbe_ch(self, nu1, nu2, om):
return self.ch(nu1, nu2, om) + self.vph_ch(nu1, nu2, om) + self.pp_ch(nu1, nu2, om) - 2.*U_ch
def sbe_sp(self, nu1, nu2, om):
return self.sp(nu1, nu2, om) + self.vph_sp(nu1, nu2, om) + self.pp_sp(nu1, nu2, om) - 2.*U_sp
def sbe_pp(self, nu1, nu2, om, flavor):
return (self.sbe_ch(nu1, nu2, om-nu1-nu2-1) - (3. - 4. * delta(flavor-1))*self.sbe_sp(nu1, nu2, om-nu1-nu2-1))/2.
def sbe_si(self, nu1, nu2, om):
return self.sbe_pp(nu1, nu2, om, 0)
def sbe_tr(self, nu1, nu2, om):
return self.sbe_pp(nu1, nu2, om, 1)
class mbe_vtx():
def __init__(self, mb):
self.mb = mb
def ch(self, nu1, nu2, om):
return self.mb.ch(nu1, nu2, om)
def sp(self, nu1, nu2, om):
return self.mb.sp(nu1, nu2, om)
def si(self, nu1, nu2, om):
return self.mb.si(nu1, nu2, om)
def tr(self, nu1, nu2, om):
return self.mb.tr(nu1, nu2, om)
def vph_ch(self, nu1, nu2, om):
return - (self.ch(nu1, nu1+om, nu2-nu1) + 3.*self.sp(nu1, nu1+om, nu2-nu1)) / 2.
def vph_sp(self, nu1, nu2, om):
return - (self.ch(nu1, nu1+om, nu2-nu1) - self.sp(nu1, nu1+om, nu2-nu1)) / 2.
def pp_ch(self, nu1, nu2, om):
return + self.si(nu1, nu2, om + nu1 + nu2 + 1)/2. + 3.*self.tr(nu1, nu2, om + nu1 + nu2 + 1)/2.
def pp_sp(self, nu1, nu2, om):
return - self.si(nu1, nu2, om + nu1 + nu2 + 1)/2. + self.tr(nu1, nu2, om + nu1 + nu2 + 1)/2.
class threeleg_uirr():
def __init__(self, nb, th):
self.nb = nb
self.th = th
def vtx_ch(self, nu1, nu2, om):
return th.ch(nu1, nu2, om) - nb.sbe_ch(nu1, nu2, om)
def vtx_sp(self, nu1, nu2, om):
return th.sp(nu1, nu2, om) - nb.sbe_sp(nu1, nu2, om)
def vtx_si(self, nu1, nu2, om):
return th.si(nu1, nu2, om) - nb.sbe_si(nu1, nu2, om)
def vtx_tr(self, nu1, nu2, om):
return th.tr(nu1, nu2, om) - nb.sbe_tr(nu1, nu2, om)
def ch(self, nu1, om):
result = 0.0
for nu2 in range(nu_min, nu_max):
result += self.vtx_ch(nu1, nu2, om)*g(nu2)*g(nu2+om)
return 1. + result/beta
def sp(self, nu1, om):
result = 0.0
for nu2 in range(nu_min, nu_max):
result += self.vtx_sp(nu1, nu2, om)*g(nu2)*g(nu2+om)
return 1. + result/beta
def si(self, nu1, om):
result = 0.0
for nu2 in range(nu_min, nu_max):
result += self.vtx_si(nu1, nu2, om)*g(nu2)*g(om-nu2-1)
return -1. + result/(2.*beta)
def tr(self, nu1, om):
result = 0.0
for nu2 in range(nu_min, nu_max):
result += self.vtx_tr(nu1, nu2, om)*g(nu2)*g(om-nu2-1)
return -1. + result/(2.*beta)
class threeleg_firr():
def __init__(self, th):
self.th = th
def vtx_ch(self, nu1, nu2, om):
return th.firr_ch(nu1, nu2, om)-U_ch
def vtx_sp(self, nu1, nu2, om):
return th.firr_sp(nu1, nu2, om)-U_sp
def vtx_si(self, nu1, nu2, om):
return th.firr_si(nu1, nu2, om)-U_si
def vtx_tr(self, nu1, nu2, om):
return th.firr_tr(nu1, nu2, om)
def ch(self, nu1, om):
result = 0.0
for nu2 in range(nu_min, nu_max):
result += self.vtx_ch(nu1, nu2, om)*g(nu2)*g(nu2+om)
return 1. + result/beta
def sp(self, nu1, om):
result = 0.0
for nu2 in range(nu_min, nu_max):
result += self.vtx_sp(nu1, nu2, om)*g(nu2)*g(nu2+om)
return 1. + result/beta
def si(self, nu1, om):
result = 0.0
for nu2 in range(nu_min, nu_max):
result += self.vtx_si(nu1, nu2, om)*g(nu2)*g(om-nu2-1)
return -1. + result/(2.*beta)
def tr(self, nu1, om):
result = 0.0
for nu2 in range(nu_min, nu_max):
result += self.vtx_tr(nu1, nu2, om)*g(nu2)*g(om-nu2-1)
return -1. + result/(2.*beta)
class parquet3():
def __init__(self, g_, nb_, mb_, fi_):
# self.nb=nabla()
# self.fi=firr()
self.g = g_
self.nb = nb_
self.mb = mb_
self.fi = fi_
def ch(self, nu, om):
if (nu == nu_min) or (nu == nu_max): return 1.
result = 0.0
for nu2 in range(nu_min, nu_max):
result += (self.mb.vph_ch(nu, nu2, om) + self.mb.pp_ch(nu, nu2, om) + self.mb.ch(nu, nu2, om)) * self.g.value(nu2) * self.g.value(nu2+om)
result += (self.nb.vph_ch(nu, nu2, om) + self.nb.pp_ch(nu, nu2, om) - 2.*U_ch) * self.g.value(nu2) * self.g.value(nu2+om)
return self.fi.ch(nu, om) + result/beta
def sp(self, nu, om):
if (nu == nu_min) or (nu == nu_max): return 1.
result = 0.0
for nu2 in range(nu_min, nu_max):
result += (self.mb.vph_sp(nu, nu2, om) + self.mb.pp_sp(nu, nu2, om) + self.mb.sp(nu, nu2, om)) * self.g.value(nu2) * self.g.value(nu2+om)
result += (self.nb.vph_sp(nu, nu2, om) + self.nb.pp_sp(nu, nu2, om) - 2.*U_sp) * self.g.value(nu2) * self.g.value(nu2+om)
return self.fi.sp(nu, om) + result/beta
def si(self, nu, om):
if (nu == nu_min) or (nu == nu_max): return -1.
result = 0.0
for nu2 in range(nu_min, nu_max):
result += (self.mb.ch(nu, nu2, om-nu-nu2-1) - 3.*self.mb.sp(nu, nu2, om-nu-nu2-1) + self.mb.si(nu, nu2, om)) * self.g.value(nu2) * self.g.value(om-nu2-1)
result += (self.nb.ch(nu, nu2, om-nu-nu2-1) - 3.*self.nb.sp(nu, nu2, om-nu-nu2-1) - U_ch + 3.*U_sp) * self.g.value(nu2) * self.g.value(om-nu2-1)
return self.fi.si(nu, om) + result/(2.*beta)
class kernel():
def __init__(self, nb_, mb_, firr_):
# self.nb=nabla()
# self.fi=firr()
# self.g=g_
self.nb = nb_
self.mb = mb_
self.firr = firr_
def ch(self, nu1, nu2, om):
result = self.firr.ch(nu1, nu2, om)
result += self.mb.vph_ch(nu1, nu2, om) + self.mb.pp_ch(nu1, nu2, om)
result += self.nb.vph_ch(nu1, nu2, om) + self.nb.pp_ch(nu1, nu2, om) - 2.*U_ch
return result
def sp(self, nu1, nu2, om):
result = self.firr.sp(nu1, nu2, om)
result += self.mb.vph_sp(nu1, nu2, om) + self.mb.pp_sp(nu1, nu2, om)
result += self.nb.vph_sp(nu1, nu2, om) + self.nb.pp_sp(nu1, nu2, om) - 2.*U_sp
return result
def si(self, nu1, nu2, om):
result = self.firr.si(nu1, nu2, om)
result += self.mb.ch(nu1, nu2, om-nu1-nu2-1)/2. - 3.*self.mb.sp(nu1, nu2, om-nu1-nu2-1)/2.
result += self.nb.ch(nu1, nu2, om-nu1-nu2-1)/2. - 3.*self.nb.sp(nu1, nu2, om-nu1-nu2-1)/2.
result += self.mb.ch(nu1, om-nu2-1, nu2-nu1)/2. - 3.*self.mb.sp(nu1, om-nu2-1, nu2-nu1)/2.
result += self.nb.ch(nu1, om-nu2-1, nu2-nu1)/2. - 3.*self.nb.sp(nu1, om-nu2-1, nu2-nu1)/2.
result += - U_ch + 3.*U_sp
return result
def tr(self, nu1, nu2, om):
result = self.firr.tr(nu1, nu2, om)
result += + self.mb.ch(nu1, nu2, om-nu1-nu2-1)/2. + self.mb.sp(nu1, nu2, om-nu1-nu2-1)/2.
result += + self.nb.ch(nu1, nu2, om-nu1-nu2-1)/2. + self.nb.sp(nu1, nu2, om-nu1-nu2-1)/2.
result += - self.mb.ch(nu1, om-nu2-1, nu2-nu1)/2. - self.mb.sp(nu1, om-nu2-1, nu2-nu1)/2.
result += - self.nb.ch(nu1, om-nu2-1, nu2-nu1)/2. - self.nb.sp(nu1, om-nu2-1, nu2-nu1)/2.
return result
###################
#Container classes#
###################
class hedin_container():
def __init__(self):
self.hedin_ch = np.zeros((N_nu, N_om), dtype=complex)
self.hedin_sp = np.zeros((N_nu, N_om), dtype=complex)
self.hedin_si = np.zeros((N_nu, N_om), dtype=complex)
def value(self, nu, om, flavor):
if om < 0:
return np.conjugate(self.value(-nu-1, -om, flavor))
else:
if (nu < nu_min) or (nu > nu_max-1) or (om > om_max-1):
if flavor == 2: return -1.
else: return +1.
else:
if flavor == 0: return self.hedin_ch[nu+N_nu//2, om]
if flavor == 1: return self.hedin_sp[nu+N_nu//2, om]
if flavor == 2: return self.hedin_si[nu+N_nu//2, om]
def ch(self, nu, om): return self.value(nu, om, 0)
def sp(self, nu, om): return self.value(nu, om, 1)
def si(self, nu, om): return self.value(nu, om, 2)
def assign(self, nu, om, flavor, value):
if flavor == 0: self.hedin_ch[nu+N_nu//2, om] = value
if flavor == 1: self.hedin_sp[nu+N_nu//2, om] = value
if flavor == 2: self.hedin_si[nu+N_nu//2, om] = value
def assign_ch(self, nu, om, value): return self.assign(nu, om, 0, value)
def assign_sp(self, nu, om, value): return self.assign(nu, om, 1, value)
def assign_si(self, nu, om, value): return self.assign(nu, om, 2, value)
def update(self, hd, flavor, xi, xi0):
for nu in range(nu_min, nu_max):
for om in range(om_min, om_max):
xi_ = xi
if om == 0: xi_ = xi0
if flavor == 0:
value = xi_/hd.ch(nu, om) + (1.-xi_)/self.ch(nu, om)
self.assign_ch(nu, om, 1./value)
elif flavor == 1:
value = xi_/hd.sp(nu, om) + (1.-xi_)/self.sp(nu, om)
self.assign_sp(nu, om, 1./value)
elif flavor == 2:
value = xi_/hd.si(nu, om) + (1.-xi_)/self.si(nu, om)
self.assign_si(nu, om, 1./value)
def update_ch(self, hd, xi, xi0):
self.update(hd, 0, xi, xi0)
def update_sp(self, hd, xi, xi0):
self.update(hd, 1, xi, xi0)
def update_si(self, hd, xi, xi0):
self.update(hd, 2, xi, xi0)
class vtx_container():
def __init__(self):
self.mb_ch = np.zeros((N_om, N_nu, N_nu), dtype=complex)
self.mb_sp = np.zeros((N_om, N_nu, N_nu), dtype=complex)
self.mb_si = np.zeros((N_om, N_nu, N_nu), dtype=complex)
self.mb_tr = np.zeros((N_om, N_nu, N_nu), dtype=complex)
def value(self, nu1, nu2, om, flavor):
if om < 0:
return np.conjugate(self.value(-nu2-1, -nu1-1, -om, flavor))
else:
if (nu1 < nu_min) or (nu1 > nu_max-1) or (nu2 < nu_min) or (nu2 > nu_max-1) or (om > om_max-1):
return 0.0
else:
if flavor == 0: return self.mb_ch[om, nu1+N_nu//2, nu2+N_nu//2]
if flavor == 1: return self.mb_sp[om, nu1+N_nu//2, nu2+N_nu//2]
if flavor == 2: return self.mb_si[om, nu1+N_nu//2, nu2+N_nu//2]
if flavor == 3: return self.mb_tr[om, nu1+N_nu//2, nu2+N_nu//2]
def ch(self, nu1, nu2, om): return self.value(nu1, nu2, om, 0)
def sp(self, nu1, nu2, om): return self.value(nu1, nu2, om, 1)
def si(self, nu1, nu2, om): return self.value(nu1, nu2, om, 2)
def tr(self, nu1, nu2, om): return self.value(nu1, nu2, om, 3)
def assign(self, nu1, nu2, om, flavor, value):
if flavor == 0: self.mb_ch[om, nu1+N_nu//2, nu2+N_nu//2] = value
if flavor == 1: self.mb_sp[om, nu1+N_nu//2, nu2+N_nu//2] = value
if flavor == 2: self.mb_si[om, nu1+N_nu//2, nu2+N_nu//2] = value
if flavor == 3: self.mb_tr[om, nu1+N_nu//2, nu2+N_nu//2] = value
def assign_ch(self, nu1, nu2, om, value): return self.assign(nu1, nu2, om, 0, value)
def assign_sp(self, nu1, nu2, om, value): return self.assign(nu1, nu2, om, 1, value)
def assign_si(self, nu1, nu2, om, value): return self.assign(nu1, nu2, om, 2, value)
def assign_tr(self, nu1, nu2, om, value): return self.assign(nu1, nu2, om, 3, value)
class w_container():
def __init__(self, g_, l_):
self.g = g_
self.l = l_
self.pi_ch = np.zeros(N_om, dtype=complex)
self.pi_sp = np.zeros(N_om, dtype=complex)
self.pi_si = np.zeros(N_om, dtype=complex)
def value(self, om, flavor):
if om < 0:
return np.conjugate(self.value(-om, flavor))
else:
if (om > om_max-1):
if flavor == 0: return U_ch
if flavor == 1: return U_sp
if flavor == 2: return U_si
else:
if flavor == 0: return U_ch / (1. - self.pi_ch[om] * U_ch)
if flavor == 1: return U_sp / (1. - self.pi_sp[om] * U_sp)
if flavor == 2: return U_si / (1. - self.pi_si[om] * U_si / 2.) # regardless of definition, an ugly factor 2 appears somewhere in the pp channel
def value_pi(self, om, flavor):
if om < 0:
return np.conjugate(self.value(-om, flavor))
else:
if (om > om_max-1):
if flavor == 0: return 0.
if flavor == 1: return 0.
if flavor == 2: return 0.
else:
if flavor == 0: return self.pi_ch[om]
if flavor == 1: return self.pi_sp[om]
if flavor == 2: return self.pi_si[om]
def assign_pi(self, om, flavor, value):
if flavor == 0: self.pi_ch[om] = value
if flavor == 1: self.pi_sp[om] = value
if flavor == 2: self.pi_si[om] = value
def assign_pi_ch(self, om, value): return self.assign_pi(om, 0, value)
def assign_pi_sp(self, om, value): return self.assign_pi(om, 1, value)
def assign_pi_si(self, om, value): return self.assign_pi(om, 2, value)
def ch(self, om):
return self.value(om, 0)
def sp(self, om):
return self.value(om, 1)
def si(self, om):
return self.value(om, 2)
def value_pi_ch(self, om):
return self.value_pi(om, 0)
def value_pi_sp(self, om):
return self.value_pi(om, 1)
def value_pi_si(self, om):
return self.value_pi(om, 2)
def update_pi(self, xi):
for om in range(om_min, om_max):
result_ch = 0.0
result_sp = 0.0
result_si = 0.0
result_si0 = 0.0
result_bubble = 0.0
result_pp_bubble = 0.0
for nu in range(nu_min, nu_max):
result_ch += self.g.value(nu) * self.g.value(nu+om) * (self.l.ch(nu, om) - 1.)
result_sp += self.g.value(nu) * self.g.value(nu+om) * (self.l.sp(nu, om) - 1.)
result_si += self.g.value(nu) * self.g.value(om-nu-1) * (self.l.si(nu, om) + 1.)
result_bubble += self.g.value(nu) * self.g.value(nu+om) - 1./((1j*nu_m(nu))*(1j*nu_m(nu+om)))
result_pp_bubble += self.g.value(nu) * self.g.value(om-nu-1) - 1./((1j*nu_m(nu))*(1j*nu_m(om-nu-1)))
result_si0 += self.g.value(nu) * self.g.value(om-nu-1) * self.l.si(nu, om)
value_ch = -beta*delta(om)/4. + result_bubble/beta + result_ch/beta
self.pi_ch[om] = xi * value_ch + (1.-xi) * self.pi_ch[om]
value_sp = -beta*delta(om)/4. + result_bubble/beta + result_sp/beta
self.pi_sp[om] = xi * value_sp + (1.-xi) * self.pi_sp[om]
if om == 0:
value_si = -beta*delta(om)/4. - result_pp_bubble/beta + result_si/beta
else:
value_si = -result_pp_bubble/beta + result_si/beta
self.pi_si[om] = xi * value_si + (1.-xi) * self.pi_si[om]
class g_container():
def __init__(self, g0_):
self.sigma = np.zeros(nu_max, dtype=np.complex_)
self.g0 = g0_
self.l = hedin_container()
self.w = w_container(self.g0, self.l)
def set_pointers(self, w_, l_):
self.w = w_
self.l = l_
def value_sigma(self, nu):
if (nu < 0):
return np.conjugate(self.value_sigma(-nu-1))
else:
return self.sigma[nu]
def value(self, nu):
if (nu < nu_max): return 1. / (1./self.g0(nu) - self.value_sigma(nu))
else: return 1. / (1.j * nu_m(nu))
def assign_sigma(self, nu, value):
self.sigma[nu] = value
def update_sigma(self, xi):
sigma = np.zeros(nu_max, dtype=np.complex_)
for nu in range(0, nu_max):
result = 0.0
for om in range(0, om_max):
result += self.value(nu+om) * (self.w.ch(om) * self.l.ch(nu, om) + self.w.sp(om) * self.l.sp(nu, om)) # om=0 and om>0
if(om > 0): result += self.value(nu-om) * (self.w.ch(-om) * self.l.ch(nu, -om) + self.w.sp(-om) * self.l.sp(nu, -om)) # om<0
sigma[nu] = U/2. - result/(2.*beta)
for nu in range(0, nu_max):
self.sigma[nu] = xi * sigma[nu] + (1.-xi) * self.sigma[nu]
class bse():
def __init__(self, g_, krnl_, mb_):
self.krnl = krnl_
self.mb = mb_
self.g = g_
def update_mbe(self, xi):
A = np.zeros((N_nu, N_nu), dtype=complex)
for om in range(om_min, om_max):
# charge
for nu1 in range(nu_min, nu_max):
for nu2 in range(nu_min, nu_max):
A[nu1-nu_min, nu2-nu_min] = self.krnl.ch(nu1, nu2, om) * self.g.value(nu2) * self.g.value(nu2+om) / beta
evals, Umat = eigensystem.eig(A)
Lambda = np.diag(evals / (1. - evals))
A = np.matmul(Umat, Lambda)
Uinv = np.linalg.inv(Umat)
Lambda = np.matmul(A, Uinv)
Umat = np.zeros((N_nu, N_nu), dtype=complex)
for nu1 in range(nu_min, nu_max):
for nu2 in range(nu_min, nu_max):
Umat[nu1-nu_min, nu2-nu_min] = self.krnl.ch(nu1, nu2, om)
A = np.matmul(Lambda, Umat)
self.mb.mb_ch[om, :, :] = (1.-xi)*self.mb.mb_ch[om, :, :] + xi*A
if check_bse:
mm = minmax_real([A], nu_min, nu_max, om)
plot_vertex_real(A, nu_min, nu_max, om, mm[0], mm[1], title='ch', filename='bse_ch')
A = np.zeros((N_nu, N_nu), dtype=complex)
print("BSE ch om: ", om)
# spin
for nu1 in range(nu_min, nu_max):
for nu2 in range(nu_min, nu_max):
A[nu1-nu_min, nu2-nu_min] = self.krnl.sp(nu1, nu2, om) * self.g.value(nu2) * self.g.value(nu2+om) / beta
evals, Umat = eigensystem.eig(A)
Lambda = np.diag(evals / (1. - evals))
A = np.matmul(Umat, Lambda)
Uinv = np.linalg.inv(Umat)
Lambda = np.matmul(A, Uinv)
Umat = np.zeros((N_nu, N_nu), dtype=complex)
for nu1 in range(nu_min, nu_max):
for nu2 in range(nu_min, nu_max):
Umat[nu1-nu_min, nu2-nu_min] = self.krnl.sp(nu1, nu2, om)
A = np.matmul(Lambda, Umat)
self.mb.mb_sp[om, :, :] = (1.-xi)*self.mb.mb_sp[om, :, :] + xi*A
if check_bse:
mm = minmax_real([A], nu_min, nu_max, om)
plot_vertex_real(A, nu_min, nu_max, om, mm[0], mm[1], title='sp', filename='bse_sp')
A = np.zeros((N_nu, N_nu), dtype=complex)
print("BSE sp om: ", om)
# singlet
for nu1 in range(nu_min, nu_max):
for nu2 in range(nu_min, nu_max):
A[nu1-nu_min, nu2-nu_min] = (-0.5) * self.krnl.si(nu1, nu2, om) * self.g.value(nu2) * self.g.value(om-nu2-1) / beta
evals, Umat = eigensystem.eig(A)
Lambda = np.diag(evals / (1. - evals))
A = np.matmul(Umat, Lambda)
Uinv = np.linalg.inv(Umat)
Lambda = np.matmul(A, Uinv)
Umat = np.zeros((N_nu, N_nu), dtype=complex)
for nu1 in range(nu_min, nu_max):
for nu2 in range(nu_min, nu_max):
Umat[nu1-nu_min, nu2-nu_min] = self.krnl.si(nu1, nu2, om)
A = np.matmul(Lambda, Umat)
self.mb.mb_si[om, :, :] = (1.-xi)*self.mb.mb_si[om, :, :] + xi*A
if check_bse:
mm = minmax_real([A], nu_min, nu_max, om)
plot_vertex_real(A, nu_min, nu_max, om, mm[0], mm[1], title='si', filename='bse_si')
A = np.zeros((N_nu, N_nu), dtype=complex)
print("BSE si om: ", om)
# triplet
for nu1 in range(nu_min, nu_max):
for nu2 in range(nu_min, nu_max):
A[nu1-nu_min, nu2-nu_min] = (+0.5) * self.krnl.tr(nu1, nu2, om) * self.g.value(nu2) * self.g.value(om-nu2-1) / beta
evals, Umat = eigensystem.eig(A)
Lambda = np.diag(evals / (1. - evals))
A = np.matmul(Umat, Lambda)
Uinv = np.linalg.inv(Umat)
Lambda = np.matmul(A, Uinv)
Umat = np.zeros((N_nu, N_nu), dtype=complex)
for nu1 in range(nu_min, nu_max):
for nu2 in range(nu_min, nu_max):
Umat[nu1-nu_min, nu2-nu_min] = self.krnl.tr(nu1, nu2, om)
A = np.matmul(Lambda, Umat)
self.mb.mb_tr[om, :, :] = (1.-xi)*self.mb.mb_tr[om, :, :] + xi*A
if check_bse:
mm = minmax_real([A], nu_min, nu_max, om)
plot_vertex_real(A, nu_min, nu_max, om, mm[0], mm[1], title='tr', filename='bse_tr')
A = np.zeros((N_nu, N_nu), dtype=complex)
A = np.zeros((N_nu, N_nu), dtype=complex)
print("BSE tr om: ", om)
######################################################
# set up exact solution
w = w() # screened interaction
hd = hedin() # exact Hedin vertices
th = thunstroem() # exact full vertex
nb = nabla(w, hd) # exact U-reducible vertices
fi = threeleg_firr(th) # exact fully gg-irreducible vertices
mb = mbe(th, nb) # exact U-irreducible vertices
if (check_threeleg_firr):
om_ = 0
plt.plot([fi.ch(nu, om_).real for nu in range(nu_min, nu_max)], color='r', marker='o')
plt.show()
plt.plot([fi.sp(nu, om_).real for nu in range(nu_min, nu_max)], color='g', marker='o')
plt.show()
plt.plot([fi.si(nu, om_).real for nu in range(nu_min, nu_max)], color='b', marker='o')
plt.show()
# check relation between gamma and f
if(check_lambda_firr):
lambda_firr = vtx_container()
for nu1 in range(nu_min, nu_max):
for nu2 in range(nu_min, nu_max):
for om in range(om_min, om_max):
lambda_firr.assign_ch(nu1, nu2, om, th.firr_ch(nu1, nu2, om)-U_ch)
lambda_firr.assign_sp(nu1, nu2, om, th.firr_sp(nu1, nu2, om)-U_sp)
lambda_firr.assign_si(nu1, nu2, om, th.firr_si(nu1, nu2, om)-U_si)
lambda_firr.assign_tr(nu1, nu2, om, th.firr_tr(nu1, nu2, om))
om_ = 0
mm = minmax_real([lambda_firr.mb_ch[om_, :, :]], nu_min, nu_max, om_)
plot_vertex_real(lambda_firr.mb_ch[om_, :, :], nu_min, nu_max, om_, mm[0], mm[1], title='firr_ch', filename='firr_ch')
mm = minmax_real([lambda_firr.mb_sp[om_, :, :]], nu_min, nu_max, om_)
plot_vertex_real(lambda_firr.mb_sp[om_, :, :], nu_min, nu_max, om_, mm[0], mm[1], title='firr_sp', filename='firr_sp')
mm = minmax_real([lambda_firr.mb_si[om_, :, :]], nu_min, nu_max, om_)
plot_vertex_real(lambda_firr.mb_si[om_, :, :], nu_min, nu_max, om_, mm[0], mm[1], title='firr_si', filename='firr_si')
mm = minmax_real([lambda_firr.mb_tr[om_, :, :]], nu_min, nu_max, om_)
plot_vertex_real(lambda_firr.mb_tr[om_, :, :], nu_min, nu_max, om_, mm[0], mm[1], title='firr_tr', filename='firr_tr')
if(check_phi):
phi1 = vtx_container()
for nu1 in range(nu_min, nu_max):
for nu2 in range(nu_min, nu_max):
for om in range(om_min, om_max):
phi1.assign_ch(nu1, nu2, om, th.phi_ch(nu1, nu2, om))
phi1.assign_sp(nu1, nu2, om, th.phi_sp(nu1, nu2, om))
phi1.assign_si(nu1, nu2, om, th.phi_si(nu1, nu2, om))
phi1.assign_tr(nu1, nu2, om, th.phi_tr(nu1, nu2, om))
om_ = 0
#mm = minmax_real([phi1.mb_ch[om_,:,:],phi1.mb_sp[om_,:,:],phi1.mb_si[om_,:,:],phi1.mb_tr[om_,:,:]],nu_min,nu_max,om_)
mm = minmax_real([phi1.mb_ch[om_, :, :]], nu_min, nu_max, om_)
plot_vertex_real(phi1.mb_ch[om_, :, :], nu_min, nu_max, om_, mm[0], mm[1], title=r'$\Phi^{ph,\mathrm{ch}}$', filename='phi_ch')