Beispiel #1
0
def create_eliashberg_ingredients(p):
    H = create_model_for_tests(**p)
    kmesh = H.get_kmesh(n_k=[p.nk] * p.dim + [1] * (3 - p.dim))
    e_k = H.fourier(kmesh)

    wmesh = MeshImFreq(beta=p.beta, S="Fermion", n_max=p.nw)
    g0_wk = lattice_dyson_g0_wk(mu=p.mu, e_k=e_k, mesh=wmesh)

    chi0_wk = imtime_bubble_chi0_wk(g0_wk, nw=p.nw)

    U_d, U_m = kanamori_charge_and_spin_quartic_interaction_tensors(
        p.norb, p.U, p.Up, p.J, p.Jp)

    chi_d = solve_rpa_PH(chi0_wk, U_d)
    chi_m = solve_rpa_PH(chi0_wk,
                         -U_m)  # Minus for correct charge rpa equation

    phi_d_wk = construct_phi_wk(chi_d, U_d)
    phi_m_wk = construct_phi_wk(chi_m, U_m)

    gamma = construct_gamma_singlet_rpa(U_d, U_m, phi_d_wk, phi_m_wk)

    eliashberg_ingredients = ParameterCollection(
        g0_wk=g0_wk,
        gamma=gamma,
        U_m=U_m,
        U_d=U_d,
        chi_m=chi_m,
        chi_d=chi_d,
    )
    return eliashberg_ingredients
Beispiel #2
0
def make_calc(beta=2.0, h_field=0.0):
    
    # ------------------------------------------------------------------
    # -- Hubbard atom with two bath sites, Hamiltonian

    p = ParameterCollection(
        beta = beta,
        h_field = h_field,
        U = 5.0,
        ntau = 40,
        niw = 15,
        )

    p.mu = 0.5*p.U
    
    # ------------------------------------------------------------------

    print '--> Solving SIAM with parameters'
    print p
    
    # ------------------------------------------------------------------

    up, do = 'up', 'dn'
    docc = c_dag(up,0) * c(up,0) * c_dag(do,0) * c(do,0)
    mA = c_dag(up,0) * c(up,0) - c_dag(do,0) * c(do,0)
    nA = c_dag(up,0) * c(up,0) + c_dag(do,0) * c(do,0)

    p.H = -p.mu * nA + p.U * docc + p.h_field * mA
    
    # ------------------------------------------------------------------

    fundamental_operators = [c(up,0), c(do,0)]
    
    ed = TriqsExactDiagonalization(p.H, fundamental_operators, p.beta)

    g_tau = GfImTime(beta=beta, statistic='Fermion', n_points=40, indices=[0])
    g_iw = GfImFreq(beta=beta, statistic='Fermion', n_points=10, indices=[0])

    p.G_tau = BlockGf(name_list=[up,do], block_list=[g_tau]*2, make_copies=True)
    p.G_iw = BlockGf(name_list=[up,do], block_list=[g_iw]*2, make_copies=True)
    
    ed.set_g2_tau(p.G_tau[up], c(up,0), c_dag(up,0))
    ed.set_g2_tau(p.G_tau[do], c(do,0), c_dag(do,0))

    ed.set_g2_iwn(p.G_iw[up], c(up,0), c_dag(up,0))
    ed.set_g2_iwn(p.G_iw[do], c(do,0), c_dag(do,0))

    p.magnetization = ed.get_expectation_value(0.5 * mA)
    p.magnetization2 = ed.get_expectation_value(0.25 * mA * mA)
    
    # ------------------------------------------------------------------
    # -- Store to hdf5
    
    filename = 'data_pyed_h_field_%4.4f.h5' % h_field
    with HDFArchive(filename,'w') as res:
        res['p'] = p
Beispiel #3
0
def make_calc(beta=2.0, nwf=8):
    
    # ------------------------------------------------------------------
    # -- Hubbard atom with two bath sites, Hamiltonian

    p = ParameterCollection(
        beta = beta,
        U = 5.0,
        nw = 1,
        nwf = nwf,
        nwf_gf = 2*nwf,
        )

    ana = analytic_hubbard_atom(**p.dict())

    p.chi = np.sum(ana.chi_m.data) / p.beta**2
    
    # ------------------------------------------------------------------
    # -- Store to hdf5
    
    filename = 'data_dynamic_beta%6.6f_nwf%i.h5' % (p.beta, p.nwf)
    with HDFArchive(filename,'w') as res:
        res['p'] = p
Beispiel #4
0
    np.testing.assert_allclose(Es[0], expected_E)
    assert allclose_by_scalar_multiplication(eigen_modes[0], expected_eigen_mode),\
                "Eigenvectors are not the same."


