Ejemplo n.º 1
0
def window_conv_depr():

    nwf_vec = np.array([5, 10, 20, 40, 80, 160, 320])
    diff_vec = np.zeros_like(nwf_vec, dtype=np.float)

    for idx, nwf in enumerate(nwf_vec):
        d = analytic_solution(beta=2.0, U=5.0, nw=1, nwf=nwf)
        diff = np.max(np.abs(d.gamma_m.data - d.gamma_m_num.data))
        diff_vec[idx] = diff
        print('nwf, diff =', idx, nwf, diff)

    print(diff_vec)

    from triqs.plot.mpl_interface import oplot, oplotr, oploti, plt

    x = 1. / nwf_vec

    plt.figure(figsize=(3.25, 3))

    plt.plot(x, diff_vec, 'o-', alpha=0.75)
    plt.xlabel(r'$1/n_{w}$')
    plt.ylabel(r'$\max|\Gamma_{ana} - \Gamma_{num}|$')
    plt.ylim([0, diff_vec.max()])
    plt.xlim([0, x.max()])

    plt.tight_layout()
    plt.savefig('figure_bse_hubbard_atom_convergence.pdf')
    plt.show()
Ejemplo n.º 2
0
def plot_res(ana, pom):

    from triqs_tprf.plot import plot_g2, get_g2_opt
    from triqs.plot.mpl_interface import oplot, oplotr, oploti, plt

    opt = get_g2_opt(pom.chi, cplx='re', cut=0.1)

    plt.figure(figsize=(6, 6))
    plot_g2(pom.G2_iw_ph,
            cplx='re',
            opt=opt,
            idx_labels=[r'\uparrow', r'\downarrow'])

    plt.figure(figsize=(6, 6))
    plot_g2(pom.chi0,
            cplx='re',
            opt=opt,
            idx_labels=[r'\uparrow', r'\downarrow'])

    plt.figure(figsize=(6, 6))
    plot_g2(pom.chi,
            cplx='re',
            opt=opt,
            idx_labels=[r'\uparrow', r'\downarrow'])

    plt.figure(figsize=(3, 3))
    plot_g2(pom.chi_m,
            cplx='re',
            opt=opt,
            idx_labels=[r'\uparrow', r'\downarrow'])

    plt.figure(figsize=(3, 3))
    plot_g2(pom.chi0_m,
            cplx='re',
            opt=opt,
            idx_labels=[r'\uparrow', r'\downarrow'])

    opt = get_g2_opt(pom.gamma, cplx='re', cut=0.1)
    opt['vmin'] = -5.
    opt['vmax'] = +5.

    plt.figure(figsize=(6, 6))
    plot_g2(pom.gamma,
            cplx='re',
            opt=opt,
            idx_labels=[r'\uparrow', r'\downarrow'])

    plt.figure(figsize=(3, 3))
    plot_g2(ana.gamma_m,
            cplx='re',
            opt=opt,
            idx_labels=[r'\uparrow', r'\downarrow'])

    plt.show()
Ejemplo n.º 3
0
def plot_output(g0_wk, gamma):
    from triqs.plot.mpl_interface import oplot, plt

    initial_delta = semi_random_initial_delta(g0_wk)

    next_delta_summation = eliashberg_product(gamma_big, g0_wk, initial_delta)

    gamma_dyn_tr, gamma_const_r = preprocess_gamma_for_fft(gamma)
    next_delta_fft = eliashberg_product_fft(gamma_dyn_tr, gamma_const_r, g0_wk,
                                            initial_delta)

    deltas = [initial_delta, next_delta_summation, next_delta_fft]

    warnings.filterwarnings("ignore")  #ignore some matplotlib warnings
    subp = [4, 3, 1]
    fig = plt.figure(figsize=(18, 15))

    titles = ['Input', 'Summation', 'FFT']

    for k_point in [Idx(0, 0, 0), Idx(1, 0, 0)]:

        ax = plt.subplot(*subp)
        subp[-1] += 1
        oplot(g0_wk[:, k_point])
        plt.title('GF')

        ax = plt.subplot(*subp)
        subp[-1] += 1
        oplot(gamma[:, k_point])
        plt.title('Gamma')

        ax = plt.subplot(*subp)
        subp[-1] += 1
        oplot(gamma_dyn_tr[:, k_point])
        plt.title('Gamma dyn tr')

        for delta, title in zip(deltas, titles):

            ax = plt.subplot(*subp)
            subp[-1] += 1
            oplot(delta[:, k_point])
            plt.title(title)

            ax.legend_ = None

    plt.show()
