def ipt_u_tp(u_int, tp, beta, seed='ins'): tau, w_n = gf.tau_wn_setup(dict(BETA=beta, N_MATSUBARA=2**8)) tau, w_n = gf.tau_wn_setup( dict(BETA=beta, N_MATSUBARA=max(2**ceil(log(8 * beta) / log(2)), 256))) giw_d, giw_o = dimer.gf_met(w_n, 0., 0., 0.5, 0.) if seed == 'ins': giw_d, giw_o = 1 / (1j * w_n + 4j / w_n), np.zeros_like(w_n) + 0j giw_d, giw_o, loops = dimer.ipt_dmft_loop( beta, u_int, tp, giw_d, giw_o, tau, w_n, 1e-7) g0iw_d, g0iw_o = dimer.self_consistency( 1j * w_n, 1j * giw_d.imag, giw_o.real, 0., tp, 0.25) siw_d, siw_o = ipt.dimer_sigma(u_int, tp, g0iw_d, g0iw_o, tau, w_n) return giw_d, giw_o, siw_d, siw_o, g0iw_d, g0iw_o, w_n
def energies(beta, filestr='SB_PM_B{}.h5'): """returns the potential, and kinetic energy Parameters ---------- beta : float, inverse temperature filestr : string, results file name, beta is replaced in format Returns ------- tuple of 3 ndarrays Contains, potential energy, Kinetic energy, values of U """ tau, w_n = gf.tau_wn_setup(dict(BETA=beta, N_MATSUBARA=beta)) giw_free = gf.greenF(w_n) e_mean = ipt.e_mean(beta) ekin = [] epot = [] with h5.File(filestr.format(beta), 'r') as results: for u_str in results: last_iter = results[u_str].keys()[-1] _, giw = get_giw(results[u_str], last_iter, tau, w_n) siw = get_sigmaiw(results[u_str], last_iter, tau, w_n) u_int = float(u_str[1:]) epot.append(ipt.epot(giw, siw, u_int, beta, w_n)) ekin.append(ipt.ekin(giw, siw, beta, w_n, e_mean, giw_free)) ur = np.array([float(u_str[1:]) for u_str in results]) return np.array(epot), np.array(ekin), ur
def show_conv(beta, u_int, filestr='SB_{simt}_B{beta}', n_freq=5, xlim=2, skip=5, simt='PM'): """Plot the evolution of the Green's function in DMFT iterations""" freq_arr = [] sim_dir = os.path.join(filestr.format( beta=beta, simt=simt), 'U' + str(u_int)) iterations = sorted( [it for it in os.listdir(sim_dir) if 'it' in it])[skip:] with open(sim_dir + '/setup', 'r') as read: setup = json.load(read) tau, w_n = gf.tau_wn_setup(setup) _, axes = plt.subplots(1, 2, figsize=(13, 8), sharey=True) for step in iterations: giw, caste = get_giw(sim_dir, [step], tau, w_n, setup) if len(giw.shape) > 1: axes[0].plot(w_n, giw[0].real, 'gs:', w_n, giw[0].imag, 'bo:') freq_arr.append( np.array([giw[0].real[:n_freq], giw[0].imag[:n_freq]])) else: axes[0].plot(w_n, giw.imag) freq_arr.append(giw.imag[:n_freq]) freq_arr = np.asarray(freq_arr).T for num, freqs in enumerate(freq_arr): axes[1].plot(freqs.T, 'o-.', label=str(num)) graf = r'$G(i\omega_n)$' label_convergence(beta, u_int, axes, graf, n_freq, xlim) return axes
def get_giw(sim_dir, iteration_slice, tau=None, w_n=None, setup=None): r"""Recovers with Fourier Transform G_iw from H5 file Parameters ---------- h5parent : hdf5 group to go iteration_slice : list of iteration names to average over tau : 1D real array time slices of HF data w_n : 1D real array matsubara frequencies Returns ------- tuple : :math:`G(\tau)`, :math:`G(i\omega_n)` """ recovered_sim_info = False if None in (tau, w_n, setup): with open(sim_dir + '/setup', 'r') as read: setup = json.load(read) tau, w_n = gf.tau_wn_setup(setup) recovered_sim_info = True gtau = averager(sim_dir, 'gtau.npy', iteration_slice) giw = gf.gt_fouriertrans(gtau, tau, w_n, gf_tail(gtau, setup['U'], setup['MU'])) if recovered_sim_info: return giw, gtau, tau, w_n, setup else: return giw, gtau
def estimate_zero_w_sigma_T_vs_U(tp, u_range, temp, phase): sd_zew, so_zew = [], [] u_range = u_range if phase == 'met' else u_range[::-1] save_file = 'dimer_ipt_{}_Z_tp{:.2}.npy'.format(phase, tp) if os.path.exists(save_file): return np.load(save_file) for T in temp: beta = 1 / T tau, w_n = gf.tau_wn_setup( dict(BETA=beta, N_MATSUBARA=max(2**ceil(log(6 * beta) / log(2)), 256))) filestr = 'disk/phase_Dimer_ipt_{}_tp{:.2}/B{:.5}/giw.npy'.format( phase, tp, beta) gfs = np.load(filestr) for i, u_int in enumerate(u_range): giw_d, giw_o = 1j * gfs[i][0], gfs[i][1] g0iw_d, g0iw_o = dimer.self_consistency( 1j * w_n, giw_d, giw_o, 0., tp, 0.25) siw_d, siw_o = ipt.dimer_sigma(u_int, tp, g0iw_d, g0iw_o, tau, w_n) sd_zew.append(np.polyfit(w_n[:2], siw_d[:2].imag, 1)) so_zew.append(np.polyfit(w_n[:2], siw_o[:2].real, 1)) sd_zew = np.array(sd_zew).reshape(len(temp), len(u_range), -1) so_zew = np.array(so_zew).reshape(len(temp), len(u_range), -1) np.save(save_file, (sd_zew, so_zew)) return sd_zew, so_zew
def loop_tp_u(tprange, u_range, beta, filestr, seed='mott gap'): save_dir = filestr.format(beta) if np.allclose(tprange, tprange[0]) and 'tp' not in save_dir: save_dir = os.path.join(save_dir, 'tp' + str(tprange[0])) elif np.allclose(u_range, u_range[0]): save_dir = os.path.join(save_dir, 'U' + str(u_range[0])) if not os.path.exists(save_dir): os.makedirs(save_dir) setup = { 'beta': beta, 'tprange': tprange.tolist(), 'u_range': u_range.tolist() } with open(save_dir + '/setup', 'w') as conf: json.dump(setup, conf, indent=2) ############################################################################### tau, w_n = gf.tau_wn_setup( dict(BETA=beta, N_MATSUBARA=max(2**ceil(log(6 * beta) / log(2)), 256))) giw_d, giw_o = dimer.gf_met(w_n, 0., tprange[0], 0.5, 0.) if seed == 'mott gap': giw_d, giw_o = 1 / (1j * w_n - 4j / w_n), np.zeros_like(w_n) + 0j giw_s = [] for tp, u_int in zip(tprange, u_range): giw_d, giw_o, loops = dimer.ipt_dmft_loop(beta, u_int, tp, giw_d, giw_o, tau, w_n, 1 / 5 / beta) giw_s.append((giw_d.imag, giw_o.real)) np.save(save_dir + '/giw', np.array(giw_s))
def plot_zero_w(function_array, iter_range, tp, betarange, ax, color): """Plot the zero frequency extrapolation of a function Parameters ---------- function_array: real ndarray contains the function (G, Sigma) to linearly fit over 2 first frequencies iter_range: list floats values of changing variable U or tp berarange: real ndarray 1D, values of beta entry: 0, 1 corresponds to diagonal or off-diagonal entry of function label_head: string for label ax, dx: matplotlib axis to plot in """ sig_11_0 = [] rtp = [] for j, u in enumerate(iter_range): sig_11_0.append([]) rtp.append([]) for i, beta in list(enumerate(betarange)): tau, w_n = gf.tau_wn_setup(dict(BETA=beta, N_MATSUBARA=2)) sig_11_0[j].append(np.polyfit( w_n, function_array[j][i][0][:2], 1)[1]) rtp[j].append(np.polyfit(w_n, function_array[j][i][1][:2], 1)[1]) ax[0].plot(1 / BETARANGE, -np.array(sig_11_0[j]), color, label=str(u)) ax[1].plot(1 / BETARANGE, tp + np.array(rtp[j]), color, label=str(u)) ax[0].set_ylabel(r'$-\Im m \Sigma_{11}(w=0)$') ax[1].set_ylabel(r'$t_\perp + \Re e\Sigma_{12}(w=0)$') ax[1].set_xlabel('$T/D$') ax[1].set_xlim([min(temp), max(temp)]) return np.array(sig_11_0)
def test_ipt_dimer_pm_g(u_int, result, beta=50.): tau, w_n = tau_wn_setup(dict(BETA=beta, N_MATSUBARA=256)) giw_d, giw_o = dimer.gf_met(w_n, 0., 0, 0.5, 0.) giw_d = dimer.ipt_dmft_loop(beta, u_int, 0, giw_d, giw_o, tau, w_n, 1e-5)[0][:64] assert np.allclose(result, giw_d, atol=3e-3)
def loop_u_tp(u_range, tp_range, beta, seed='mott gap'): """Solves IPT dimer and return Im Sigma_AA, Re Simga_AB returns list len(betarange) x 2 Sigma arrays """ tau, w_n = gf.tau_wn_setup( dict(BETA=beta, N_MATSUBARA=max(2**ceil(log(4 * beta) / log(2)), 256))) giw_d, giw_o = dimer.gf_met(w_n, 0., 0., 0.5, 0.) if seed == 'I': giw_d, giw_o = 1 / (1j * w_n - 4j / w_n), np.zeros_like(w_n) + 0j sigma_iw = [] iterations = [] for tp, u_int in zip(tp_range, u_range): giw_d, giw_o, loops = dimer.ipt_dmft_loop(beta, u_int, tp, giw_d, giw_o, tau, w_n, 1e-3) iterations.append(loops) g0iw_d, g0iw_o = dimer.self_consistency(1j * w_n, 1j * giw_d.imag, giw_o.real, 0., tp, 0.25) siw_d, siw_o = ipt.dimer_sigma(u_int, tp, g0iw_d, g0iw_o, tau, w_n) sigma_iw.append((siw_d.imag, siw_o.real)) print(np.array(iterations)) return sigma_iw
def test_selfconsistency(tp): """Check that the Bethe lattice self-consistency is working""" _, w_n = tau_wn_setup(dict(BETA=100., N_MATSUBARA=400)) giwd, giwo = dimer.gf_met(w_n, 0., tp, 0.5, 0.) g0iwd, g0iwo = dimer.self_consistency(1j * w_n, giwd, giwo, 0., tp, 0.25) assert np.allclose(giwd, g0iwd) assert np.allclose(giwo, g0iwo)
def loop_u_tp(u_range, tprange, beta, seed='mott gap'): tau, w_n = gf.tau_wn_setup(dict(BETA=beta, N_MATSUBARA=max(5 * beta, 256))) giw_d, giw_o = dimer.gf_met(w_n, 0., 0., 0.5, 0.) if seed == 'mott gap': giw_d, giw_o = 1 / (1j * w_n + 4j / w_n), np.zeros_like(w_n) + 0j giw_s = [] sigma_iw = [] ekin, epot = [], [] iterations = [] for u_int, tp in zip(u_range, tprange): giw_d, giw_o, loops = dimer.ipt_dmft_loop(beta, u_int, tp, giw_d, giw_o, tau, w_n) giw_s.append((giw_d, giw_o)) iterations.append(loops) g0iw_d, g0iw_o = dimer.self_consistency(1j * w_n, 1j * giw_d.imag, giw_o.real, 0., tp, 0.25) siw_d, siw_o = ipt.dimer_sigma(u_int, tp, g0iw_d, g0iw_o, tau, w_n) sigma_iw.append((siw_d.copy(), siw_o.copy())) ekin.append(dimer.ekin(giw_d, giw_o, w_n, tp, beta)) epot.append( dimer.epot(giw_d, w_n, beta, u_int**2 / 4 + tp**2, ekin[-1], u_int) / 4) # last division because I want per spin epot print(np.array(iterations)) return np.array(giw_s), np.array(sigma_iw), np.array(ekin), np.array( epot), w_n
def free_energy_change(beta, u_int, mix_grid): tau, w_n = tau_wn_setup(dict(BETA=beta, N_MATSUBARA=2**11)) ig_iwn, is_iwn = dmft_loop(u_int, 0.5, -1.j / (w_n - 1 / w_n), w_n, tau, conv=1e-10) mg_iwn, ms_iwn = dmft_loop(u_int, 0.5, greenF(w_n), w_n, tau, conv=1e-10) solution_diff = mg_iwn - ig_iwn integrand = [] for l in mix_grid: g_in = mix(mg_iwn, ig_iwn, l) g_grad = one_loop(g_in, 0.5, U, w_n, tau) - g_in integrand.append(np.dot(g_grad, solution_diff).real / beta) return np.array([0] + [ trapz(integrand[:i], mix_grid[:i]) for i in range(2, len(mix_grid) + 1) ])
def hysteresis(beta, u_range): log_g_sig = [] tau, w_n = tau_wn_setup(dict(BETA=beta, N_MATSUBARA=beta)) g_iwn = greenF(w_n) for u_int in u_range: g_iwn, sigma = dmft_loop(u_int, 0.5, g_iwn, w_n, tau) log_g_sig.append((g_iwn, sigma)) return log_g_sig
def hysteresis(beta, D_range): log_g_sig = [] tau, w_n = tau_wn_setup(dict(BETA=beta, N_MATSUBARA=2**11)) g_iwn = greenF(w_n, D=1) for D in D_range: g_iwn, sigma = dmft_loop(1, D / 2, g_iwn, w_n, tau) log_g_sig.append((g_iwn, sigma)) return log_g_sig
def extract_double_occupation(beta, u_range): docc = [] tau, w_n = gf.tau_wn_setup(dict(BETA=beta, N_MATSUBARA=beta)) g_iwn = gf.greenF(w_n) for u_int in u_range: g_iwn, sigma = ipt.dmft_loop(u_int, 0.5, g_iwn, w_n, tau, conv=1e-4) docc.append(ipt.epot(g_iwn, sigma, u_int, beta, w_n) * 2 / u_int) return np.array(docc)
def setup_PM_sim(parms): tau, w_n = tau_wn_setup(parms) gw = greenF(w_n, mu=parms['MU'], D=2 * parms['t']) gt = gw_invfouriertrans(gw, tau, w_n) gt = interpol(gt, parms['n_tau_mc']) parms['dtau_mc'] = parms['BETA'] / parms['n_tau_mc'] v = ising_v(parms['dtau_mc'], parms['U'], L=parms['n_tau_mc']) return tau, w_n, gt, gw, v
def test_ipt_pm_g(u_int, result, beta=50., n_tau=2**11, n_matsubara=64): parms = {'BETA': beta, 'N_TAU': n_tau, 'N_MATSUBARA': n_matsubara, 't': 0.5, 'MU': 0, 'U': u_int, } tau, w_n = tau_wn_setup(parms) g_iwn0 = greenF(w_n, D=2*parms['t']) g_iwn_log, sigma_iwn = ipt_imag.dmft_loop(100, parms['U'], parms['t'], g_iwn0, w_n, tau) assert np.allclose(result, g_iwn_log[-1][32:], atol=1e-3 )
def setup_PM_sim(parms): tau, w_n = tau_wn_setup(parms) gw = greenF(w_n, mu=parms['MU'], D=2*parms['t']) gt = gw_invfouriertrans(gw, tau, w_n) gt = interpol(gt, parms['n_tau_mc']) parms['dtau_mc'] = parms['BETA']/parms['n_tau_mc'] v = ising_v(parms['dtau_mc'], parms['U'], L=parms['n_tau_mc']) return tau, w_n, gt, gw, v
def test_fourier_trasforms(chempot, beta=50., n_matsubara=128): """Test the tail improved fourier transforms""" parms = {'BETA': beta, 'N_MATSUBARA': n_matsubara} tau, w_n = gf.tau_wn_setup(parms) giw = gf.greenF(w_n, mu=chempot) for gwr in [giw, np.array([giw, giw])]: g_tau = gf.gw_invfouriertrans(gwr, tau, w_n, [1., -chempot, 0.25]) g_iomega = gf.gt_fouriertrans(g_tau, tau, w_n, [1., -chempot, 0.25]) assert np.allclose(gwr, g_iomega)
def test_fourier_trasforms(chempot, beta=50., n_tau=2**11, n_matsubara=64): """Test the tail improved fourier transforms""" parms = {'BETA': beta, 'N_TAU': n_tau, 'N_MATSUBARA': n_matsubara} tau, w_n = tau_wn_setup(parms) gw = greenF(w_n, mu=chempot) for gwr in [gw, np.array([gw, gw])]: g_tau = gw_invfouriertrans(gwr, tau, w_n) g_iomega = gt_fouriertrans(g_tau, tau, w_n) assert np.allclose(gwr, g_iomega)
def collect_bined_saves(): binede_dat = glob('gtau_bin_*') G = np.array([np.load(dfile) for dfile in binede_dat]) gtau = G.mean(1) tau, w_n = gf.tau_wn_setup(dict(BETA=32., N_MATSUBARA=32)) fw = gf.matsubara_freq(32., 64, -63) giw = gf.gt_fouriertrans(gtau, tau, w_n, [1., 0., .25 + 2.5**2 / 4]) sgiw = np.concatenate((giw.conj().T[::-1], giw.T)) np.savez('bined', w_n=fw, giw=sgiw)
def test_GF(): """Test the Matrix product and Matrix inversion of a 2x2 Matrix which for the case of the dimer has a symmetric structure in which only requires the first row""" _, w_n = tau_wn_setup(dict(BETA=100., N_MATSUBARA=400)) giwd, giwo = dimer.gf_met(w_n, 0., 0.25, 0.5, 0.) inv_giwd, inv_giwo = dimer.mat_inv(giwd, giwo) one, zero = dimer.mat_mul(inv_giwd, inv_giwo, giwd, giwo) assert np.allclose(one, 1.) assert np.allclose(zero, 0.)
def setup_PM_sim(parms): """Setup the default state for a Paramagnetic simulation""" tau, w_n = tau_wn_setup(parms) giw = greenF(w_n, mu=parms['MU'], D=2 * parms['t']) gtau = gw_invfouriertrans(giw, tau, w_n) parms['dtau_mc'] = tau[1] intm = interaction_matrix(parms.get('BANDS', 1)) v = ising_v(parms['dtau_mc'], parms['U'], len(tau) * parms['SITES'], intm.shape[1], parms['spin_polarization']) return tau, w_n, gtau, giw, v, intm
def ipt_u_tp(u_int, tp, beta, seed="ins"): tau, w_n = gf.tau_wn_setup(dict(BETA=beta, N_MATSUBARA=1024)) giw_d, giw_o = dimer.gf_met(w_n, 0., 0., 0.5, 0.) if seed == "ins": giw_d, giw_o = 1 / (1j * w_n + 4j / w_n), np.zeros_like(w_n) + 0j giw_d, giw_o, loops = dimer.ipt_dmft_loop( beta, u_int, tp, giw_d, giw_o, tau, w_n, 1e-12) g0iw_d, g0iw_o = dimer.self_consistency( 1j * w_n, 1j * giw_d.imag, giw_o.real, 0., tp, 0.25) siw_d, siw_o = ipt.dimer_sigma(u_int, tp, g0iw_d, g0iw_o, tau, w_n) return giw_d, giw_o, siw_d, siw_o, g0iw_d, g0iw_o, w_n
def test_ipt_pm_g(u_int, result, beta=50., n_matsubara=64): """Test the solution of the single band impurity problem""" parms = { 'BETA': beta, 'N_MATSUBARA': n_matsubara, 't': 0.5, 'MU': 0, 'U': u_int, } tau, w_n = tau_wn_setup(parms) g_iwn0 = greenF(w_n, D=2 * parms['t']) g_iwn, _ = ipt_imag.dmft_loop(parms['U'], parms['t'], g_iwn0, w_n, tau) assert np.allclose(result, g_iwn, atol=3e-3)
def loop_urange(urange, tp, beta): ekin, epot = [], [] tau, w_n = gf.tau_wn_setup(dict(BETA=beta, N_MATSUBARA=2**10)) giw_d, giw_o = dimer.gf_met(w_n, 0., 0., 0.5, 0.) for u_int in urange: giw_d, giw_o, _ = dimer.ipt_dmft_loop(beta, u_int, tp, giw_d, giw_o, tau, w_n, 1e-4) ekin.append(dimer.ekin(giw_d, giw_o, w_n, tp, beta)) epot.append( dimer.epot(giw_d, w_n, beta, u_int**2 / 4 + tp**2 + 0.25, ekin[-1], u_int)) return np.array(ekin), np.array(epot)
def test_ipt_pm_g(u_int, result, beta=50., n_tau=2**11, n_matsubara=64): parms = { 'BETA': beta, 'N_TAU': n_tau, 'N_MATSUBARA': n_matsubara, 't': 0.5, 'MU': 0, 'U': u_int, } tau, w_n = tau_wn_setup(parms) g_iwn0 = greenF(w_n, D=2 * parms['t']) g_iwn_log, sigma_iwn = ipt_imag.dmft_loop(100, parms['U'], parms['t'], g_iwn0, w_n, tau) assert np.allclose(result, g_iwn_log[-1][32:], atol=1e-3)
def dos_plot(BETA, tp, filestr, ax=None): """Plots double occupation""" if ax is None: _, ax = plt.subplots() with h5.File(filestr.format(tp=tp, BETA=BETA), 'r') as results: fl_dos = [] tau, w_n = gf.tau_wn_setup(dict(BETA=BETA, N_MATSUBARA=BETA)) for u_str in results: lastit = results[u_str].keys()[-1] giwd, _ = get_giw(results[u_str], lastit, tau, w_n) fl_dos.append(-1. / np.pi * gf.fit_gf(w_n[:3], giwd.imag)(0.)) u_range = np.array([float(u_str[1:]) for u_str in results.keys()]) ax.scatter(u_range, fl_dos, s=120, marker='>', vmin=0, vmax=2. / np.pi) ax.set_title('Hysteresis loop of the \n density of states') ax.set_ylabel(r'$A(\omega=0)$') ax.set_xlabel('U/D')
def loop_u_tp(u_range, tprange, beta, seed='mott gap'): tau, w_n = gf.tau_wn_setup(dict(BETA=beta, N_MATSUBARA=max(5 * beta, 256))) giw_d, giw_o = dimer.gf_met(w_n, 0., 0., 0.5, 0.) if seed == 'mott gap': giw_d, giw_o = 1 / (1j * w_n + 4j / w_n), np.zeros_like(w_n) + 0j sigma_iw = [] for u_int, tp in zip(u_range, tprange): giw_d, giw_o, loops = dimer.ipt_dmft_loop( beta, u_int, tp, giw_d, giw_o, tau, w_n) g0iw_d, g0iw_o = dimer.self_consistency( 1j * w_n, 1j * giw_d.imag, giw_o.real, 0., tp, 0.25) siw_d, siw_o = ipt.dimer_sigma(u_int, tp, g0iw_d, g0iw_o, tau, w_n) sigma_iw.append((siw_d.copy(), siw_o.copy())) print(seed, ' U', u_int, ' tp: ', tp, ' loops: ', loops) return np.array(sigma_iw), w_n
def loop_u_tp(u_range, tprange, beta, seed='mott gap'): tau, w_n = gf.tau_wn_setup(dict(BETA=beta, N_MATSUBARA=256)) giw_d, giw_o = dimer.gf_met(w_n, 0., 0., 0.5, 0.) if seed == 'ins': giw_d, giw_o = 1 / (1j * w_n + 4j / w_n), np.zeros_like(w_n) + 0j sols = [dmft_solve(giw_d, giw_o, u_int, tp, beta, tau, w_n) for u_int, tp in zip(u_range, tprange)] giw_s = np.array([g[0] for g in sols]) sigma_iw = np.array([g[1] for g in sols]) ekin = np.array([g[2] for g in sols]) epot = np.array([g[3] for g in sols]) iterations = np.array([g[4] for g in sols]) print(iterations) return giw_s, sigma_iw, ekin, epot, w_n
def get_giw(filestr, tau=None, w_n=None, setup=None): """Recovers with Fourier Transform G_iw and G_tau from npy file Parameters ---------- filestr : string file with array data G(tau) setup : dictionary about simulation parameters tau : real float array Imaginary time points w_n : real float array fermionic matsubara frequencies. Only use the positive ones Returns ------- tuple complex ndarray (giw, gtau) Interacting Greens function in matsubara frequencies and original Imaginary time. Entries are list ordered and not in matrix shape See also -------- get_sigmaiw """ recovered_sim_info = False if None in (tau, w_n, setup): sim_dir = os.path.dirname(os.path.dirname(os.path.abspath(filestr))) with open(sim_dir + '/setup', 'r') as read: setup = json.load(read) tau, w_n = gf.tau_wn_setup(setup) recovered_sim_info = True gtau = np.load(filestr) mu, tp, u_int = setup['MU'], setup['tp'], setup['U'] giw = gf.gt_fouriertrans(gtau.reshape(2, 2, -1), tau, w_n, gf_tail(gtau.reshape(2, 2, -1), u_int, mu, tp)) if recovered_sim_info: return giw.reshape(4, -1), gtau, tau, w_n, setup else: return giw.reshape(4, -1), gtau
def plot_zero_w(function_array, iter_range, beta, entry, label_head, ax, dx): """Plot the zero frequency extrapolation of a function Parameters ---------- function_array: real ndarray contains the function (G, Sigma) to linearly fit over 2 first frequencies iter_range: list floats values of changing variable U or tp berarange: real ndarray 1D, values of beta entry: 0, 1 corresponds to diagonal or off-diagonal entry of function label_head: string for label ax, dx: matplotlib axis to plot in """ tau, w_n = gf.tau_wn_setup(dict(BETA=beta, N_MATSUBARA=20)) dat = [] for j, u in enumerate(iter_range): dat.append(np.polyfit(w_n[:2], function_array[j][entry][:2], 1)) ax.plot(iter_range, -np.array(dat)[:, 1], label=label_head) dx.plot(iter_range, -np.array(dat)[:, 0], label=label_head)
from dmft.common import greenF, tau_wn_setup from dmft.twosite import matsubara_Z import numpy as np import matplotlib.pylab as plt U = np.linspace(0, 2.7, 36) U = np.concatenate((U, U[-2:11:-1])) parms = {'MU': 0, 't': 0.5, 'N_TAU': 2**10, 'N_MATSUBARA': 2**7} lop_g=[] for beta in [16, 25, 50]: u_zet = [] parms['BETA'] = beta tau, w_n = tau_wn_setup(parms) g_iwn0 = greenF(w_n, D=2*parms['t']) for u_int in U: mix = 0.4 if u_int > 1.5 else 1 g_iwn_log, sigma = ipt_imag.dmft_loop(100, u_int, parms['t'], g_iwn0, w_n, tau, mix) g_iwn0 = g_iwn_log[-1] lop_g.append(g_iwn_log) u_zet.append(matsubara_Z(sigma.imag, beta)) plt.plot(U, u_zet, label='$\\beta={}$'.format(beta)) plt.title('Hysteresis loop of the quasiparticle weigth') plt.legend() plt.ylabel('Z') plt.xlabel('U/D')