Esempio n. 1
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')
Esempio n. 2
0
if __name__ == '__main__':

    if mpi.is_master_node():
        with HDFArchive('data_model.h5', 'r') as A:
            p = A["p"]
    else:
        p = None
    p = mpi.bcast(p)

    p.convert_keys_from_string_to_python('index_converter')

    pom = PomerolED(p.index_converter, verbose=True)
    pom.diagonalize(p.H)

    p.g_iw = pom.G_iw(p.gf_struct, p.beta, n_iw=400)
    p.g_tau = pom.G_tau(p.gf_struct, p.beta, n_tau=200)['0']
    p.tau = np.array([float(tau) for tau in p.g_tau.mesh])

    opt = dict(block_order='AABB',
               beta=p.beta,
               gf_struct=p.gf_struct,
               blocks=set([('0', '0')]),
               n_iw=1,
               n_inu=10)

    p.g4_ph = pom.G2_iw_inu_inup(channel='PH', **opt)['0', '0']

    if mpi.is_master_node():
        with HDFArchive('data_pomerol.h5', 'w') as A:
            A['p'] = p
Esempio n. 3
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)
ed.diagonalize(H)

###########
# G^{(2)} #
###########

common_g2_params = {
    'gf_struct': gf_struct,
    'beta': beta,
    'blocks': g2_blocks,
    'n_iw': g2_n_iw
}

# Compute G^{(2),ph}(i\omega;i\nu,i\nu'), AABB block order
G2_iw_inu_inup_ph_AABB = ed.G2_iw_inu_inup(channel="PH",
                                           block_order="AABB",
                                           n_inu=g2_n_inu,
                                           **common_g2_params)

# Compute G^{(2),ph}(i\omega;i\nu,i\nu'), ABBA block order
G2_iw_inu_inup_ph_ABBA = ed.G2_iw_inu_inup(channel="PH",
                                           block_order="ABBA",
                                           n_inu=g2_n_inu,
                                           **common_g2_params)

# Compute G^{(2),pp}(i\omega;i\nu,i\nu'), AABB block order
G2_iw_inu_inup_pp_AABB = ed.G2_iw_inu_inup(channel="PP",
                                           block_order="AABB",
                                           n_inu=g2_n_inu,
                                           **common_g2_params)

# Compute G^{(2),pp}(i\omega;i\nu,i\nu'), ABBA block order
Esempio n. 5
0
    H_ED = H

    # 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 HDFArchive(arname, 'w') as ar:
            ar['ref'] = ref
            ar['G_iw'] = G_iw
            ar['G2_iw'] = G2_iw

else:  # haspomerol is False
    with HDFArchive(arname, 'r') as ar:
        ref = ar['ref']
        G_iw = ar['G_iw']
        G2_iw = ar['G2_iw']

gimp = G_iw[spin]
Esempio n. 6
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
Esempio n. 7
0
def make_calc(nw=10, beta=2.0, h_field=0.0):

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

    p = ParameterCollection(
        beta=beta,
        V1=2.0,
        V2=5.0,
        epsilon1=0.00,
        epsilon2=4.00,
        h_field=h_field,
        mu=2.0,
        U=5.0,
        ntau=40,
        niw=15,
        n_inu=nw,
    )

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

    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)
    nB = c_dag(up, 1) * c(up, 1) + c_dag(do, 1) * c(do, 1)
    nC = c_dag(up, 2) * c(up, 2) + c_dag(do, 2) * c(do, 2)

    p.H = -p.mu * nA + p.U * docc + p.h_field * mA + \
        p.epsilon1 * nB + p.epsilon2 * nC + \
        p.V1 * (c_dag(up,0)*c(up,1) + c_dag(up,1)*c(up,0) + \
              c_dag(do,0)*c(do,1) + c_dag(do,1)*c(do,0) ) + \
        p.V2 * (c_dag(up,0)*c(up,2) + c_dag(up,2)*c(up,0) + \
              c_dag(do,0)*c(do,2) + c_dag(do,2)*c(do,0) )

    # ------------------------------------------------------------------
    # -- 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 = {
        (up, 0): ('loc', 0, 'up'),
        (do, 0): ('loc', 0, 'down'),
        (up, 1): ('loc', 1, 'up'),
        (do, 1): ('loc', 1, 'down'),
        (up, 2): ('loc', 2, 'up'),
        (do, 2): ('loc', 2, 'down'),
    }

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

    gf_struct = [[up, [0]], [do, [0]]]

    # -- Single-particle Green's functions
    p.G_iw = ed.G_iw(gf_struct, beta, n_iw=100)
    p.G_tau = ed.G_tau(gf_struct, beta, n_tau=400)

    # -- Particle-particle two-particle Matsubara frequency Green's function
    opt = dict(block_order='AABB',
               beta=beta,
               gf_struct=gf_struct,
               blocks=set([(up, up), (up, do)]),
               n_iw=1,
               n_inu=p.n_inu)

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

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

    mpi.barrier()
    if mpi.is_master_node():
        filename = 'data_pomerol_h_field_%4.4f.h5' % h_field
        with HDFArchive(filename, 'w') as res:
            res['p'] = p
