def gen_fermi_twobody(label): string = "pqsr" c1 = it.permutations("ou") c2 = it.permutations("ou", r=2) ops = [Operator(label + "(oooo)", "p q sd rd")] set_fermi("oooo", ops[0]) for i in it.product(c1, c2): s = i[0] + i[1] out = [] for ind, typ in zip(string, s): if typ == 'o': if ind in "pq": out.append(ind) elif ind in "sr": out.append(ind + "d") elif typ == 'u': if ind in "pq": out.append(ind + "d") elif ind in "sr": out.append(ind) op = Operator(label + "(" + "".join(s) + ")", " ".join(out)) set_fermi(s, op) ops.append(op) op = Operator(label + "(uuuu)", "pd qd s r") set_fermi("uuuu", op) ops.append(op) return ops
def gen_fermi_onebody(label): ops = [Operator(label + "(oo)", "p qd"), Operator(label + "(uu)", "pd q")] set_fermi("oo", ops[0]) set_fermi("uu", ops[1]) return ops
def gen_fermi_onebody(label): ops = [ Operator(label+"(oo)", "p qd", typs="oo"), Operator(label+"(ou)", "p q", typs="ou"), Operator(label+"(uo)", "pd qd", typs="uo"), Operator(label+"(uu)", "pd q", typs="uu") ] return ops
def gen_fermi_threebody(): ops = [Operator("h3(uuouuo)", "pd qd r u t sd")] set_fermi("uuouuo", ops[0]) #ops = [Operator("h3(uuouuo)", "pd qd r u t sd", typs="uuouuo")] #set_fermi("uuouuo", ops[0]) return ops
def gen_fermi_twobody(label): string = "pqsr" ops = [] for i in range(4+1): for j in it.combinations(range(4), i): typs = ['o'] * 4 for indx in j: typs[indx] = 'u' typs = "".join(typs) out = [] for ind, typ in zip(string, typs): if typ == 'o': if ind in "pq": out.append(ind) elif ind in "sr": out.append(ind + "d") elif typ == 'u': if ind in "pq": out.append(ind + "d") elif ind in "sr": out.append(ind) op = Operator(label+f"({typs})", " ".join(out), typs=typs, weight=Fraction(1,2)) set_fermi(typs, op) ops.append(op) return ops
def run(h): # aaa bra = Operator("bra", "c b a k j i") ket = Operator("ket", "id jd kd ad bd cd") #bra = Operator("bra", "b a j i") #bra = Operator("bra", "j b i a") #bra = Operator("bra", "a3 a2 a1 i3 i2 i1") #ket = Operator("ket", "i1d i2d i6d a1d a5d a6d") #bra = Operator("bra", "a3 a2 a1 i3 i2 i1") #ket = Operator("ket", "i1d i2d i6d a1d a5d a6d") #ket = Operator("ket", "i1d i2d i3d a1d a2d a6d") # aab #bra = Operator("bra", "cb b a kb j i") #ket = Operator("ket", "id jd kbd ad bd cbd") # abb #bra = Operator("bra", "cb bb a kb jb i") #ket = Operator("ket", "id jbd kbd ad bbd cbd") # bbb #bra = Operator("bra", "cb bb ab kb jb ib") #ket = Operator("ket", "ibd jbd kbd abd bbd cbd") #bra = Operator("bra", "cb b a kb j i") #ket = Operator("ket", "id jd kbd ad bd cbd") for t in ts: fs = OperatorString(bra * h * t * ket) root_node = Node(fs) wicks(root_node) # Pretty Print #lines, _, _, _ = get_utf8_tree(root_node) #for line in lines: # print(line) #print(root_node.right.right.right.right.left.data) #print(fs) #root_node.print() full = collect_fully_contracted(root_node) #print(full) #sys.exit() new_eqs = [] new_weights = {} if len(full) == 0: continue for i, eq in enumerate(full): evs = [x.evaluate() for x in eq.deltas] if 0 in evs: continue mv = h.eval_deltas(eq.deltas) mt = t.eval_deltas(eq.deltas) #equiv = new_eqs_weights[key] #print(equiv) #print(eq.deltas) #print(eq.sign * eq.weight, mv) new_eqs.append((eq.sign * eq.weight, mv, mt)) new_weights[(mv, mt)] = eq.sign * eq.weight terms = list(zip(*new_eqs)) #print(terms) if len(terms) > 0: uniques = find_equiv(list(terms[1:])) print("==================================") print(h) print('----------------') for cnt, term in uniques: print(int(math.sqrt(cnt)) * new_weights[term], term) print("==================================\n")
new_terms.remove(term) cnt += 1 uniques.append((cnt, tmp_terms[0])) if len(new_terms) == 0: break tmp_terms = new_terms[:] return uniques hs = [ Operator("va(oooo)", "p q sd rd", typs='oooo', weight=Fraction(1, 2)), Operator("va(ouou)", "p qd sd r", typs='ouou', weight=1), Operator("va(oouu)", "p q s r", typs='oouu', weight=Fraction(1, 2)), Operator("va(uuuu)", "pd qd s r", typs='uuuu', weight=Fraction(1, 2)), Operator("vb(oooo)", "p qb sbd rd", typs='oooo', weight=1), Operator("vb(ouou)", "p qbd sbd r", typs='ouou', weight=1), Operator("vb(ouuo)", "p qbd sb rd", typs='ouuo', weight=1), Operator("vb(uoou)", "pd qb sbd r", typs='uoou', weight=1), Operator("vb(uouo)", "pd qb sb rd", typs='uouo', weight=1), Operator("vb(uuuu)", "pd qbd sb r", typs='uuuu', weight=1), Operator("vc(oooo)", "pb qb sbd rbd", typs='oooo', weight=Fraction(1, 2)), Operator("vc(ouou)", "pb qbd sbd rb", typs='ouou', weight=1), Operator("vc(uuuu)", "pbd qbd sb rb", typs='uuuu', weight=Fraction(1, 2)), ] ts = [
new_terms.remove(term) cnt += 1 uniques.append((cnt, tmp_terms[0])) if len(new_terms) == 0: break tmp_terms = new_terms[:] return uniques hs = [ # h1 aa Operator("h1a(oo)", "p qd", typs='oo'), Operator("h1a(uu)", "pd q", typs='uu'), # h1 bb Operator("h1b(oo)", "pb qbd", typs='oo'), Operator("h1b(uu)", "pbd qb", typs='uu'), # h2 aa Operator("h2a(oooo)", "p q sd rd", typs='oooo', weight=Fraction(1, 2)), Operator("h2a(ouou)", "p qd sd r", typs='ouou', weight=1), Operator("h2a(uuuu)", "pd qd s r", typs='uuuu', weight=Fraction(1, 2)), # h2 ab Operator("h2b(oooo)", "p qb sbd rd", typs='oooo', weight=1), Operator("h2b(ouou)", "p qbd sbd r", typs='ouou', weight=1), Operator("h2b(ouuo)", "p qbd sb rd", typs='ouuo', weight=1),
weight=Fraction(1,2)) set_fermi(typs, op) ops.append(op) return ops if __name__ == "__main__": ops = gen_fermi_onebody() #ops = gen_fermi_twobody() #ops = gen_fermi_threebody() bra = Operator("bra", "c b a k j i") ket = Operator("ket", "id jd kd ad bd dd") #sys.exit() for op in ops: print('--------', op, '-----------') fs = OperatorString(bra.string + op.string + ket.string) root_node = Node(fs) wicks(root_node) full = collect_fully_contracted(root_node) for eq in full: evs = [kd.evaluate() for kd in eq[1]]
uniques.append((cnt, tmp_terms[0])) if len(new_terms) == 0: break tmp_terms = new_terms[:] return uniques hs = [ Operator("h1a(oo)", "p qd", typs='oo'), Operator("h1a(uu)", "pd q", typs='uu'), Operator("h1b(oo)", "pb qbd", typs='oo'), Operator("h1b(uu)", "pbd qb", typs='uu'), Operator("h2a(oooo)", "p q sd rd", typs='oooo', weight=Fraction(1,2)), Operator("h2a(ouou)", "p qd sd r", typs='ouou', weight=1), Operator("h2a(uuuu)", "pd qd s r", typs='uuuu', weight=Fraction(1,2)), Operator("h2b(oooo)", "p qb sbd rd", typs='oooo', weight=1), Operator("h2b(ouou)", "p qbd sbd r", typs='ouou', weight=1),