if __name__ == "__main__":
    p = ParameterCollection(
        filename='eliashberg_benchmark_two_band_new.tar.gz',
        benchmark_filename='./eliashberg_benchmark_two_band.tar.gz',
        dim=2,
        norb=2,
        t1=1.0,
        t2=0.5,
        t12=0.1,
        t21=0.1,
        mu=0.0,
        beta=1,
        U=1.0,
        Up=0.8,
        J=0.1,
        Jp=0.1,
        nk=2,
        nw=100,
        version_info=version.info,
    )

    #save_new_benchmarks(p.filename, p)

    p_benchmark = read_TarGZ_HDFArchive(p.benchmark_filename)['p']
    model_parameters_to_test = [
        'dim', 'norb', 't1', 't2', 't12', 't21', 'mu', 'beta', 'U'
Beispiel #5
0
    gamma_triplet = construct_gamma_triplet_rpa(U_d, U_m, 0 * phi_d_wk,
                                                0 * phi_m_wk)
    benchmark_value = -0.5 * U_d + 0.5 * U_m
    np.testing.assert_equal(gamma_triplet.data[0, 0], benchmark_value)


if __name__ == "__main__":
    p = ParameterCollection(
        dim=2,
        norb=2,
        t1=1.0,
        t2=0.5,
        t12=0.1,
        t21=0.1,
        mu=0.1,
        beta=1,
        U=1.0,
        Up=0.8,
        J=0.1,
        Jp=0.1,
        nk=3,
        nw=50,
    )

    eliashberg_ingredients = create_eliashberg_ingredients(p)
    chi_d = eliashberg_ingredients.chi_d
    chi_m = eliashberg_ingredients.chi_m
    U_d = eliashberg_ingredients.U_d
    U_m = eliashberg_ingredients.U_m

    test_phi_wk_mesh_type(chi_d, U_d)
        np.testing.assert_equal(random_delta1.data, random_delta2.data)
        raise ValueError
    except AssertionError:
        pass


if __name__ == "__main__":

    p = ParameterCollection(
        dim=2,
        norb=2,
        t1=1.0,
        t2=0.5,
        t12=0.1,
        t21=0.1,
        mu=0.0,
        beta=1,
        U=0.0,
        Up=0.0,
        J=0.0,
        Jp=0.0,
        nk=2,
        nw=100,
    )

    eliashberg_ingredients = create_eliashberg_ingredients(p)
    g0_wk = eliashberg_ingredients.g0_wk

    test_same_output_for_same_seed(g0_wk)
    test_different_output_for_different_seed(g0_wk)
Beispiel #7
0
def make_calc():

    # ------------------------------------------------------------------
    # -- Read precomputed ED data

    filename = "data_pomerol.tar.gz"
    p = read_TarGZ_HDFArchive(filename)

    # ------------------------------------------------------------------
    # -- RPA tensor

    from triqs_tprf.rpa_tensor import get_rpa_tensor
    from triqs_tprf.rpa_tensor import fundamental_operators_from_gf_struct

    fundamental_operators = fundamental_operators_from_gf_struct(p.gf_struct)
    p.U_abcd = get_rpa_tensor(p.H_int, fundamental_operators)

    # ------------------------------------------------------------------
    # -- Generalized PH susceptibility

    loc_bse = ParameterCollection()

    loc_bse.chi_wnn = chi_from_gg2_PH(p.G_iw, p.G2_iw_ph)
    loc_bse.chi0_wnn = chi0_from_gg2_PH(p.G_iw, p.G2_iw_ph)

    loc_bse.gamma_wnn = inverse_PH(loc_bse.chi0_wnn) - inverse_PH(
        loc_bse.chi_wnn)
    loc_bse.chi_wnn_ref = inverse_PH(
        inverse_PH(loc_bse.chi0_wnn) - loc_bse.gamma_wnn)

    np.testing.assert_array_almost_equal(loc_bse.chi_wnn.data,
                                         loc_bse.chi_wnn_ref.data)

    loc_bse.chi0_w = trace_nn(loc_bse.chi0_wnn)
    loc_bse.chi_w = trace_nn(loc_bse.chi_wnn)

    # ------------------------------------------------------------------
    # -- RPA, using BSE inverses and constant Gamma

    loc_rpa = ParameterCollection()
    loc_rpa.U_abcd = p.U_abcd

    # -- Build constant gamma
    loc_rpa.gamma_wnn = loc_bse.gamma_wnn.copy()
    loc_rpa.gamma_wnn.data[:] = loc_rpa.U_abcd[None, None, None, ...]
    # Nb! In the three frequency form $\Gamma \propto U/\beta^2$
    loc_rpa.gamma_wnn.data[:] /= p.beta**2

    loc_rpa.chi0_wnn = loc_bse.chi0_wnn
    loc_rpa.chi0_w = loc_bse.chi0_w

    # -- Solve RPA
    loc_rpa.chi_wnn = inverse_PH(
        inverse_PH(loc_rpa.chi0_wnn) - loc_rpa.gamma_wnn)
    loc_rpa.chi_w = trace_nn(loc_rpa.chi_wnn)

    # ------------------------------------------------------------------
    # -- Bubble RPA on lattice

    lat_rpa = ParameterCollection()

    # -- Setup dummy lattice Green's function equal to local Green's function

    bz = BrillouinZone(
        BravaisLattice(units=np.eye(3), orbital_positions=[(0, 0, 0)]))
    periodization_matrix = np.diag(np.array(list([1] * 3), dtype=np.int32))
    kmesh = MeshBrillouinZone(bz, periodization_matrix)
    wmesh = MeshImFreq(beta=p.beta, S='Fermion', n_max=p.nwf_gf)

    lat_rpa.g_wk = Gf(mesh=MeshProduct(wmesh, kmesh),
                      target_shape=p.G_iw.target_shape)
    lat_rpa.g_wk[:, Idx(0, 0, 0)] = p.G_iw

    # -- chi0_wk bubble and chi_wk_rpa bubble RPA

    from triqs_tprf.lattice_utils import imtime_bubble_chi0_wk
    lat_rpa.chi0_wk = imtime_bubble_chi0_wk(lat_rpa.g_wk, nw=1)

    from triqs_tprf.lattice import solve_rpa_PH
    lat_rpa.chi_wk = solve_rpa_PH(lat_rpa.chi0_wk, p.U_abcd)

    lat_rpa.chi0_w = lat_rpa.chi0_wk[:, Idx(0, 0, 0)]
    lat_rpa.chi_w = lat_rpa.chi_wk[:, Idx(0, 0, 0)]

    print '--> cf Tr[chi0] and chi0_wk'
    print loc_rpa.chi0_w.data.reshape((4, 4)).real
    print lat_rpa.chi0_w.data.reshape((4, 4)).real

    np.testing.assert_array_almost_equal(loc_rpa.chi0_w.data,
                                         lat_rpa.chi0_w.data,
                                         decimal=2)

    print 'ok!'

    print '--> cf Tr[chi_rpa] and chi_wk_rpa'
    print loc_rpa.chi_w.data.reshape((4, 4)).real
    print lat_rpa.chi_w.data.reshape((4, 4)).real

    np.testing.assert_array_almost_equal(loc_rpa.chi_w.data,
                                         lat_rpa.chi_w.data,
                                         decimal=2)

    print 'ok!'

    # ------------------------------------------------------------------
    # -- Lattice BSE

    lat_bse = ParameterCollection()

    lat_bse.g_wk = lat_rpa.g_wk

    from triqs_tprf.lattice import fourier_wk_to_wr
    lat_bse.g_wr = fourier_wk_to_wr(lat_bse.g_wk)

    from triqs_tprf.lattice import chi0r_from_gr_PH
    lat_bse.chi0_wnr = chi0r_from_gr_PH(nw=1, nnu=p.nwf, gr=lat_bse.g_wr)

    from triqs_tprf.lattice import chi0q_from_chi0r
    lat_bse.chi0_wnk = chi0q_from_chi0r(lat_bse.chi0_wnr)

    # -- Lattice BSE calc
    from triqs_tprf.lattice import chiq_from_chi0q_and_gamma_PH
    lat_bse.chi_kwnn = chiq_from_chi0q_and_gamma_PH(lat_bse.chi0_wnk,
                                                    loc_bse.gamma_wnn)

    # -- Trace results
    from triqs_tprf.lattice import chi0q_sum_nu_tail_corr_PH
    from triqs_tprf.lattice import chi0q_sum_nu
    lat_bse.chi0_wk_tail_corr = chi0q_sum_nu_tail_corr_PH(lat_bse.chi0_wnk)
    lat_bse.chi0_wk = chi0q_sum_nu(lat_bse.chi0_wnk)

    from triqs_tprf.lattice import chiq_sum_nu, chiq_sum_nu_q
    lat_bse.chi_kw = chiq_sum_nu(lat_bse.chi_kwnn)

    lat_bse.chi0_w_tail_corr = lat_bse.chi0_wk_tail_corr[:, Idx(0, 0, 0)]
    lat_bse.chi0_w = lat_bse.chi0_wk[:, Idx(0, 0, 0)]
    lat_bse.chi_w = lat_bse.chi_kw[Idx(0, 0, 0), :]

    print '--> cf Tr[chi0_wnk] and chi0_wk'
    print lat_bse.chi0_w_tail_corr.data.reshape((4, 4)).real
    print lat_bse.chi0_w.data.reshape((4, 4)).real
    print lat_rpa.chi0_w.data.reshape((4, 4)).real

    np.testing.assert_array_almost_equal(lat_bse.chi0_w_tail_corr.data,
                                         lat_rpa.chi0_w.data)

    np.testing.assert_array_almost_equal(lat_bse.chi0_w.data,
                                         lat_rpa.chi0_w.data,
                                         decimal=2)

    print 'ok!'

    print '--> cf Tr[chi_kwnn] and chi_wk'
    print lat_bse.chi_w.data.reshape((4, 4)).real
    print loc_bse.chi_w.data.reshape((4, 4)).real

    np.testing.assert_array_almost_equal(lat_bse.chi_w.data,
                                         loc_bse.chi_w.data)

    print 'ok!'

    # ------------------------------------------------------------------
    # -- Store to hdf5

    filename = 'data_bse_rpa.h5'
    with HDFArchive(filename, 'w') as res:
        res['p'] = p
    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()


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

    p = ParameterCollection(beta=20., U=5., nw=1, nwf=20, nwf_gf=80)
    #ana = analytic_solution(**p.dict())
    ana = analytic_hubbard_atom(**p.dict())

    ana.gamma_m.data[:] -= p.U
    ana.gamma_m_num.data[:] -= p.U

    #for data in [ana.gamma_m.data, ana.gamma_m_num.data]:
    #    #print np.max(np.abs(data.imag))
    #    np.testing.assert_array_almost_equal(data.imag, np.zeros_like(data))

    diff = np.max(np.abs(ana.gamma_m_num.data.imag - ana.gamma_m.data.imag))
    print 'max(abs(Im[diff])) =', diff

    diff = np.max(np.abs(ana.gamma_m_num.data.real - ana.gamma_m.data.real))
    print 'max(abs(Re[diff])) =', diff
Beispiel #9
0
def get_chi0_wnk(g_wk, nw=1, nwf=None):
    r""" Compute the generalized lattice bubble susceptibility 
    :math:`\chi^{(0)}_{abcd}(\omega, \nu, \mathbf{k})` from the single-particle
    Green's function :math:`G_{ab}(\omega, \mathbf{k})`.

    Parameters
    ----------

    g_wk : Single-particle Green's function :math:`G_{ab}(\omega, \mathbf{k})`.
    nw : Number of bosonic freqiencies in :math:`\chi`.
    nwf : Number of fermionic freqiencies in :math:`\chi`.    

    Returns
    -------

    chi0_wnk : Generalized lattice bubble susceptibility
               :math:`\chi^{(0)}_{abcd}(\omega, \nu, \mathbf{k})`
    """

    fmesh = g_wk.mesh.components[0]
    kmesh = g_wk.mesh.components[1]

    if nwf is None:
        nwf = len(fmesh) / 2

    mpi.barrier()
    mpi.report('g_wk ' + str(g_wk[Idx(2), Idx(0, 0, 0)][0, 0]))
    n = np.sum(g_wk.data) / len(kmesh)
    mpi.report('n ' + str(n))
    mpi.barrier()

    mpi.report('--> g_wr from g_wk')
    g_wr = fourier_wk_to_wr(g_wk)

    mpi.barrier()
    mpi.report('g_wr ' + str(g_wr[Idx(2), Idx(0, 0, 0)][0, 0]))
    n_r = np.sum(g_wr.data, axis=0)[0]
    mpi.report('n_r=0 ' + str(n_r[0, 0]))
    mpi.barrier()

    mpi.report('--> chi0_wnr from g_wr')
    chi0_wnr = chi0r_from_gr_PH(nw=nw, nn=nwf, g_nr=g_wr)

    #mpi.report('--> chi0_wnr from g_wr (nompi)')
    #chi0_wnr_nompi = chi0r_from_gr_PH_nompi(nw=nw, nn=nwf, g_wr=g_wr)

    del g_wr

    #abs_diff = np.abs(chi0_wnr.data - chi0_wnr_nompi.data)
    #mpi.report('shape = ' + str(abs_diff.shape))
    #idx = np.argmax(abs_diff)
    #mpi.report('argmax = ' + str(idx))
    #diff = np.max(abs_diff)
    #mpi.report('diff = %6.6f' % diff)
    #del chi0_wnr
    #chi0_wnr = chi0_wnr_nompi

    #exit()

    mpi.barrier()
    mpi.report('chi0_wnr ' +
               str(chi0_wnr[Idx(0), Idx(0), Idx(0, 0, 0)][0, 0, 0, 0]))
    chi0_r0 = np.sum(chi0_wnr[:, :, Idx(0, 0, 0)].data)
    mpi.report('chi0_r0 ' + str(chi0_r0))
    mpi.barrier()

    mpi.report('--> chi0_wnk from chi0_wnr')
    chi0_wnk = chi0q_from_chi0r(chi0_wnr)

    del chi0_wnr

    mpi.barrier()
    mpi.report('chi0_wnk ' +
               str(chi0_wnk[Idx(0), Idx(0), Idx(0, 0, 0)][0, 0, 0, 0]))
    chi0 = np.sum(chi0_wnk.data) / len(kmesh)
    mpi.report('chi0 = ' + str(chi0))
    mpi.barrier()

    #if mpi.is_master_node():
    if False:
        from triqs_tprf.ParameterCollection import ParameterCollection
        p = ParameterCollection()
        p.g_wk = g_wk
        p.g_wr = g_wr
        p.chi0_wnr = chi0_wnr
        p.chi0_wnk = chi0_wnk

        print '--> Writing debug info for BSE'
        with HDFArchive('data_debug_bse.h5', 'w') as arch:
            arch['p'] = p

    mpi.barrier()

    return chi0_wnk
Beispiel #10
0
                               p_benchmark.gamma_dyn_tr.data,
                               atol=1e-10)
    np.testing.assert_allclose(gamma_const_r.data,
                               p_benchmark.gamma_const_r.data,
                               atol=1e-10)


