Esempio n. 1
0
        def calc_reference():

            ref_orbs = [
                '%s' % i for i in range(n_orbs * parms['N_x'] * parms['N_y'])
            ]
            ref_gf_struct = op.set_operator_structure(spin_names,
                                                      ref_orbs,
                                                      off_diag=off_diag)
            ref_index_converter = {(sn, o): ("loc", int(o),
                                             "down" if sn == "dn" else "up")
                                   for sn, o in product(spin_names, ref_orbs)}
            #print ref_index_converter,ref_orbs
            ref_ed = PomerolED(ref_index_converter, verbose=True)
            ref_N = sum(
                ops.n(sn, o) for sn, o in product(spin_names, ref_orbs))
            #  2 3
            #  0 1
            ref_H = (parms["U"] * (ops.n('up', '0') * ops.n('dn', '0') +
                                   ops.n('up', '1') * ops.n('dn', '1')) -
                     2. * parms['t1'] *
                     (ops.c_dag('up', '0') * ops.c('up', '1') +
                      ops.c_dag('up', '1') * ops.c('up', '0') +
                      ops.c_dag('dn', '0') * ops.c('dn', '1') +
                      ops.c_dag('dn', '1') * ops.c('dn', '0')) -
                     parms['chemical_potential'] * ref_N)
            # Run the solver
            ref_ed.diagonalize(ref_H)
            # Compute G(i\omega)
            ref_G_iw = ref_ed.G_iw(ref_gf_struct, parms['beta'], parms['n_iw'])
            return ref_G_iw
