Ejemplo n.º 1
0
def test_cf_G_tau_and_G_iw_nonint(verbose=False):

    beta = 3.22
    eps = 1.234

    niw = 64
    ntau = 2 * niw + 1
    
    H = eps * c_dag(0,0) * c(0,0)

    fundamental_operators = [c(0,0)]

    ed = TriqsExactDiagonalization(H, fundamental_operators, beta)

    # ------------------------------------------------------------------
    # -- Single-particle Green's functions

    G_tau = GfImTime(beta=beta, statistic='Fermion', n_points=ntau, target_shape=(1,1))
    G_iw = GfImFreq(beta=beta, statistic='Fermion', n_points=niw, target_shape=(1,1))

    G_iw << inverse( iOmega_n - eps )
    G_tau << InverseFourier(G_iw)

    G_tau_ed = GfImTime(beta=beta, statistic='Fermion', n_points=ntau, target_shape=(1,1))
    G_iw_ed = GfImFreq(beta=beta, statistic='Fermion', n_points=niw, target_shape=(1,1))

    ed.set_g2_tau(G_tau_ed[0, 0], c(0,0), c_dag(0,0))
    ed.set_g2_iwn(G_iw_ed[0, 0], c(0,0), c_dag(0,0))

    # ------------------------------------------------------------------
    # -- Compare gfs

    from pytriqs.utility.comparison_tests import assert_gfs_are_close
    
    assert_gfs_are_close(G_tau, G_tau_ed)
    assert_gfs_are_close(G_iw, G_iw_ed)
    
    # ------------------------------------------------------------------
    # -- Plotting
    
    if verbose:
        from pytriqs.plot.mpl_interface import oplot, plt
        subp = [3, 1, 1]
        plt.subplot(*subp); subp[-1] += 1
        oplot(G_tau.real)
        oplot(G_tau_ed.real)

        plt.subplot(*subp); subp[-1] += 1
        diff = G_tau - G_tau_ed
        oplot(diff.real)
        oplot(diff.imag)
        
        plt.subplot(*subp); subp[-1] += 1
        oplot(G_iw)
        oplot(G_iw_ed)
        
        plt.show()
Ejemplo n.º 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
Ejemplo n.º 3
0
def test_fundamental():

    assert( op_is_fundamental(c(0, 0)) is True )
    assert( op_is_fundamental(c_dag(0, 0)) is True )
    assert( op_is_fundamental(c_dag(0, 0)*c(0, 0)) is False )
    assert( op_is_fundamental(Operator(1.0)) is False )

    assert( op_serialize_fundamental(c(0,0)) == (False, (0,0)) )
    assert( op_serialize_fundamental(c_dag(0,0)) == (True, (0,0)) )

    assert( op_serialize_fundamental(c(2,4)) == (False, (2,4)) )
    assert( op_serialize_fundamental(c_dag(4,3)) == (True, (4,3)) )
Ejemplo n.º 4
0
def test_single_particle_transform(verbose=False):

    if verbose:
        print '--> test_single_particle_transform'
        
    h_loc = np.array([
        [1.0, 0.0],
        [0.0, -1.0],
        ])

    op_imp = [c(0,0), c(0,1)]

    H_loc = get_quadratic_operator(h_loc, op_imp)
    H_loc_ref = c_dag(0,0) * c(0,0) - c_dag(0,1) * c(0,1)

    assert( (H_loc - H_loc_ref).is_zero() )

    h_loc_ref = quadratic_matrix_from_operator(H_loc, op_imp)
    np.testing.assert_array_almost_equal(h_loc, h_loc_ref)

    if verbose:
        print 'h_loc =\n', h_loc
        print 'h_loc_ref =\n', h_loc_ref
        print 'H_loc =', H_loc

    T_ab = np.array([
        [1., 1.],
        [1., -1.],
        ]) / np.sqrt(2.)

    Ht_loc = operator_single_particle_transform(H_loc, T_ab, op_imp)
    ht_loc = quadratic_matrix_from_operator(Ht_loc, op_imp)

    ht_loc_ref = np.array([
        [0., 1.],
        [1., 0.],
        ])

    Ht_loc_ref = c_dag(0, 0) * c(0, 1) + c_dag(0, 1) * c(0, 0)

    if verbose:
        print 'ht_loc =\n', ht_loc
        print 'ht_loc_ref =\n', ht_loc_ref
        print 'Ht_loc =', Ht_loc
        print 'Ht_loc_ref =', Ht_loc_ref
    
    assert( (Ht_loc - Ht_loc_ref).is_zero() )
