Example #1
0
    def testE1(self):
        bra = braE1("occ", "vir")
        ket = ketE1("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")
        tr1 = Term(1, [],
                   [Tensor([a, i], ""), Tensor([j, b], "")], [],
                   [Delta(i, j), Delta(a, b)])
        ref = Expression([tr1])
        aref = AExpression(Ex=ref)
        self.assertTrue(aout.pmatch(aref))

        op = E1("A", ["occ"], ["vir"])
        out = apply_wick(bra * op)
        out.resolve()
        aout = AExpression(Ex=out)
        ext = Tensor([a, i], "")
        ten = Tensor([a, i], "A")
        at1 = ATerm(scalar=1, sums=[], tensors=[ext, ten])
        self.assertTrue(len(aout.terms) == 1)
        self.assertTrue(at1 == aout.terms[0])
Example #2
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)
Example #3
0
    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)
Example #4
0
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
Example #5
0
from wick.expression import AExpression
from wick.wick import apply_wick
from wick.convenience import one_e, two_e, E1, braE1

H1 = one_e("f", ["occ", "vir"], norder=True)
H2 = two_e("I", ["occ", "vir"], norder=True)

H = H1 + H2
bra = braE1("occ", "vir")
ket = E1("c", ["occ"], ["vir"])

HC = H*ket
S = bra*HC
out = apply_wick(S)
out.resolve()
final = AExpression(Ex=out)
print(final)
Example #6
0
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)
Example #7
0
from wick.wick import apply_wick
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("")