Esempio n. 2
0
def run_test(t1, filename):
    dptkeys = [
        'verbosity', 'calculate_sigma', 'calculate_sigma1', 'calculate_sigma2'
    ]

    parms = {
        # Solver parameters
        'n_iw': 100,
        # Physical parameters
        'U': 0.5,
        't1': t1,
        'beta': 10,
        # DMFT loop control parameters
        'calculate_sigma': True,
        'calculate_sigma1': True,
        'calculate_sigma2': True,
        'measure_G2_iw_ph': True,
        "measure_G2_n_bosonic": 10,
        "measure_G2_n_fermionic": 10,
        "verbosity": 4,
    }

    parms["N_x"] = 2
    parms["N_y"] = 1
    parms["N_z"] = 1
    parms["ksi_delta"] = 1.0

    # Chemical potential depends on the definition of H(k) that is used
    parms['chemical_potential_bare'] = 0.
    parms['chemical_potential'] = parms['U'] / 2. + parms[
        'chemical_potential_bare']

    n_orbs = 1  # Number of orbitals
    off_diag = True
    spin_names = ['up', 'dn']  # Outer (non-hybridizing) blocks
    orb_names = ['%s' % i for i in range(n_orbs)]  # Orbital indices
    gf_struct = op.set_operator_structure(spin_names,
                                          orb_names,
                                          off_diag=off_diag)

    if haspomerol:
        #####
        #
        # Reference: 4 site cluster, calculate only G, not G2
        #
        #####
        def calc_reference():

            ref_orbs = [
                '%s' % i for i in range(n_orbs * parms['N_x'] * parms['N_y'])
            ]
            ref_gf_struct = op.set_operator_structure(spin_names,
                                                      ref_orbs,
                                                      off_diag=off_diag)
            ref_index_converter = {(sn, o): ("loc", int(o),
                                             "down" if sn == "dn" else "up")
                                   for sn, o in product(spin_names, ref_orbs)}
            #print ref_index_converter,ref_orbs
            ref_ed = PomerolED(ref_index_converter, verbose=True)
            ref_N = sum(
                ops.n(sn, o) for sn, o in product(spin_names, ref_orbs))
            #  2 3
            #  0 1
            ref_H = (parms["U"] * (ops.n('up', '0') * ops.n('dn', '0') +
                                   ops.n('up', '1') * ops.n('dn', '1')) -
                     2. * parms['t1'] *
                     (ops.c_dag('up', '0') * ops.c('up', '1') +
                      ops.c_dag('up', '1') * ops.c('up', '0') +
                      ops.c_dag('dn', '0') * ops.c('dn', '1') +
                      ops.c_dag('dn', '1') * ops.c('dn', '0')) -
                     parms['chemical_potential'] * ref_N)
            # Run the solver
            ref_ed.diagonalize(ref_H)
            # Compute G(i\omega)
            ref_G_iw = ref_ed.G_iw(ref_gf_struct, parms['beta'], parms['n_iw'])
            return ref_G_iw

        ref_G_iw = calc_reference()
        ref = ref_G_iw[ref_spin]

        g2_blocks = set([("up", "up"), ("up", "dn"), ("dn", "up"),
                         ("dn", "dn")])
        index_converter = {(sn, o):
                           ("loc", int(o), "down" if sn == "dn" else "up")
                           for sn, o in product(spin_names, orb_names)}

        # 1 Bath degree of freedom
        # Level of the bath sites
        epsilon = [
            -parms['chemical_potential_bare'],
        ]
        index_converter.update({
            ("B%i_%s" % (k, sn), 0):
            ("bath" + str(k), 0, "down" if sn == "dn" else "up")
            for k, sn in product(range(len(epsilon)), spin_names)
        })

        # Make PomerolED solver object
        ed = PomerolED(index_converter, verbose=True)
        N = sum(ops.n(sn, o) for sn, o in product(spin_names, orb_names))
        H_loc = (parms["U"] * (ops.n('up', '0') * ops.n('dn', '0')) -
                 parms['chemical_potential'] * N)

        # Bath Hamiltonian: levels
        H_bath = sum(eps * ops.n("B%i_%s" % (k, sn), 0)
                     for sn, (k,
                              eps) in product(spin_names, enumerate(epsilon)))

        # Hybridization Hamiltonian
        # Bath-impurity hybridization
        V = [
            -2 * bath_prefactor * t1,
        ]
        H_hyb = ops.Operator()
        for k, v in enumerate(V):
            H_hyb += sum(
                v * ops.c_dag("B%i_%s" % (k, sn), 0) * ops.c(sn, '0') +
                np.conj(v) * ops.c_dag(sn, '0') * ops.c("B%i_%s" % (k, sn), 0)
                for sn in spin_names)

        # Obtain bath sites from Delta and create H_ED
        H_ED = H_loc + H_bath + H_hyb

        # Run the solver
        ed.diagonalize(H_ED)
        # Compute G(i\omega)
        G_iw = ed.G_iw(gf_struct, parms['beta'], parms['n_iw'])

        if parms["measure_G2_iw_ph"]:
            common_g2_params = {
                'gf_struct': gf_struct,
                'beta': parms['beta'],
                'blocks': g2_blocks,
                'n_iw': parms['measure_G2_n_bosonic']
            }
            G2_iw = ed.G2_iw_inu_inup(channel="PH",
                                      block_order="AABB",
                                      n_inu=parms['measure_G2_n_fermionic'],
                                      **common_g2_params)

        if mpi.is_master_node():
            with ar.HDFArchive(filename, 'w') as arch:
                arch["parms"] = parms
                arch["G_iw"] = G_iw
                arch["G2_iw"] = G2_iw
                arch["ref"] = ref
    else:  # haspomerol is False
        with ar.HDFArchive(filename, 'r') as arch:
            ref = arch['ref']
            G_iw = arch['G_iw']
            G2_iw = arch['G2_iw']

    BL = lattice.BravaisLattice(units=[
        (1, 0, 0),
    ])  #linear lattice
    kmesh = gf.MeshBrillouinZone(lattice.BrillouinZone(BL), parms["N_x"])
    Hk_blocks = [gf.Gf(indices=orb_names, mesh=kmesh) for spin in spin_names]
    Hk = gf.BlockGf(name_list=spin_names, block_list=Hk_blocks)

    def Hk_f(k):
        return -2 * parms['t1'] * (np.cos(k[0])) * np.eye(1)

    for spin, _ in Hk:
        for k in Hk.mesh:
            Hk[spin][k] = Hk_f(k.value)

    # Construct the DF2 program
    X = dualfermion.Dpt(beta=parms['beta'],
                        gf_struct=gf_struct,
                        Hk=Hk,
                        n_iw=parms['n_iw'],
                        n_iw2=parms["measure_G2_n_fermionic"],
                        n_iW=parms["measure_G2_n_bosonic"])

    for name, g0 in X.Delta:
        X.Delta[name] << gf.inverse(
            gf.iOmega_n +
            parms['chemical_potential_bare']) * bath_prefactor**2 * 4 * t1**2

    X.G2_iw << G2_iw

    # Run the dual perturbation theory
    X.gimp << G_iw  # Load G from impurity solver
    dpt_parms = {key: parms[key] for key in parms if key in dptkeys}
    X.run(**dpt_parms)
Esempio n. 3
0
from triqs.utility.comparison_tests import *
from triqs.utility.h5diff import h5diff

# Basic input parameters
beta = 40

# Init the SumK class
SK = SumkDFT(hdf_file='SrVO3.ref.h5', use_dft_blocks=True)