Ejemplo n.º 5
0
def test_sparse_matrix_representation():

    up, do = 0, 1
    fundamental_operators = [c(up, 0), c(do, 0)]

    rep = SparseMatrixRepresentation(fundamental_operators)

    # -- Test an operator
    O_mat = rep.sparse_matrix(c(up, 0))
    O_ref = rep.sparse_operators.c_dag[0].getH()
    compare_sparse_matrices(O_mat, O_ref)

    # -- Test
    O_mat = rep.sparse_matrix(c(do, 0))
    O_ref = rep.sparse_operators.c_dag[1].getH()
    compare_sparse_matrices(O_mat, O_ref)

    # -- Test expression
    H_expr = c(up, 0) * c(do, 0) * c_dag(up, 0) * c_dag(do, 0)
    H_mat = rep.sparse_matrix(H_expr)
    c_dag0, c_dag1 = rep.sparse_operators.c_dag
    c_0, c_1 = c_dag0.getH(), c_dag1.getH()
    H_ref = c_0 * c_1 * c_dag0 * c_dag1
    compare_sparse_matrices(H_mat, H_ref)
Ejemplo n.º 6
0
def solve_aims(G0_iw_list_):

    G_iw_list = []
    G_tau_list = []
    average_sign_list = []

    for G0_iw in G0_iw_list_:

        print 'G0_iw', G0_iw

        # ==== Local Hamiltonian ====
        c_dag_vec = matrix([[c_dag('bl', idx) for idx in idx_lst]])
        c_vec = matrix([[c('bl', idx)] for idx in idx_lst])

        h_0_mat = t_ij_list[0]
        h_0 = (c_dag_vec * h_0_mat * c_vec)[0, 0]

        # ==== Interacting Hamiltonian ====
        Umat, Upmat = U_matrix_kanamori(len(orb_names), U_int=U, J_hund=J)
        #op_map = { (s,o): ('bl',i) for i, (s,o) in enumerate(product(spin_names, orb_names)) }
        op_map = {(s, o): ('bl', i)
                  for i, (o, s) in enumerate(product(orb_names, spin_names))}
        h_int = h_int_kanamori(spin_names,
                               orb_names,
                               Umat,
                               Upmat,
                               J,
                               off_diag=True,
                               map_operator_structure=op_map)

        G_tau, G_iw, average_sign = ctqmc_solver(h_int, G0_iw)

        G_iw_list.append(G_iw)
        G_tau_list.append(G_tau)
        average_sign_list.append(average_sign)

    return G_tau_list, G_iw_list, average_sign_list
