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
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 = list(zip(*t)) o1, o2, o3, o4 = ops o1, o2 = dagger(o1), dagger(o2) H += h_quart[idx] * o1 * o2 * o3 * o4 return H
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
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 range(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 list(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
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
def d_dag(b, m): return dagger(d(b, m))