num_orbitals = SK.corr_shells[0]['dim']
l = SK.corr_shells[0]['l']
spin_names = ['down', 'up']
orb_names = ['%s' % i for i in range(num_orbitals)]
orb_hybridized = False

gf_struct = set_operator_structure(spin_names, orb_names, orb_hybridized)
glist = [GfImFreq(indices=inner, beta=beta) for block, inner in gf_struct]
Sigma_iw = BlockGf(name_list=[block for block, inner in gf_struct],
                   block_list=glist,
                   make_copies=False)

SK.set_Sigma([Sigma_iw])
Gloc = SK.extract_G_loc()

if mpi.is_master_node():
    with HDFArchive('srvo3_Gloc.out.h5', 'w') as ar:
        ar['Gloc'] = Gloc[0]

if mpi.is_master_node():
    h5diff("srvo3_Gloc.out.h5", "srvo3_Gloc.ref.h5")
Esempio n. 4
0
spin_names = ['up', 'down']  # Outer (non-hybridizing) blocks
orb_names = ['%s' % i for i in range(n_orbs)]  # Orbital indices
off_diag = False  # Include orbital off-diagonal elements?
n_loop = 2  # Number of DMFT self-consistency loops

# Solver parameters
p = {}
p["n_warmup_cycles"] = 10000  # Number of warmup cycles to equilibrate
p["n_cycles"] = 100000  # Number of measurements
p["length_cycle"] = 500  # Number of MC steps between consecutive measures
p["move_double"] = True  # Use four-operator moves

# Block structure of Green's functions
# gf_struct = [ ('up',[0,1,2,3,4]), ('down',[0,1,2,3,4]) ]
# This can be computed using the TRIQS function as follows:
gf_struct = op.set_operator_structure(spin_names, orb_names, off_diag=off_diag)

# Construct the 4-index U matrix U_{ijkl}
# The spherically-symmetric U matrix is parametrised by the radial integrals
# F_0, F_2, F_4, which are related to U and J. We use the functions provided
# in the TRIQS library to construct this easily:
U_mat = op.U_matrix(l=l, U_int=U, J_hund=J, basis='spherical')

# Set the interacting part of the local Hamiltonian
# Here we use the full rotationally-invariant interaction parametrised
# by the 4-index tensor U_{ijkl}.
# The TRIQS library provides a function to build this Hamiltonian from the U tensor:
H = op.h_int_slater(spin_names, orb_names, U_mat, off_diag=off_diag)

# Construct the solver
S = Solver(beta=beta, gf_struct=gf_struct)
Esempio n. 5
0
def test_solver_dry_run():
    # Half band width
    D = 2.0
    mu = 1.0
    U = 4.0
    J = 1.0

    l = 1
    n_orbs = 2 * l +1

    # Inter-orbital hybridization
    off_diag = True

    spin_names = ['ud']
    orb_names = [i for i in range(2*n_orbs)]

    # Block structure of Green's functions
    gf_struct = op.set_operator_structure(spin_names, orb_names, off_diag=off_diag)
    # Convert to dict
    if isinstance(gf_struct, list):
        gf_struct = {x[0]: x[1] for x in gf_struct}

    # Local interaction Hamiltonian
    U_mat = to_spin_full_U_matrix(op.U_matrix(l=l, U_int=U, J_hund=J, basis='spherical'))

    s = ALPSCTHYBSolver(beta, gf_struct, U_mat, n_iw=n_iw)

    Delta_iw = make_block_gf(GfImFreq, gf_struct, beta, n_iw)

    for name, b in Delta_iw:
        b << (D/2.0)**2 * SemiCircular(D)

    # Random local transfer matrix
    H0 = [numpy.random.rand(2*n_orbs, 2*n_orbs) for name, b in Delta_iw]
    H0 = [h + h.conjugate().transpose() for h in H0]

    G0_iw = make_block_gf(GfImFreq, gf_struct, beta, n_iw)
    G0_iw.zero()
    for ib, (name, g0) in enumerate(G0_iw):
        dim = len(g0.indices)
        g0 << inverse(iOmega_n - H0[ib] - Delta_iw[name])
    s.set_G0_iw(G0_iw)

    #rot = compute_diag_basis(G0_iw)
    #s.rotate_basis(rot, direction='forward')

    p = {
        'exec_path'     : './dummy/hybmat',
        'work_dir'      : './',
        'dry_run'       : True,
        'random_seed_offset' : 20,
        'timelimit'     : 60,
    }
    s.solve(None, '', p)

    #s.rotate_basis(rot, direction='backward')

    # Check Delta(iwn)
    diff = s.get_Delta_iw() - Delta_iw

    for name, b in diff:
        assert numpy.all(numpy.abs(b.data) < 1e-10)