Ejemplo n.º 7
0
    def solve(self,
              H_int,
              E_levels,
              integrals_of_motion=None,
              density_matrix_cutoff=1e-10,
              file_quantum_numbers="",
              file_eigenvalues=""):

        self.__copy_E_levels(E_levels)

        H_0 = sum(
            self.E_levels[sn][oi1, oi2].real * c_dag(sn, on1) * c(sn, on2)
            for sn, (oi1, on1), (
                oi2, on2) in product(self.spin_names, enumerate(
                    self.orb_names), enumerate(self.orb_names)))
        if self.verbose and mpi.is_master_node():
            print "\n*** compute G_iw and Sigma_iw"
            print "*** E_levels =", E_levels
            print "*** H_0 =", H_0
            # print "*** integrals_of_motion =", integrals_of_motion

        N_op = sum(
            c_dag(sn, on) * c(sn, on)
            for sn, on in product(self.spin_names, self.orb_names))

        if integrals_of_motion is None:
            if self.spin_orbit:
                # use only N op as integrals_of_motion when spin-orbit coupling is included
                self.__ed.diagonalize(H_0 + H_int, integrals_of_motion=[N_op])
            else:
                # use N and S_z as integrals of motion by default
                self.__ed.diagonalize(H_0 + H_int)
        else:
            assert isinstance(integrals_of_motion, list)

            # check commutation relation in advance (just for test)
            if self.verbose and mpi.is_master_node():
                print "*** Integrals of motion:"
                for i, op in enumerate(integrals_of_motion):
                    print " op%d =" % i, op

                print "*** commutation relations:"
                is_commute = lambda h, op: h * op - op * h
                str_if_commute = lambda h, op: "== 0" if is_commute(
                    h, op).is_zero() else "!= 0"
                for i, op in enumerate(integrals_of_motion):
                    print " [H_0, op%d]" % i, str_if_commute(
                        H_0,
                        op), " [H_int, op%d]" % i, str_if_commute(H_int, op)

            self.__ed.diagonalize(H_0 + H_int, integrals_of_motion)

        # save data
        if file_quantum_numbers:
            self.__ed.save_quantum_numbers(file_quantum_numbers)
        if file_eigenvalues:
            self.__ed.save_eigenvalues(file_eigenvalues)

        # set density-matrix cutoff
        self.__ed.set_density_matrix_cutoff(density_matrix_cutoff)

        # Compute G(i\omega)
        self.G_iw << self.__ed.G_iw(self.gf_struct, self.beta, self.n_iw)

        # Compute G0 and Sigma
        E_list = [self.E_levels[sn]
                  for sn in self.spin_names]  # from dict to list
        self.G0_iw << iOmega_n
        self.G0_iw -= E_list
        self.Sigma_iw << self.G0_iw - inverse(self.G_iw)
        self.G0_iw.invert()

        # *********************************************************************
        # TODO: tail
        # set tail of Sigma at all zero in the meantime, because tail of G is
        #  not computed in pomerol solver. This part should be improved.
        # *********************************************************************
        for s, sig in self.Sigma_iw:
            sig.tail.zero()
Ejemplo n.º 8
0
Archivo: calc.py Proyecto: daihui/pyed
if __name__ == '__main__':

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

    beta = 10.0
    V1 = 1.0
    V2 = 1.0
    epsilon1 = +2.30
    epsilon2 = -2.30
    t = 0.1
    mu = 1.0
    U = 2.0

    up, do = 0, 1
    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)

    hopA = c_dag(up, 0) * c(do, 0) + c_dag(do, 0) * c(up, 0)
    hopB = c_dag(up, 1) * c(do, 1) + c_dag(do, 1) * c(up, 1)
    hopC = c_dag(up, 2) * c(do, 2) + c_dag(do, 2) * c(up, 2)

    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) ) + \
        -t * (hopA + hopB + hopC)
Ejemplo n.º 9
0
def test_two_particle_greens_function():

    # ------------------------------------------------------------------
    # -- Hubbard atom with two bath sites, Hamiltonian
    
    beta = 2.0
    V1 = 2.0
    V2 = 5.0
    epsilon1 = 0.00
    epsilon2 = 4.00
    mu = 2.0
    U = 0.0

    up, do = 0, 1
    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)

    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

    fundamental_operators = [
        c(up,0), c(do,0), c(up,1), c(do,1), c(up,2), c(do,2)]
    
    ed = TriqsExactDiagonalization(H, fundamental_operators, beta)

    # ------------------------------------------------------------------
    # -- single particle Green's functions

    g_tau = GfImTime(name=r'$g$', beta=beta,
                     statistic='Fermion', n_points=100,
                     target_shape=(1,1))
    
    ed.set_g2_tau(g_tau[0, 0], c(up,0), c_dag(up,0))
    
    # ------------------------------------------------------------------
    # -- Two particle Green's functions

    ntau = 10
    imtime = MeshImTime(beta, 'Fermion', ntau)
    prodmesh = MeshProduct(imtime, imtime, imtime)

    g40_tau = Gf(name='g40_tau', mesh=prodmesh, target_shape=(1,1,1,1))
    g4_tau = Gf(name='g4_tau', mesh=prodmesh, target_shape=(1,1,1,1))

    ed.set_g40_tau_matrix(g40_tau, g_tau)
    ed.set_g4_tau(g4_tau[0, 0, 0, 0], c(up,0), c_dag(up,0), c(up,0), c_dag(up,0))

    # ------------------------------------------------------------------
    # -- compare

    zero_outer_planes_and_equal_times(g4_tau)
    zero_outer_planes_and_equal_times(g40_tau)
    np.testing.assert_array_almost_equal(g4_tau.data, g40_tau.data)
