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 dmft_solve(giw_d, giw_o, u_int, tp, beta, tau, w_n): 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) ekin = dimer.ekin(giw_d, giw_o, w_n, tp, beta) # last division because I want per spin epot epot = dimer.epot(giw_d, w_n, beta, u_int ** 2 / 4 + tp**2, ekin, u_int) / 4 return (giw_d, giw_o), (siw_d, siw_o), ekin, epot, loops
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 loop_beta(u_int, tp, betarange, seed): avgH = [] for beta in betarange: 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 == 'I': giw_d, giw_o = 1 / (1j * w_n - 4j / w_n), np.zeros_like(w_n) + 0j giw_d, giw_o, _ = dimer.ipt_dmft_loop( beta, u_int, tp, giw_d, giw_o, tau, w_n, 1e-6) ekin = dimer.ekin(giw_d[:int(8 * beta)], giw_o[:int(8 * beta)], w_n[:int(8 * beta)], tp, beta) epot = dimer.epot(giw_d[:int(8 * beta)], w_n[:int(8 * beta)], beta, u_int ** 2 / 4 + tp**2 + 0.25, ekin, u_int) avgH.append(ekin + epot) return np.array(avgH)
def test_dimer_energies(u_int, mu, tp, beta=100): h_loc, (a_up, b_up, a_dw, b_dw) = dimer.hamiltonian(u_int, mu, tp) e_imp = (tp * (a_up.T * b_up + a_dw.T * b_dw + b_up.T * a_up + b_dw.T * a_dw)).todense() eig_e, eig_v = op.diagonalize(h_loc.todense()) w_n = gf.matsubara_freq(beta, 2**8) # n=2**7=256 gf_di = op.gf_lehmann(eig_e, eig_v, a_up.T, beta, 1j * w_n) gf_of = op.gf_lehmann(eig_e, eig_v, a_up.T, beta, 1j * w_n, b_up) ekin_gf = dimer.ekin(gf_di, gf_of, w_n, tp, beta, 0) ekin_ed = op.expected_value(e_imp, eig_e, eig_v, beta) assert abs(ekin_ed - ekin_gf) < 5e-4 epot_gf = dimer.epot(gf_di, w_n, beta, u_int**2 / 4 + tp**2, ekin_gf, u_int) docc = (a_up.T * a_up * a_dw.T * a_dw + b_up.T * b_up * b_dw.T * b_dw).todense() epot_ed = op.expected_value(docc, eig_e, eig_v, beta) * u_int assert abs(epot_ed - epot_gf) < 1e-3