if __name__ == '__main__':
    p = ParameterCollection(
        filename="preprocess_gamma_for_fft_benchmark_new.tar.gz",
        benchmark_filename="preprocess_gamma_for_fft_benchmark.tar.gz",
        dim=1,
        norb=2,
        t=2.0,
        mu=0.0,
        beta=5,
        U=1.0,
        Up=0.8,
        J=0.1,
        Jp=0.1,
        nk=3,
        nw=500,
        version_info=version.info,
    )
    eliashberg_ingredients = create_eliashberg_ingredients(p)
    gamma = eliashberg_ingredients.gamma
    U_d = eliashberg_ingredients.U_d
    U_m = eliashberg_ingredients.U_m

    test_split_into_dynamic_wk_and_constant_k_mesh_types(gamma)
    test_split_into_dynamic_wk_and_constant_k_mesh_values(gamma, U_d, U_m)
    test_dynamic_and_constant_to_tr_mesh_types(gamma)
Beispiel #11
0
from triqs_tprf.lattice_utils import imtime_bubble_chi0_wk

# ----------------------------------------------------------------------


def test_chi0_wk_save_memory(g0_wk, p):
    chi0_wk = imtime_bubble_chi0_wk(g0_wk, nw=p.nw_chi, save_memory=False)
    chi0_wk_save_memory = imtime_bubble_chi0_wk(g0_wk, nw=p.nw_chi, save_memory=True)

    assert np.allclose(chi0_wk.data, chi0_wk_save_memory.data)