Esempio n. 8
0
def make_calc():

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

    params = dict(
        beta=2.0,
        V1=2.0,
        V2=5.0,
        epsilon1=0.00,
        epsilon2=4.00,
        mu=2.0,
        U=5.0,
        ntau=40,
        niw=15,
    )

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

    class Dummy():
        def __init__(self):
            pass

    d = Dummy()  # storage space
    d.params = params

    print '--> Solving SIAM with parameters'
    for key, value in params.items():
        print '%10s = %-10s' % (key, str(value))
        globals()[key] = value  # populate global namespace

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

    up, do = 'up', 'dn'
    docc = 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)
    nB = c_dag(up, 1) * c(up, 1) + c_dag(do, 1) * c(do, 1)
    nC = c_dag(up, 2) * c(up, 2) + c_dag(do, 2) * c(do, 2)

    d.H = -mu * nA + epsilon1 * nB + epsilon2 * nC + U * docc + \
        V1 * (c_dag(up,0)*c(up,1) + c_dag(up,1)*c(up,0) + \
              c_dag(do,0)*c(do,1) + c_dag(do,1)*c(do,0) ) + \
        V2 * (c_dag(up,0)*c(up,2) + c_dag(up,2)*c(up,0) + \
              c_dag(do,0)*c(do,2) + c_dag(do,2)*c(do,0) )

    # ------------------------------------------------------------------
    # -- 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 = {
        (up, 0): ('loc', 0, 'up'),
        (do, 0): ('loc', 0, 'down'),
        (up, 1): ('loc', 1, 'up'),
        (do, 1): ('loc', 1, 'down'),
        (up, 2): ('loc', 2, 'up'),
        (do, 2): ('loc', 2, 'down'),
    }

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

    gf_struct = [[up, [0]], [do, [0]]]

    # -- Single-particle Green's functions
    G_iw = ed.G_iw(gf_struct, beta, n_iw=niw)
    G_tau = ed.G_tau(gf_struct, beta, n_tau=ntau)
    G_w = ed.G_w(gf_struct,
                 beta,
                 energy_window=(-2.5, 2.5),
                 n_w=100,
                 im_shift=0.01)

    d.G_iw = G_iw['up']
    d.G_tau = G_tau['up']
    d.G_w = G_w['up']

    # -- Particle-particle two-particle Matsubara frequency Green's function
    opt = dict(block_order='AABB',
               beta=beta,
               gf_struct=gf_struct,
               blocks=set([("up", "dn")]),
               n_iw=niw,
               n_inu=niw)

    G2_iw = ed.G2_iw_inu_inup(channel='AllFermionic', **opt)
    d.G2_iw = G2_iw['up', 'dn']

    G2_iw_pp = ed.G2_iw_inu_inup(channel='PP', **opt)
    d.G2_iw_pp = G2_iw_pp['up', 'dn']

    G2_iw_ph = ed.G2_iw_inu_inup(channel='PH', **opt)
    d.G2_iw_ph = G2_iw_ph['up', 'dn']

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

    filename = 'data_pomerol.h5'
    with HDFArchive(filename, 'w') as res:
        for key, value in d.__dict__.items():
            res[key] = value