Exemple #1
0
    E_tot_ref = get_total_energy_mf_ref(t, beta, U, mu, n, m)
    print('E_tot_ref =', E_tot_ref)

    print('--> tight binding model')
    t_r = get_tb_model(t, U, n, m, mu=0.)

    print('--> dispersion e_k')
    kmesh = t_r.get_kmesh(n_k)
    e_k = t_r.fourier(kmesh)

    #print e_k.data

    print('--> lattice g0_wk')
    wmesh = MeshImFreq(beta=beta, S='Fermion', n_max=nw)
    g0_wk = lattice_dyson_g0_wk(mu=mu, e_k=e_k, mesh=wmesh)

    E_kin = get_kinetic_energy(e_k, g0_wk)
    print('E_kin =', E_kin)

    np.testing.assert_almost_equal(E_kin_ref, E_kin, decimal=6)

    rho = get_density_matrix(g0_wk)
    print('rho =\n', rho)

    n = rho[0, 0] + rho[1, 1]
    m = 0.5 * (rho[0, 0] - rho[1, 1])

    print('n, m =', n, m)

    E_tot = E_kin - U * (n**2 / 4 - m**2)
Exemple #2
0
def test_square_lattice_chi00():

    # ------------------------------------------------------------------
    # -- Discretizations

    n_k = (2, 2, 1)
    nw_g = 500
    nn = 400
    nw = 1

    # ------------------------------------------------------------------
    # -- tight binding parameters

    beta = 20.0
    mu = 0.0
    t = 1.0

    h_loc = np.array([
        [-0.3, -0.5],
        [-0.5, .4],
    ])

    T = -t * np.array([
        [1., 0.23],
        [0.23, 0.5],
    ])

    # ------------------------------------------------------------------
    # -- tight binding

    print('--> tight binding model')
    t_r = TBLattice(
        units=[(1, 0, 0), (0, 1, 0)],
        hopping={
            # nearest neighbour hopping -t
            (0, 0): h_loc,
            (0, +1): T,
            (0, -1): T,
            (+1, 0): T,
            (-1, 0): T,
        },
        orbital_positions=[(0, 0, 0)] * 2,
        orbital_names=['up_0', 'do_0'],
    )

    kmesh = t_r.get_kmesh(n_k)
    e_k = t_r.fourier(kmesh)

    wmesh = MeshImFreq(beta=beta, S='Fermion', n_max=nw_g)

    print('--> g0_wk')
    g0_wk = lattice_dyson_g0_wk(mu=mu, e_k=e_k, mesh=wmesh)

    print('--> g0_wr')
    g0_wr = fourier_wk_to_wr(g0_wk)

    print('--> g0_tr')
    g0_tr = fourier_wr_to_tr(g0_wr)

    # ------------------------------------------------------------------
    # -- anaytic chi00

    print('--> chi00_wk analytic')
    chi00_wk_analytic = lindhard_chi00_wk(e_k=e_k, nw=nw, beta=beta, mu=mu)

    print('--> chi00_wr analytic')
    chi00_wr_analytic = chi_wr_from_chi_wk(chi00_wk_analytic)

    # ------------------------------------------------------------------
    # -- imtime chi00

    print('--> chi0_tr_from_grt_PH')
    chi00_tr = chi0_tr_from_grt_PH(g0_tr)

    print('--> chi_wr_from_chi_tr')
    chi00_wr = chi_wr_from_chi_tr(chi00_tr, nw=1)

    print('--> chi_w0r_from_chi_tr')
    chi00_wr_ref = chi_w0r_from_chi_tr(chi00_tr)

    print('--> chi0_w0r_from_grt_PH')
    chi00_wr_opt = chi0_w0r_from_grt_PH(g0_tr)

    print('dchi00_wr     =',
          np.max(np.abs(chi00_wr_analytic.data - chi00_wr.data)))
    print('dchi00_wr_ref =',
          np.max(np.abs(chi00_wr_analytic.data - chi00_wr_ref.data)))
    print('dchi00_wr_opt =',
          np.max(np.abs(chi00_wr_analytic.data - chi00_wr_opt.data)))

    np.testing.assert_array_almost_equal(chi00_wr_analytic.data,
                                         chi00_wr.data,
                                         decimal=8)

    np.testing.assert_array_almost_equal(chi00_wr_analytic.data,
                                         chi00_wr_ref.data,
                                         decimal=4)

    np.testing.assert_array_almost_equal(chi00_wr_analytic.data,
                                         chi00_wr_opt.data,
                                         decimal=4)

    print('--> chi_wk_from_chi_wr')
    chi00_wk_imtime = chi_wk_from_chi_wr(chi00_wr)

    # ------------------------------------------------------------------
    # -- imtime chi00 helper function

    chi00_wk_imtime_2 = imtime_bubble_chi0_wk(g0_wk, nw=1)

    # ------------------------------------------------------------------
    # -- imfreq chi00

    print('--> chi00_wnr')
    chi00_wnr = chi0r_from_gr_PH(nw=1, nn=nn, g_nr=g0_wr)

    print('--> chi00_wnk')
    chi00_wnk = chi0q_from_chi0r(chi00_wnr)

    # -- Test per k and w calculator for chi0_wnk
    print('--> chi00_wnk_ref')
    from triqs_tprf.lattice import chi0q_from_g_wk_PH
    chi00_wnk_ref = chi0q_from_g_wk_PH(nw=1, nn=nn, g_wk=g0_wk)

    diff = np.max(np.abs(chi00_wnk.data - chi00_wnk_ref.data))
    print('chi00_wnk diff =', diff)
    np.testing.assert_array_almost_equal(chi00_wnk.data, chi00_wnk_ref.data)

    print('--> chi00_wk_imfreq')
    chi00_wk_imfreq = chi0q_sum_nu(chi00_wnk)

    print('--> chi00_wk_imfreq_tail_corr')
    chi00_wk_imfreq_tail_corr = chi0q_sum_nu_tail_corr_PH(chi00_wnk)

    # ------------------------------------------------------------------
    # -- Compare results

    def cf_chi_w0(chi1, chi2, decimal=9):
        chi1, chi2 = chi1[Idx(0), :].data, chi2[Idx(0), :].data
        diff = np.linalg.norm(chi1 - chi2)
        print('|dchi| =', diff)
        np.testing.assert_array_almost_equal(chi1, chi2, decimal=decimal)

    print('--> Cf analytic with imtime')
    cf_chi_w0(chi00_wk_analytic, chi00_wk_imtime, decimal=7)

    print('--> Cf analytic with imtime 2')
    cf_chi_w0(chi00_wk_analytic, chi00_wk_imtime_2, decimal=4)

    print('--> Cf analytic with imfreq')
    cf_chi_w0(chi00_wk_analytic, chi00_wk_imfreq, decimal=2)

    print('--> Cf analytic with imfreq (tail corr)')
    cf_chi_w0(chi00_wk_analytic, chi00_wk_imfreq_tail_corr, decimal=5)