Ejemplo n.º 10
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
Ejemplo n.º 11
0
# ----------------------------------------------------------------------
if __name__ == '__main__':

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

    beta = 2.0
    V1 = 2.0
    V2 = 5.0
    epsilon1 = 0.00
    epsilon2 = 4.00
    mu = 2.0
    U = 0.0

    up, do = 0, 1
    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)

    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

    fundamental_operators = [
        c(up, 0), c(do, 0),
Ejemplo n.º 12
0
    fundamental_operators = fundamental_operators_from_gf_struct(gf_struct)

    beta = 10.0
    U = 2.0
    mu = 1.0
    h = 0.1
    #V = 0.5
    V = 1.0
    epsilon = 2.3

    H = U * n('up', 0) * n('do', 0) + \
        - mu * (n('up', 0) + n('do', 0)) + \
        h * n('up', 0) - h * n('do', 0) + \
        epsilon * (n('up', 1) + n('do', 1)) - epsilon * (n('up', 2) + n('do', 2)) + \
        V * ( c_dag('up', 0) * c('up', 1) + c_dag('up', 1) * c('up', 0) ) + \
        V * ( c_dag('do', 0) * c('do', 1) + c_dag('do', 1) * c('do', 0) ) + \
        V * ( c_dag('up', 0) * c('up', 2) + c_dag('up', 2) * c('up', 0) ) + \
        V * ( c_dag('do', 0) * c('do', 2) + c_dag('do', 2) * c('do', 0) )

    ed = TriqsExactDiagonalization(H, fundamental_operators, beta)

    n_tau = 101
    G_tau_up = Gf(mesh=MeshImTime(beta, 'Fermion', n_tau), target_shape=[])
    G_tau_do = Gf(mesh=MeshImTime(beta, 'Fermion', n_tau), target_shape=[])

    ed.set_g2_tau(G_tau_up, c('up', 0), c_dag('up', 0))
    ed.set_g2_tau(G_tau_do, c('do', 0), c_dag('do', 0))

    with HDFArchive('anderson.pyed.h5', 'w') as Results:
        Results['up'] = G_tau_up
Ejemplo n.º 13
0
def make_calc(U=10):

    # ------------------------------------------------------------------
    # -- 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=U,
        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 = 0, 1
    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

    fundamental_operators = [
        c(up, 0), c(do, 0),
        c(up, 1), c(do, 1),
        c(up, 2), c(do, 2)
    ]

    ed = TriqsExactDiagonalization(d.H, fundamental_operators, beta)

    # ------------------------------------------------------------------
    # -- Single-particle Green's functions

    Gopt = dict(beta=beta, statistic='Fermion', indices=[1])
    d.G_tau = GfImTime(name=r'$G(\tau)$', n_points=ntau, **Gopt)
    d.G_iw = GfImFreq(name='$G(i\omega_n)$', n_points=niw, **Gopt)

    ed.set_g2_tau(d.G_tau, c(up, 0), c_dag(up, 0))
    ed.set_g2_iwn(d.G_iw, c(up, 0), c_dag(up, 0))

    # chi2pp = + < c^+_u(\tau^+) c_u(0^+) c^+_d(\tau) c_d(0) >
    #        = - < c^+_u(\tau^+) c^+_d(\tau) c_u(0^+) c_d(0) >

    chi2opt = dict(beta=beta, statistic='Fermion', indices=[1], n_points=ntau)
    d.chi2pp_tau = GfImTime(name=r'$\chi^{(2)}_{PP}(\tau)$', **chi2opt)
    ed.set_g2_tau(d.chi2pp_tau,
                  c_dag(up, 0) * c_dag(do, 0),
                  c(up, 0) * c(do, 0))
    d.chi2pp_tau *= -1.0 * -1.0  # commutation sign and gf sign
    d.chi2pp_iw = g_iw_from_tau(d.chi2pp_tau, niw)

    # chi2ph = < c^+_u(\tau^+) c_u(\tau) c^+_d(0^+) c_d(0) >

    d.chi2ph_tau = GfImTime(name=r'$\chi^{(2)}_{PH}(\tau)$', **chi2opt)
    #d.chi2ph_tau = Gf(name=r'$\chi^{(2)}_{PH}(\tau)$', **chi2opt)
    ed.set_g2_tau(d.chi2ph_tau,
                  c_dag(up, 0) * c(up, 0),
                  c_dag(do, 0) * c(do, 0))
    d.chi2ph_tau *= -1.0  # gf sign
    d.chi2ph_iw = g_iw_from_tau(d.chi2ph_tau, niw)

    # ------------------------------------------------------------------
    # -- Two particle Green's functions

    imtime = MeshImTime(beta, 'Fermion', ntau)
    prodmesh = MeshProduct(imtime, imtime, imtime)
    G2opt = dict(mesh=prodmesh, target_shape=[1, 1, 1, 1])

    d.G02_tau = Gf(name='$G^{(2)}_0(\tau_1, \tau_2, \tau_3)$', **G2opt)
    ed.set_g40_tau(d.G02_tau, d.G_tau)
    d.G02_iw = chi4_iw_from_tau(d.G02_tau, niw)

    d.G2_tau = Gf(name='$G^{(2)}(\tau_1, \tau_2, \tau_3)$', **G2opt)
    ed.set_g4_tau(d.G2_tau, c_dag(up, 0), c(up, 0), c_dag(do, 0), c(do, 0))
    #ed.set_g4_tau(d.G2_tau, c(up,0), c_dag(up,0), c(do,0), c_dag(do,0)) # <cc^+cc^+>
    d.G2_iw = chi4_iw_from_tau(d.G2_tau, niw)

    # -- trying to fix the bug in the fft for w2

    d.G02_iw.data[:] = d.G02_iw.data[:, ::-1, ...].conj()
    d.G2_iw.data[:] = d.G2_iw.data[:, ::-1, ...].conj()

    # ------------------------------------------------------------------
    # -- 3/2-particle Green's functions (equal times)

    prodmesh = MeshProduct(imtime, imtime)
    chi3opt = dict(mesh=prodmesh, target_shape=[1, 1, 1, 1])

    # chi3pp = <c^+_u(\tau) c_u(0^+) c^+_d(\tau') c_d(0) >
    #        = - <c^+_u(\tau) c^+_d(\tau') c_u(0^+) c_d(0) >

    d.chi3pp_tau = Gf(name='$\Chi^{(3)}_{PP}(\tau_1, \tau_2, \tau_3)$',
                      **chi3opt)
    ed.set_g3_tau(d.chi3pp_tau, c_dag(up, 0), c_dag(do, 0),
                  c(up, 0) * c(do, 0))
    d.chi3pp_tau *= -1.0  # from commutation
    d.chi3pp_iw = chi3_iw_from_tau(d.chi3pp_tau, niw)

    # chi3ph = <c^+_u(\tau) c_u(\tau') c^+_d(0^+) c_d(0) >

    d.chi3ph_tau = Gf(name='$\Chi^{(3)}_{PH}(\tau_1, \tau_2, \tau_3)$',
                      **chi3opt)
    ed.set_g3_tau(d.chi3ph_tau, c_dag(up, 0), c(up, 0),
                  c_dag(do, 0) * c(do, 0))
    d.chi3ph_iw = chi3_iw_from_tau(d.chi3ph_tau, niw)

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

    filename = 'data_ed.h5'
    with HDFArchive(filename, 'w') as res:
        for key, value in d.__dict__.items():
            res[key] = value
Ejemplo n.º 14
0
def test_trimer_hamiltonian():

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

    beta = 2.0
    V1 = 2.0
    V2 = 5.0
    epsilon1 = 0.00
    epsilon2 = 4.00
    mu = 2.0
    U = 1.0

    # -- construction using triqs operators

    up, do = 0, 1
    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)

    H_expr = -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) )

    # ------------------------------------------------------------------
    fundamental_operators = [
        c(up, 0), c(do, 0),
        c(up, 1), c(do, 1),
        c(up, 2), c(do, 2)
    ]

    rep = SparseMatrixRepresentation(fundamental_operators)
    H_mat = rep.sparse_matrix(H_expr)

    # -- explicit construction

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

    op = Dummy()
    op.cdagger = rep.sparse_operators.c_dag
    op.c = np.array([cdag.getH() for cdag in op.cdagger])
    op.n = np.array([cdag * cop for cop, cdag in zip(op.c, op.cdagger)])

    H_ref = -mu * (op.n[0] + op.n[1]) + \
        epsilon1 * (op.n[2] + op.n[3]) + \
        epsilon2 * (op.n[4] + op.n[5]) + \
        U * op.n[0] * op.n[1] + \
        V1 * (op.cdagger[0] * op.c[2] + op.cdagger[2] * op.c[0] + \
              op.cdagger[1] * op.c[3] + op.cdagger[3] * op.c[1] ) + \
        V2 * (op.cdagger[0] * op.c[4] + op.cdagger[4] * op.c[0] + \
              op.cdagger[1] * op.c[5] + op.cdagger[5] * op.c[1] )

    # ------------------------------------------------------------------
    # -- compare

    compare_sparse_matrices(H_mat, H_ref)