if __name__ == "__main__":
    p = ParameterCollection(
        dim=2,
        norb=2,
        t1=1.0,
        t2=0.5,
        t12=0.1,
        t21=0.1,
        mu=0.0,
        beta=1,
        nk=2,
        nw=20,
        nw_chi=10,
    )

    g0_wk = create_g0_wk_for_test_model(p)

    test_chi0_wk_save_memory(g0_wk, p)
Beispiel #12
0
from triqs_tprf.lattice import eliashberg_product
from triqs_tprf.eliashberg import solve_eliashberg

# ----------------------------------------------------------------------

from triqs_tprf.utilities import write_TarGZ_HDFArchive, read_TarGZ_HDFArchive, show_version_info
import triqs_tprf.version as version

# ----------------------------------------------------------------------

p = ParameterCollection(
    filename='eliashberg_benchmark_new.tar.gz',
    dim=2,
    norbs=1,
    t=1.0,
    mu=0.0,
    beta=1,
    U=1.0,
    nk=2,
    nw=100,
    version_info=version.info,
)

# -- Setup model, RPA susceptibilities and spin/charge interaction

full_units = [(1, 0, 0), (0, 1, 0), (0, 0, 1)]
all_nn_hoppings = list(itertools.product([-1, 0, 1], repeat=p.dim))
non_diagonal_hoppings = [
    ele for ele in all_nn_hoppings if sum(np.abs(ele)) == 1
]

t = -p.t * np.eye(p.norbs)
    patched_product.return_value = g0_wk

    for k_input in [1, 3]:
        Es, evs = solve_eliashberg(gamma, g0_wk, k=k_input)
        assert len(Es) == k_input
        assert len(evs) == k_input


if __name__ == "__main__":
    p = ParameterCollection(
        dim=2,
        norb=1,
        t=1.0,
        mu=0.0,
        beta=1,
        U=1.0,
        Up=0.0,
        J=0.0,
        Jp=0.0,
        nk=2,
        nw=100,
    )

    eliashberg_ingredients = create_eliashberg_ingredients(p)
    g0_wk = eliashberg_ingredients.g0_wk
    gamma = eliashberg_ingredients.gamma

    test_no_initial_delta_input(g0_wk=g0_wk, gamma=gamma)
    test_initial_delta_input(g0_wk=g0_wk, gamma=gamma)
    test_tol_used_in_IRAM(g0_wk, gamma)
    test_tol_used_in_PM(g0_wk, gamma)
Beispiel #14
0
def test_solve_eliashberg(g0_wk, gamma, expected_E, expected_eigen_mode):
    Es, eigen_modes = solve_eliashberg(gamma, g0_wk, product='FFT', solver='IRAM')
    np.testing.assert_allclose(Es[0], expected_E) 
    assert allclose_by_scalar_multiplication(eigen_modes[0], expected_eigen_mode),\
                "Eigenvectors are not the same."

if __name__ == "__main__":
    p = ParameterCollection(
            benchmark_filename = "./eliashberg_benchmark_one_band.tar.gz",
            filename = 'eliashberg_benchmark_one_band_new.tar.gz',
            dim = 2,
            norb = 1,
            t = 1.0,
            mu = 0.0,
            beta = 1,
            U = 1.0,
            Up = 0.0,
            J = 0.0,
            Jp = 0.0,
            nk = 2,
            nw = 100,
            version_info = version.info,
            )

    #save_new_benchmarks(p.filename, p)

    p_benchmark = read_TarGZ_HDFArchive(p.benchmark_filename)['p']
    model_parameters_to_test = ['dim', 'norb', 't', 'mu', 'beta', 'U']
    assert_parameter_collection_not_equal_model_parameters(p, p_benchmark, model_parameters_to_test)

    eliashberg_ingredients = create_eliashberg_ingredients(p)
Beispiel #15
0
        g0_wk, gamma_wnn, nw_index=nw_index
    )

    assert isinstance(chi_k_at_specific_w.mesh, MeshBrillouinZone)
    assert isinstance(chi0_k_at_specific_w.mesh, MeshBrillouinZone)


if __name__ == "__main__":
    p = ParameterCollection(
        dim=2,
        norb=2,
        t1=1.0,
        t2=0.5,
        t12=0.1,
        t21=0.1,
        mu=0.0,
        beta=1,
        nk=2,
        nw=100,
        nw_gamma=10,
        nwf=10,
        nw_index=3,
        seed=101,
    )

    g0_wk = create_g0_wk_for_test_model(p)
    gamma_wnn = create_random_gamma_wnn(p)

    test_solve_lattice_bse_at_specific_w_against_full(g0_wk, gamma_wnn, p.nw_index)
    test_lattice_bse_at_specific_w_mesh_types(g0_wk, gamma_wnn, p.nw_index)
    
Beispiel #16
0
def analytic_hubbard_atom(beta, U, nw, nwf, nwf_gf):
    r""" Compute dynamical response functions for the Hubbard atom at half filling.

    This function returns an object that contains the single-particle
    Greens function :math:`G(\omega)`, the magnetic two-particle generalized susceptibility
    :math:`\chi_m(\omega, \nu, \nu')`, and the corresponding bare bubble 
    :math:`\chi^{(0)}_m(\omega, \nu, \nu')`, and the magnetic vertex function
    :math:`\Gamma_m(\omega, \nu, \nu')`.

    This is implemented using analytical formulas from 
    Thunstrom et al. [PRB 98, 235107 (2018)]
    please cite the paper if you use this function!

    In particular this is one exact solution to the Bethe-Salpeter
    equation, that is the infinite matrix inverse problem:

    .. math::
        \Gamma_m = [\chi^{(0)}_m]^{-1} - \chi_m^{-1}

    Parameters
    ----------

    beta : float
        Inverse temperature.

    U : float
        Hubbard U interaction parameter.

    nw : int
        Number of bosonic Matsubara frequencies 
        in the computed two-particle response functions.

    nwf : int
        Number of fermionic Matsubara frequencies
        in the computed two-particle response functions.

    nwf_gf : int
        Number of fermionic Matsubara frequencies
        in the computed single-particle Greens function.

    Returns
    -------

    p : ParameterCollection
        Object containing all the response functions and some other
        observables, `p.G_iw`, `p.chi_m`, `p.chi0_m`, 
        `p.gamma_m`, `p.Z`, `p.m2`, `p.chi_m_static`.

    """

    d = ParameterCollection()
    d.beta, d.U, d.nw, d.nwf, d.nwf_gf = beta, U, nw, nwf, nwf_gf

    g_iw = single_particle_greens_function(beta=beta, U=U, nw=nwf_gf)
    d.G_iw = g_iw

    # make block gf of the single gf
    G_iw_block = BlockGf(name_list=['up', 'dn'], block_list=[g_iw, g_iw])
    g_mat = block_iw_AB_to_matrix_valued(G_iw_block)

    d.chi_m = chi_ph_magnetic(beta=beta, U=U, nw=nw, nwf=nwf)
    d.chi0_m = chi0_from_gg2_PH(g_mat, d.chi_m)

    # -- Numeric vertex from BSE
    d.gamma_m_num = inverse_PH(d.chi0_m) - inverse_PH(d.chi_m)

    # -- Analytic vertex
    d.gamma_m = gamma_ph_magnetic(beta=beta, U=U, nw=nw, nwf=nwf)

    # -- Analytic magnetization expecation value
    # -- and static susceptibility

    d.Z = 2. + 2 * np.exp(-beta * 0.5 * U)
    d.m2 = 0.25 * (2 / d.Z)
    d.chi_m_static = 2. * beta * d.m2

    d.label = r'Analytic'

    return d
