示例#1
0
def setup_dmft_calculation(p):

    p = copy.deepcopy(p)
    p.iter = 0

    # -- Local Hubbard interaction
    from triqs.operators import n
    p.solve.h_int = p.U * n('up', 0) * n(
        'do', 0) - 0.5 * p.U * (n('up', 0) + n('do', 0))

    # -- 2D square lattice w. nearest neighbour hopping t
    from triqs_tprf.tight_binding import TBLattice
    T = -p.t * np.eye(2)
    H = TBLattice(units=[(1, 0, 0), (0, 1, 0)],
                  orbital_positions=[(0, 0, 0)] * 2,
                  orbital_names=['up', 'do'],
                  hopping={
                      (0, +1): T,
                      (0, -1): T,
                      (+1, 0): T,
                      (-1, 0): T
                  })

    kmesh = H.get_kmesh(n_k=(p.n_k, p.n_k, 1))
    p.e_k = H.fourier(kmesh)

    # -- Initial zero guess for the self-energy
    p.sigma_w = Gf(mesh=MeshImFreq(p.init.beta, 'Fermion', p.init.n_iw),
                   target_shape=[2, 2])
    p.sigma_w.zero()

    return p
示例#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)
示例#3
0
    T = -t * np.eye(1)
    t_r = TBLattice(
        units=[(1, 0, 0), (0, 1, 0)],
        hopping={
            # nearest neighbour hopping -t
            (0, +1): T,
            (0, -1): T,
            (+1, 0): T,
            (-1, 0): T,
        },
        orbital_positions=[(0, 0, 0)],
        orbital_names=['0'],
    )

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

    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)

    # -- Call TPRF chi0_wk bubble calc
    chi00_wk = imtime_bubble_chi0_wk(g0_wk, nw=1)

    # -- Analytic reference (Lindhard formula in momentum space)
    print('--> lindhard_chi00_wk')
    kmesh = t_r.get_kmesh(n_k=(32, 32, 1))
    e_k = t_r.fourier(kmesh)
    chi00_wk_analytic = lindhard_chi00_wk(e_k=e_k, nw=1, beta=beta, mu=mu)
示例#4
0
import sys

import numpy as np

from triqs.gf import Gf, MeshImFreq, Idx

from triqs_tprf.tight_binding import TBLattice
from triqs_tprf.lattice import lattice_dyson_g0_wk

norb, nk, nw = [int(ele) for ele in sys.argv[1:]]

t = -2.0 * np.eye(norb)
t_r = TBLattice(
    units=[(1, 0, 0)],
    hopping={
        (+1, ): t,
        (-1, ): t,
    },
    orbital_positions=[(0, 0, 0)] * norb,
    orbital_names=[str(ele) for ele in range(norb)],
)

kmesh = t_r.get_kmesh((nk, 1, 1))
e_k = t_r.fourier(kmesh)
wmesh = MeshImFreq(beta=1.0, S='Fermion', n_max=nw)

g0_wk = lattice_dyson_g0_wk(mu=0.0, e_k=e_k, mesh=wmesh)

print(g0_wk.data.shape)
示例#5
0
                # nearest neighbour hopping -t
                (0,): h_loc,
                (+1,): T,
                (-1,): T,
                },
            orbital_positions = [(0,0,0)] * norb,
            orbital_names = ['up_0', 'do_0'],
            )

        Sz = np.kron(np.diag([+0.5, -0.5]), np.eye((1)))

    print('h_loc =\n', h_loc)
    print('T = \n', T)
    print('Sz =\n', Sz)
    
    kmesh = t_r.get_kmesh(n_k=(n_k, 1, 1))
    e_k = t_r.fourier(kmesh)
    
    # ------------------------------------------------------------------
    # -- Hartree solver

    hs = HartreeSolver(e_k, beta, H_int, gf_struct)
    eps = 1e-9

    hr = HartreeResponse(hs, eps=eps)

    hr.chi0_SzSz = hr.bare_response(Sz, Sz)
    hr.chi_SzSz = hr.response(Sz, Sz)

    hfr = HartreeFockResponse(hs, eps=eps)