Ejemplo n.º 15
0
    T_imp = block_diag(T_imp, T_imp)
    T_bath = block_diag(T_bath, T_bath)

    print 'V =\n', V
    print 'T_imp =\n', T_imp
    print 'T_bath =\n', T_bath

    T = np.block([[T_imp, V], [V.T, T_bath]])

    print 'T =\n', T

    H_int = h_int_kanamori(spin_names, imp_idxs,
                           np.array([[0, U - 3 * J], [U - 3 * J, 0]]),
                           np.array([[U, U - 2 * J], [U - 2 * J, U]]), J, True)

    H = H_int + get_quadratic_operator(T, fop)

    ed = TriqsExactDiagonalization(H, fop, beta)

    n_tau = 101
    G_tau_up = Gf(mesh=MeshImTime(beta, 'Fermion', n_tau), target_shape=[2, 2])
    G_tau_do = Gf(mesh=MeshImTime(beta, 'Fermion', n_tau), target_shape=[2, 2])

    for i1, i2 in itertools.product(range(norb), repeat=2):
        ed.set_g2_tau(G_tau_up[i1, i2], c('up', i1), c_dag('up', i2))
        ed.set_g2_tau(G_tau_do[i1, i2], c('do', i1), c_dag('do', i2))

    with HDFArchive('kanamori_offdiag.pyed.h5', 'w') as Results:
        Results['up'] = G_tau_up
        Results['dn'] = G_tau_do
