<jupyter_start><jupyter_text>Load pywicked, setup orbital spaces, and create WickTheorem object<jupyter_code>import pywicked as pw
from IPython.display import display, Math, Latex

pw.osi.reset()
pw.osi.add_space("v",pw.rdm.unoccupied,["a","b"])
pw.osi.add_space("o",pw.rdm.occupied,["i","j"])
wdt = pw.WDiagTheorem()<jupyter_output><empty_output><jupyter_text>Create operators<jupyter_code>T = pw.make_operator("T",["o->v","oo->vv"])
F = pw.make_operator("F", ["o->o","o->v","v->o","v->v"]);
V = pw.make_operator("V", ["oo->oo", "oo->ov", "oo->vv",
                           "ov->oo", "ov->ov", "ov->vv",
                           "vv->oo", "vv->ov", "vv->vv"]);
H = pw.make_operator("v", ["o->o"  , "o->v"  , "v->o"  , "v->v",
                           "oo->oo", "oo->ov", "oo->vv",
                           "ov->oo", "ov->ov", "ov->vv",
                           "vv->oo", "vv->ov", "vv->vv"]);<jupyter_output><empty_output><jupyter_text>Setup the similarity-transformed Hamiltonian and compute expectation value<jupyter_code>Hbar = pw.bch_series(H,T,4)
sum = wdt.contract_sum(pw.rational(1,1),Hbar, 0, 0);
display(Math("E = " + sum.latex()))<jupyter_output><empty_output><jupyter_text>Create ambit equations<jupyter_code>eqs = sum.to_manybody_equation("R")

print "Generated %d equations" % len(eqs)

for eq in eqs:
    print eq.ambit()<jupyter_output>Generated 3 equations
R += 0.500000 * T[o0,v0] * T[o1,v1] * v[v0,v1,o0,o1];
R += 1.000000 * T[o0,v0] * v[v0,o0];
R += 0.250000 * T[o0,o1,v0,v1] * v[v0,v1,o0,o1];<jupyter_text>Compute the CCSD similarity-transformed Hamiltonian<jupyter_code>Hbar = pw.bch_series(H,T,4)
sum = wdt.contract_sum(pw.rational(1,1),Hbar, 2, 4)

print sum.str()

eqs = sum.to_manybody_equation("R")

print "Generated %d equations" % len(eqs)

n1 = 0
n2 = 0
for eq in eqs:
    ambit = eq.ambit()
    if ("R[o0,v0]" in ambit):
        n1 = n1 + 1
    if ("R[o1,o0,v0,v1]" in ambit):
        n2 = n2 + 1
        print ambit     
        
print "n1 = %d" % n1
print "n2 = %d" % n2<jupyter_output>1/2 T^{o1}_{v3} T^{o0,o2}_{v0,v1} v^{v2,v3}_{o1,o2} { a+(v0) a+(v1) a-(v2) a-(o0) }
-1/4 T^{o0}_{v3} T^{o1,o2}_{v0,v1} v^{v2,v3}_{o1,o2} { a+(v0) a+(v1) a-(v2) a-(o0) }
-1/2 T^{o0}_{v3} v^{v2,v3}_{v0,v1} { a+(v0) a+(v1) a-(v2) a-(o0) }
-1/2 T^{o2}_{v2} T^{o0,o1}_{v0,v3} v^{v2,v3}_{v1,o2} { a+(v0) a+(v1) a-(o1) a-(o0) }
-1/2 T^{o2}_{v2} T^{o0,o3}_{v0,v1} v^{v2,o1}_{o2,o3} { a+(v0) a+(v1) a-(o1) a-(o0) }
-1/2 T^{o0}_{v2} T^{o2}_{v3} T^{o1,o3}_{v0,v1} v^{v2,v3}_{o2,o3} { a+(v0) a+(v1) a-(o1) a-(o0) }
+1/8 T^{o0}_{v2} T^{o1}_{v3} T^{o2,o3}_{v0,v1} v^{v2,v3}_{o2,o3} { a+(v0) a+(v1) a-(o1) a-(o0) }
+1/4 T^{o0}_{v2} T^{o1}_{v3} v^{v2,v3}_{v0,v1} { a+(v0) a+(v1) a-(o1) a-(o0) }
-T^{o0}_{v2} T^{o1,o2}_{v0,v3} v^{v2,v3}_{v1,o2} { a+(v0) a+(v1) a-(o1) a-(o0) }
+1/4 T^{o0}_{v2} T^{o2,o3}_{v0,v1} v^{v2,o1}_{o2,o3} { a+(v0) a+(v1) a-(o1) a-(o0) }
+1/2 T^{o0}_{v2} T^{o1,o2}_{v0,v1} v^{v2}_{o2} { a+(v0) a+(v1) a-(o1) a-(o0) }
-T^{o0}_{v2} v^{v1,v2}_{v0,o1} { a+(v0) a+(o1) a-(v1) a-(o0) }
+T^{o0}_{v2} [...]<jupyter_text>Compute the CCSDTQ similarity-transformed Hamiltonian<jupyter_code>T = pw.make_operator("T",["o->v","oo->vv","ooo->vvv","oooo->vvvv"])

Hbar = pw.bch_series(H,T,4)
sum = wdt.contract_sum(pw.rational(1,1),Hbar, 2, 8)

eqs = sum.to_manybody_equation("R")

print "Generated %d equations" % len(eqs)

numr1 = 0
numr2 = 0
for eq in eqs:
    print eq.ambit()
wdt.set_print(pw.PrintLevel.summary)
Hthis = pw.make_operator("H", ["ov->oo"]);
Hbar2 = pw.bch_series(Hthis,T,4)
sum = wdt.contract_sum(pw.rational(1,1),Hbar2, 2, 2)

print sum.str()

eqs = sum.to_manybody_equation("R")<jupyter_output>-1/2 H^{v1,o0}_{o1,o2} T^{o2}_{v0} T^{o1}_{v1} { a+(v0) a-(o0) }
1/2 H^{v1,o0}_{o1,o2} T^{o1}_{v0} T^{o2}_{v1} { a+(v0) a-(o0) }
1/2 H^{v1,o0}_{o1,o2} T^{o1,o2}_{v0,v1} { a+(v0) a-(o0) }
-1 H^{v0,o1}_{o0,o2} T^{o2}_{v0} { a+(o0) a-(o1) }
{'fraction_non_alphanumeric': 0.2726568551510457, 'fraction_numerical': 0.08133230054221534, 'mean_word_length': 4.277929155313352, 'pattern_counts': {'":': 0, '<': 22, '<?xml version=': 0, '>': 55, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '277356', 'license': 'MIT', 'n_tokens_mistral': 2094, 'n_tokens_neox': 2045, 'n_words': 307, 'path': 'examples/cc_eqns.ipynb', 'repo_name': 'fevangelista/wicked', 'size': '3873'}