示例#6
0
from triqs_tprf.tight_binding import TBLattice

t_r = TBLattice(
    units = [(1, 0, 0)],
    hopping = {
        # nearest neighbour hopping -t
        (0,): h_loc,
        (+1,): T,
        (-1,): T,
        },
    orbital_positions = [(0,0,0)] * norb,
    orbital_names = ['up_0', 'do_0', 'up_1', 'do_1'],
    )

kmesh = t_r.get_kmesh(n_k=(256, 1, 1))
e_k = t_r.fourier(kmesh)

# ----------------------------------------------------------------------
# -- Bare susceptibility from Green's function bubble

nw = 20
beta = 0.544

from triqs.gf import MeshImFreq, Idx
wmesh = MeshImFreq(beta=beta, S='Fermion', n_max=nw)

from triqs_tprf.lattice import lattice_dyson_g0_wk
g0_wk = lattice_dyson_g0_wk(mu=0., e_k=e_k, mesh=wmesh)

from triqs_tprf.lattice_utils import imtime_bubble_chi0_wk
示例#7
0
beta = 40.0

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

t = -1.0 * np.eye(norbs)

H = TBLattice(
    units=full_units[:dim],
    hopping={hop: t
             for hop in non_diagonal_hoppings},
    orbital_positions=[(0, 0, 0)] * norbs,
)
kmesh = H.get_kmesh(n_k=[nk] * dim + [1] * (3 - dim))
e_k = H.fourier(kmesh)

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

print('--> Dyson g0_wk')
t = time.time()
g0_wk = lattice_dyson_g0_wk(mu=0.0, e_k=e_k, mesh=wmesh)
print(' {} seconds'.format(time.time() - t))

print('--> Bubble chi0_wk')
t = time.time()
chi0_wk = imtime_bubble_chi0_wk(g0_wk, nw=nw)
print(' {} seconds'.format(time.time() - t))
    units=[(1, 0, 0), (0, 1, 0)],
    hopping={
        # nearest neighbour hopping -t
        (0, +1):
        -t_intra * np.eye(n_orb_spin) - t_inter * inter_orbital_hopping,
        (0, -1):
        -t_intra * np.eye(n_orb_spin) - t_inter * inter_orbital_hopping,
        (+1, 0):
        -t_intra * np.eye(n_orb_spin) - t_inter * inter_orbital_hopping,
        (-1, 0):
        -t_intra * np.eye(n_orb_spin) - t_inter * inter_orbital_hopping,
    },
    orbital_positions=[(0, 0, 0)] * n_orb_spin,
)

kmesh = H.get_kmesh(n_k=(16, 16, 1))
e_k = H.fourier(kmesh)
print(e_k)

# ----------------------------------------------------------------------
# -- Bare susceptibility from Green's function bubble

from triqs.gf import MeshImFreq
from triqs_tprf.lattice import lattice_dyson_g0_wk

wmesh = MeshImFreq(beta=5.0, S='Fermion', n_max=30)
g0_wk = lattice_dyson_g0_wk(mu=0., e_k=e_k, mesh=wmesh)

from triqs_tprf.lattice_utils import imtime_bubble_chi0_wk

chi00_wk = imtime_bubble_chi0_wk(g0_wk, nw=1)
示例#9
0
    T = -t * np.eye(2)

    t_r = TBLattice(
        units=[(1, 0, 0)],
        hopping={
            # nearest neighbour hopping -t
            (
                0, ): h_loc,
            (+1, ): T,
            (-1, ): T,
        },
        orbital_positions=[(0, 0, 0)] * 2,
        orbital_names=['up', 'do'],
    )

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

    # -- Local double occupancy operator

    gf_struct = [[0, 2]]

    docc = n(0, 0) * n(0, 1)

    Sz = 0.5 * np.diag([1., -1.])

    # -- Sweep in interaction U

    U_vec = np.arange(9., -0.5, -1.5)
    h_vec = 1e-3 * np.linspace(-1., 1., num=11)