Ejemplo n.º 16
0
          n_iw=1025,
          n_tau=2500,
          n_l=20)

solver = SolverCore(**cp)

# Set hybridization function
mu = 0.5
half_bandwidth = 1.0
delta_w = GfImFreq(indices=[0], beta=cp['beta'])
delta_w << (half_bandwidth / 2.0)**2 * SemiCircular(half_bandwidth)
for name, g0 in solver.G0_iw:
    g0 << inverse(iOmega_n + mu - delta_w)

sp = dict(
    h_int=n('up', 0) * n('do', 0) + c_dag('up', 0) * c('do', 0) +
    c_dag('do', 0) * c('up', 0),
    max_time=-1,
    length_cycle=50,
    n_warmup_cycles=50,
    n_cycles=500,
    move_double=False,
)

solver.solve(**sp)

filename = 'h5_read_write.h5'

with HDFArchive(filename, 'w') as A:
    A['solver'] = solver
Ejemplo n.º 17
0
# Number of particles on the impurity
N = sum(n(sn, o) for sn, o in product(spin_names, orb_names))

# Local Hamiltonian
H_loc = h_int_kanamori(spin_names, orb_names,
                       np.array([[0, U - 3 * J], [U - 3 * J, 0]]),
                       np.array([[U, U - 2 * J], [U - 2 * J, U]]), J, True)