Beispiel #17
0
    plt.show()


#================================================================================

if __name__ == '__main__':
    p = ParameterCollection(
        dim=1,
        norb=2,
        t1=1.0,
        t2=0.5,
        t12=0.1,
        t21=0.1,
        mu=0.0,
        beta=1,
        U=1.0,
        Up=0.8,
        J=0.1,
        Jp=0.1,
        nk=3,
        nw=30,
        atol=1e-8,
    )

    eliashberg_ingredients = create_eliashberg_ingredients(p)
    g0_wk = eliashberg_ingredients.g0_wk
    gamma = eliashberg_ingredients.gamma
    # For the eliashberg SUM procedure a Gamma with a twice as big w-mesh then the GF is needed.
    big_nw = 2 * p.nw + 1
    eliashberg_ingredients_big = create_eliashberg_ingredients(
Beispiel #18
0
from triqs_tprf.lattice import lattice_dyson_g0_wk, solve_rpa_PH
from triqs_tprf.lattice_utils import imtime_bubble_chi0_wk
from triqs_tprf.lattice import gamma_PP_singlet
from triqs_tprf.lattice import eliashberg_product, eliashberg_product_fft
from triqs_tprf.lattice import split_into_dynamic_wk_and_constant_k, dynamic_and_constant_to_tr
from triqs_tprf.eliashberg import solve_eliashberg, solve_eliashberg_fft
from triqs_tprf.rpa_tensor import kanamori_charge_and_spin_quartic_interaction_tensors

# ----------------------------------------------------------------------

p = ParameterCollection(
        dim = 1,
        norbs = 1,
        t = 1.0,
        mu = 0.0,
        beta = 5,
        U = 1.0,
        nk = 4,
        nw = 500,
        )

# -- Setup model, RPA susceptibilities and spin/charge interaction

full_units = [(1, 0, 0), (0, 1, 0), (0, 0, 1)]
all_nn_hoppings = list(itertools.product([-1, 0, 1], repeat=p.dim)) 
non_diagonal_hoppings = [ele for ele in all_nn_hoppings if sum(np.abs(ele)) == 1] 

t = -p.t * np.eye(p.norbs)

H = TBLattice(
            units = full_units[:p.dim],
Beispiel #19
0
    np.testing.assert_allclose(delta_1.data, delta_2.data)

    print(
        'The functions eliashberg_product_fft and eliashberg_product_fft_constant'
        ' yield the same result for a Gamma that is only constant in momentum space.'
        '\nThe function split_into_dynamic_wk_and_constant_k therefore also worked correcty.'
    )


if __name__ == '__main__':

    p = ParameterCollection(
        dim=2,
        norb=1,
        t=2.0,
        mu=0.0,
        beta=5,
        U=1.0,
        Up=0.0,
        J=0.0,
        Jp=0.0,
        nk=4,
        nw=200,
    )
    eliashberg_ingredients = create_eliashberg_ingredients(p)
    g0_wk = eliashberg_ingredients.g0_wk
    gamma = eliashberg_ingredients.gamma

    test_eliashberg_product_fft_constant(g0_wk, gamma)
Beispiel #20
0
def make_calc():

    # ------------------------------------------------------------------
    # -- Read precomputed ED data

    filename = "bse_and_rpa_loc_vs_latt.tar.gz"
    p = read_TarGZ_HDFArchive(filename)['p']

    # ------------------------------------------------------------------
    # -- RPA tensor

    from triqs_tprf.rpa_tensor import get_rpa_tensor
    from triqs_tprf.rpa_tensor import fundamental_operators_from_gf_struct

    fundamental_operators = fundamental_operators_from_gf_struct(p.gf_struct)
    p.U_abcd = get_rpa_tensor(p.H_int, fundamental_operators)

    # ------------------------------------------------------------------
    # -- Generalized PH susceptibility

    loc_bse = ParameterCollection()

    loc_bse.chi_wnn = chi_from_gg2_PH(p.G_iw, p.G2_iw_ph)
    loc_bse.chi0_wnn = chi0_from_gg2_PH(p.G_iw, p.G2_iw_ph)

    loc_bse.gamma_wnn = inverse_PH(loc_bse.chi0_wnn) - inverse_PH(
        loc_bse.chi_wnn)
    loc_bse.chi_wnn_ref = inverse_PH(
        inverse_PH(loc_bse.chi0_wnn) - loc_bse.gamma_wnn)

    np.testing.assert_array_almost_equal(loc_bse.chi_wnn.data,
                                         loc_bse.chi_wnn_ref.data)

    from triqs_tprf.bse import solve_local_bse
    loc_bse.gamma_wnn_ref = solve_local_bse(loc_bse.chi0_wnn, loc_bse.chi_wnn)

    np.testing.assert_array_almost_equal(loc_bse.gamma_wnn.data,
                                         loc_bse.gamma_wnn_ref.data)

    loc_bse.chi0_w = trace_nn(loc_bse.chi0_wnn)
    loc_bse.chi_w = trace_nn(loc_bse.chi_wnn)

    # ------------------------------------------------------------------
    # -- RPA, using BSE inverses and constant Gamma

    loc_rpa = ParameterCollection()

    loc_rpa.chi0_wnn = loc_bse.chi0_wnn
    loc_rpa.chi0_w = loc_bse.chi0_w

    loc_rpa.U_abcd = p.U_abcd

    # -- Build constant gamma
    from triqs_tprf.rpa_tensor import get_gamma_rpa
    loc_rpa.gamma_wnn = get_gamma_rpa(loc_rpa.chi0_wnn, loc_rpa.U_abcd)

    # -- Solve RPA
    loc_rpa.chi_wnn = inverse_PH(
        inverse_PH(loc_rpa.chi0_wnn) - loc_rpa.gamma_wnn)
    loc_rpa.chi_w = trace_nn(loc_rpa.chi_wnn)

    # ------------------------------------------------------------------
    # -- Bubble RPA on lattice

    lat_rpa = ParameterCollection()

    # -- Setup dummy lattice Green's function equal to local Green's function

    bz = BrillouinZone(
        BravaisLattice(units=np.eye(3), orbital_positions=[(0, 0, 0)]))
    periodization_matrix = np.diag(np.array(list([1] * 3), dtype=np.int32))
    kmesh = MeshBrillouinZone(bz, periodization_matrix)
    wmesh = MeshImFreq(beta=p.beta, S='Fermion', n_max=p.nwf_gf)

    lat_rpa.g_wk = Gf(mesh=MeshProduct(wmesh, kmesh),
                      target_shape=p.G_iw.target_shape)
    lat_rpa.g_wk[:, Idx(0, 0, 0)] = p.G_iw

    # -- chi0_wk bubble and chi_wk_rpa bubble RPA

    from triqs_tprf.lattice_utils import imtime_bubble_chi0_wk
    lat_rpa.chi0_wk = imtime_bubble_chi0_wk(lat_rpa.g_wk, nw=1)

    from triqs_tprf.lattice import solve_rpa_PH
    lat_rpa.chi_wk = solve_rpa_PH(lat_rpa.chi0_wk, p.U_abcd)

    lat_rpa.chi0_w = lat_rpa.chi0_wk[:, Idx(0, 0, 0)]
    lat_rpa.chi_w = lat_rpa.chi_wk[:, Idx(0, 0, 0)]

    print '--> cf Tr[chi0] and chi0_wk'
    print loc_rpa.chi0_w.data.reshape((4, 4)).real
    print lat_rpa.chi0_w.data.reshape((4, 4)).real

    np.testing.assert_array_almost_equal(loc_rpa.chi0_w.data,
                                         lat_rpa.chi0_w.data,
                                         decimal=2)

    print 'ok!'

    print '--> cf Tr[chi_rpa] and chi_wk_rpa'
    print loc_rpa.chi_w.data.reshape((4, 4)).real
    print lat_rpa.chi_w.data.reshape((4, 4)).real

    np.testing.assert_array_almost_equal(loc_rpa.chi_w.data,
                                         lat_rpa.chi_w.data,
                                         decimal=2)

    print 'ok!'

    # ------------------------------------------------------------------
    # -- Lattice BSE

    lat_bse = ParameterCollection()

    lat_bse.g_wk = lat_rpa.g_wk

    lat_bse.mu = p.mu

    lat_bse.e_k = Gf(mesh=kmesh, target_shape=p.G_iw.target_shape)
    lat_bse.e_k[Idx(0, 0, 0)] = np.eye(2)

    lat_bse.sigma_w = p.G_iw.copy()
    lat_bse.sigma_w << iOmega_n + lat_bse.mu * np.eye(2) - lat_bse.e_k[Idx(
        0, 0, 0)] - inverse(p.G_iw)

    lat_bse.g_wk_ref = lat_bse.g_wk.copy()
    lat_bse.g_wk_ref[:, Idx(0, 0, 0)] << inverse(iOmega_n +
                                                 lat_bse.mu * np.eye(2) -
                                                 lat_bse.e_k[Idx(0, 0, 0)] -
                                                 lat_bse.sigma_w)

    np.testing.assert_array_almost_equal(lat_bse.g_wk.data,
                                         lat_bse.g_wk_ref.data)

    #for w in lat_bse.g_wk.mesh.components[0]:
    #    print w, lat_bse.g_wk[w, Idx(0,0,0)][0, 0]

    from triqs_tprf.lattice import fourier_wk_to_wr
    lat_bse.g_wr = fourier_wk_to_wr(lat_bse.g_wk)

    from triqs_tprf.lattice import chi0r_from_gr_PH
    lat_bse.chi0_wnr = chi0r_from_gr_PH(nw=1, nn=p.nwf, g_nr=lat_bse.g_wr)

    from triqs_tprf.lattice import chi0q_from_chi0r
    lat_bse.chi0_wnk = chi0q_from_chi0r(lat_bse.chi0_wnr)

    #for n in lat_bse.chi0_wnk.mesh.components[1]:
    #    print n.value, lat_bse.chi0_wnk[Idx(0), n, Idx(0,0,0)][0,0,0,0]

    # -- Lattice BSE calc
    from triqs_tprf.lattice import chiq_from_chi0q_and_gamma_PH
    lat_bse.chi_kwnn = chiq_from_chi0q_and_gamma_PH(lat_bse.chi0_wnk,
                                                    loc_bse.gamma_wnn)

    # -- Lattice BSE calc with built in trace
    from triqs_tprf.lattice import chiq_sum_nu_from_chi0q_and_gamma_PH
    lat_bse.chi_kw_ref = chiq_sum_nu_from_chi0q_and_gamma_PH(
        lat_bse.chi0_wnk, loc_bse.gamma_wnn)

    # -- Lattice BSE calc with built in trace using g_wk
    from triqs_tprf.lattice import chiq_sum_nu_from_g_wk_and_gamma_PH
    lat_bse.chi_kw_tail_corr_ref = chiq_sum_nu_from_g_wk_and_gamma_PH(
        lat_bse.g_wk, loc_bse.gamma_wnn)

    # -- Trace results
    from triqs_tprf.lattice import chi0q_sum_nu_tail_corr_PH
    from triqs_tprf.lattice import chi0q_sum_nu
    lat_bse.chi0_wk_tail_corr = chi0q_sum_nu_tail_corr_PH(lat_bse.chi0_wnk)
    lat_bse.chi0_wk = chi0q_sum_nu(lat_bse.chi0_wnk)

    from triqs_tprf.lattice import chiq_sum_nu, chiq_sum_nu_q
    lat_bse.chi_kw = chiq_sum_nu(lat_bse.chi_kwnn)

    np.testing.assert_array_almost_equal(lat_bse.chi_kw.data,
                                         lat_bse.chi_kw_ref.data)

    from triqs_tprf.bse import solve_lattice_bse
    lat_bse.chi_kw_tail_corr, tmp = solve_lattice_bse(lat_bse.g_wk,
                                                      loc_bse.gamma_wnn)

    from triqs_tprf.bse import solve_lattice_bse_e_k_sigma_w
    lat_bse.chi_kw_tail_corr_new = solve_lattice_bse_e_k_sigma_w(
        lat_bse.mu, lat_bse.e_k, lat_bse.sigma_w, loc_bse.gamma_wnn)

    np.testing.assert_array_almost_equal(lat_bse.chi_kw_tail_corr.data,
                                         lat_bse.chi_kw_tail_corr_ref.data)
    np.testing.assert_array_almost_equal(lat_bse.chi_kw_tail_corr.data,
                                         lat_bse.chi_kw_tail_corr_new.data)
    np.testing.assert_array_almost_equal(lat_bse.chi_kw_tail_corr_ref.data,
                                         lat_bse.chi_kw_tail_corr_new.data)

    lat_bse.chi0_w_tail_corr = lat_bse.chi0_wk_tail_corr[:, Idx(0, 0, 0)]
    lat_bse.chi0_w = lat_bse.chi0_wk[:, Idx(0, 0, 0)]
    lat_bse.chi_w_tail_corr = lat_bse.chi_kw_tail_corr[Idx(0, 0, 0), :]
    lat_bse.chi_w = lat_bse.chi_kw[Idx(0, 0, 0), :]

    print '--> cf Tr[chi0_wnk] and chi0_wk'
    print lat_bse.chi0_w_tail_corr.data.reshape((4, 4)).real
    print lat_bse.chi0_w.data.reshape((4, 4)).real
    print lat_rpa.chi0_w.data.reshape((4, 4)).real

    np.testing.assert_array_almost_equal(lat_bse.chi0_w_tail_corr.data,
                                         lat_rpa.chi0_w.data)

    np.testing.assert_array_almost_equal(lat_bse.chi0_w.data,
                                         lat_rpa.chi0_w.data,
                                         decimal=2)

    print 'ok!'

    print '--> cf Tr[chi_kwnn] and chi_wk (without chi0 tail corr)'
    print lat_bse.chi_w.data.reshape((4, 4)).real
    print loc_bse.chi_w.data.reshape((4, 4)).real

    np.testing.assert_array_almost_equal(lat_bse.chi_w.data,
                                         loc_bse.chi_w.data)

    print 'ok!'

    # ------------------------------------------------------------------
    # -- Use chi0 tail corrected trace to correct chi_rpa cf bubble

    dchi_wk = lat_bse.chi0_wk_tail_corr - lat_bse.chi0_wk
    dchi_w = dchi_wk[:, Idx(0, 0, 0)]

    loc_rpa.chi_w_tail_corr = loc_rpa.chi_w + dchi_w

    # -- this will be the same, but it will be close to the real physical value
    lat_bse.chi_w_tail_corr_ref = lat_bse.chi_w + dchi_w
    loc_bse.chi_w_tail_corr_ref = loc_bse.chi_w + dchi_w

    print '--> cf Tr[chi_rpa] and chi_wk_rpa'
    print loc_rpa.chi_w.data.reshape((4, 4)).real
    print loc_rpa.chi_w_tail_corr.data.reshape((4, 4)).real
    print lat_rpa.chi_w.data.reshape((4, 4)).real

    np.testing.assert_array_almost_equal(loc_rpa.chi_w_tail_corr.data,
                                         lat_rpa.chi_w.data,
                                         decimal=3)

    print '--> cf Tr[chi_kwnn] with tail corr (from chi0_wnk)'
    print lat_bse.chi_w_tail_corr.data.reshape((4, 4)).real
    print lat_bse.chi_w_tail_corr_ref.data.reshape((4, 4)).real

    np.testing.assert_array_almost_equal(lat_bse.chi_w_tail_corr.data,
                                         lat_bse.chi_w_tail_corr_ref.data)

    print 'ok!'

    # ------------------------------------------------------------------
    # -- Store to hdf5

    filename = 'data_bse_rpa.h5'
    with HDFArchive(filename, 'w') as res:
        res['p'] = p
Beispiel #21
0
# ----------------------------------------------------------------------
if __name__ == '__main__':

    with HDFArchive("data_ctint.h5", 'r') as results:
        p = results["p"]

    print p
    p.G_iw['up'].name = r'$G_{ctint, \uparrow}$'
    p.G_iw['dn'].name = r'$G_{ctint, \downarrow}$'

    p.chi_m = p.G2_iw[('up', 'up')] - p.G2_iw[('up', 'dn')]

    parm = ParameterCollection(
        U=p.U,
        beta=p.beta,
        nw=1,
        nwf=p.n_iw / 2,
        nwf_gf=p.n_iw,
    )

    a = analytic_hubbard_atom(**parm.dict())
    a.G_iw.name = r'$G_{analytic}$'

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

    subp = [2, 2, 1]

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

    oploti(p.G_iw)
Beispiel #22
0
def analytic_hubbard_atom(beta, U, nw, nwf, nwf_gf):

    d = ParameterCollection()
    d.beta, d.U, d.nw, d.nwf, d.nwf_gf = beta, U, nw, nwf, nwf_gf

    g_iw = single_particle_greens_function(beta=beta, U=U, nw=nwf_gf)
    d.G_iw = g_iw

    # make block gf of the single gf
    G_iw_block = BlockGf(name_list=['up', 'dn'], block_list=[g_iw, g_iw])
    g_mat = block_iw_AB_to_matrix_valued(G_iw_block)

    d.chi_m = chi_ph_magnetic(beta=beta, U=U, nw=nw, nwf=nwf)
    d.chi0_m = chi0_from_gg2_PH(g_mat, d.chi_m)

    # -- Numeric vertex from BSE
    d.gamma_m_num = inverse_PH(d.chi0_m) - inverse_PH(d.chi_m)

    # -- Analytic vertex
    d.gamma_m = gamma_ph_magnetic(beta=beta, U=U, nw=nw, nwf=nwf)

    # -- Analytic magnetization expecation value
    # -- and static susceptibility

    d.Z = 2. + 2 * np.exp(-beta * 0.5 * U)
    d.m2 = 0.25 * (2 / d.Z)
    d.chi_m_static = 2. * beta * d.m2

    d.label = r'Analytic'

    return d
Beispiel #23
0
def get_chi0_wnk(g_wk, nw=1, nwf=None):

    fmesh = g_wk.mesh.components[0]
    kmesh = g_wk.mesh.components[1]

    if nwf is None:
        nwf = len(fmesh) / 2

    mpi.barrier()
    mpi.report('g_wk ' + str(g_wk[Idx(2), Idx(0, 1, 2)][0, 0]))
    n = np.sum(g_wk.data) / len(kmesh)
    mpi.report('n ' + str(n))
    mpi.barrier()

    mpi.report('--> g_wr from g_wk')
    g_wr = fourier_wk_to_wr(g_wk)

    mpi.barrier()
    mpi.report('g_wr ' + str(g_wr[Idx(2), Idx(0, 1, 2)][0, 0]))
    n_r = np.sum(g_wr.data, axis=0)[0]
    mpi.report('n_r=0 ' + str(n_r[0, 0]))
    mpi.barrier()

    mpi.report('--> chi0_wnr from g_wr')
    chi0_wnr = chi0r_from_gr_PH(nw=nw, nnu=nwf, gr=g_wr)

    #mpi.report('--> chi0_wnr from g_wr (nompi)')
    #chi0_wnr_nompi = chi0r_from_gr_PH_nompi(nw=nw, nnu=nwf, gr=g_wr)

    del g_wr

    #abs_diff = np.abs(chi0_wnr.data - chi0_wnr_nompi.data)
    #mpi.report('shape = ' + str(abs_diff.shape))
    #idx = np.argmax(abs_diff)
    #mpi.report('argmax = ' + str(idx))
    #diff = np.max(abs_diff)
    #mpi.report('diff = %6.6f' % diff)
    #del chi0_wnr
    #chi0_wnr = chi0_wnr_nompi

    #exit()

    mpi.barrier()
    mpi.report('chi0_wnr ' +
               str(chi0_wnr[Idx(0), Idx(0), Idx(0, 0, 0)][0, 0, 0, 0]))
    chi0_r0 = np.sum(chi0_wnr[:, :, Idx(0, 0, 0)].data)
    mpi.report('chi0_r0 ' + str(chi0_r0))
    mpi.barrier()

    mpi.report('--> chi0_wnk from chi0_wnr')
    chi0_wnk = chi0q_from_chi0r(chi0_wnr)

    del chi0_wnr

    mpi.barrier()
    mpi.report('chi0_wnk ' +
               str(chi0_wnk[Idx(0), Idx(0), Idx(0, 0, 0)][0, 0, 0, 0]))
    chi0 = np.sum(chi0_wnk.data) / len(kmesh)
    mpi.report('chi0 = ' + str(chi0))
    mpi.barrier()

    #if mpi.is_master_node():
    if False:
        from triqs_tprf.ParameterCollection import ParameterCollection
        p = ParameterCollection()
        p.g_wk = g_wk
        p.g_wr = g_wr
        p.chi0_wnr = chi0_wnr
        p.chi0_wnk = chi0_wnk

        print '--> Writing debug info for BSE'
        with HDFArchive('data_debug_bse.h5', 'w') as arch:
            arch['p'] = p

    mpi.barrier()

    return chi0_wnk
Beispiel #24
0
    # With block structure
    G_lst = []
    for bl, idx_lst in struct:
        G_lst.append(Gf(mesh=mesh, indices=idx_lst))
    return BlockGf(name_list=[bl[0] for bl in struct], block_list=G_lst)


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

    p = ParameterCollection(
        beta=5.,
        U=5.,
        mu=2.5,
        h=0.0,
        n_iw=100,
        delta=0.1,
        gf_struct=[['up', [0]], ['dn', [0]]],
        store_list=['G_iw', 'G2_iw', 'G2c_iw'],
    )

    p.solver_core = ParameterCollection(beta=p.beta,
                                        gf_struct=dict(p.gf_struct),
                                        n_iw=p.n_iw,
                                        n_tau=100001)

    p.solve = ParameterCollection(
        n_warmup_cycles=int(1e4),
        #n_cycles = 10000000,
        n_cycles=int(1e4) / mpi.size,
        length_cycle=20,
Beispiel #25
0
def make_calc():

    # ------------------------------------------------------------------
    # -- Hamiltonian

    p = ParameterCollection(
        beta = 0.5,
        U = 0.5,
        nw = 1,
        nwf = 15,
        V = 1.0,
        eps = 0.2,
        )

    p.nwf_gf = 4 * p.nwf
    p.mu = 0.5*p.U

    # ------------------------------------------------------------------

    ca_up, cc_up = c('0', 0), c_dag('0', 0)
    ca_do, cc_do = c('0', 1), c_dag('0', 1)

    ca0_up, cc0_up = c('1', 0), c_dag('1', 0)
    ca0_do, cc0_do = c('1', 1), c_dag('1', 1)

    docc = cc_up * ca_up * cc_do * ca_do
    nA = cc_up * ca_up + cc_do * ca_do
    hybridiz = p.V * (cc0_up * ca_up + cc_up * ca0_up + cc0_do * ca_do + cc_do * ca0_do)
    bath_lvl = p.eps * (cc0_up * ca0_up + cc0_do * ca0_do)

    p.H_int = p.U * docc
    p.H = -p.mu * nA + p.H_int + hybridiz + bath_lvl

    # ------------------------------------------------------------------
    # -- Exact diagonalization

    # Conversion from TRIQS to Pomerol notation for operator indices
    # TRIQS:   block_name, inner_index
    # Pomerol: site_label, orbital_index, spin_name
    index_converter = {
        ('0', 0) : ('loc', 0, 'up'),
        ('0', 1) : ('loc', 0, 'down'),
        ('1', 0) : ('loc', 1, 'up'),
        ('1', 1) : ('loc', 1, 'down'),
        }

    # -- Create Exact Diagonalization instance
    ed = PomerolED(index_converter, verbose=True)
    ed.diagonalize(p.H) # -- Diagonalize H

    p.gf_struct = [['0', [0, 1]]]

    # -- Single-particle Green's functions
    p.G_iw = ed.G_iw(p.gf_struct, p.beta, n_iw=p.nwf_gf)['0']

    # -- Particle-particle two-particle Matsubara frequency Green's function
    opt = dict(
        beta=p.beta, gf_struct=p.gf_struct,
        blocks=set([("0", "0")]),
        n_iw=p.nw, n_inu=p.nwf)

    p.G2_iw_ph = ed.G2_iw_inu_inup(channel='PH', **opt)[('0', '0')]

    filename = 'data_pomerol.h5'
    with HDFArchive(filename,'w') as res:
        res['p'] = p

    import os
    os.system('tar czvf data_pomerol.tar.gz data_pomerol.h5')
    os.remove('data_pomerol.h5')
Beispiel #26
0
def make_calc():

    # ------------------------------------------------------------------
    # -- Hubbard atom with two bath sites, Hamiltonian

    p = ParameterCollection(
        beta=1.0,
        U=5.0,
        nw=1,
        nwf=20,
    )

    p.nwf_gf = 4 * p.nwf
    p.mu = 0.5 * p.U

    # ------------------------------------------------------------------

    ca_up, cc_up = c('0', 0), c_dag('0', 0)
    ca_do, cc_do = c('0', 1), c_dag('0', 1)

    docc = cc_up * ca_up * cc_do * ca_do
    nA = cc_up * ca_up + cc_do * ca_do
    p.H = -p.mu * nA + p.U * docc

    # ------------------------------------------------------------------
    # -- Exact diagonalization

    # Conversion from TRIQS to Pomerol notation for operator indices
    # TRIQS:   block_name, inner_index
    # Pomerol: site_label, orbital_index, spin_name
    index_converter = {
        ('0', 0): ('loc', 0, 'up'),
        ('0', 1): ('loc', 0, 'down'),
    }

    # -- Create Exact Diagonalization instance
    ed = PomerolED(index_converter, verbose=True)
    ed.diagonalize(p.H)  # -- Diagonalize H

    gf_struct = [['0', [0, 1]]]

    # -- Single-particle Green's functions
    p.G_iw = ed.G_iw(gf_struct, p.beta, n_iw=p.nwf_gf)['0']

    # -- Particle-particle two-particle Matsubara frequency Green's function
    opt = dict(beta=p.beta,
               gf_struct=gf_struct,
               blocks=set([("0", "0")]),
               n_iw=p.nw,
               n_inu=p.nwf)

    p.G2_iw_ph = ed.G2_iw_inu_inup(channel='PH', **opt)[('0', '0')]

    # ------------------------------------------------------------------
    # -- Generalized susceptibility in magnetic PH channel

    p.chi_m = Gf(mesh=p.G2_iw_ph.mesh, target_shape=[1, 1, 1, 1])
    p.chi_m[0, 0, 0, 0] = p.G2_iw_ph[0, 0, 0, 0] - p.G2_iw_ph[0, 0, 1, 1]

    p.chi0_m = chi0_from_gg2_PH(p.G_iw, p.chi_m)
    p.label = r'Pomerol'

    # ------------------------------------------------------------------
    # -- Generalized susceptibility in PH channel

    p.chi = chi_from_gg2_PH(p.G_iw, p.G2_iw_ph)
    p.chi0 = chi0_from_gg2_PH(p.G_iw, p.G2_iw_ph)
    p.gamma = inverse_PH(p.chi0) - inverse_PH(p.chi)

    # ------------------------------------------------------------------
    # -- Store to hdf5

    filename = 'data_pomerol.h5'
    with HDFArchive(filename, 'w') as res:
        res['p'] = p