Ejemplo n.º 4
0
def strip_sigma(nw, beta, sigma_in, debug=False):

    np.testing.assert_almost_equal(beta, sigma_in.mesh.beta)

    wmesh = MeshImFreq(beta, 'Fermion', n_max=nw)
    sigma = Gf(mesh=wmesh, target_shape=sigma_in.target_shape)

    for w in wmesh:
        index = w.linear_index + wmesh.first_index()  # absolute index
        sigma[w] = sigma_in[Idx(index)]

    if debug:
        from triqs.plot.mpl_interface import oplot, plt
        oplot(p.Sigmalatt_iw)
        oplot(sigma, 'x')
        plt.show()
        exit()

    return sigma
Ejemplo n.º 5
0
        ax = plt.subplot(*subp)
        subp[-1] += 1
        oplotr(p.G_tau['up'], 'b', alpha=0.25)
        oplotr(p.G_tau['dn'], 'g', alpha=0.25)
        ax.legend().set_visible(False)

    subp = [2, 1, 2]
    plt.subplot(*subp)
    subp[-1] += 1
    plt.title(r'$\chi \approx %2.2f$' % out.chi)
    plt.plot(out.h_vec, out.m_vec, '-og', alpha=0.5)
    plt.plot(out.h_vec, out.m_ref_vec, 'xb', alpha=0.5)
    plt.plot(out.h_vec, -out.chi * out.h_vec, '-r', alpha=0.5)

    plt.tight_layout()
    plt.savefig('figure_static_field.pdf')


# ----------------------------------------------------------------------
if __name__ == '__main__':

    paths = glob.glob('pyed_*')

    for path in paths:
        print('--> path:', path)
        os.chdir(path)
        calc_field()
        os.chdir('../')

    plt.show()
Ejemplo n.º 6
0
def test_cf_G_tau_and_G_iw_nonint(verbose=False):

    beta = 3.22
    eps = 1.234

    niw = 64
    ntau = 2 * niw + 1

    H = eps * c_dag(0, 0) * c(0, 0)

    fundamental_operators = [c(0, 0)]

    ed = TriqsExactDiagonalization(H, fundamental_operators, beta)

    # ------------------------------------------------------------------
    # -- Single-particle Green's functions

    G_tau = GfImTime(beta=beta,
                     statistic='Fermion',
                     n_points=ntau,
                     target_shape=(1, 1))
    G_iw = GfImFreq(beta=beta,
                    statistic='Fermion',
                    n_points=niw,
                    target_shape=(1, 1))

    G_iw << inverse(iOmega_n - eps)
    G_tau << Fourier(G_iw)

    G_tau_ed = GfImTime(beta=beta,
                        statistic='Fermion',
                        n_points=ntau,
                        target_shape=(1, 1))
    G_iw_ed = GfImFreq(beta=beta,
                       statistic='Fermion',
                       n_points=niw,
                       target_shape=(1, 1))

    ed.set_g2_tau(G_tau_ed[0, 0], c(0, 0), c_dag(0, 0))
    ed.set_g2_iwn(G_iw_ed[0, 0], c(0, 0), c_dag(0, 0))

    # ------------------------------------------------------------------
    # -- Compare gfs

    from triqs.utility.comparison_tests import assert_gfs_are_close

    assert_gfs_are_close(G_tau, G_tau_ed)
    assert_gfs_are_close(G_iw, G_iw_ed)

    # ------------------------------------------------------------------
    # -- Plotting

    if verbose:
        from triqs.plot.mpl_interface import oplot, plt
        subp = [3, 1, 1]
        plt.subplot(*subp)
        subp[-1] += 1
        oplot(G_tau.real)
        oplot(G_tau_ed.real)

        plt.subplot(*subp)
        subp[-1] += 1
        diff = G_tau - G_tau_ed
        oplot(diff.real)
        oplot(diff.imag)

        plt.subplot(*subp)
        subp[-1] += 1
        oplot(G_iw)
        oplot(G_iw_ed)

        plt.show()