H_loc -= mu * N

# Bath Hamiltonian
H_bath = sum(epsilon[o] * n("B_" + sn, o)
             for sn, o in product(spin_names, orb_names))

# Hybridization Hamiltonian
H_hyb = sum(V[o1, o2] * c_dag("B_" + sn, o1) * c(sn, o2) +
            np.conj(V[o2, o1]) * c_dag(sn, o1) * c("B_" + sn, o2)
            for sn, o1, o2 in product(spin_names, orb_names, orb_names))

# Complete Hamiltonian
H = H_loc + H_hyb + H_bath

# Diagonalize H
ed.diagonalize(H)

# Compute G(i\omega)
G_iw = ed.G_iw(gf_struct, beta, n_iw)

# Compute G(\tau)
G_tau = ed.G_tau(gf_struct, beta, n_tau)
Ejemplo n.º 18
0
def make_calc(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.10,
        epsilon2=3.00,
        h_field=h_field,
        mu=0.0,
        U=5.0,
        ntau=800,
        niw=15,
    )

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

    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) )

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

    fundamental_operators = [
        c(up, 0), c(do, 0),
        c(up, 1), c(do, 1),
        c(up, 2), c(do, 2)
    ]

    ed = TriqsExactDiagonalization(p.H, fundamental_operators, p.beta)

    g_tau = GfImTime(beta=beta, statistic='Fermion', n_points=400, 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][0, 0], c(up, 0), c_dag(up, 0))
    ed.set_g2_tau(p.G_tau[do][0, 0], c(do, 0), c_dag(do, 0))

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

    p.magnetization = ed.get_expectation_value(0.5 * mA)

    p.O_tau = Gf(mesh=MeshImTime(beta, 'Fermion', 400), target_shape=[])
    ed.set_g2_tau(p.O_tau, n(up, 0), n(do, 0))
    p.O_tau.data[:] *= -1.

    p.exp_val = ed.get_expectation_value(n(up, 0) * n(do, 0))

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

    filename = 'data_pyed_h_field_%4.4f.h5' % h_field
    with HDFArchive(filename, 'w') as res:
        res['p'] = p
Ejemplo n.º 19
0
Ek = np.array([
    [1.00,  0.75],
    [0.75, -1.20],
    ])

E_loc = np.array([
    [0.2, 0.3],
    [0.3, 0.4],
    ])

V = np.array([
    [1.0, 0.25],
    [0.25, -1.0],
    ])

h_loc = c_dag('0', 0) * E_loc[0, 0] * c('0', 0) + \
        c_dag('0', 0) * E_loc[0, 1] * c('0', 1) + \
        c_dag('0', 1) * E_loc[1, 0] * c('0', 0) + \
        c_dag('0', 1) * E_loc[1, 1] * c('0', 1)

Delta_iw << inverse( iOmega_n - Ek ) + inverse( iOmega_n + Ek )
Delta_iw.from_L_G_R(V, Delta_iw, V)

Delta_tau = Gf(mesh=tmesh, target_shape=target_shape)
Delta_tail, Delta_tail_err = Delta_iw.fit_hermitian_tail()
Delta_tau << InverseFourier(Delta_iw, Delta_tail)

G0_iw = Gf(mesh=wmesh, target_shape=target_shape)
G0_iw << inverse( iOmega_n - Delta_iw - E_loc )

