import h5py
import matplotlib.pyplot as plt
import numpy as np
import multifile
import os
import math
from matplotlib import cm
plt.rcParams['text.usetex'] = True
plt.rcParams['text.latex.preamble'] = r'\usepackage{amssymb}'
SMALL_SIZE = 8
MEDIUM_SIZE = 12
BIGGER_SIZE = 16
plt.rc('font', size=BIGGER_SIZE) # controls default text sizes
plt.rc('axes', titlesize=BIGGER_SIZE) # fontsize of the axes title
plt.rc('axes', labelsize=BIGGER_SIZE) # fontsize of the x and y labels
plt.rc('xtick', labelsize=BIGGER_SIZE) # fontsize of the tick labels
plt.rc('ytick', labelsize=BIGGER_SIZE) # fontsize of the tick labels
plt.rc('legend', fontsize=MEDIUM_SIZE) # legend fontsize
plt.rc('figure', titlesize=BIGGER_SIZE) # fontsize of the figure title
plt.rcParams["font.family"] = "serif"
plt.rcParams["text.usetex"] = True
plt.rcParams["font.family"] = "cmr10", # Computer Modern Roman
def load_objs(dat_names, Beta=20):
objs = []
omega0_vals = set([])
g0_vals = set([])
mf = multifile.MultiFile(dat_names[0] + '/')
f = mf.open_final_file()
momgrid = np.array(f["w_func/momgrid"])
ffgrid = np.array(f["Sig/fgrid"])
f.close()
mf.close()
#Beta = 10.0 #obj['Omega0'] = mf.params_file["Model"].attrs["Beta"]
freq = lambda n: (2*n) * np.pi/Beta
dat_names
for dat_dir in dat_names:
mf = multifile.MultiFile(dat_dir + '/')
obj = {}
obj['dir'] = dat_dir
obj['U'] = mf.params_file["Model"].attrs["U"]
obj['Vh'] = mf.params_file["Model"].attrs["g0"]
obj['Omega0'] = mf.params_file["Model"].attrs["OMEGA0"]
obj['g0'] = np.sqrt(obj['Vh'] * obj['Omega0']/2.0)
obj['mu'] = mf.params_file["Model"].attrs["Mu"]
obj['BZ_path'] = np.array(mf.params_file["Model/Special_paths/path_Gamma_X_M"])
jj = 0
for ii in range(len(obj['BZ_path'])-1):
if obj['BZ_path'][ii-jj] == obj['BZ_path'][ii+1-jj]:
obj['BZ_path'] = np.delete(obj['BZ_path'], ii)
jj += 1
#print(obj['BZ_path'])
omega0_vals.add(obj['Omega0'])
g0_vals.add(obj['g0'])
obj['Vh'] = 2*obj['g0']*obj['g0']/obj['Omega0']
U_Omega0 = lambda n: obj['Vh'] * freq(n)*freq(n) * (obj['Omega0']*obj['Omega0'] + freq(n)*freq(n))
D0 = lambda n: -2*obj['Omega0']/(freq(n)*freq(n) + obj['Omega0']*obj['Omega0'])
#print(obj['Vh'])
if not mf.is_finished:
f = mf.open_file_number(int(mf.scales_count))
B = obj['U'] - obj['Vh']
print( (B - np.min(-np.array(f["w_func/RE_D"]))/(4*np.pi*np.pi))/B/B )
#print(dat_dir)
continue
f = mf.open_final_file()
obj['Sig'] = np.array(f["Sig/RE"]) + 1j * np.array(f["Sig/IM"])
obj['delta_mu'] = f["Flow_obs"].attrs["delta_mu"]
#print(f["Flow_obs/S_Wave_Susc_info"].attrs.keys())
#print(np.array(f["Flow_obs/S_Wave_Susc_info"].keys)[0, 0])
obj['leading_susc'] = f["Flow_obs/S_Wave_Susc_info"].attrs['Leading_name']
obj['max_sc'] = f["Flow_obs/S_Wave_Susc_info"].attrs['RE_Max_sc']
obj['max_d'] = f["Flow_obs/S_Wave_Susc_info"].attrs['RE_Max_d']
obj['max_m'] = f["Flow_obs/S_Wave_Susc_info"].attrs['RE_Max_m']
obj['max_sc_pp'] = np.max(np.array(f["Flow_obs/Postprocessing_Susc_info/RE_Susc_sc"])[0,:, 0, 0, 0, 0, 0, 0])
obj['max_d_pp'] = np.max(np.array(f["Flow_obs/Postprocessing_Susc_info/RE_Susc_d"])[0,:, 0, 0, 0, 0, 0, 0]) #136
obj['max_m_pp'] = np.max(np.array(f["Flow_obs/Postprocessing_Susc_info/RE_Susc_m"])[0,:, 0, 0, 0, 0, 0, 0])
if np.array(f["Flow_obs/Postprocessing_Susc_info/RE_Susc_sc"]).shape[3] > 1:
print("dwave!")
obj['max_dsc_pp'] = np.max(np.array(f["Flow_obs/Postprocessing_Susc_info/RE_Susc_sc"])[0,:, 0, 1, 0, 1, 0, 0])
obj['sc_pp'] =np.max(np.array(f["Flow_obs/Postprocessing_Susc_info/RE_Susc_sc"])[0,:, 0, 0, 0, 0, 0, 0])
obj['d_pp'] = np.max(np.array(f["Flow_obs/Postprocessing_Susc_info/RE_Susc_d"])[0,:, 0, 0, 0, 0, 0, 0]) #136
obj['m_pp'] = np.max(np.array(f["Flow_obs/Postprocessing_Susc_info/RE_Susc_m"])[0,:, 0, 0, 0, 0, 0, 0])
obj['leading_w'] = f["Flow_obs/w_info"].attrs['Leading_name']
obj['max_w_sc'] = f["Flow_obs/w_info"].attrs['RE_Max_sc']
obj['max_w_d'] = f["Flow_obs/w_info"].attrs['RE_Max_d']
obj['max_w_m'] = f["Flow_obs/w_info"].attrs['RE_Max_m']
old = np.array(f["Flow_obs/S_Wave_Susc_info/RE_Susc_d"])[0, :]
obj["diverged"] = mf.is_diverged
wd = np.array(f["w_func/RE_D"])[:, :]/(4*np.pi*np.pi)
wd = wd[int((wd.shape[0]-1)/2), :]
obj['susc_d_pp'] = np.array(f["Flow_obs/Postprocessing_Susc_info/RE_Susc_d"])[0,:, 0, 0, 0, 0, 0, 0]
bose_bare_V = np.zeros(wd.shape)
D0_vals = np.zeros(wd.shape)
#print(bare_V.shape)
for Q_ in range(bose_bare_V.shape[0]):
bose_bare_V[Q_] = obj['U'] - obj['Vh'] + 2.0*U_Omega0(0)
D0_vals[Q_] = D0(0)
bose_bare_V_static = bose_bare_V[ :]
obj['susc_d'] = ( bose_bare_V_static+wd)/bose_bare_V_static/bose_bare_V_static
wd_pp = obj['susc_d_pp'] * bose_bare_V_static * bose_bare_V_static - bose_bare_V_static
obj['phonon_selfenergy'] = -obj['g0']*obj['g0']*obj['susc_d_pp']/(1 - (-2/obj['Omega0'])*obj['g0']*obj['g0']*obj['susc_d_pp'])
#print(obj['susc_d'][int((bose_bare_V.shape[0]-1)/2), 136] - old[136])#obj['susc_d'])
#print(wd[int((bose_bare_V.shape[0]-1)/2), 136], bose_bare_V[int((bose_bare_V.shape[0]-1)/2), 136] )#obj['susc_d'])
f.close()
objs.append(obj)
return (objs, omega0_vals, g0_vals, momgrid, ffgrid)
from scipy.optimize import curve_fit
def linear(x, c):
return -x + c
def plot_d_susc_vs_g0(objs, title_ = "", label_ = ""):
objs_ = sorted(objs, key=lambda o: o["Vh"] )
plt.grid(True)
#plt.ylim([2, 5])
#plt.xlim([0.0, 3.5])
plt.title(r"$\Omega = "+str(objs[0]['Omega0'])+r"$")
plt.xlabel(r"$2g_0^2/\Omega_0$")
plt.ylabel(r"$\chi_D^{-1}(\pi, \pi)$")
#plt.xscale('log')
chi_vals = []
Vh_vals = []
for o in objs_:
if abs(o["Vh"]- o["U"]) < 0.001:
continue
if o["max_d"] != o["max_d"] or math.isinf(o["max_d"]):
continue
if o["max_d"] == 0:
continue
else:
chi_vals.append(1.0/o["max_d"])
Vh_vals.append(o["Vh"])
#print(chi_vals)
popt, pcov = curve_fit(linear, Vh_vals, chi_vals, p0=[0])
print(round(pcov[0][0], 4))
fitted_y_vals = [linear(x, popt[0]) for x in Vh_vals]
plt.plot(Vh_vals, chi_vals, "*-", label=r"$U$ = "+str(objs[0]['U']) + label_)
plt.plot(Vh_vals, fitted_y_vals, "-.")
import matplotlib.pyplot as plt
import matplotlib.tri as tri
import numpy as np
import numpy.random as rnd
import matplotlib.mlab as mlab
import time
from scipy.interpolate import griddata
import math
def plot_leading_fluctuations_all(objs, title_ = ""):
fig, axs = plt.subplots(1, 3, figsize=(13, 8))
axs[0].set_ylabel('U')
axs[1].set_title(title_, pad=20, fontsize=20)
for i in [0, 1, 2]:
axs[i].set_xlim(0, 3)
axs[i].set_ylim(0, 3)
axs[i].set_aspect('equal')
axs[i].set_xlabel('Vh')
XXsc = []
YYsc = []
ZZsc = []
XXd = []
YYd = []
ZZd = []
XXm = []
YYm = []
ZZm = []
ZZwsc = []
ZZwd = []
ZZwm = []
for obj in objs:
if ( (not math.isnan(obj["max_sc"])) and math.isfinite(obj["max_sc"])):
XXsc.append(obj["Vh"])
YYsc.append(obj["U"])
ZZsc.append(round(obj['max_sc'], 2))
ZZwsc.append(obj['max_w_sc'])
if ( (not math.isnan(obj["max_d"])) and math.isfinite(obj["max_d"])):
XXd.append(obj["Vh"])
YYd.append(obj["U"])
ZZd.append(round(obj['max_d'], 2))
ZZwd.append(obj['max_w_d'])
if ( (not math.isnan(obj["max_m"])) and math.isfinite(obj["max_m"])):
XXm.append(obj["Vh"])
YYm.append(obj["U"])
ZZm.append(round(obj['max_m'], 2))
ZZwm.append(obj['max_w_m'])
the_levels= sorted(list(set(ZZsc))) #[0, 0.8, 1.0, 1.4, 1.9, 2.5, 2.7, 3.5, 4.4, 5.6, 7.5, 8.9, 14, 17, 20, 30.4, 55, 64 ,100, 210, 500]
the_levelsd= sorted(list(set(ZZd))) #[0, 0.8, 1.0, 1.4, 1.9, 2.5, 2.7, 3.5, 4.4, 5.6, 7.5, 8.9, 14, 17, 20, 30.4, 55, 64 ,100, 210, 500]
the_levelsm= sorted(list(set(ZZm))) #[0, 0.8, 1.0, 1.4, 1.9, 2.5, 2.7, 3.5, 4.4, 5.6, 7.5, 8.9, 14, 17, 20, 30.4, 55, 64 ,100, 210, 500]
colorsr = [(.9 +(0.9-lam)/9.0, .9 + (0.9-lam)/9.0 - lam*lam, 0.9+(0.9-lam)/9.0 - lam*lam) for lam in np.linspace(0, 0.9, len(the_levels))]
colorsg = [(.9+(0.9-lam)/9.0 - lam*lam, .9+(0.9-lam)/9.0, 0.9+(0.9-lam)/9.0 - lam*lam) for lam in np.linspace(0, 0.9, len(the_levelsd))]
colorsb = [(.9+(0.9-lam)/9.0 - lam*lam, .9+(0.9-lam)/9.0 - lam*lam, .9+(0.9-lam)/9.0) for lam in np.linspace(0, 0.9, len(the_levelsm))]
#ZZsc = [min(100, x) for x in ZZsc]
#ZZd = [min(100, x) for x in ZZd]
#ZZm = [min(100, x) for x in ZZm]
if len(XXsc) > 1:
XXsc_, YYsc_ = np.meshgrid(np.linspace(min(XXsc), max(XXsc), 100), np.linspace(min(YYsc), max(YYsc), 100))
ZZsc_ = griddata((XXsc, YYsc), ZZsc, (XXsc_, YYsc_), method='nearest')
contourfr = axs[0].contourf(XXsc_, YYsc_, ZZsc_,levels = the_levels, colors = colorsr, extend='max', alpha=0.5)
#contourfr = axs[0].tricontourf(XXsc, YYsc, ZZsc, levels = the_levels, colors = colorsr, extend='max')
if len(XXd) > 1:
XXd_, YYd_ = np.meshgrid(np.linspace(min(XXd), max(XXd), 100), np.linspace(min(YYd), max(YYd), 100))
ZZd_ = griddata((XXd, YYd), ZZd, (XXd_, YYd_), method='nearest')
contourfg = axs[1].contourf(XXd_, YYd_, ZZd_, levels = the_levelsd, colors = colorsg, extend='max', alpha=0.5)
if len(XXm) > 1:
# Generate grid points for contour plot
XXm_, YYm_ = np.meshgrid(np.linspace(min(XXm), max(XXm), 100), np.linspace(min(YYm), max(YYm), 100))
ZZm_ = griddata((XXm, YYm), ZZm, (XXm_, YYm_), method='nearest')
contourfb = axs[2].contourf(XXm_, YYm_, ZZm_, levels = the_levelsm, colors = colorsb, extend='max', alpha=0.5 )
#cbar = fig.colorbar(contourfg, shrink=0.7, pad=-0.1, ticks = [])
#cbar = fig.colorbar(contourfb, shrink=0.7,pad=-0.1, ticks = [])
#cbar = fig.colorbar(contourfr, shrink=0.7, pad=0.02, ticks = [])
if len(XXd) > 1:
cbar = fig.colorbar(contourfg, shrink=0.4, ax=axs[1])
if len(XXm) > 1:
cbar = fig.colorbar(contourfb, shrink=0.4, ax=axs[2])
if len(XXsc) > 1:
cbar = fig.colorbar(contourfr, shrink=0.4, ax=axs[0])
plt.show()
def get_renormalised_omegas(objs):
objs_ = sorted(objs, key=lambda o: o["Vh"] )
pure_chi_d_electronic_vals = []
chi_d_vals = []
Vh_vals = []
U_vals = []
Omega0_vals = []
phonon_selfenergy_vals = []
for o in objs_:
#if o["diverged"]:
#print("susc_d")
# continue
#if abs(o["U"] - o["Vh"]) < 0.1:
# continue
if abs(o["Vh"]) < 0.01:
phonon_selfenergy_vals.append(np.zeros(o["phonon_selfenergy"].shape))
else:
phonon_selfenergy_vals.append(o["phonon_selfenergy"][:])
if "pure_susc_d" in o.keys():
pure_chi_d_electronic_vals.append(o["pure_susc_d"][:])
chi_d_vals.append(o["susc_d"][:])
Vh_vals.append(o["Vh"])
U_vals.append(o["U"])
Omega0_vals.append(o["Omega0"])
#if (1.0 - 2.0*(phonon_selfenergy_vals[-1][136]/Omega0_vals[-1]))<0:
# break
Vh_vals = np.array(Vh_vals)
Omega0_vals = np.array(Omega0_vals)
pure_chi_d_electronic_vals = np.array(pure_chi_d_electronic_vals)
phonon_selfenergy_vals = np.array(phonon_selfenergy_vals)
#print(phonon_selfenergy_vals.shape)
#sqrt_vals = -Vh_vals*chi_d_vals+ 1
sqrt_vals = 1.0 + 2.0*(phonon_selfenergy_vals[:, 136]/Omega0_vals)
dispersion_vals = np.array([(0 if e < 0 else e) for e in sqrt_vals])
phonon_selfenergy_vals_over_BZ = np.zeros((phonon_selfenergy_vals.shape[0], len(objs_[0]['BZ_path'])))
dispersion_vals_over_BZ = np.zeros((phonon_selfenergy_vals.shape[0], len(objs_[0]['BZ_path'])))
for VHidx in range((phonon_selfenergy_vals.shape[0])):
for i in range(len(objs_[0]['BZ_path'])):
momidx = objs_[0]['BZ_path'][i]
phonon_se_val = phonon_selfenergy_vals[VHidx, momidx]
phonon_selfenergy_vals_over_BZ[VHidx, i] = phonon_se_val
dispersion_vals_over_BZ[VHidx, i] = np.sqrt(1.0 + 2.0*phonon_se_val/Omega0_vals[0])
#zero_crossing = [Vh_vals[-1], None] if dispersion_vals[-1] == 0 else None
zero_crossing = None
if (dispersion_vals[-1] == 0 and len(dispersion_vals) > 3):
#print("hohohoho")
#print(len(Vh_vals[:-1]))
zero_crossing = find_zero_crossing(Vh_vals[:-1], dispersion_vals[:-1], degree=min(3, len(Vh_vals)-1) )
#print(zero_crossing)
Vh_vals[-1] = zero_crossing[0]
dispersion_vals[-1] = 0
return Vh_vals, np.sqrt(dispersion_vals), dispersion_vals_over_BZ, phonon_selfenergy_vals_over_BZ, zero_crossing, U_vals
def get_renormalised_omegas2(objs):
print("howdy")
objs_ = sorted(objs, key=lambda o: o["Vh"] )
pure_chi_d_electronic_vals = []
chi_d_vals = []
Vh_vals = []
U_vals = []
Omega0_vals = []
phonon_selfenergy_vals = []
for o in objs_:
if o["diverged"]:
#print("susc_d")
continue
if abs(o["U"] - o["Vh"]) < 0.1:
continue
if abs(o["Vh"]) < 0.01:
phonon_selfenergy_vals.append(np.zeros(o["phonon_selfenergy"].shape))
else:
phonon_selfenergy_vals.append(o["phonon_selfenergy"][:])
if "pure_susc_d" in o.keys():
pure_chi_d_electronic_vals.append(o["pure_susc_d"][:])
chi_d_vals.append(o["susc_d"][:])
Vh_vals.append(o["Vh"])
U_vals.append(o["U"])
Omega0_vals.append(o["Omega0"])
if (1.0 - 2.0*(phonon_selfenergy_vals[-1][136]/Omega0_vals[-1]))<0:
break
Vh_vals = np.array(Vh_vals)
Omega0_vals = np.array(Omega0_vals)
pure_chi_d_electronic_vals = np.array(pure_chi_d_electronic_vals)
phonon_selfenergy_vals = np.array(phonon_selfenergy_vals)
print(phonon_selfenergy_vals.shape)
#sqrt_vals = -Vh_vals*chi_d_vals+ 1
sqrt_vals = 1.0 + 2.0*(phonon_selfenergy_vals[:, 136]/Omega0_vals)
dispersion_vals = np.array([(0 if e < 0 else e) for e in sqrt_vals])
phonon_selfenergy_vals_over_BZ = np.zeros((phonon_selfenergy_vals.shape[0], len(objs_[0]['BZ_path'])))
dispersion_vals_over_BZ = np.zeros((phonon_selfenergy_vals.shape[0], len(objs_[0]['BZ_path'])))
for VHidx in range((phonon_selfenergy_vals.shape[0])):
for i in range(len(objs_[0]['BZ_path'])):
momidx = objs_[0]['BZ_path'][i]
phonon_se_val = phonon_selfenergy_vals[VHidx, momidx]
phonon_selfenergy_vals_over_BZ[VHidx, i] = phonon_se_val
dispersion_vals_over_BZ[VHidx, i] = np.sqrt(1.0 + 2.0*phonon_se_val/Omega0_vals[0])
#zero_crossing = [Vh_vals[-1], None] if dispersion_vals[-1] == 0 else None
zero_crossing = None
if (dispersion_vals[-1] == 0 and len(dispersion_vals) > 3):
#print("hohohoho")
#print(len(Vh_vals[:-1]))
zero_crossing = find_zero_crossing(Vh_vals[:-1], dispersion_vals[:-1], degree=min(3, len(Vh_vals)-1) )
#print(zero_crossing)
Vh_vals[-1] = zero_crossing[0]
dispersion_vals[-1] = 0
return Vh_vals, np.sqrt(dispersion_vals), dispersion_vals_over_BZ, phonon_selfenergy_vals_over_BZ, zero_crossing, U_vals
import numpy as np
def find_zero_crossing(x_points, y_points, degree=3):
# Fit a polynomial to the data points
coefs = np.polyfit(x_points, y_points, degree)
# Create a polynomial object
poly = np.poly1d(coefs)
# Generate an extended range of x-values to look for zero crossing
x_interp = np.linspace(min(x_points) - 1, max(x_points) + 1, 1000)
y_interp = poly(x_interp)
# Find the roots of the polynomial to see where it hits zero
roots = poly.roots
real_roots = roots[np.isreal(roots)].real # Only consider real roots
first_root = min(real_roots) if real_roots.size > 0 else None # Get the first real root
if first_root is not None:
first_root_y = poly(first_root)
# Ensure y is zero, due to possible numerical issues
first_root_y = 0
else:
first_root_y = None
return first_root, first_root_y
# Example usage
x_points = np.array([1, 2, 3, 4])
y_points = np.array([2, 3, 5, 4])
zero_crossing = find_zero_crossing(x_points, y_points, degree=3)
print("Zero crossing point:", zero_crossing)
Zero crossing point: (4.633220336886764, 0)
files_dir_halffilling_beta20 = "/media/aiman/data/phase_diagrams_final_halffilled/"
dat_names_halffilling_beta20 = os.listdir(files_dir_halffilling_beta20)
dat_names_halffilling_beta20 = [files_dir_halffilling_beta20 + "/" + o for o in dat_names_halffilling_beta20]
objs_omega_halffilling, omega0_vals, g0_vals, momgrid, ffgrid = load_objs(dat_names_halffilling_beta20)
files_dir_doped_beta20 = "/media/aiman/data/phase_diagrams_final_doped/"
dat_names_doped_beta20 = os.listdir(files_dir_doped_beta20)
dat_names_doped_beta20 = [files_dir_doped_beta20 + "/" + o for o in dat_names_doped_beta20]
objs_omega_doped, omega0_vals, g0_vals, momgrid, ffgrid = load_objs(dat_names_doped_beta20)
--------------------------------------------------------------------------- NameError Traceback (most recent call last) /tmp/ipykernel_2593445/200536738.py in <module> 1 files_dir_halffilling_beta20 = "/media/aiman/data/phase_diagrams_final_halffilled/" 2 ----> 3 dat_names_halffilling_beta20 = os.listdir(files_dir_halffilling_beta20) 4 dat_names_halffilling_beta20 = [files_dir_halffilling_beta20 + "/" + o for o in dat_names_halffilling_beta20] 5 NameError: name 'os' is not defined
objs_omega0_halffilling_beta20 = list(filter(lambda o: np.abs(o['Omega0'] - 0.01)<1e-4, objs_omega_halffilling))
objs_omega1_halffilling_beta20 = list(filter(lambda o: np.abs(o['Omega0'] - 1.0)<1e-4, objs_omega_halffilling))
objs_omega2_halffilling_beta20 = list(filter(lambda o: np.abs(o['Omega0'] - 2.0)<1e-4, objs_omega_halffilling))
objs_omega5_halffilling_beta20 = list(filter(lambda o: np.abs(o['Omega0'] - 5.0)<1e-4, objs_omega_halffilling))
objs_omega10_halffilling_beta20 = list(filter(lambda o: np.abs(o['Omega0'] - 10.0)<1e-4, objs_omega_halffilling))
objs_omega10000_halffilling_beta20 = list(filter(lambda o: np.abs(o['Omega0'] - 10000)<1e-4, objs_omega_halffilling))
objs_omega0_doped_beta20 = list(filter(lambda o: np.abs(o['Omega0'] - 0.01)<1e-4, objs_omega_doped))
objs_omega1_doped_beta20 = list(filter(lambda o: np.abs(o['Omega0'] - 1.0)<1e-4, objs_omega_doped))
objs_omega2_doped_beta20 = list(filter(lambda o: np.abs(o['Omega0'] - 2.0)<1e-4, objs_omega_doped))
objs_omega5_doped_beta20 = list(filter(lambda o: np.abs(o['Omega0'] - 5.0)<1e-4, objs_omega_doped))
objs_omega10_doped_beta20 = list(filter(lambda o: np.abs(o['Omega0'] - 10.0)<1e-4, objs_omega_doped))
objs_omega10000_doped_beta20 = list(filter(lambda o: np.abs(o['Omega0'] - 10000)<1e-4, objs_omega_doped))
def makes_objs_by_Us(objs):
objs_by_Us = {}
for o in objs:
if o["U"] not in objs_by_Us.keys():
objs_by_Us[o["U"]] = []
objs_by_Us[o["U"]].append(o)
return objs_by_Us
objs_beta20_halffilling_omega0_Us = makes_objs_by_Us(objs_omega0_halffilling_beta20)
objs_beta20_halffilling_omega1_Us = makes_objs_by_Us(objs_omega1_halffilling_beta20)
objs_beta20_halffilling_omega2_Us = makes_objs_by_Us(objs_omega2_halffilling_beta20)
objs_beta20_halffilling_omega5_Us = makes_objs_by_Us(objs_omega5_halffilling_beta20)
objs_beta20_halffilling_omega10_Us = makes_objs_by_Us(objs_omega10_halffilling_beta20)
objs_beta20_halffilling_omega10000_Us = makes_objs_by_Us(objs_omega10000_halffilling_beta20)
objs_beta20_doped_omega0_Us = makes_objs_by_Us(objs_omega0_doped_beta20)
objs_beta20_doped_omega1_Us = makes_objs_by_Us(objs_omega1_doped_beta20)
objs_beta20_doped_omega2_Us = makes_objs_by_Us(objs_omega2_doped_beta20)
objs_beta20_doped_omega5_Us = makes_objs_by_Us(objs_omega5_doped_beta20)
objs_beta20_doped_omega10_Us = makes_objs_by_Us(objs_omega10_doped_beta20)
objs_beta20_doped_omega10000_Us = makes_objs_by_Us(objs_omega10000_doped_beta20)
Us_list = sorted(objs_beta20_halffilling_omega2_Us.keys())
print("Us list")
Us_list
Us list
[0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0]
Uval = 1.0
BZ_path_distances = []
BZ_path = objs_beta20_halffilling_omega10_Us[Uval][0]['BZ_path']
for i in range(len(BZ_path)):
if i == 0:
BZ_path_distances.append(0.0)
continue
BZ_path_distances.append(BZ_path_distances[-1]+np.linalg.norm( momgrid[BZ_path[i]] - momgrid[BZ_path[i-1]] ))
print(momgrid[BZ_path[i]], i, BZ_path_distances[-1])#, momgrid[i], momgrid[i-1] )
markers = "o"
#BZ_distances = objs_beta20_halffilling_omega1_Us[Uval][0]['BZ_path']
[0.07853982 0. ] 1 0.07853981633974483 [0.15707963 0. ] 2 0.15707963267948966 [0.23561945 0. ] 3 0.23561944901923448 [0.31415927 0. ] 4 0.3141592653589793 [0.39269908 0. ] 5 0.39269908169872414 [0.78539816 0. ] 6 0.7853981633974483 [1.17809725 0. ] 7 1.1780972450961724 [1.57079633 0. ] 8 1.5707963267948966 [1.96349541 0. ] 9 1.9634954084936207 [2.35619449 0. ] 10 2.356194490192345 [2.74889357 0. ] 11 2.748893571891069 [3.14159265 0. ] 12 3.141592653589793 [3.14159265 0.39269908] 13 3.5342917352885173 [3.14159265 0.78539816] 14 3.9269908169872414 [3.14159265 1.17809725] 15 4.319689898685965 [3.14159265 1.57079633] 16 4.71238898038469 [3.14159265 1.96349541] 17 5.105088062083414 [3.14159265 2.35619449] 18 5.497787143782139 [3.14159265 2.74889357] 19 5.890486225480863 [3.14159265 2.82743339] 20 5.969026041820609 [3.14159265 2.9059732 ] 21 6.047565858160354 [3.14159265 2.98451302] 22 6.126105674500099 [3.14159265 3.06305284] 23 6.2046454908398445 [3.14159265 3.14159265] 24 6.28318530717959 [3.06305284 3.06305284] 25 6.394257380633549 [2.98451302 2.98451302] 26 6.505329454087509 [2.9059732 2.9059732] 27 6.616401527541468 [2.82743339 2.9059732 ] 28 6.694941343881213 [2.74889357 2.74889357] 29 6.870561712157231 [2.35619449 2.35619449] 30 7.425922079427027 [1.96349541 1.96349541] 31 7.981282446696822 [1.57079633 1.57079633] 32 8.536642813966617 [1.17809725 1.17809725] 33 9.092003181236413 [0.78539816 0.78539816] 34 9.647363548506208 [0.39269908 0.39269908] 35 10.202723915776003 [0.23561945 0.31415927] 36 10.378344284052021 [0.23561945 0.23561945] 37 10.456884100391767 [0.15707963 0.15707963] 38 10.567956173845726 [0.07853982 0.07853982] 39 10.679028247299685 [0. 0.] 40 10.790100320753645
#xs, ys =get_renormalised_omegas(objs_vanhove_halffilling_omega0p01_Us[1.0] )
#plt.plot(xs, ys/0.01, "*-")
#plt.xlim(0, 3)
plt.ylabel(r"$\Omega_{eff}/\Omega_0$")
plt.xlabel(r"")
x_positions = [BZ_path_distances[0], BZ_path_distances[12], BZ_path_distances[24], BZ_path_distances[40]] # Specify the x positions for the ticks
x_labels = [r'$\Gamma$', r"$X$", r"$M$", r"$\Gamma$"] # Labels for the custom ticks
desired_Vh = 2.0
# Set the custom ticks
plt.xticks(ticks=x_positions, labels=x_labels)
#print([obj["Vh"] for obj in objs_beta20_halffilling_omega2_Us[1.0]])
objs_beta20_halffilling_omega2_at_Vh = [[obj for obj in objs_beta20_halffilling_omega2_Us[objs_key] if abs(obj["Vh"] - desired_Vh) < 1e-4][0] for objs_key in objs_beta20_halffilling_omega2_Us.keys()]
for Uval in [0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0]:
vhvals, ys, disps, ses,_, uvals =get_renormalised_omegas(objs_beta20_halffilling_omega2_Us[Uval])
#print(xs)
for x in range(len(vhvals)):
if abs(vhvals[x]-desired_Vh) < 1e-4:
print(vhvals[x])
#print("yooo", objs_beta20_halffilling_omega1_Us[Uval][x]['Vh'], objs_beta20_halffilling_omega1_Us[Uval][x]['U'])
plt.plot(BZ_path_distances, disps[x], "*-", label= r"$U$= {0}t, $\Omega_0 = 1t$".format(Uval))
#pass
plt.legend()
#objs_beta20_halffilling_omega1_Us[Uval][0]['BZ_path']
#print((objs_beta20_halffilling_omega1_Us[Uval][0]['BZ_path']))
2.0000000000000004 2.0000000000000004 2.0000000000000004 2.0000000000000004 2.0000000000000004 2.0000000000000004 2.0000000000000004
/tmp/ipykernel_61597/3791386730.py:6: UserWarning: cmr10 font should ideally be used with mathtext, set axes.formatter.use_mathtext to True
plt.ylabel(r"$\Omega_{eff}/\Omega_0$")
<matplotlib.legend.Legend at 0x75142bff18d0>
#xs, ys =get_renormalised_omegas(objs_vanhove_halffilling_omega0p01_Us[1.0] )
#plt.plot(xs, ys/0.01, "*-")
plt.xlim(0, 3)
plt.ylim(-1.5, 1.5)
plt.ylabel(r"$\Omega_{eff}(\pi, \pi)/\Omega_0$")
plt.xlabel(r"$V_H$")
for Uval in [0.5, 0.75, 1.0, 1.25, 1.5, 1.75, 2.0, 2.25, 2.5, 2.75]:
xs, ys, disps, ses,_ =get_renormalised_omegas(objs_beta20_halffilling_omega1_Us[Uval])
plt.plot(xs, ys, "*-", label= r"$U$= {0}t, $\Omega_0 = 1t$".format(Uval))
plt.legend()
#xs, ys =get_renormalised_omegas(objs_vanhove_halffilling_omega0p01_Us[1.0] )
#plt.plot(xs, ys/0.01, "*-")
plt.xlim(0, 3)
plt.ylim(0, 2)
plt.ylabel(r"$\Omega_{eff}(\pi, \pi)/\Omega_0$")
plt.xlabel(r"$V_H$")
for Uval in [0.5, 1.0, 1.5, 2.0, 2.5]:
xs, ys, disps, ses,_ =get_renormalised_omegas(objs_vanhove_halffilling_omega01_Us[Uval])
plt.plot(xs, ys, "*-", label= r"$U$= {0}t, $\Omega_0 = 1t$".format(Uval))
plt.legend()
print(_)
def plot_leading_fluctuations_beta20(objs, Us_list_, title_ = "", crystal_instability= None, ax_ = None, fig_ = None, no_xticks = False, no_yticks = False):
#fig, ax = plt.subplots()
if ax_ is None:
ax_ = plt.gca()
if fig_ is None:
fig_ = plt.gcf()
ax = ax_
fig = fig_
num = len(Us_list_)
dU = Us_list[1]
print(dU)
ax.set_xlim(-0.5, num-0.5)
ax.set_ylim(-0.5, num-0.5)
ax.set_aspect('equal')
XXsc = []
YYsc = []
ZZsc = []
XXall = []
YYall = []
ZZall = []
XXd = []
YYd = []
ZZd = []
ZZdall = []
XXm = []
YYm = []
ZZm = []
ZZmall = []
ZZwsc = []
ZZwd = []
ZZwm = []
_pp_str = "_pp"
vals_phasediagram = np.ones( (int(num), int(num))) * 130
#dbg_phasediagram = np.zeroes
ax.text(3.0/dU+0.05, 0/dU+0.05, r"$\square$", size=23, rotation=0,
ha="center", va="center"
)
ax.text(3.0/dU+0.05, 0.5/dU+0.05, r"$\square$", size=23, rotation=0,
ha="center", va="center"
)
for obj in objs:
if ((obj["U"]+0.001) % 0.5) > 1e-2 or ((obj["Vh"]+0.001) % 0.5) > 1e-2:
continue
color = np.array([0.0, 0.0, 0.0])
leading = obj["leading_susc"]
is_divergent =obj["diverged"]
if "sc" in leading:
if np.abs(obj["max_sc"+_pp_str] - obj["max_d"+_pp_str])/(obj["max_d"+_pp_str] + obj["max_sc"+_pp_str]) < 0.05:
leading += ", d"
if np.abs(obj["max_sc"+_pp_str] - obj["max_m"+_pp_str])/(obj["max_m"+_pp_str] + obj["max_sc"+_pp_str]) < 0.05:
leading += ", m"
if "d" in leading:
if np.abs(obj["max_sc"+_pp_str] - obj["max_d"+_pp_str])/(obj["max_d"+_pp_str] + obj["max_sc"+_pp_str]) < 0.05:
leading += ", sc"
if np.abs(obj["max_d"+_pp_str] - obj["max_m"+_pp_str])/(obj["max_m"+_pp_str] + obj["max_d"+_pp_str]) < 0.05:
leading += ", m"
if "m" in leading:
if np.abs(obj["max_sc"+_pp_str] - obj["max_m"+_pp_str])/(obj["max_m"+_pp_str] + obj["max_sc"+_pp_str]) < 0.05:
leading += ", sc"
if np.abs(obj["max_d"+_pp_str] - obj["max_m"+_pp_str])/(obj["max_m"+_pp_str] + obj["max_d"+_pp_str]) < 0.05:
leading += ", d"
if False and is_divergent:
ax.text(obj["Vh"]/dU, obj["U"]/dU, r"$\cdot$", size=12, rotation=0,
ha="center", va="center"
)
if "sc" in leading:
if np.abs(obj["max_sc"+_pp_str] - obj["max_d"+_pp_str])/(obj["max_d"+_pp_str] + obj["max_sc"+_pp_str]) < 0.1:
leading += ", d"
color += np.array([1.0, 0.0, 0.0])
ax.text(obj["Vh"]/dU+0.05, obj["U"]/dU+0.05, r"$\bigcirc$", size=23, rotation=0,
ha="center", va="center"
)
if "d" in leading:
ax.text(obj["Vh"]/dU+0.05, obj["U"]/dU+0.05, r"$\square$", size=23, rotation=0,
ha="center", va="center"
)
color += np.array([0.0, 1.0, 0.0])
if "m" in leading:
ax.text(obj["Vh"]/dU+0.05, obj["U"]/dU+0.05, r"$\triangle$", size=23, rotation=0,
ha="center", va="center",
)
color += np.array([0.0, 0.0, 1.0])
if (obj['max_sc'+_pp_str] > 0 and "sc" in obj["leading_susc"]):
XXsc.append(obj["Vh"])
YYsc.append(obj["U"])
ZZsc.append(obj['max_sc'+_pp_str])
ZZwsc.append(obj['max_w_sc'])
if (obj['max_d'+_pp_str] > 0 and "d" in obj["leading_susc"]):
XXd.append(obj["Vh"])
YYd.append(obj["U"])
ZZd.append(obj['max_d'+_pp_str])
ZZwd.append(obj['max_w_d'])
if (obj['max_m'+_pp_str] > 0 and "m" in obj["leading_susc"]):
XXm.append(obj["Vh"])
YYm.append(obj["U"])
ZZm.append(obj['max_m'+_pp_str])
ZZwm.append(obj['max_w_m'])
max_coupling = max(obj['max_m'+_pp_str], max(obj['max_sc'+_pp_str], obj['max_d'+_pp_str]))
if max_coupling == max_coupling:
vals_phasediagram[int((obj["U"]/dU + 0.01)), int((obj["Vh"]/dU) + 0.01) ] = max(obj['max_m'+_pp_str], max(obj['max_sc'+_pp_str], obj['max_d'+_pp_str]))
the_levels= sorted(list(set(ZZsc))) #[0, 0.8, 1.0, 1.4, 1.9, 2.5, 2.7, 3.5, 4.4, 5.6, 7.5, 8.9, 14, 17, 20, 30.4, 55, 64 ,100, 210, 500]
the_levelsd= sorted(list(set(ZZd))) #[0, 0.8, 1.0, 1.4, 1.9, 2.5, 2.7, 3.5, 4.4, 5.6, 7.5, 8.9, 14, 17, 20, 30.4, 55, 64 ,100, 210, 500]
the_levelsm= sorted(list(set(ZZm))) #[0, 0.8, 1.0, 1.4, 1.9, 2.5, 2.7, 3.5, 4.4, 5.6, 7.5, 8.9, 14, 17, 20, 30.4, 55, 64 ,100, 210, 500]
colorsr = [(.9 +(0.9-lam)/9.0, .9 + (0.9-lam)/9.0 - lam*lam, 0.9+(0.9-lam)/9.0 - lam*lam) for lam in np.linspace(0, 0.9, len(the_levels))]
colorsg = [(.9+(0.9-lam)/9.0 - lam*lam, .9+(0.9-lam)/9.0, 0.9+(0.9-lam)/9.0 - lam*lam) for lam in np.linspace(0, 0.9, len(the_levelsd))]
colorsb = [(.9+(0.9-lam)/9.0 - lam*lam, .9+(0.9-lam)/9.0 - lam*lam, .9+(0.9-lam)/9.0) for lam in np.linspace(0, 0.9, len(the_levelsm))]
vals_phasediagram[vals_phasediagram > 130.0] = 130.0
#for i in range(vals_phasediagram.shape[0]):
# dx = +1 if i+1 < vals_phasediagram.shape[0] else -1
# dy = +1 if i+1 < vals_phasediagram.shape[0] else -1
# vals_phasediagram[i, i] = dU*(vals_phasediagram[i, i+dy] + vals_phasediagram[i+dx, i])
ax.set_title(title_, pad=10, fontsize=20, loc='left')
if not no_xticks:
ax.set_xlabel(r'$V_H/t$')
ax_.set_xticks(np.linspace(0, num-1, 4), np.linspace(0, 3, 4)) # Relabel x-axis from 0 to 3
else:
ax_.set_xticks([])
if not no_yticks:
ax_.set_yticks(np.linspace(0, num-1, 4), np.linspace(0, 3, 4)) # Relabel y-axis from 0 to 3
ax.set_ylabel(r'$U/t$')
else:
ax_.set_yticks([])
#print(vals_phasediagram)
clx = ax_.imshow(np.log(vals_phasediagram+1.0)/np.log(10), cmap='coolwarm', interpolation="nearest", vmax=np.log(130+1.0)/np.log(10))#interpolation='hamming') #hermit, hanning, hamming, byssel
#fig_.colorbar(clx, ax = ax_, label=r'$log(1+max\chi)$')
return clx
#plt.show()
fig, axes = plt.subplots(nrows=3, ncols=2, figsize=(5.1*2*0.9, 5.1*0.9*3)) # Adjust figsize as needed
plot_leading_fluctuations_beta20(objs_omega0_halffilling_beta20, Us_list, title_ = r"$\omega_0 = 0.01t$", ax_ = axes[0][0], no_xticks = True)
plot_leading_fluctuations_beta20(objs_omega2_halffilling_beta20, Us_list, title_ = r"$\omega_0 = 2t$", ax_ = axes[1][0], no_xticks = True, no_yticks = False)
plot_leading_fluctuations_beta20(objs_omega10_halffilling_beta20, Us_list, title_ = r"$\omega_0 = 10t$", ax_ = axes[2][0], no_xticks = False, no_yticks = False)
plot_leading_fluctuations_beta20(objs_omega1_halffilling_beta20, Us_list, title_ = r"$\omega_0 = 1t$", ax_ = axes[0][1], no_yticks = True, no_xticks = True)
plot_leading_fluctuations_beta20(objs_omega5_halffilling_beta20, Us_list, title_ = r"$\omega_0 = 5t$", ax_ = axes[1][1], no_yticks = True, no_xticks = True)
clx = plot_leading_fluctuations_beta20(objs_omega10000_halffilling_beta20, Us_list, title_ = r"$\omega_0 = 10000t$", ax_ = axes[2][1], no_yticks = True)
plt.subplots_adjust(wspace=-0.42, hspace=0.2)
fig.colorbar(clx, ax = axes, label=r'$\log_{10}(1+\chi t)$', location="bottom", shrink=0.70, pad=0.07,
aspect=50)
plt.savefig('phase_diag_halffilling_beta20.svg', dpi=300, bbox_inches='tight', pad_inches=0) # Save the figure with higher DPI for better resolution
/tmp/ipykernel_2591101/1143482828.py:1: UserWarning: cmr10 font should ideally be used with mathtext, set axes.formatter.use_mathtext to True
fig, axes = plt.subplots(nrows=3, ncols=2, figsize=(5.1*2*0.9, 5.1*0.9*3)) # Adjust figsize as needed
/tmp/ipykernel_2591101/1143482828.py:9: UserWarning: cmr10 font should ideally be used with mathtext, set axes.formatter.use_mathtext to True
fig.colorbar(clx, ax = axes, label=r'$\log_{10}(1+\chi t)$', location="bottom", shrink=0.70, pad=0.07,
0.5 0.5 0.5 0.5 0.5 0.5
fig, axes = plt.subplots(nrows=3, ncols=2, figsize=(4.8*2*0.9, 4.8*0.9*3)) # Adjust figsize as needed
plot_leading_fluctuations_beta20(objs_omega0_doped_beta20, Us_list, title_ = r"$\omega_0 = 0.01t$", ax_ = axes[0][0], no_xticks = True)
plot_leading_fluctuations_beta20(objs_omega2_doped_beta20, Us_list, title_ = r"$\omega_0 = 2t$", ax_ = axes[1][0], no_xticks = True)
plot_leading_fluctuations_beta20(objs_omega10_doped_beta20, Us_list, title_ = r"$\omega_0 = 10t$", ax_ = axes[2][0], no_xticks = False)
plot_leading_fluctuations_beta20(objs_omega1_doped_beta20, Us_list, title_ = r"$\omega_0 = 1t$", ax_ = axes[0][1], no_yticks = True, no_xticks = True)
plot_leading_fluctuations_beta20(objs_omega5_doped_beta20, Us_list, title_ = r"$\omega_0 = 5t$", ax_ = axes[1][1], no_yticks = True, no_xticks = True)
clx = plot_leading_fluctuations_beta20(objs_omega10000_doped_beta20, Us_list, title_ = r"$\omega_0 = 10000t$", ax_ = axes[2][1], no_yticks = True)
plt.subplots_adjust(wspace=-0.42, hspace=0.2)
fig.colorbar(clx, ax = axes, label=r'$\log_{10}(1+\chi t)$', location="bottom", shrink=0.70, pad=0.07,
aspect=50)
#cbar.ax.tick_params(width=0.1)
#cbar.ax.set_aspect(20)
plt.savefig('phase_diag_doped_beta20.svg', dpi=300, bbox_inches='tight', pad_inches=0) # Save the figure with higher DPI for better resolution
/tmp/ipykernel_2591101/3114420073.py:1: UserWarning: cmr10 font should ideally be used with mathtext, set axes.formatter.use_mathtext to True
fig, axes = plt.subplots(nrows=3, ncols=2, figsize=(4.8*2*0.9, 4.8*0.9*3)) # Adjust figsize as needed
/tmp/ipykernel_2591101/3114420073.py:9: UserWarning: cmr10 font should ideally be used with mathtext, set axes.formatter.use_mathtext to True
fig.colorbar(clx, ax = axes, label=r'$\log_{10}(1+\chi t)$', location="bottom", shrink=0.70, pad=0.07,
0.5 0.5 0.5 0.5 0.5 0.5
def plot_suscs_vs_Vh(chann, objs__, desired_U, title_ = "", label_ = "", max_Vh = 1e10, min_Vh = -1, linestyle_ = "-", ax = None, hide_x_labels = False, no_labels = False):
objs_ = []
for obj in objs__:
if (abs(obj["U"] - desired_U))<1e-4:
objs_.append(obj)
objs = sorted(objs_, key=lambda o: o["Vh"] )
#plt.grid(True)
if ax == None:
ax = plt.gca()
#ax.set_title(r"$\omega_0 = "+str(int(objs[0]['Omega0']))+r"t$", y=1.0, fontsize=20)
if not hide_x_labels:
ax.set_xlabel(r"$V_H/t$")#(r"$2g_0^2/\Omega_0$")
else:
ax.set_xlabel(r"")
ax.set_xticks([]) # Remove tick marks
ax.set_xticklabels([])
ax.set_ylabel(r"$\chi^{-1}/t$")
#plt.xscale('log')
chi_vals = []
Vh_vals = []
symbols = {"sc": "o", "d": "s"}
colours = {"sc": "red", "d": "green"}
for o in objs:
if o["Vh"] > max_Vh:
continue
#if abs(o["Vh"]- o["U"]) < 0.001:
# continue
#if o["max_"+chann] != o["max_"+chann] or math.isinf(o["max_"+chann]):
# continue
if o["max_"+chann] == 0:
continue
else:
#print(o[chann+"_pp"])
chi_vals.append(1.0/(o[chann+"_pp"]))
Vh_vals.append(o["Vh"])
#print(chi_vals)
#popt, pcov = curve_fit(linear, Vh_vals, chi_vals, p0=[0])
#print(round(pcov[0][0], 4))
#fitted_y_vals = [linear(x, popt[0]) for x in Vh_vals]
#plt.gca().set_aspect('equal')
ax.plot(Vh_vals, chi_vals,
linestyle=linestyle_, marker=symbols[chann], markersize=8, color = colours[chann], linewidth=2, markeredgewidth=1, markeredgecolor='black', markerfacecolor=colours[chann],
label=r"$\chi^{{"+chann.upper() + r"} }$, $U$ = "+str(objs[0]['U']) + label_ if not no_labels else None)
#plt.plot(x, y, linestyle='--', marker='o', markersize=10, markerfacecolor='red', markeredgewidth=2, markeredgecolor='black', linewidth=2)
#plt.plot(Vh_vals, fitted_y_vals, "-.")
#plt.figure(figsize=(6.4, 4.8))
plot_suscs_vs_Vh('d', objs_omega0_doped_beta20, 0.0, max_Vh = 2.1)
plot_suscs_vs_Vh('sc', objs_omega0_doped_beta20, 0.0, max_Vh = 2.1)
plot_suscs_vs_Vh('d', objs_omega0_doped_beta20, 0.5, linestyle_="-.", max_Vh = 2.1)
plot_suscs_vs_Vh('sc', objs_omega0_doped_beta20, 0.5, linestyle_="-.", max_Vh = 2.1)
plot_suscs_vs_Vh('d', objs_omega0_doped_beta20, 1.0, linestyle_=":", max_Vh = 2.1)
plot_suscs_vs_Vh('sc', objs_omega0_doped_beta20, 1.0, linestyle_=":", max_Vh = 2.1)
#plt.legend()
plot_suscs_vs_Vh('d', objs_omega1_doped_beta20, 0.0)
plot_suscs_vs_Vh('sc', objs_omega1_doped_beta20, 0.0)
plot_suscs_vs_Vh('d', objs_omega1_doped_beta20, 0.5, linestyle_="-.")
plot_suscs_vs_Vh('sc', objs_omega1_doped_beta20, 0.5, linestyle_="-.")
plot_suscs_vs_Vh('d', objs_omega1_doped_beta20, 1.0, linestyle_=":")
plot_suscs_vs_Vh('sc', objs_omega1_doped_beta20, 1.0, linestyle_=":")
plt.legend()
<matplotlib.legend.Legend at 0x74a99b5633d0>
plot_suscs_vs_Vh('d', objs_omega2_doped_beta20, 0.0)
plot_suscs_vs_Vh('sc', objs_omega2_doped_beta20, 0.0)
plot_suscs_vs_Vh('d', objs_omega2_doped_beta20, 0.5, linestyle_="-.")
plot_suscs_vs_Vh('sc', objs_omega2_doped_beta20, 0.5, linestyle_="-.")
plot_suscs_vs_Vh('d', objs_omega2_doped_beta20, 1.0, linestyle_=":")
plot_suscs_vs_Vh('sc', objs_omega2_doped_beta20, 1.0, linestyle_=":")
#plt.legend()
plot_suscs_vs_Vh('d', objs_omega10_doped_beta20, 0.0)
plot_suscs_vs_Vh('sc', objs_omega10_doped_beta20, 0.0)
plot_suscs_vs_Vh('d', objs_omega10_doped_beta20, 0.5, linestyle_="-.")
plot_suscs_vs_Vh('sc', objs_omega10_doped_beta20, 0.5, linestyle_="-.")
plot_suscs_vs_Vh('d', objs_omega10_doped_beta20, 1.0, linestyle_=":")
plot_suscs_vs_Vh('sc', objs_omega10_doped_beta20, 1.0, linestyle_=":")
plot_suscs_vs_Vh('d', objs_omega0_doped_beta20, 0.0, max_Vh = 2.1)
plot_suscs_vs_Vh('sc', objs_omega0_doped_beta20, 0.0, max_Vh = 2.1)
plot_suscs_vs_Vh('d', objs_omega0_doped_beta20, 0.5, max_Vh = 2.1)
plot_suscs_vs_Vh('sc', objs_omega0_doped_beta20, 0.5, max_Vh = 2.1)
plot_suscs_vs_Vh('d', objs_omega0_doped_beta20, 1.0, max_Vh = 2.1)
plot_suscs_vs_Vh('sc', objs_omega0_doped_beta20, 1.0, max_Vh = 2.1)
plt.legend()
<matplotlib.legend.Legend at 0x7fcbc93e7d00>
plot_suscs_vs_Vh('d', objs_omega2_halffilling_beta20, 0.0)
plot_suscs_vs_Vh('sc', objs_omega2_halffilling_beta20, 0.0)
plot_suscs_vs_Vh('d', objs_omega2_halffilling_beta20, 0.5)
plot_suscs_vs_Vh('sc', objs_omega2_halffilling_beta20, 0.5)
plot_suscs_vs_Vh('d', objs_omega2_halffilling_beta20, 1.0)
plot_suscs_vs_Vh('sc', objs_omega2_halffilling_beta20, 1.0)
plt.legend()
<matplotlib.legend.Legend at 0x7fcbc911fca0>
fig, axes = plt.subplots(nrows=1, ncols=2, figsize=(4.2*2*0.9, 3.8*1*0.9)) # Adjust figsize as needed
plot_suscs_vs_Vh('d', objs_omega2_doped_beta20, 0.0, ax= axes[0], no_labels = True)
plot_suscs_vs_Vh('sc', objs_omega2_doped_beta20, 0.0, ax= axes[0], no_labels = True)
plot_suscs_vs_Vh('d', objs_omega2_doped_beta20, 0.5, linestyle_="-.", ax= axes[0], no_labels = True)
plot_suscs_vs_Vh('sc', objs_omega2_doped_beta20, 0.5, linestyle_="-.", ax= axes[0], no_labels = True)
plot_suscs_vs_Vh('d', objs_omega2_doped_beta20, 1.0, linestyle_=":", ax= axes[0], no_labels = True)
plot_suscs_vs_Vh('sc', objs_omega2_doped_beta20, 1.0, linestyle_=":", ax= axes[0], hide_x_labels= False, no_labels = True)
plot_suscs_vs_Vh('d', objs_omega1_doped_beta20, 0.0, ax= axes[1], no_labels = True)
plot_suscs_vs_Vh('sc', objs_omega1_doped_beta20, 0.0, ax= axes[1], no_labels = True)
plot_suscs_vs_Vh('d', objs_omega1_doped_beta20, 0.5, linestyle_="-.", ax= axes[1], no_labels = True)
plot_suscs_vs_Vh('sc', objs_omega1_doped_beta20, 0.5, linestyle_="-.", ax= axes[1], no_labels = True)
plot_suscs_vs_Vh('d', objs_omega1_doped_beta20, 1.0, linestyle_=":", ax= axes[1], no_labels = True)
plot_suscs_vs_Vh('sc', objs_omega1_doped_beta20, 1.0, linestyle_=":", ax= axes[1], no_labels = True)
line_styles = ['-', '-.', ':']
U_values = [0, 0.5, 1.0]
# Markers representing different χ values
markers = {r'$\mathrm{D}$': 's', r'$\mathrm{SC}$': 'o'}
colors = {r'$\mathrm{D}$': 'green', r'$\mathrm{SC}$': 'red'}
for chi, marker in markers.items():
axes[0].plot([], [], color=colors[chi], marker=marker, linestyle='', markersize=8, label=chi, markeredgecolor='black')
axes[0].plot([], [], " ", marker=" ", label=" ")
for ls, U in zip(line_styles, U_values):
axes[0].plot([], [], linestyle=ls, color='black', label=f"$U$ = ${U}t$")
# First legend: Line styles
legend1 = axes[0].legend(title="", loc="upper right", prop={'size': 15}, ncol=2, columnspacing=0.6, handletextpad=0.2, labelspacing=0.2, handlelength=1.4, borderpad=0.2)
# Second legend: Markers
#legend2 = axes[0].legend(title="Markers", loc="upper right")
# Add the first legend back to the plot
ax= axes[0].add_artist(legend1)
#axes[0].set_aspect('equal')
#axes[0].set_aspect(1./axes[0].get_data_ratio())
#axes[1].set_aspect('equal')
#axes[1].set_aspect(1./axes[1].get_data_ratio())
axes[1].set_ylabel("")
axes[1].set_yticks([])
plt.subplots_adjust(wspace=0.00)
#plt.legend()
plt.savefig('horizontal_susc_vs_Vh_doped_beta20_norest.svg', dpi=300, bbox_inches='tight', pad_inches=0) # Save the figure with higher DPI for better resolution
#plt.legend()
/tmp/ipykernel_61597/735712104.py:1: UserWarning: cmr10 font should ideally be used with mathtext, set axes.formatter.use_mathtext to True fig, axes = plt.subplots(nrows=1, ncols=2, figsize=(4.2*2*0.9, 3.8*1*0.9)) # Adjust figsize as needed
fig, axes = plt.subplots(nrows=2, ncols=1, figsize=(6.2*1*0.9, 4.8*0.9*2)) # Adjust figsize as needed
plot_suscs_vs_Vh('d', objs_omega2_halffilling_beta20, 0.0, ax= axes[0], no_labels = True)
plot_suscs_vs_Vh('sc', objs_omega2_halffilling_beta20, 0.0, ax= axes[0], no_labels = True)
plot_suscs_vs_Vh('d', objs_omega2_halffilling_beta20, 0.5, linestyle_="-.", ax= axes[0], no_labels = True)
plot_suscs_vs_Vh('sc', objs_omega2_halffilling_beta20, 0.5, linestyle_="-.", ax= axes[0], no_labels = True)
plot_suscs_vs_Vh('d', objs_omega2_halffilling_beta20, 1.0, linestyle_=":", ax= axes[0], no_labels = True)
plot_suscs_vs_Vh('sc', objs_omega2_halffilling_beta20, 1.0, linestyle_=":", ax= axes[0], hide_x_labels= True, no_labels = True)
plot_suscs_vs_Vh('d', objs_omega1_halffilling_beta20, 0.0, ax= axes[1], no_labels = True)
plot_suscs_vs_Vh('sc', objs_omega1_halffilling_beta20, 0.0, ax= axes[1], no_labels = True)
plot_suscs_vs_Vh('d', objs_omega1_halffilling_beta20, 0.5, linestyle_="-.", ax= axes[1], no_labels = True)
plot_suscs_vs_Vh('sc', objs_omega1_halffilling_beta20, 0.5, linestyle_="-.", ax= axes[1], no_labels = True)
plot_suscs_vs_Vh('d', objs_omega1_halffilling_beta20, 1.0, linestyle_=":", ax= axes[1], no_labels = True)
plot_suscs_vs_Vh('sc', objs_omega1_halffilling_beta20, 1.0, linestyle_=":", ax= axes[1], no_labels = True)
line_styles = ['-', '-.', ':']
U_values = [0, 0.5, 1.0]
# Markers representing different χ values
markers = {r'$(\chi^{\mathrm{D}})^{-1}$': 's', r'$(\chi^{\mathrm{SC}})^{-1}$': 'o'}
colors = {r'$(\chi^{\mathrm{D}})^{-1}$': 'green', r'$(\chi^{\mathrm{SC}})^{-1}$': 'red'}
for ls, U in zip(line_styles, U_values):
axes[1].plot([], [], linestyle=ls, color='black', label=f"$U$ = ${U}t$", markeredgecolor='black')
for chi, marker in markers.items():
axes[1].plot([], [], color=colors[chi], marker=marker, linestyle='', markersize=8, label=chi, markeredgecolor='black')
# First legend: Line styles
legend1 = axes[1].legend(title="", loc="center right", prop={'size': 14}, bbox_to_anchor=(1, 0.3))
# Second legend: Markers
#legend2 = axes[0].legend(title="Markers", loc="upper right")
# Add the first legend back to the plot
ax= axes[1].add_artist(legend1)
plt.subplots_adjust(hspace=0.00)
#plt.legend()
plt.savefig('susc_vs_Vh_half_beta20_norest.svg', dpi=300, bbox_inches='tight', pad_inches=0) # Save the figure with higher DPI for better resolution
#plt.legend()
#objs_beta20_halffilling_omega1_Us
def phonon_softening_plot(objs_Us__, desired_U = 0.0, ax_ = plt.gca(), fig_ = plt.gcf(), no_yticks = False, no_xticks = False, no_labels = False):
ax_.set_xlabel(r"")
ax_.set_ylim(0, 1)
if not no_yticks:
ax_.set_ylabel(r"$\omega_{\mathrm{eff}}/\omega_0$")
else:
ax_.set_yticks([])
x_positions = [BZ_path_distances[0], BZ_path_distances[12], BZ_path_distances[24], BZ_path_distances[40]] # Specify the x positions for the ticks
x_labels = [r'$\Gamma$', r"$X$", r"$M$", r"$\Gamma$"] # Labels for the custom ticks
# Set the custom ticks
if not no_xticks:
ax_.set_xticks(ticks=x_positions, labels=x_labels)
else:
ax_.set_xticks([])
for Vhval_ in [0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0]:#[0. , 0.125, 0.25 , 0.375, 0.5 , 0.625 ,0.75 ,0.875, 1.125 ,1.25 , 1.375, 1.5, 1.625 ,1.75 ,1.875 ,2. ]:
objs_at_Vh = [[obj for obj in objs_Us__[objs_key] if abs(obj["Vh"] - Vhval_)<1e-2] for objs_key in objs_Us__.keys()]
objs_at_Vh_new = []
for oo in objs_at_Vh:
if len(oo) != 0:
#print(o[0])
objs_at_Vh_new.append(oo[0])
vhvals, ys, disps, ses,_,uvals =get_renormalised_omegas(objs_at_Vh_new)
for x in range(len(uvals)):
#print(objs_at_Vh_new[x]['Vh'], objs_at_Vh_new[x]['U'])
if abs(uvals[x]-desired_U) < 1e-2:
norm = plt.Normalize(0, 3)
colormap = cm.get_cmap('coolwarm') # Use the 'coolwarm' colormap
the_label = (None if no_labels else r"$V_H$= {0}t".format(Vhval_))
ax_.plot(BZ_path_distances, disps[x], "*-", color=colormap(norm(Vhval_)), label= the_label, markersize=8)
#pass
/tmp/ipykernel_2591101/1116296765.py:2: UserWarning: cmr10 font should ideally be used with mathtext, set axes.formatter.use_mathtext to True def phonon_softening_plot(objs_Us__, desired_U = 0.0, ax_ = plt.gca(), fig_ = plt.gcf(), no_yticks = False, no_xticks = False, no_labels = False):
#result = next((item for item in objs_beta20_doped_omega1_Us[1.0] if abs(item["Vh"])< 0.0001 ), None)
#print(result)
#objs_beta20_halffilling_omega1_Us[0.0].append(result)
#objs_beta20_halffilling_omega1_Us[1.0].append(result)
#objs_beta20_halffilling_omega1_Us[1.0][-1]
fig, axes = plt.subplots(nrows=3, ncols=1, figsize=(5.4*1*0.9, 4.0*3*0.9)) # Adjust figsize as needed
phonon_softening_plot(objs_beta20_halffilling_omega1_Us, desired_U=0.0, ax_= axes[0], no_xticks = True)
phonon_softening_plot(objs_beta20_halffilling_omega1_Us, desired_U=0.5, ax_= axes[1], no_xticks = True)
phonon_softening_plot(objs_beta20_halffilling_omega1_Us, desired_U=1.0, ax_= axes[2], no_xticks = False)
plt.legend()
plt.subplots_adjust(wspace=0.0, hspace=0.08)
#axes[0].set_title(r"$U="+str(0.0)+ r"t$, $\beta = 20/t$, $\omega_0 = 1t$, Doped", loc="left")
axes[0].set_title(r"$U="+str(0.0)+ r"t$", loc="right", y=0.0)
axes[1].set_title(r"$U="+str(0.5)+ r"t$", loc="right", y = 0.0)
axes[2].set_title(r"$U="+str(1.0)+ r"t$", loc="right", y = 0.0)
plt.savefig('phonon_softening_halffilling_norest.svg', dpi=300, bbox_inches='tight', pad_inches=0) # Save the figure with higher DPI for better resolution
fig, axes = plt.subplots(nrows=3, ncols=1, figsize=(5.4*1*0.9, 4.0*3*0.9)) # Adjust figsize as needed
phonon_softening_plot(objs_beta20_doped_omega1_Us, desired_U=0.0, ax_= axes[0], no_xticks = True)
phonon_softening_plot(objs_beta20_doped_omega1_Us, desired_U=0.5, ax_= axes[1], no_xticks = True)
phonon_softening_plot(objs_beta20_doped_omega1_Us, desired_U=1.0, ax_= axes[2], no_xticks = False)
plt.legend()
plt.subplots_adjust(wspace=0.0, hspace=0.08)
#axes[0].set_title(r"$U="+str(0.0)+ r"t$, $\beta = 20/t$, $\omega_0 = 1t$, Doped", loc="left")
axes[0].set_title(r"$U="+str(0.0)+ r"t$", loc="right", y=0.0)
axes[1].set_title(r"$U="+str(0.5)+ r"t$", loc="right", y = 0.0)
axes[2].set_title(r"$U="+str(1.0)+ r"t$", loc="right", y = 0.0)
plt.savefig('phonon_softening_doped_norest.svg', dpi=300, bbox_inches='tight', pad_inches=0) # Save the figure with higher DPI for better resolution
fig, axes = plt.subplots(nrows=3, ncols=2, figsize=(4.0*2*0.9, 4.2*3*0.9)) # Adjust figsize as needed
phonon_softening_plot(objs_beta20_doped_omega1_Us, desired_U=0.0, ax_= axes[0][1], no_xticks = True, no_yticks=True)
phonon_softening_plot(objs_beta20_doped_omega1_Us, desired_U=0.5, ax_= axes[1][1], no_xticks = True, no_yticks=True)
phonon_softening_plot(objs_beta20_doped_omega1_Us, desired_U=1.0, ax_= axes[2][1], no_xticks = False, no_yticks=True)
#plt.legend()
phonon_softening_plot(objs_beta20_halffilling_omega1_Us, desired_U=0.0, ax_= axes[0][0], no_xticks = True)
phonon_softening_plot(objs_beta20_halffilling_omega1_Us, desired_U=0.5, ax_= axes[1][0], no_xticks = True)
phonon_softening_plot(objs_beta20_halffilling_omega1_Us, desired_U=1.0, ax_= axes[2][0], no_xticks = False)
axes[0][0].legend(handlelength=1.3, # Shorter handles
handletextpad=0.2, # Less space between handles and text
labelspacing=0.3, # Less vertical space between labels
borderpad=0.1, fontsize=13)
plt.subplots_adjust(wspace=0.0, hspace=0.08)
#axes[0].set_title(r"$U="+str(0.0)+ r"t$, $\beta = 20/t$, $\omega_0 = 1t$, Doped", loc="left")
#axes[0][1].set_title(r"$U="+str(0.0)+ r"t$", loc="right", y=0.0)
#axes[1][1].set_title(r"$U="+str(0.5)+ r"t$", loc="right", y = 0.0)
#axes[2][1].set_title(r"$U="+str(1.0)+ r"t$", loc="right", y = 0.0)
plt.subplots_adjust(wspace=0.0, hspace=0.08)
#axes[0].set_title(r"$U="+str(0.0)+ r"t$, $\beta = 20/t$, $\omega_0 = 1t$, Doped", loc="left")
#axes[0][0].set_title(r"$U="+str(0.0)+ r"t$", loc="right", y=0.0)
#axes[1][0].set_title(r"$U="+str(0.5)+ r"t$", loc="right", y = 0.0)
#axes[2][0].set_title(r"$U="+str(1.0)+ r"t$", loc="right", y = 0.0)
ax_right = axes[0][1].twinx()
ax_right.tick_params(right=False, labelright=False)
ax_right.spines['right'].set_visible(False)
ax_right.set_ylabel(r'$U = 0t$')
ax2_right = axes[1][1].twinx()
ax2_right.tick_params(right=False, labelright=False)
ax2_right.spines['right'].set_visible(False)
ax2_right.set_ylabel(r'$U = 0.5t$')
ax3_right = axes[2][1].twinx()
ax3_right.tick_params(right=False, labelright=False)
ax3_right.spines['right'].set_visible(False)
ax3_right.set_ylabel(r'$U = 1t$')
axes[0][0].set_title(r"$n=0.5$", fontsize=20)
axes[0][1].set_title(r"$n=0.39$", fontsize=20)
plt.savefig('phonon_softening_halffilling_and_finitedoping_norest.svg', dpi=300, bbox_inches='tight', pad_inches=0) # Save the figure with higher DPI for better resolution
/tmp/ipykernel_61597/2785357819.py:1: UserWarning: cmr10 font should ideally be used with mathtext, set axes.formatter.use_mathtext to True fig, axes = plt.subplots(nrows=3, ncols=2, figsize=(4.0*2*0.9, 4.2*3*0.9)) # Adjust figsize as needed /tmp/ipykernel_61597/2785357819.py:40: UserWarning: cmr10 font should ideally be used with mathtext, set axes.formatter.use_mathtext to True ax_right = axes[0][1].twinx() /tmp/ipykernel_61597/2785357819.py:45: UserWarning: cmr10 font should ideally be used with mathtext, set axes.formatter.use_mathtext to True ax2_right = axes[1][1].twinx() /tmp/ipykernel_61597/2785357819.py:50: UserWarning: cmr10 font should ideally be used with mathtext, set axes.formatter.use_mathtext to True ax3_right = axes[2][1].twinx()
fig, axes = plt.subplots(nrows=1, ncols=3, figsize=(4.8*3*0.9, 4.8*0.9)) # Adjust figsize as needed
phonon_softening_plot(objs_beta20_doped_omega1_Us, desired_U=0.0, ax_= axes[0], no_yticks = False)
phonon_softening_plot(objs_beta20_doped_omega1_Us, desired_U=0.5, ax_= axes[1], no_yticks = True)
phonon_softening_plot(objs_beta20_doped_omega1_Us, desired_U=1.0, ax_= axes[2], no_yticks = True)
plt.legend()
plt.subplots_adjust(wspace=0.0, hspace=-0.1)
#axes[0].set_title(r"$U="+str(0.0)+ r"t$, $\beta = 20/t$, $\omega_0 = 1t$, Doped", loc="left")
axes[0].set_title(r"$U="+str(0.0)+ r"t$", loc="center")
axes[1].set_title(r"$U="+str(0.5)+ r"t$", loc="center")
axes[2].set_title(r"$U="+str(1.0)+ r"t$", loc="center")
plt.savefig('phonon_softening_doped_norest.png', dpi=300, bbox_inches="tight") # Save the figure with higher DPI for better resolution
phonon_softening_plot(objs_beta20_halffilling_omega2_Us)
plt.legend()
plt.title(r"$\beta = 20/t$, $\Omega_0 = 2t$, $U="+str(desired_U)+ r"t$, Half filling")
Text(0.5, 1.0, '$\\beta = 20/t$, $\\Omega_0 = 2t$, $U=0.0t$, Half filling')
phonon_softening_plot(objs_beta20_halffilling_omega10_Us)
plt.legend()
plt.title(r"$\beta = 20/t$, $\Omega_0 = 10t$, $U="+str(desired_U)+ r"t$, Half filling")
(12, 410) (12, 410) (12, 410) (12, 410) (12, 410) (12, 410) (12, 410)
Text(0.5, 1.0, '$\\beta = 20/t$, $\\Omega_0 = 10t$, $U=0.0t$, Half filling')
import numpy as np
from matplotlib.colors import TwoSlopeNorm
def plot_dispersion_colormap(momgrid, dispersion, K_DIM, overlay_grid_points=False):
"""
Plot a colormap of the dispersion over the Brillouin zone,
with zero dispersion mapped to white, a black contour line
along the Fermi surface (dispersion = 0), and optionally overlay
crosses at the grid points. The plot is set to have equal aspect ratio.
Parameters:
momgrid (np.ndarray): Array of shape (K_DIM*K_DIM, 2) containing (kx, ky) coordinates.
dispersion (np.ndarray): 1D array of dispersion values of length K_DIM*K_DIM.
K_DIM (int): Number of discretization points along one axis.
overlay_grid_points (bool): If True, overlays crosses at the grid points.
"""
# Reshape the dispersion into a 2D grid
dispersion_2D = dispersion.reshape(K_DIM, K_DIM)
# Reshape momgrid into two 2D arrays for kx and ky
kx_vals = momgrid[:, 0].reshape(K_DIM, K_DIM)
ky_vals = momgrid[:, 1].reshape(K_DIM, K_DIM)
# Set normalization so that 0 is white in the colormap
vmin = dispersion_2D.min()
vmax = dispersion_2D.max()
norm = TwoSlopeNorm(vmin=vmin, vcenter=0, vmax=vmax)
plt.figure(figsize=(8, 8))
# Use a diverging colormap, e.g. 'seismic'
cp = plt.contourf(kx_vals, ky_vals, dispersion_2D, levels=50, cmap='seismic', norm=norm)
plt.colorbar(cp, label='Dispersion')
# Draw a black contour line where dispersion equals zero (Fermi surface)
plt.contour(kx_vals, ky_vals, dispersion_2D, levels=[0], colors='black', linewidths=1.5)
# Optionally overlay grid points as crosses
if overlay_grid_points:
plt.scatter(momgrid[:, 0], momgrid[:, 1], color='k', marker='x', s=50)
#plt.legend()
plt.xlabel('$k_x$')
plt.ylabel('$k_y$')
plt.title('Dispersion Colormap on the Brillouin Zone')
# Ensure the plot is square in ratio
plt.gca().set_aspect('equal', adjustable='box')
plt.show()
def calculate_dispersion(K_DIM, t_prime, mu, delta_mu = 0):
"""
Calculate the dispersion relation of the square lattice Hubbard model.
Parameters:
K_DIM (int): The discretization size in momentum space.
t_prime (float): The next-nearest neighbor hopping parameter.
mu (float): The chemical potential.
Returns:
np.ndarray: A 1D array of size K_DIM * K_DIM containing dispersion values.
"""
dispersion = np.zeros(K_DIM * K_DIM)
k_vals = np.linspace(0, 2.0*np.pi, K_DIM, endpoint=False) # Discretized k-space values
for i, kx in enumerate(k_vals):
for j, ky in enumerate(k_vals):
index = i * K_DIM + j
epsilon_k = -2 * (np.cos(kx) + np.cos(ky)) - 4 * t_prime * np.cos(kx) * np.cos(ky) - mu
dispersion[index] = epsilon_k - delta_mu
return dispersion
def extract_indices_with_y(momgrid_, target_y, tol=1e-3):
return np.where(np.abs(momgrid_[:, 1] - target_y) < tol)[0]
def compute_filling_old(dispersion, matsubara_freq, beta):
"""
Constructs the Green's function G(iω_n, k) from dispersion data and
computes an estimate for the filling by summing over Matsubara frequencies
and integrating over momentum (k).
Parameters:
dispersion (np.ndarray): 1D array of dispersion values ε(k) for each momentum point.
matsubara_freq (np.ndarray): 1D array of fermionic Matsubara frequencies ω_n.
Typically, ω_n = (2n+1)π/β.
beta (float): Inverse temperature.
Returns:
filling (float): Estimated filling (electron density).
G (np.ndarray): Green's function array of shape (N_ω, N_k).
G[w_idx, k_idx] = 1/(iω_n - ε(k)).
"""
N_k = len(dispersion)
N_omega = len(matsubara_freq)
# Construct the Green's function: shape (N_omega, N_k)
# Note: 1j * omega gives the imaginary frequency.
G = np.zeros((N_omega, N_k), dtype=complex)
for iw, omega in enumerate(matsubara_freq):
G[iw, :] = 1.0 / (1j * omega - dispersion)
# In many-body theory, the electron filling can be computed via:
# n = (1/β) Σ_{iω_n} e^(iω_n 0^+) G(iω_n)
# Here we approximate the k-integral by averaging over the discrete momenta.
# We assume the exponential factor is unity for simplicity.
# Sum over Matsubara frequencies (axis 0) and multiply by 1/β.
# Then average over momentum points (k).
# Taking the real part yields the physical filling.
filling = np.mean((1.0 / beta) * np.sum(G, axis=0)).real + 0.5
return filling, G
def compute_filling(dispersion, matsubara_freq, beta, self_energy=None):
"""
Constructs the Green's function G(iω_n, k) from dispersion data and
computes an estimate for the filling by summing over Matsubara frequencies
and integrating over momentum (k). Optionally accepts a self-energy array.
Parameters:
dispersion (np.ndarray): 1D array of dispersion values ε(k) for each momentum point.
matsubara_freq (np.ndarray): 1D array of fermionic Matsubara frequencies ω_n.
Typically, ω_n = (2n+1)π/β.
beta (float): Inverse temperature.
self_energy (np.ndarray, optional): 2D array of self-energy values for each Matsubara frequency
and momentum point. Shape should be (N_omega, N_k). If not provided, assumes zero self-energy.
Returns:
filling (float): Estimated filling (electron density).
G (np.ndarray): Green's function array of shape (N_ω, N_k).
G[w_idx, k_idx] = 1/(iω_n - ε(k) - Σ(iω_n, k)).
"""
N_k = len(dispersion)
N_omega = len(matsubara_freq)
# Construct the Green's function: shape (N_omega, N_k)
G = np.zeros((N_omega, N_k), dtype=complex)
# If self_energy is provided, align it with matsubara_freq
if self_energy is not None:
self_energy_offset = N_omega // 2 - self_energy.shape[0] // 2
else:
self_energy_offset = 0 # No offset needed if no self_energy
for iw, omega in enumerate(matsubara_freq):
# Determine the correct self-energy index based on the offset
if self_energy is not None and 0 <= iw - self_energy_offset < self_energy.shape[0]:
sigma_k = self_energy[iw - self_energy_offset, :]
else:
sigma_k = np.zeros(N_k, dtype=complex) # Set self-energy to zero if not available
# Green's function: G(iω_n, k) = 1 / (iω_n - ε(k) - Σ(iω_n, k))
G[iw, :] = 1.0 / (1j * omega - dispersion - sigma_k)
# Sum over Matsubara frequencies (axis 0) and multiply by 1/β.
# Then average over momentum points (k).
# Taking the real part yields the physical filling.
filling = np.mean((1.0 / beta) * np.sum(G, axis=0)).real + 0.5
return filling, G
"""0.5 -0.00640619085759981
2.9999999999999996 0.026700793882697412
1.0000000000000002 -0.010361348593420085
2.0 -0.0059208549827153515
1.4999999999999998 -0.010772081468000494
2.5000000000000004 0.00504440748107497
0.0 0.0"""
sig = objs_beta20_doped_omega0_Us[0.0][4]["Sig"][:, :, 0, 0]
delta_mu = objs_beta20_doped_omega0_Us[0.0][4]["delta_mu"]
dispersion = calculate_dispersion(16, -0.25, -1.0, +delta_mu)
ren_dispersion = dispersion + np.real(sig[80, :])
filling_, _ = compute_filling(dispersion, ffgrid_new, 20.0, sig)
plot_dispersion_colormap(momgrid[:256], ren_dispersion, 16, overlay_grid_points=True)
dispersion_bare = calculate_dispersion(16, -0.25, -0.8)
compute_filling(dispersion_bare, ffgrid_new, 20.0)[0]
plot_dispersion_colormap(momgrid[:256], dispersion_bare, 16, overlay_grid_points=True)
sig = objs_beta20_halffilling_omega1_Us[0.0][5]["Sig"][:, :, 0, 0]
delta_mu = objs_beta20_halffilling_omega1_Us[0.0][5]["delta_mu"]
dispersion = calculate_dispersion(16, 0.0, 0.0, +delta_mu)
ren_dispersion = dispersion + np.real(sig[80, :])
filling_, _ = compute_filling(dispersion, ffgrid_new, 20.0, sig)
print(filling_)
plot_dispersion_colormap(momgrid[:256], ren_dispersion, 16, overlay_grid_points=True)
0.4994523786619725
filling_
--------------------------------------------------------------------------- NameError Traceback (most recent call last) /tmp/ipykernel_2593445/3465235675.py in <module> ----> 1 filling_ NameError: name 'filling_' is not defined