コード例 #1
0
    def set_g4_tau_matrix(self, g4_tau, op_list):

        assert (g4_tau.target_shape == tuple([len(op_list)] * 4))

        for (i1, o1), (i2, o2), (i3, o3), (i4, o4) in \
            mpi_op_comb(op_list, repeat=4):

            self.set_g4_tau(g4_tau[i1, i2, i3, i4], o1, dagger(o2), o3,
                            dagger(o4))

        g4_tau = mpi_all_reduce_g(g4_tau)

        return g4_tau
コード例 #2
0
ファイル: OperatorUtils.py プロジェクト: yuechm/pyed
def operator_single_particle_transform(op, U, fundamental_operators):
    
    """ Transform the operator op according to the single particle 
    transform matrix U defined in the subspace of operators listed in 
    fundamental_operators. """

    # -- Convert fundamental operators back and forth from index

    op_idx_map = get_operator_index_map(fundamental_operators)
    op_idx_set = set(op_idx_map)

    # -- Transformed creation operator

    def c_transf(s, i):
        if (s, i) not in op_idx_set:
            return c(s, i)

        k = op_idx_map.index((s, i))
        
        ret = Operator()
        for l in xrange(U.shape[0]):
            op_idx = op_idx_map[l]
            ret += U[k, l] * c(*op_idx)

        return ret

    # -- Precompute transformed operators
    
    op_trans_dict = {}
    for fop in fundamental_operators:
        dag, idxs = op_serialize_fundamental(fop)
        op_trans_dict[(dag, idxs)] = c_transf(*idxs)
        op_trans_dict[(not dag, idxs)] = dagger(c_transf(*idxs))
            
    # -- Loop over given operator and substitute operators
    # -- fundamental_operators with the transformed operators
    
    op_trans = Operator()
    
    for term in op:
        op_factor = Operator(1.)
        for factor in term:
            if type(factor) is list:
                for dag, idxs in factor:
                    tup = (dag, tuple(idxs))
                    if tup in op_trans_dict.keys():
                        op_factor *= op_trans_dict[tup]
                    else:
                        op_factor *= {False:c, True:c_dag}[dag](*idxs)
                    
            else: # constant prefactor
                op_factor *= factor

        op_trans += op_factor

    return op_trans
コード例 #3
0
    def set_g2_tau_matrix(self, g_tau, op_list):

        assert (g_tau.target_shape == tuple([len(op_list)] * 2))

        for (i1, o1), (i2, o2) in mpi_op_comb(op_list, repeat=2):
            self.set_g2_tau(g_tau[i1, i2], o1, dagger(o2))

        g_tau = mpi_all_reduce_g(g_tau)

        return g_tau
コード例 #4
0
ファイル: OperatorUtils.py プロジェクト: mzingl/tprf
def operator_from_quartic_tensor(h_quart, fundamental_operators):

    # -- Convert fundamental operators back and forth from index

    op_idx_map = get_operator_index_map(fundamental_operators)
    op_idx_set = set(op_idx_map)

    nop = len(fundamental_operators)

    H = Operator(0.)

    for t in itertools.product(enumerate(fundamental_operators), repeat=4):
        idx, ops = zip(*t)
        o1, o2, o3, o4 = ops
        o1, o2 = dagger(o1), dagger(o2)

        H += h_quart[idx] * o1 * o2 * o3 * o4

    return H
コード例 #5
0
ファイル: OperatorUtils.py プロジェクト: mzingl/tprf
def get_quadratic_operator(h, fundamental_operators):

    # -- Check Hermicity
    np.testing.assert_array_almost_equal(h, h.T.conj())

    H = Operator(0.)
    for idx1, o1 in enumerate(fundamental_operators):
        o1 = dagger(o1)
        for idx2, o2 in enumerate(fundamental_operators):
            H += h[idx1, idx2] * o1 * o2

    return H
コード例 #6
0
ファイル: transform_kanamori.py プロジェクト: yuechm/pyed
 def d_dag(b, m):
     return dagger(d(b, m))
