def testE2(self): bra = braE2("occ", "vir", "occ", "vir") ket = ketE2("occ", "vir", "occ", "vir") out = apply_wick(bra * ket) aout = AExpression(Ex=out) i = Idx(0, "occ") a = Idx(0, "vir") j = Idx(1, "occ") b = Idx(1, "vir") k = Idx(2, "occ") c = Idx(2, "vir") l = Idx(3, "occ") d = Idx(3, "vir") tensors = [Tensor([a, b, i, j], ""), Tensor([k, l, c, d], "")] tr1 = Term( 1, [], tensors, [], [Delta(i, k), Delta(j, l), Delta(a, c), Delta(b, d)]) tr2 = Term( -1, [], tensors, [], [Delta(i, l), Delta(j, k), Delta(a, c), Delta(b, d)]) tr3 = Term( -1, [], tensors, [], [Delta(i, k), Delta(j, l), Delta(a, d), Delta(b, c)]) tr4 = Term( 1, [], tensors, [], [Delta(i, l), Delta(j, k), Delta(a, d), Delta(b, c)]) ref = Expression([tr1, tr2, tr3, tr4]) aref = AExpression(Ex=ref) self.assertTrue(aout.pmatch(aref)) op = E2("A", ["occ"], ["vir"]) out = apply_wick(bra * op) out.resolve() aout = AExpression(Ex=out) ext = Tensor([a, b, i, j], "") ten = Tensor([a, b, i, j], "A", sym=get_sym(True)) at1 = ATerm(scalar=1, sums=[], tensors=[ext, ten]) self.assertTrue(len(aout.terms) == 1) self.assertTrue(at1.pmatch(aout.terms[0]))
def test_connected(self): H1 = one_e("f", ["occ", "vir"], norder=True) H2 = two_e("I", ["occ", "vir"], norder=True) H = H1 + H2 bra = braE2("occ", "vir", "occ", "vir") C0 = E0("c") C1 = E1("c", ["occ"], ["vir"]) C2 = E2("c", ["occ"], ["vir"]) ket = C0 + C1 + C2 HC = H * ket S = bra * HC out = apply_wick(S) out.resolve() final = AExpression(Ex=out) out = [at.connected() for at in final.terms] ref = [True] * 19 ref[0] = ref[1] = ref[2] = ref[3] = False self.assertTrue(ref == out)
def test_ccsd_T1(self): H1 = one_e("f", ["occ", "vir"], norder=True) H2 = two_e("I", ["occ", "vir"], norder=True) H = H1 + H2 bra = braE1("occ", "vir") T1 = E1("t", ["occ"], ["vir"]) T2 = E2("t", ["occ"], ["vir"]) T = T1 + T2 HT = commute(H, T) HTT = commute(HT, T) HTTT = commute(commute(commute(H2, T1), T1), T1) S = bra*(H + HT + Fraction('1/2')*HTT + Fraction('1/6')*HTTT) out = apply_wick(S) out.resolve() final = AExpression(Ex=out) out = str(final) + "\n" ref = get_ref("ccsd_T1.out") self.assertTrue(ref == out)
from fractions import Fraction from wick.expression import AExpression from wick.wick import apply_wick from wick.convenience import one_e, two_e, E1, E2, braEip1, Eip1, Eip2, commute H1 = one_e("f", ["occ", "vir"], norder=True) H2 = two_e("I", ["occ", "vir"], norder=True) H = H1 + H2 bra = braEip1("occ") T1 = E1("t", ["occ"], ["vir"]) T2 = E2("t", ["occ"], ["vir"]) R1 = Eip1("r", ["occ"]) R2 = Eip2("r", ["occ"], ["vir"]) T = T1 + T2 R = R1 + R2 HT = commute(H, T) HTT = commute(HT, T) HTTT = commute(HTT, T) HTTTT = commute(HTTT, T) Hbar = H + HT + Fraction('1/2') * HTT S0 = Hbar E0 = apply_wick(S0) E0.resolve() Hbar += Fraction('1/6') * HTTT + Fraction('1/24') * HTTTT S = bra * (Hbar - E0) * R
from fractions import Fraction from wick.expression import AExpression from wick.wick import apply_wick from wick.convenience import one_e, two_e, E1, E2, ketE1, commute H1 = one_e("f", ["occ", "vir"], norder=True) H2 = two_e("I", ["occ", "vir"], norder=True) H = H1 + H2 T1 = E1("t", ["occ"], ["vir"]) T2 = E2("t", ["occ"], ["vir"]) T = T1 + T2 L1 = E1("L", ["vir"], ["occ"]) L2 = E2("L", ["vir"], ["occ"]) L = L1 + L2 ket = ketE1("occ", "vir") HT = commute(H, T) HTT = commute(HT, T) HTTT = commute(HTT, T) HTTTT = commute(HTTT, T) Hbar = H + HT + Fraction('1/2') * HTT Hbar += Fraction('1/6') * HTTT + Fraction('1/24') * HTTTT # Pieces not proportaional to lambda S = Hbar * ket out = apply_wick(S) out.resolve() ex = AExpression(Ex=out)
from wick.expression import AExpression from wick.wick import apply_wick from wick.convenience import one_e, two_e, E0, E2, braE2 H1 = one_e("f", ["occ", "vir"], norder=True) H2 = two_e("I", ["occ", "vir"], norder=True) H = H1 + H2 bra = braE2("occ", "vir", "occ", "vir") C0 = E0("c") C2 = E2("c", ["occ"], ["vir"]) ket = C0 + C2 HC = H * ket S = bra * HC out = apply_wick(S) out.resolve() final = AExpression(Ex=out) print("Sigma2") print(final) S = HC out = apply_wick(S) out.resolve() final = AExpression(Ex=out) print("Sigma0") print(final)
from wick.convenience import one_e, two_e, E1, E2, braE1, commute index_key = { "occ": "ijklmno", "oa": "IJKLMNO", "va": "ABCDEFG", "vir": "abcdefg" } H1 = one_e("f", ["occ", "oa", "va", "vir"], norder=True, index_key=index_key) H2 = two_e("I", ["occ", "oa", "va", "vir"], norder=True, index_key=index_key) H = H1 + H2 bra = braE1("occ", "vir", index_key=index_key) T1 = E1("t", ["occ", "oa"], ["va", "vir"], index_key=index_key) T2 = E2("t", ["occ", "oa"], ["va", "vir"], index_key=index_key) T = T1 + T2 HT = commute(H, T) HTT = commute(HT, T) HTTT = commute(commute(commute(H2, T1), T1), T1) S = bra * H out = apply_wick(S) out.resolve() final = AExpression(Ex=out) print("Constant:") print(final) print("") S = bra * HT