import pytriqs.utility.mpi as mpi

from pytriqs.gf import Gf, MeshImFreq, MeshProduct
from pytriqs.gf import MeshBrillouinZone, MeshCyclicLattice
from pytriqs.lattice import BrillouinZone, BravaisLattice

from triqs_tprf.lattice import lattice_dyson_g0_wk
from triqs_tprf.lattice import fourier_wk_to_wr
from triqs_tprf.lattice import fourier_wr_to_wk

bz = BrillouinZone(BravaisLattice([[1, 0], [0, 1]]))

periodization_matrix = np.diag(np.array([10, 10, 1], dtype=np.int32))

bzmesh = MeshBrillouinZone(bz, periodization_matrix)
lmesh = MeshCyclicLattice(bz.lattice, periodization_matrix)

e_k = Gf(mesh=bzmesh, target_shape=[1, 1])

for k in bzmesh:
    e_k[k] = -2 * (np.cos(k[0]) + np.cos(k[1]))  # does not work...

mesh = MeshImFreq(beta=1.0, S='Fermion', n_max=1024)
g0_wk = lattice_dyson_g0_wk(mu=1.0, e_k=e_k, mesh=mesh)

g0_wr = fourier_wk_to_wr(g0_wk)
g0_wk_ref = fourier_wr_to_wk(g0_wr)

np.testing.assert_array_almost_equal(g0_wk.data, g0_wk_ref.data)
Exemple #4
0
H = TBLattice(
            units = full_units[:p.dim],
            hopping = {hop : t for hop in non_diagonal_hoppings},
            orbital_positions = [(0,0,0)]*p.norbs,
            )

e_k = H.on_mesh_brillouin_zone(n_k=[p.nk]*p.dim + [1]*(3-p.dim))

# A bigger w-mesh is needed to construct a Gamma with a twice as big w-mesh than GF
big_factor = 2.0

wmesh = MeshImFreq(beta=p.beta, S='Fermion', n_max=p.nw)
wmesh_big = MeshImFreq(beta=p.beta, S='Fermion', n_max=int(big_factor*p.nw))

g0_wk = lattice_dyson_g0_wk(mu=p.mu, e_k=e_k, mesh=wmesh)
g0_wk_big = lattice_dyson_g0_wk(mu=p.mu, e_k=e_k, mesh=wmesh_big)

chi0_wk_big = imtime_bubble_chi0_wk(g0_wk_big, nw=int(big_factor*p.nw)+1)

U_c, U_s = kanamori_charge_and_spin_quartic_interaction_tensors(p.norbs, p.U, 0, 0, 0)

chi_s_big = solve_rpa_PH(chi0_wk_big, U_s)
chi_c_big = solve_rpa_PH(chi0_wk_big, -U_c) # Minus for correct charge rpa equation

gamma_big = gamma_PP_singlet(chi_c_big, chi_s_big, U_c, U_s)

# -- Preprocess gamma for the FFT implementation

gamma_dyn_wk, gamma_const_k = split_into_dynamic_wk_and_constant_k(gamma_big)
gamma_dyn_tr, gamma_const_r = dynamic_and_constant_to_tr(gamma_dyn_wk, gamma_const_k)
Exemple #5
0
import numpy as np
from triqs_tprf.tight_binding import TBLattice
import triqs_tprf as trpf
from pytriqs.gf import *
from triqs_tprf.lattice import lattice_dyson_g0_wk
import matplotlib.pyplot as plt
t = 1.0
H = TBLattice(
    units=[(1, 0, 0), (0, 1, 0)],
    hopping={
        # nearest neighbour hopping -t
        (0, +1): -t * np.eye(2),
        (0, -1): -t * np.eye(2),
        (+1, 0): -t * np.eye(2),
        (-1, 0): -t * np.eye(2),
    },
    orbital_positions=[(0, 0, 0)] * 2,
    orbital_names=['up', 'do'],
)
e_k = H.on_mesh_brillouin_zone(n_k=(32, 32, 1))

beta = 50
n_iw = 130
mu = -5
imesh = MeshImFreq(beta, 'Fermion', n_iw)
g = lattice_dyson_g0_wk(mu, e_k, imesh)

gm = GfImFreq(mesh=imesh, data=g[(0, 0)].data[:, 0].reshape(-1, 1, 1), beta=50)
g_pade = GfReFreq(window=(-2, 2), n_points=200, target_shape=[1, 1])
g_pade.set_from_pade(gm)
print(g_pade.data.shape)