S.G0_iw << G0_iw
Ejemplo n.º 20
0
    def solve(self, **params_kw):
        """
        Solve the impurity problem: calculate G(iw) and Sigma(iw)
        Parameters
        ----------
        params_kw : dict {'param':value} that is passed to the core solver.
                     Two required :ref:`parameters <solve_parameters>` are
                        * `h_int` (:ref:`Operator object <triqslibs:operators>`): the local Hamiltonian of the impurity problem to be solved,
                        * `n_cycles` (int): number of measurements to be made.
                    Other parameters are 
                        * `calc_gtau` (bool): calculate G(tau)
                        * `calc_gw` (bool): calculate G(w) and Sigma(w)
                        * `calc_gl` (bool): calculate G(legendre)
                        * `calc_dm` (bool): calculate density matrix

        
        """

        h_int = params_kw['h_int']
        try:
            calc_gtau = params_kw['calc_gtau']
        except KeyError:
            calc_gtau = False

        try:
            calc_gw = params_kw['calc_gw']
        except KeyError:
            calc_gw = False

        try:
            calc_gl = params_kw['calc_gl']
        except KeyError:
            calc_gl = False

        try:
            calc_dm = params_kw['calc_dm']
        except KeyError:
            calc_dm = False

        Delta_iw = 0 * self.G0_iw
        Delta_iw << iOmega_n
        Delta_iw -= inverse(self.G0_iw)

        for block, ind in self.gf_struct:
            a = Delta_iw[block].fit_tail()
            self.eal[block] = a[0][0]

        G0_iw_F = 0 * self.G_iw
        if calc_gw:
            G0_w_F = 0 * self.G_w

        G0_iw_F << iOmega_n
        if calc_gw:
            G0_w_F << Omega

        for block, ind in self.gf_struct:
            G0_iw_F[block] -= self.eal[block]
            if calc_gw:
                G0_w_F[block] -= self.eal[block]

        G0_iw_F = inverse(G0_iw_F)
        if calc_gw:
            G0_w_F = inverse(G0_w_F)

        H_loc = 1.0 * h_int
        for block, ind in self.gf_struct:
            for ii, ii_ind in enumerate(ind):
                for jj, jj_ind in enumerate(ind):
                    H_loc += self.eal[block][ii, jj] * c_dag(
                        block, ii_ind) * c(block, jj_ind)

        self.ad = AtomDiag(H_loc, self.fops)

        self.G_iw = atomic_g_iw(self.ad, self.beta, self.gf_struct, self.n_iw)
        if calc_gw:
            self.G_w = atomic_g_w(self.ad, self.beta, self.gf_struct,
                                  (self.w_min, self.w_max), self.n_w,
                                  self.idelta)
        if calc_gtau:
            self.G_tau = atomic_g_tau(self.ad, self.beta, self.gf_struct,
                                      self.n_tau)
        if calc_gl:
            self.G_l = atomic_g_l(self.ad, self.beta, self.gf_struct, self.n_l)
        if calc_dm:
            self.dm = atomic_density_matrix(self.ad, self.beta)

        self.Sigma_iw = inverse(G0_iw_F) - inverse(self.G_iw)
        if calc_gw:
            self.Sigma_w = inverse(G0_w_F) - inverse(self.G_w)
Ejemplo n.º 21
0
                        for k, sn in product(range(len(epsilon)), spin_names)})

# Make PomerolED solver object
ed = PomerolED(index_converter, verbose=True)

# Number of particles on the impurity
H_loc = -mu * (n('up', 0) + n('dn', 0)) + U * n('up', 0) * n('dn', 0)

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

# Hybridization Hamiltonian
H_hyb = Operator()
for k, v in enumerate(V):
    H_hyb += sum(v * c_dag("B%i_%s" % (k, sn), 0) * c(sn, 0) +
                 np.conj(v) * c_dag(sn, 0) * c("B%i_%s" % (k, sn), 0)
                 for sn in spin_names)

# Complete Hamiltonian
H = H_loc + H_hyb + H_bath

# Diagonalize H
ed.diagonalize(H)

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

common_g2_params = {
    'gf_struct': gf_struct,
Ejemplo n.º 22
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
Ejemplo n.º 23
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')
Ejemplo n.º 24
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