Ejemplo n.º 1
0
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')
Ejemplo n.º 2
0
def estimate_dos_at_fermi_level_T_vs_U(tp, ulist, temp, phase):
    dos_fl = []
    save_file = 'dimer_ipt_{}_tp{:.2}.npy'.format(phase, tp)
    if os.path.exists(save_file):
        return -np.load(save_file)

    for T in temp:
        w_n = gf.matsubara_freq(1 / T, 3)
        filestr = 'disk/phase_Dimer_ipt_{}_tp{}/B{:.5}/giw.npy'.format(
            phase, tp, 1 / T)
        gfs = np.load(filestr)
        dos_fl.append(
            np.array([gf.fit_gf(w_n, gfs[i][0][:3])(0.) for i in ulist]))

    np.save(save_file, dos_fl)

    return -np.array(dos_fl)
Ejemplo n.º 3
0
def estimate_dos_at_fermi_level_U_vs_tp(tpr, ulist, beta, phase):
    dos_fl = []
    w_n = gf.matsubara_freq(beta, 3)
    save_file = 'dimer_ipt_{}_B{}.npy'.format(phase, beta)
    if os.path.exists(save_file):
        return -np.load(save_file).T

    for tp in tpr:
        filestr = 'disk/phase_Dimer_ipt_{}_B{}/tp{:.3}/giw.npy'.format(
            phase, beta, tp)
        gfs = np.load(filestr)
        dos_fl.append(
            np.array([gf.fit_gf(w_n, gfs[i][0][:3])(0.) for i in ulist]))

    np.save(save_file, dos_fl)

    return -np.array(dos_fl).T
Ejemplo n.º 4
0
def dos_at_fermi_level_temp(xlist, temp, phasename, datapath):
    dos_fl = []
    save_file = 'phase_dimer_ipt_{}.npy'.format(phasename)
    if os.path.exists(save_file):
        dos_fl = np.load(save_file)
        return dos_fl

    for T in temp:
        w_n = gf.matsubara_freq(1 / T, 3)
        filestr = datapath.format(phasename, 1 / T)
        gfs = np.load(filestr)
        dos_fl.append(np.array([gf.fit_gf(w_n, gfs[i][0][:3])(0.)
                                for i in xlist]))

    dos_fl = -np.array(dos_fl)
    np.save(save_file, dos_fl)

    return dos_fl
Ejemplo n.º 5
0
def dos_at_fermi_level_fixbeta(xlist, ylist, beta, phasename, datapath):
    dos_fl = []
    w_n = gf.matsubara_freq(beta, 3)
    save_file = 'phase_dimer_ipt_{}.npy'.format(phasename)
    if os.path.exists(save_file):
        dos_fl = np.load(save_file)
        return dos_fl

    for xdat in xlist:
        filestr = datapath.format(phasename, xdat)
        gfs = np.load(filestr)
        dos_fl.append(np.array([gf.fit_gf(w_n, gfs[i][0][:3])(0.)
                                for i in ylist]))

    dos_fl = -np.array(dos_fl).T
    np.save(save_file, dos_fl)

    return dos_fl
Ejemplo n.º 6
0
def phase_diag_b(BETA_range, tp, filestr='HF_DIM_tp{tp}_B{BETA}.h5'):

    for BETA in BETA_range:
        tau, w_n = gf.tau_wn_setup(dict(BETA=BETA, N_MATSUBARA=BETA))
        with h5.File(filestr.format(tp=tp, BETA=BETA), 'r') as results:
            fl_dos = []
            for u_str in results.keys():
                lastit = results[u_str].keys()[-1]
                giwd, _ = get_giw(results[u_str], lastit, tau, w_n)
                fl_dos.append(gf.fit_gf(w_n[:3], giwd.imag)(0.))

            u_range = np.array([float(u_str[1:]) for u_str in results.keys()])
            plt.scatter(u_range,
                        np.ones(len(fl_dos)) / BETA,
                        c=fl_dos,
                        s=150,
                        vmin=-2,
                        vmax=0)
    plt.ylim([0, 0.04])
    plt.title(r'Phase diagram at $t_\perp={}$'.format(tp))
    plt.ylabel(r'$T/D$')
    plt.xlabel('$U/D$')
Ejemplo n.º 7
0
def fit_dos(beta, avg, filestr='disk/SB_PM_B{}'):
    """Fits for all Green's functions at a given beta their
    density of states at the Fermi energy

    Parameters
    ----------
    beta: float inverse temperature
    avg: int number of last iterations to average over

    Return
    ------
    arrays of Interaction, Fitted and source GF imaginary part
    """

    u_range = []
    figiw = []
    lgiw = []

    ulist = sorted([u_str for u_str in os.listdir(filestr.format(beta))
                    if 'U' in u_str])
    for u_str in ulist:
        sim_dir = os.path.join(filestr.format(beta), u_str)
        last_iterations = sorted(
            [it for it in os.listdir(sim_dir) if 'it' in it])[-avg:]
        with open(sim_dir + '/setup', 'r') as read:
            setup = json.load(read)
            setup['U'] = float(u_str[1:])
            tau, w_n = gf.tau_wn_setup(setup)

        giw, _ = get_giw(sim_dir, last_iterations, tau, w_n, setup)

        gfit = gf.fit_gf(w_n[:3], giw.imag)
        figiw.append(gfit)
        lgiw.append(giw)

    u_range = np.asarray([float(u_str[1:]) for u_str in ulist])
    return u_range, figiw, lgiw
Ejemplo n.º 8
0
def test_fit_gf():
    """Test the interpolation of Green function in Bethe Lattice"""
    w_n = gf.matsubara_freq(100, 3)
    giw = gf.greenF(w_n).imag
    cont_g = gf.fit_gf(w_n, giw)
    assert abs(cont_g(0.) + 2.) < 1e-4
Ejemplo n.º 9
0
for beta, result in zip(betarange, results):
    u_zet = [matsubara_Z(sigma.imag, beta) for _, sigma in result]
    axz.plot(Drange, u_zet, '+-', label='$\\beta={}$'.format(beta))
    axz.set_title('Hysteresis loop of the quasiparticle weigth')
    axz.legend(loc=0)
    axz.set_ylabel('Z')
    axz.set_xlabel('D/U')

###############################################################################
# Spectral density at Fermi level
# -------------------------------

figf, axf = plt.subplots()
for beta, result in zip(betarange, results):
    tau, w_n = tau_wn_setup(dict(BETA=beta, N_MATSUBARA=3))
    u_fl = [-fit_gf(w_n, g_iwn.imag)(0.) for g_iwn, _ in result]
    axf.plot(Drange, u_fl, 'x:', label='$\\beta={}$'.format(beta))

axf.set_ylabel('Dos(0)')
axf.set_xlabel('D/U')

###############################################################################
# Double occupation
# -----------------
#

figd, axd = plt.subplots()
for beta, result in zip(betarange, results):
    tau, w_n = tau_wn_setup(dict(BETA=beta, N_MATSUBARA=2**11))
    V = np.asarray([
        2 * (0.5 * s * g + 1 / 8. / w_n**2).real.sum() / beta