コード例 #7
0
    index_list = []
    for i1 in xrange(4):
        for i2 in xrange(i1, 4):
            index_list.append((i1, i2))

    #F = 0.0001 / m.beta
    F = 0.1 / m.beta
    F_vec = np.array([-F, F])
    
    work_list = np.array(index_list)
    work_list = mpi.slice_array(work_list)

    for i1, i2 in work_list:

        o1, o2 = m.op_imp[i1], m.op_imp[i2]
        O1 = dagger(o1) * o2
        O1 = O1 + dagger(O1)

        ed_p = TriqsExactDiagonalization(m.H + F * O1, m.op_full, m.beta)
        ed_m = TriqsExactDiagonalization(m.H - F * O1, m.op_full, m.beta)
        
        p.g_tau_field[(i1, i2)] = g_tau.copy()
        ed_p.set_g2_tau_matrix(p.g_tau_field[(i1, i2)], m.op_imp)

        for i3, i4 in itertools.product(range(4), repeat=2):

            o3, o4 = m.op_imp[i3], m.op_imp[i4]
            O2 = dagger(o3) * o4

            O2_vec = np.zeros(2, dtype=np.complex)
            O2_vec[0] = ed_m.get_expectation_value(O2)
コード例 #8
0
ファイル: setup_model.py プロジェクト: HugoStrand/cthyb
        #p.T = np.kron(ortho_group.rvs(2), np.eye(2)) # orbital only rotation

    # use parametrized "weak" realvalued 4x4 transform
    p.T = unitary_transf_4x4(t_vec=[0.3, 0.3, 0.3, 0.0, 0.0, 0.0])
    #p.T = unitary_transf_4x4(t_vec=[0.25*np.pi, 0.0, 0.0, 0.0, 0.0, 0.0])
    #p.T = np.eye(4)
    p.T = np.matrix(p.T)
    print p.T

    # -- Different types of operator sets

    p.op_imp = [c('0', 0), c('0', 1), c('0', 2), c('0', 3)]
    p.op_full = p.op_imp + [c('1', 0), c('1', 1), c('1', 2), c('1', 3)]

    p.spin_block_ops = [c('0', 0), c('1', 0), c('0', 1), c('1', 1)]
    p.spin_block_ops += [dagger(op) for op in p.spin_block_ops]

    p.org_ops = copy.copy(p.op_imp)
    p.org_ops += [dagger(op) for op in p.org_ops]

    p.diag_ops = [c('0_0', 0), c('0_1', 0), c('0_2', 0), c('0_3', 0)]
    p.diag_ops += [dagger(op) for op in p.diag_ops]

    p.gf_struct = [['0', [0, 1, 2, 3]]]
    p.gf_struct_diag = [['0_0', [0]], ['0_1', [0]], ['0_2', [0]], ['0_3', [0]]]

    p.index_converter = {
        ('0', 0): ('loc', 0, 'up'),
        ('0', 1): ('loc', 0, 'down'),
        ('0', 2): ('loc', 1, 'up'),
        ('0', 3): ('loc', 1, 'down'),
コード例 #9
0
ファイル: calc_pyed.py プロジェクト: HugoStrand/cthyb
                         beta=m.beta,
                         statistic='Boson',
                         n_points=50,
                         target_shape=(4, 4, 4, 4))

    p.chi = np.zeros_like(p.chi_static)

    tau = np.array([float(tau) for tau in p.chi_tau.mesh])

    for i1, i2, i3, i4, in itertools.product(range(4), repeat=4):

        print i1, i2, i3, i4

        o1, o2, o3, o4 = m.op_imp[i1], m.op_imp[i2], m.op_imp[i3], m.op_imp[i4]

        O1 = dagger(o1) * o2
        O2 = dagger(o3) * o4

        p.O1_exp[i1, i2] = ed.get_expectation_value(O1)
        p.O2_exp[i3, i4] = ed.get_expectation_value(O2)

        p.chi_dissconn[i1, i2, i3, i4] = p.O1_exp[i1, i2] * p.O2_exp[i3, i4]

        p.chi_static[i1, i2, i3, i4] = ed.get_expectation_value(O1 * O2)

        ed.set_g2_tau(p.chi_tau[i1, i2, i3, i4], O1, O2)

        chi_tau = p.chi_tau[i1, i2, i3, i4]
        chi_tau *= -1.  # cancel gf -1 prefactor

        chi_dissconn = p.chi_dissconn[i1, i2, i3, i4]