def main(): i, j, k, l = symbols('i,j,k,l', below_fermi=True) a, b, c, d = symbols('a,b,c,d', above_fermi=True) H1, H2 = getHamiltonian() eq_H1 = computeHausdorff(H1) #e^(-T)H1e^T eq_H2 = computeHausdorff(H2) print("CC energy:") Energy = wicks(eq_H1 + eq_H2, simplify_dummies=True, keep_only_fully_contracted=True, simplify_kronecker_deltas=True) Energy = substitute_dummies(Energy, new_indices=True, pretty_indices=pretty_dummies_dict) print(latex(Energy)) print() """ print("CC dE_H1/(dLia):") eqH1T1 = wicks(Fd(i)*F(a)*eq_H1, simplify_dummies=True, keep_only_fully_contracted=True, simplify_kronecker_deltas=True) P = PermutationOperator eqH1T1 = simplify_index_permutations(eqH1T1, [P(a, b), P(i, j)]) eqH1T1 = substitute_dummies(eqH1T1,new_indices=True, pretty_indices=pretty_dummies_dict) print(latex(eqH1T1)) print() print("CC dE_H2/(dLia):") eqH2T1 = wicks(Fd(i)*F(a)*eq_H2, simplify_dummies=True, keep_only_fully_contracted=True, simplify_kronecker_deltas=True) P = PermutationOperator eqH2T1 = simplify_index_permutations(eqH2T1, [P(a, b), P(i, j)]) eqH2T1 = substitute_dummies(eqH2T1,new_indices=True, pretty_indices=pretty_dummies_dict) print(latex(eqH2T1)) print() """ print("CC dE_H1/(dLijab):") eqH1T2 = wicks(Fd(j) * F(b) * Fd(i) * F(a) * eq_H1, simplify_dummies=True, keep_only_fully_contracted=True, simplify_kronecker_deltas=True) P = PermutationOperator eqH1T2 = simplify_index_permutations(eqH1T2, [P(a, b), P(i, j)]) eqH1T2 = substitute_dummies(eqH1T2, new_indices=True, pretty_indices=pretty_dummies_dict) print(latex(eqH1T2)) print() print("CC dE_H2/(dLijab):") eqH2T2 = wicks(Fd(j) * F(b) * Fd(i) * F(a) * eq_H2, simplify_dummies=True, keep_only_fully_contracted=True, simplify_kronecker_deltas=True) P = PermutationOperator eqH2T2 = simplify_index_permutations(eqH2T2, [P(i, j), P(a, b)]) eqH2T2 = substitute_dummies(eqH2T2, new_indices=True, pretty_indices=pretty_dummies_dict) print(latex(eqH2T2)) print()
def OPDM(L, R, flavor): display( Markdown( rf""" Computing OPDM for {flavor} (skipping summation for dummy variables)""" )) i, j = symbols('i,j', below_fermi=True) a, b = symbols('a,b', above_fermi=True) PermutList = [PermutationOperator(i, j), PermutationOperator(a, b)] oo = Fd(i) * F(j) cc = BCH.level(oo, "SD") g_oo = evaluate_deltas(wicks(L * cc * R, keep_only_fully_contracted=True)) g_oo = simplify_index_permutations(g_oo, PermutList) index_rule = {'below': 'klmno', 'above': 'abcde'} g_oo = substitute_dummies(g_oo, new_indices=True, pretty_indices=index_rule) gamma = Symbol('\gamma_{ij}') final_eq = Eq(gamma, g_oo) display(final_eq) ov = Fd(i) * F(a) cc = BCH.level(ov, "SD") g_ov = evaluate_deltas(wicks(L * cc * R, keep_only_fully_contracted=True)) g_ov = simplify_index_permutations(g_ov, PermutList) index_rule = {'below': 'jklmn', 'above': 'bcdef'} g_ov = substitute_dummies(g_ov, new_indices=True, pretty_indices=index_rule) gamma = Symbol('\gamma_{ia}') final_eq = Eq(gamma, g_ov) display(final_eq) vo = Fd(a) * F(i) cc = BCH.level(vo, "SD") g_vo = evaluate_deltas(wicks(L * cc * R, keep_only_fully_contracted=True)) g_vo = simplify_index_permutations(g_vo, PermutList) index_rule = {'below': 'jklmn', 'above': 'bcdef'} g_vo = substitute_dummies(g_vo, new_indices=True, pretty_indices=index_rule) gamma = Symbol('\gamma_{ai}') final_eq = Eq(gamma, g_vo) display(final_eq) vv = Fd(a) * F(b) cc = BCH.level(vv, "SD") g_vv = evaluate_deltas(wicks(L * cc * R, keep_only_fully_contracted=True)) g_vv = simplify_index_permutations(g_vv, PermutList) index_rule = {'below': 'ijklm', 'above': 'cdefg'} g_vv = substitute_dummies(g_vv, new_indices=True, pretty_indices=index_rule) gamma = Symbol('\gamma_{ab}') final_eq = Eq(gamma, g_vv) display(final_eq)
def OPTDM(Lf1, Rf1, Lf2, Rf2, flavor1, flavor2): display( Markdown( rf""" Computing Dyson OPTDM between {flavor1} $\rightarrow$ {flavor2} (skipping summation for dummy variables)""" )) i = symbols('i', below_fermi=True) a = symbols('a', above_fermi=True) index_rule = {'below': 'jklmn', 'above': 'bcde'} oo = Fd(i) cc = BCH.level(oo, "SD") g_oo = evaluate_deltas( wicks(Lf2 * cc * Rf1, keep_only_fully_contracted=True)) g_oo = substitute_dummies(g_oo, new_indices=True, pretty_indices=index_rule) gamma = Symbol('\gamma_i^{R}') final_eq = Eq(gamma, g_oo) display(final_eq) ov = Fd(a) cc = BCH.level(ov, "SD") g_ov = evaluate_deltas( wicks(Lf2 * cc * Rf1, keep_only_fully_contracted=True)) index_rule = {'below': 'jklmn', 'above': 'bcdef'} g_ov = substitute_dummies(g_ov, new_indices=True, pretty_indices=index_rule) gamma = Symbol('\gamma_a^{R}') final_eq = Eq(gamma, g_ov) display(final_eq) vo = F(i) cc = BCH.level(vo, "SD") g_vo = evaluate_deltas( wicks(Lf1 * cc * Rf2, keep_only_fully_contracted=True)) index_rule = {'below': 'jklmn', 'above': 'bcdef'} g_vo = substitute_dummies(g_vo, new_indices=True, pretty_indices=index_rule) gamma = Symbol('\gamma_i^{L}') final_eq = Eq(gamma, g_vo) display(final_eq) vv = F(a) cc = BCH.level(vv, "SD") g_vv = evaluate_deltas( wicks(Lf1 * cc * Rf2, keep_only_fully_contracted=True)) index_rule = {'below': 'ijklm', 'above': 'cdefg'} g_vv = substitute_dummies(g_vv, new_indices=True, pretty_indices=index_rule) gamma = Symbol('\gamma_a^{L}') final_eq = Eq(gamma, g_vv) display(final_eq)
def test_fully_contracted(): i, j, k, l = symbols("i j k l", below_fermi=True) a, b, c, d = symbols("a b c d", above_fermi=True) p, q, r, s = symbols("p q r s", cls=Dummy) Fock = AntiSymmetricTensor("f", (p,), (q,)) * NO(Fd(p) * F(q)) V = (AntiSymmetricTensor("v", (p, q), (r, s)) * NO(Fd(p) * Fd(q) * F(s) * F(r))) / 4 Fai = wicks(NO(Fd(i) * F(a)) * Fock, keep_only_fully_contracted=True, simplify_kronecker_deltas=True) assert Fai == AntiSymmetricTensor("f", (a,), (i,)) Vabij = wicks(NO(Fd(i) * Fd(j) * F(b) * F(a)) * V, keep_only_fully_contracted=True, simplify_kronecker_deltas=True) assert Vabij == AntiSymmetricTensor("v", (a, b), (i, j))
def test_wicks(): p, q, r, s = symbols("p,q,r,s", above_fermi=True) # Testing for particles only str = F(p) * Fd(q) assert wicks(str) == NO(F(p) * Fd(q)) + KroneckerDelta(p, q) str = Fd(p) * F(q) assert wicks(str) == NO(Fd(p) * F(q)) str = F(p) * Fd(q) * F(r) * Fd(s) nstr = wicks(str) fasit = NO( KroneckerDelta(p, q) * KroneckerDelta(r, s) + KroneckerDelta(p, q) * AnnihilateFermion(r) * CreateFermion(s) + KroneckerDelta(r, s) * AnnihilateFermion(p) * CreateFermion(q) - KroneckerDelta(p, s) * AnnihilateFermion(r) * CreateFermion(q) - AnnihilateFermion(p) * AnnihilateFermion(r) * CreateFermion(q) * CreateFermion(s) ) assert nstr == fasit assert (p * q * nstr).expand() == wicks(p * q * str) assert (nstr * p * q * 2).expand() == wicks(str * p * q * 2) # Testing CC equations particles and holes i, j, k, l = symbols("i j k l", below_fermi=True, cls=Dummy) a, b, c, d = symbols("a b c d", above_fermi=True, cls=Dummy) p, q, r, s = symbols("p q r s", cls=Dummy) assert wicks(F(a) * NO(F(i) * F(j)) * Fd(b)) == NO( F(a) * F(i) * F(j) * Fd(b) ) + KroneckerDelta(a, b) * NO(F(i) * F(j)) assert wicks(F(a) * NO(F(i) * F(j) * F(k)) * Fd(b)) == NO( F(a) * F(i) * F(j) * F(k) * Fd(b) ) - KroneckerDelta(a, b) * NO(F(i) * F(j) * F(k)) expr = wicks(Fd(i) * NO(Fd(j) * F(k)) * F(l)) assert expr == -KroneckerDelta(i, k) * NO(Fd(j) * F(l)) - KroneckerDelta(j, l) * NO( Fd(i) * F(k) ) - KroneckerDelta(i, k) * KroneckerDelta(j, l) + KroneckerDelta(i, l) * NO( Fd(j) * F(k) ) + NO( Fd(i) * Fd(j) * F(k) * F(l) ) expr = wicks(F(a) * NO(F(b) * Fd(c)) * Fd(d)) assert expr == -KroneckerDelta(a, c) * NO(F(b) * Fd(d)) - KroneckerDelta(b, d) * NO( F(a) * Fd(c) ) - KroneckerDelta(a, c) * KroneckerDelta(b, d) + KroneckerDelta(a, d) * NO( F(b) * Fd(c) ) + NO( F(a) * F(b) * Fd(c) * Fd(d) )
def test_NO(): i, j, k, l = symbols('i j k l', below_fermi=True) a, b, c, d = symbols('a b c d', above_fermi=True) p, q, r, s = symbols('p q r s', cls=Dummy) assert (NO(Fd(p)*F(q) + Fd(a)*F(b)) == NO(Fd(p)*F(q)) + NO(Fd(a)*F(b))) assert (NO(Fd(i)*NO(F(j)*Fd(a))) == NO(Fd(i)*F(j)*Fd(a))) assert NO(1) == 1 assert NO(i) == i assert (NO(Fd(a)*Fd(b)*(F(c) + F(d))) == NO(Fd(a)*Fd(b)*F(c)) + NO(Fd(a)*Fd(b)*F(d))) assert NO(Fd(a)*F(b))._remove_brackets() == Fd(a)*F(b) assert NO(F(j)*Fd(i))._remove_brackets() == F(j)*Fd(i) assert (NO(Fd(p)*F(q)).subs(Fd(p), Fd(a) + Fd(i)) == NO(Fd(a)*F(q)) + NO(Fd(i)*F(q))) assert (NO(Fd(p)*F(q)).subs(F(q), F(a) + F(i)) == NO(Fd(p)*F(a)) + NO(Fd(p)*F(i))) expr = NO(Fd(p)*F(q))._remove_brackets() assert wicks(expr) == NO(expr) assert NO(Fd(a)*F(b)) == - NO(F(b)*Fd(a)) no = NO(Fd(a)*F(i)*F(b)*Fd(j)) l1 = [ ind for ind in no.iter_q_creators() ] assert l1 == [0, 1] l2 = [ ind for ind in no.iter_q_annihilators() ] assert l2 == [3, 2]
def test_NO(): i, j, k, l = symbols('i j k l', below_fermi=True) a, b, c, d = symbols('a b c d', above_fermi=True) p, q, r, s = symbols('p q r s', cls=Dummy) assert (NO(Fd(p) * F(q) + Fd(a) * F(b)) == NO(Fd(p) * F(q)) + NO(Fd(a) * F(b))) assert (NO(Fd(i) * NO(F(j) * Fd(a))) == NO(Fd(i) * F(j) * Fd(a))) assert NO(1) == 1 assert NO(i) == i assert (NO(Fd(a) * Fd(b) * (F(c) + F(d))) == NO(Fd(a) * Fd(b) * F(c)) + NO(Fd(a) * Fd(b) * F(d))) assert NO(Fd(a) * F(b))._remove_brackets() == Fd(a) * F(b) assert NO(F(j) * Fd(i))._remove_brackets() == F(j) * Fd(i) assert (NO(Fd(p) * F(q)).subs(Fd(p), Fd(a) + Fd(i)) == NO(Fd(a) * F(q)) + NO(Fd(i) * F(q))) assert (NO(Fd(p) * F(q)).subs(F(q), F(a) + F(i)) == NO(Fd(p) * F(a)) + NO(Fd(p) * F(i))) expr = NO(Fd(p) * F(q))._remove_brackets() assert wicks(expr) == NO(expr) assert NO(Fd(a) * F(b)) == -NO(F(b) * Fd(a)) no = NO(Fd(a) * F(i) * F(b) * Fd(j)) l1 = [ind for ind in no.iter_q_creators()] assert l1 == [0, 1] l2 = [ind for ind in no.iter_q_annihilators()] assert l2 == [3, 2]
def test_wicks(): p,q,r,s = symbols('pqrs',above_fermi=True) # Testing for particles only str = F(p)*Fd(q) assert wicks(str) == NO(F(p)*Fd(q)) + KroneckerDelta(p,q) str = Fd(p)*F(q) assert wicks(str) == NO(Fd(p)*F(q)) str = F(p)*Fd(q)*F(r)*Fd(s) nstr= wicks(str) fasit = NO( KroneckerDelta(p, q)*KroneckerDelta(r, s) + KroneckerDelta(p, q)*AnnihilateFermion(r)*CreateFermion(s) + KroneckerDelta(r, s)*AnnihilateFermion(p)*CreateFermion(q) - KroneckerDelta(p, s)*AnnihilateFermion(r)*CreateFermion(q) - AnnihilateFermion(p)*AnnihilateFermion(r)*CreateFermion(q)*CreateFermion(s)) assert nstr == fasit assert (p*q*nstr).expand() == wicks(p*q*str) assert (nstr*p*q*2).expand() == wicks(str*p*q*2) # Testing CC equations particles and holes i,j,k,l = symbols('ijkl',below_fermi=True,dummy=True) a,b,c,d = symbols('abcd',above_fermi=True,dummy=True) p,q,r,s = symbols('pqrs',dummy=True) assert (wicks(F(a)*NO(F(i)*F(j))*Fd(b)) == NO(F(a)*F(i)*F(j)*Fd(b)) + KroneckerDelta(a,b)*NO(F(i)*F(j))) assert (wicks(F(a)*NO(F(i)*F(j)*F(k))*Fd(b)) == NO(F(a)*F(i)*F(j)*F(k)*Fd(b)) - KroneckerDelta(a,b)*NO(F(i)*F(j)*F(k))) expr = wicks(Fd(i)*NO(Fd(j)*F(k))*F(l)) assert (expr == -KroneckerDelta(i,k)*NO(Fd(j)*F(l)) - KroneckerDelta(j,l)*NO(Fd(i)*F(k)) - KroneckerDelta(i,k)*KroneckerDelta(j,l)+ KroneckerDelta(i,l)*NO(Fd(j)*F(k)) + NO(Fd(i)*Fd(j)*F(k)*F(l))) expr = wicks(F(a)*NO(F(b)*Fd(c))*Fd(d)) assert (expr == -KroneckerDelta(a,c)*NO(F(b)*Fd(d)) - KroneckerDelta(b,d)*NO(F(a)*Fd(c)) - KroneckerDelta(a,c)*KroneckerDelta(b,d)+ KroneckerDelta(a,d)*NO(F(b)*Fd(c)) + NO(F(a)*F(b)*Fd(c)*Fd(d)))
def test_fully_contracted(): i, j, k, l = symbols('i j k l', below_fermi=True) a, b, c, d = symbols('a b c d', above_fermi=True) p, q, r, s = symbols('p q r s', cls=Dummy) Fock = (AntiSymmetricTensor('f', (p, ), (q, )) * NO(Fd(p) * F(q))) V = (AntiSymmetricTensor('v', (p, q), (r, s)) * NO(Fd(p) * Fd(q) * F(s) * F(r))) / 4 Fai = wicks(NO(Fd(i) * F(a)) * Fock, keep_only_fully_contracted=True, simplify_kronecker_deltas=True) assert Fai == AntiSymmetricTensor('f', (a, ), (i, )) Vabij = wicks(NO(Fd(i) * Fd(j) * F(b) * F(a)) * V, keep_only_fully_contracted=True, simplify_kronecker_deltas=True) assert Vabij == AntiSymmetricTensor('v', (a, b), (i, j))
def get_two_body_equation(equation_h, equation_u): two_body_eq = wicks( Fd(j) * F(b) * Fd(i) * F(a) * equation_u, **wicks_kwargs) p = PermutationOperator two_body_eq = simplify_index_permutations(two_body_eq, [p(i, j), p(a, b)]) two_body_eq = substitute_dummies(two_body_eq, **sub_kwargs) return two_body_eq
def get_one_body_equation(equation_h, equation_u): one_body_eq = wicks( Fd(j) * F(b) * Fd(i) * F(a) * equation_h, **wicks_kwargs) p = PermutationOperator one_body_eq = simplify_index_permutations(one_body_eq, [p(a, b), p(i, j)]) one_body_eq = substitute_dummies(one_body_eq, **sub_kwargs) return one_body_eq
def level(H, expr): pretty_dummies_dict = { 'above': 'defg', 'below': 'lmno', 'general': 'pqrst' } #display(Markdown # (rf"""Calculating 4 nested commutators""")) C = Commutator T1, T2 = get_CC_operators() T = T1 + T2 comm1 = wicks(C(H, T)) comm1 = evaluate_deltas(comm1) comm1 = substitute_dummies(comm1) T1, T2 = get_CC_operators() T = T1 + T2 comm2 = wicks(C(comm1, T)) comm2 = evaluate_deltas(comm2) comm2 = substitute_dummies(comm2) T1, T2 = get_CC_operators() T = T1 + T2 comm3 = wicks(C(comm2, T)) comm3 = evaluate_deltas(comm3) comm3 = substitute_dummies(comm3) T1, T2 = get_CC_operators() T = T1 + T2 comm4 = wicks(C(comm3, T)) comm4 = evaluate_deltas(comm4) comm4 = substitute_dummies(comm4) eq = H + comm1 + comm2 / 2 + comm3 / 6 + comm4 / 24 eq = eq.expand() eq = evaluate_deltas(eq) eq = substitute_dummies(eq, new_indices=True, pretty_indices=pretty_dummies_dict) return eq
def computeHausdorff(H): print("Calculating 4 nested commutators") C = Commutator T1, T2 = get_T_operators() T = T2 print("commutator 1...") comm1 = wicks(C(H, T)) comm1 = evaluate_deltas(comm1) comm1 = substitute_dummies(comm1) T1, T2 = get_T_operators() T = T2 print("commutator 2...") comm2 = wicks(C(comm1, T)) comm2 = evaluate_deltas(comm2) comm2 = substitute_dummies(comm2) T1, T2 = get_T_operators() T = T2 print("commutator 3...") comm3 = wicks(C(comm2, T)) comm3 = evaluate_deltas(comm3) comm3 = substitute_dummies(comm3) T1, T2 = get_T_operators() T = T2 print("commutator 4...") comm4 = wicks(C(comm3, T)) comm4 = evaluate_deltas(comm4) comm4 = substitute_dummies(comm4) print("construct Hausdorff expansion...") eq = H + comm1 + comm2 / 2 + comm3 / 6 + comm4 / 24 eq = eq.expand() eq = evaluate_deltas(eq) eq = substitute_dummies(eq, new_indices=True, pretty_indices=pretty_dummies_dict) print("*********************") print() return eq
def compute_hausdorff(h, cluster_func, num_terms=4): commutator = Commutator comm_term = h equation = comm_term for i in range(num_terms): t = sum(cluster_func()) comm_term = wicks(commutator(comm_term, t)) comm_term = substitute_dummies(evaluate_deltas(comm_term)) equation += comm_term / factorial(i + 1) equation = equation.expand() equation = evaluate_deltas(equation) equation = substitute_dummies(equation, new_indices=True, pretty_indices=pretty_dummies) return equation
def test_NO(): i, j, k, l = symbols('i j k l', below_fermi=True) a, b, c, d = symbols('a b c d', above_fermi=True) p, q, r, s = symbols('p q r s', cls=Dummy) assert (NO(Fd(p)*F(q) + Fd(a)*F(b)) == NO(Fd(p)*F(q)) + NO(Fd(a)*F(b))) assert (NO(Fd(i)*NO(F(j)*Fd(a))) == NO(Fd(i)*F(j)*Fd(a))) assert NO(1) == 1 assert NO(i) == i assert (NO(Fd(a)*Fd(b)*(F(c) + F(d))) == NO(Fd(a)*Fd(b)*F(c)) + NO(Fd(a)*Fd(b)*F(d))) assert NO(Fd(a)*F(b))._remove_brackets() == Fd(a)*F(b) assert NO(F(j)*Fd(i))._remove_brackets() == F(j)*Fd(i) assert (NO(Fd(p)*F(q)).subs(Fd(p), Fd(a) + Fd(i)) == NO(Fd(a)*F(q)) + NO(Fd(i)*F(q))) assert (NO(Fd(p)*F(q)).subs(F(q), F(a) + F(i)) == NO(Fd(p)*F(a)) + NO(Fd(p)*F(i))) expr = NO(Fd(p)*F(q))._remove_brackets() assert wicks(expr) == NO(expr) assert NO(Fd(a)*F(b)) == - NO(F(b)*Fd(a)) no = NO(Fd(a)*F(i)*F(b)*Fd(j)) l1 = [ ind for ind in no.iter_q_creators() ] assert l1 == [0, 1] l2 = [ ind for ind in no.iter_q_annihilators() ] assert l2 == [3, 2] no = NO(Fd(a)*Fd(i)) assert no.has_q_creators == 1 assert no.has_q_annihilators == -1 assert str(no) == ':CreateFermion(a)*CreateFermion(i):' assert repr(no) == 'NO(CreateFermion(a)*CreateFermion(i))' assert latex(no) == r'\left\{a^\dagger_{a} a^\dagger_{i}\right\}' raises(NotImplementedError, lambda: NO(Bd(p)*F(q)))
def test_NO(): i, j, k, l = symbols("i j k l", below_fermi=True) a, b, c, d = symbols("a b c d", above_fermi=True) p, q, r, s = symbols("p q r s", cls=Dummy) assert NO(Fd(p) * F(q) + Fd(a) * F(b)) == NO(Fd(p) * F(q)) + NO(Fd(a) * F(b)) assert NO(Fd(i) * NO(F(j) * Fd(a))) == NO(Fd(i) * F(j) * Fd(a)) assert NO(1) == 1 assert NO(i) == i assert NO(Fd(a) * Fd(b) * (F(c) + F(d))) == NO(Fd(a) * Fd(b) * F(c)) + NO( Fd(a) * Fd(b) * F(d) ) assert NO(Fd(a) * F(b))._remove_brackets() == Fd(a) * F(b) assert NO(F(j) * Fd(i))._remove_brackets() == F(j) * Fd(i) assert NO(Fd(p) * F(q)).subs(Fd(p), Fd(a) + Fd(i)) == NO(Fd(a) * F(q)) + NO( Fd(i) * F(q) ) assert NO(Fd(p) * F(q)).subs(F(q), F(a) + F(i)) == NO(Fd(p) * F(a)) + NO( Fd(p) * F(i) ) expr = NO(Fd(p) * F(q))._remove_brackets() assert wicks(expr) == NO(expr) assert NO(Fd(a) * F(b)) == -NO(F(b) * Fd(a)) no = NO(Fd(a) * F(i) * F(b) * Fd(j)) l1 = [ind for ind in no.iter_q_creators()] assert l1 == [0, 1] l2 = [ind for ind in no.iter_q_annihilators()] assert l2 == [3, 2] no = NO(Fd(a) * Fd(i)) assert no.has_q_creators == 1 assert no.has_q_annihilators == -1 assert str(no) == ":CreateFermion(a)*CreateFermion(i):" assert repr(no) == "NO(CreateFermion(a)*CreateFermion(i))" assert latex(no) == r"\left\{a^\dagger_{a} a^\dagger_{i}\right\}" raises(NotImplementedError, lambda: NO(Bd(p) * F(q)))
#Setup Hamiltonian, not on normal order form h = AntiSymmetricTensor('h', (p, ), (q, )) pq = ap_dagger * aq V = AntiSymmetricTensor('V', (p, q), (r, s)) pqsr = Fd(p) * Fd(q) * F(s) * F(r) H0 = h * pq HI = Rational(1, 4) * V * pqsr H = H0 + HI #Compute the normal ordered form of the Hamiltonian #sympy.physics.secondquant.wicks(e, **kw_args)[source] #Returns the normal ordered equivalent of an expression using Wicks Theorem H_N = evaluate_deltas(wicks(H)) H_N = substitute_dummies(H_N, new_indices=True, pretty_indices=pretty_dummies_dict) Eref = evaluate_deltas(wicks(H, keep_only_fully_contracted=True)) Eref = substitute_dummies(Eref, new_indices=True, pretty_indices=pretty_dummies_dict) print("Eref: ", latex(Eref)) print() print("Normal ordered Hamiltonian") print(latex(H_N)) print()
def main(): print() print("Calculates the Coupled-Cluster energy- and amplitude equations") print("See 'An Introduction to Coupled Cluster Theory' by") print("T. Daniel Crawford and Henry F. Schaefer III") print("http://www.ccc.uga.edu/lec_top/cc/html/review.html") print() # setup hamiltonian p, q, r, s = symbols('p,q,r,s', cls=Dummy) f = AntiSymmetricTensor('f', (p,), (q,)) pr = NO((Fd(p)*F(q))) v = AntiSymmetricTensor('v', (p, q), (r, s)) pqsr = NO(Fd(p)*Fd(q)*F(s)*F(r)) H = f*pr + Rational(1, 4)*v*pqsr print("Using the hamiltonian:", latex(H)) print("Calculating 4 nested commutators") C = Commutator T1, T2 = get_CC_operators() T = T1 + T2 print("commutator 1...") comm1 = wicks(C(H, T)) comm1 = evaluate_deltas(comm1) comm1 = substitute_dummies(comm1) T1, T2 = get_CC_operators() T = T1 + T2 print("commutator 2...") comm2 = wicks(C(comm1, T)) comm2 = evaluate_deltas(comm2) comm2 = substitute_dummies(comm2) T1, T2 = get_CC_operators() T = T1 + T2 print("commutator 3...") comm3 = wicks(C(comm2, T)) comm3 = evaluate_deltas(comm3) comm3 = substitute_dummies(comm3) T1, T2 = get_CC_operators() T = T1 + T2 print("commutator 4...") comm4 = wicks(C(comm3, T)) comm4 = evaluate_deltas(comm4) comm4 = substitute_dummies(comm4) print("construct Hausdoff expansion...") eq = H + comm1 + comm2/2 + comm3/6 + comm4/24 eq = eq.expand() eq = evaluate_deltas(eq) eq = substitute_dummies(eq, new_indices=True, pretty_indices=pretty_dummies_dict) print("*********************") print() print("extracting CC equations from full Hbar") i, j, k, l = symbols('i,j,k,l', below_fermi=True) a, b, c, d = symbols('a,b,c,d', above_fermi=True) print() print("CC Energy:") print(latex(wicks(eq, simplify_dummies=True, keep_only_fully_contracted=True))) print() print("CC T1:") eqT1 = wicks(NO(Fd(i)*F(a))*eq, simplify_kronecker_deltas=True, keep_only_fully_contracted=True) eqT1 = substitute_dummies(eqT1) print(latex(eqT1)) print() print("CC T2:") eqT2 = wicks(NO(Fd(i)*Fd(j)*F(b)*F(a))*eq, simplify_dummies=True, keep_only_fully_contracted=True, simplify_kronecker_deltas=True) P = PermutationOperator eqT2 = simplify_index_permutations(eqT2, [P(a, b), P(i, j)]) print(latex(eqT2))
from sympy.physics.secondquant import Commutator, F, Fd, wicks, NO from sympy import symbols, simplify a = symbols("b0:8") exp = F(a[1])*F(a[0])*Fd(a[3])*Fd(a[2]) * F(a[4])*F(a[5])*Fd(a[6])*Fd(a[7]) exp = wicks(exp) print(exp)
V = AntiSymmetricTensor('V', (p, q), (r, s)) pqsr = NO(Fd(p) * Fd(q) * F(s) * F(r)) HI = Rational(1, 4) * V * pqsr HN = E0 + F + HI i, j, k, l = symbols('i,j,k,l', below_fermi=True) a, b, c, d = symbols('a,b,c,d', above_fermi=True) print("Compute CCD energy and amplitude equations term by term") #BCH: HN + [HN,T] + 0.5*[[HN,T],T] + 1/6 * [[[HN,T],T],T] + 1/24 * [[[[HN,T],T],T],T] print("zero-order term") print("<Phi|HN|Phi> = ", latex(wicks(HN, simplify_dummies=True, keep_only_fully_contracted=True))) eqT2 = wicks(NO(Fd(i) * Fd(j) * F(b) * F(a)) * HN, simplify_dummies=True, keep_only_fully_contracted=True, simplify_kronecker_deltas=True) P = PermutationOperator eqT2 = simplify_index_permutations(eqT2, [P(a, b), P(i, j)]) print("<Phi|HN|Phi_ij^ab = ", latex(eqT2)) print() C = Commutator T1, T2 = get_CC_operators() T = T2 print("[HN,T]-term") comm1 = wicks(C(HN, T))
print "Setting up hamiltonian" p,q,r,s = symbols('pqrs',dummy=True) f = AntiSymmetricTensor('f',(p,),(q,)) pr = NO((Fd(p)*F(q))) v = AntiSymmetricTensor('v',(p,q),(r,s)) pqsr = NO(Fd(p)*Fd(q)*F(s)*F(r)) H=f*pr +Number(1,4)*v*pqsr print "Calculating nested commutators" C = Commutator T1,T2 = get_CC_operators() T = T1+ T2 print "comm1..." comm1 = wicks(C(H,T),simplify_dummies=True, simplify_kronecker_deltas=True) T1,T2 = get_CC_operators() T = T1+ T2 print "comm2..." comm2 = wicks(C(comm1,T),simplify_dummies=True, simplify_kronecker_deltas=True) T1,T2 = get_CC_operators() T = T1+ T2 print "comm3..." comm3 = wicks(C(comm2,T),simplify_dummies=True, simplify_kronecker_deltas=True) T1,T2 = get_CC_operators() T = T1+ T2 print "comm4..." comm4 = wicks(C(comm3,T),simplify_dummies=True, simplify_kronecker_deltas=True)
def main(): print() print("Calculates the Coupled-Cluster energy- and amplitude equations") print("See 'An Introduction to Coupled Cluster Theory' by") print("T. Daniel Crawford and Henry F. Schaefer III") print( "Reference to a Lecture Series: http://vergil.chemistry.gatech.edu/notes/sahan-cc-2010.pdf" ) print() # setup hamiltonian p, q, r, s = symbols('p,q,r,s', cls=Dummy) f = AntiSymmetricTensor('f', (p, ), (q, )) pr = NO(Fd(p) * F(q)) v = AntiSymmetricTensor('v', (p, q), (r, s)) pqsr = NO(Fd(p) * Fd(q) * F(s) * F(r)) H = f * pr + Rational(1, 4) * v * pqsr print("Using the hamiltonian:", latex(H)) print("Calculating 4 nested commutators") C = Commutator T1, T2 = get_CC_operators() T = T1 + T2 print("commutator 1...") comm1 = wicks(C(H, T)) comm1 = evaluate_deltas(comm1) comm1 = substitute_dummies(comm1) T1, T2 = get_CC_operators() T = T1 + T2 print("commutator 2...") comm2 = wicks(C(comm1, T)) comm2 = evaluate_deltas(comm2) comm2 = substitute_dummies(comm2) T1, T2 = get_CC_operators() T = T1 + T2 print("commutator 3...") comm3 = wicks(C(comm2, T)) comm3 = evaluate_deltas(comm3) comm3 = substitute_dummies(comm3) T1, T2 = get_CC_operators() T = T1 + T2 print("commutator 4...") comm4 = wicks(C(comm3, T)) comm4 = evaluate_deltas(comm4) comm4 = substitute_dummies(comm4) print("construct Hausdorff expansion...") eq = H + comm1 + comm2 / 2 + comm3 / 6 + comm4 / 24 eq = eq.expand() eq = evaluate_deltas(eq) eq = substitute_dummies(eq, new_indices=True, pretty_indices=pretty_dummies_dict) print("*********************") print() print("extracting CC equations from full Hbar") i, j, k, l = symbols('i,j,k,l', below_fermi=True) a, b, c, d = symbols('a,b,c,d', above_fermi=True) print() print("CC Energy:") print( latex(wicks(eq, simplify_dummies=True, keep_only_fully_contracted=True))) # print("HERE") # print("HERE") # print("HERE") # print(pycode(wicks(eq, simplify_dummies=True, # keep_only_fully_contracted=True))) # with open("cc_energy.py", "w") as f: # f. with open("ccsd.jl", "w") as f: eq_energy = wicks(eq, simplify_dummies=True, keep_only_fully_contracted=True) f.write(julia_code(eq_energy)) print() print("CC T1:") eqT1 = wicks(NO(Fd(i) * F(a)) * eq, simplify_kronecker_deltas=True, keep_only_fully_contracted=True) eqT1 = substitute_dummies(eqT1) print(latex(eqT1)) print() print("CC T2:") eqT2 = wicks(NO(Fd(i) * Fd(j) * F(b) * F(a)) * eq, simplify_dummies=True, keep_only_fully_contracted=True, simplify_kronecker_deltas=True) # P = PermutationOperator # eqT2 = simplify_index_permutations(eqT2, [P(a, b), P(i, j)]) print(latex(eqT2)) print(latex(simplify(eqT2)))
def main(): print print "Calculates the Coupled-Cluster energy- and amplitude equations" print "See 'An Introduction to Coupled Cluster Theory' by" print "T. Daniel Crawford and Henry F. Schaefer III" print "http://www.ccc.uga.edu/lec_top/cc/html/review.html" print # setup hamiltonian p, q, r, s = symbols("pqrs", dummy=True) f = AntiSymmetricTensor("f", (p,), (q,)) pr = NO((Fd(p) * F(q))) v = AntiSymmetricTensor("v", (p, q), (r, s)) pqsr = NO(Fd(p) * Fd(q) * F(s) * F(r)) H = f * pr # Uncomment the next line to use a 2-body hamiltonian: # H=f*pr + Number(1,4)*v*pqsr print "Using the hamiltonian:", latex(H) print "Calculating nested commutators" C = Commutator T1, T2 = get_CC_operators() T = T1 + T2 print "comm1..." comm1 = wicks(C(H, T), simplify_dummies=True, simplify_kronecker_deltas=True) T1, T2 = get_CC_operators() T = T1 + T2 print "comm2..." comm2 = wicks(C(comm1, T), simplify_dummies=True, simplify_kronecker_deltas=True) T1, T2 = get_CC_operators() T = T1 + T2 print "comm3..." comm3 = wicks(C(comm2, T), simplify_dummies=True, simplify_kronecker_deltas=True) T1, T2 = get_CC_operators() T = T1 + T2 print "comm4..." comm4 = wicks(C(comm3, T), simplify_dummies=True, simplify_kronecker_deltas=True) print "construct Hausdoff expansion..." eq = H + comm1 + comm2 / 2 + comm3 / 6 + comm4 / 24 eq = eq.expand() eq = evaluate_deltas(eq) eq = substitute_dummies(eq, new_indices=True, reverse_order=False, pretty_indices=pretty_dummies_dict) print "*********************" print print "extracting CC equations from full Hbar" i, j, k, l = symbols("ijkl", below_fermi=True) a, b, c, d = symbols("abcd", above_fermi=True) print print "CC Energy:" print latex(wicks(eq, simplify_dummies=True, keep_only_fully_contracted=True)) print print "CC T1:" eqT1 = wicks(NO(Fd(i) * F(a)) * eq, simplify_kronecker_deltas=True, keep_only_fully_contracted=True) eqT1 = substitute_dummies(eqT1, reverse_order=False) print latex(eqT1) print print "CC T2:" eqT2 = wicks( NO(Fd(i) * Fd(j) * F(b) * F(a)) * eq, simplify_dummies=True, keep_only_fully_contracted=True, simplify_kronecker_deltas=True, ) P = PermutationOperator eqT2 = simplify_index_permutations(eqT2, [P(a, b), P(i, j)]) print latex(eqT2)
def LVECTORS(L0, L1, L2, flavor): display( Markdown( rf""" Computing left sigma amplitudes for {flavor} (skipping summation for dummy variables)""" )) p, q, r, s = symbols('p,q,r,s', cls=Dummy) f = AntiSymmetricTensor('f', (p, ), (q, )) pr = NO((Fd(p) * F(q))) v = AntiSymmetricTensor('v', (p, q), (r, s)) pqsr = NO(Fd(p) * Fd(q) * F(s) * F(r)) ham = f * pr + Rational(1, 4) * v * pqsr cc = BCH.level(ham, "SD") E_cc = evaluate_deltas(wicks(cc, keep_only_fully_contracted=True)) i, j, k = symbols('i,j,k', below_fermi=True) a, b, c = symbols('a,b,c', above_fermi=True) if flavor == "IP": sig11 = evaluate_deltas( wicks(L1 * (cc - E_cc) * F(i), keep_only_fully_contracted=True)) index_rule = {'below': 'jklmno', 'above': 'abcdefg'} sig11 = substitute_dummies(sig11, new_indices=True, pretty_indices=index_rule) if flavor == "EA": sig11 = evaluate_deltas( wicks(L1 * (cc - E_cc) * Fd(a), keep_only_fully_contracted=True)) index_rule = {'below': 'ijklmno', 'above': 'bcdefg'} sig11 = substitute_dummies(sig11, new_indices=True, pretty_indices=index_rule) if flavor == "DIP": PermutList = [PermutationOperator(i, j)] sig11 = evaluate_deltas( wicks(L1 * (cc - E_cc) * F(j) * F(i), keep_only_fully_contracted=True)) index_rule = {'below': 'klmno', 'above': 'abcdefg'} sig11 = substitute_dummies(sig11, new_indices=True, pretty_indices=index_rule) sig11 = simplify_index_permutations(sig11, PermutList) if flavor == "DEA": PermutList = [PermutationOperator(a, b)] sig11 = evaluate_deltas( wicks(L1 * (cc - E_cc) * Fd(a) * Fd(b), keep_only_fully_contracted=True)) index_rule = {'below': 'ijklmno', 'above': 'cdefg'} sig11 = substitute_dummies(sig11, new_indices=True, pretty_indices=index_rule) sig11 = simplify_index_permutations(sig11, PermutList) sigma_11 = Symbol('(L_{1}(\overline{H}_{SS}-E_{cc}))') final_eq = Eq(sigma_11, sig11) display(final_eq) if flavor == "IP": PermutList = [PermutationOperator(i, j)] sig12 = evaluate_deltas( wicks((L2 * cc) * F(i), keep_only_fully_contracted=True)) index_rule = {'below': 'jklmno', 'above': 'abcdefg'} sig12 = substitute_dummies(sig12, new_indices=True, pretty_indices=index_rule) sig12 = simplify_index_permutations(sig12, PermutList) if flavor == "EA": PermutList = [PermutationOperator(a, b)] sig12 = evaluate_deltas( wicks((L2 * cc) * Fd(a), keep_only_fully_contracted=True)) index_rule = {'below': 'ijklmno', 'above': 'bcdefg'} sig12 = substitute_dummies(sig12, new_indices=True, pretty_indices=index_rule) sig12 = simplify_index_permutations(sig12, PermutList) if flavor == "DIP": PermutList = [ PermutationOperator(i, j), PermutationOperator(j, k), PermutationOperator(i, k) ] sig12 = evaluate_deltas( wicks(L2 * cc * F(j) * F(i), keep_only_fully_contracted=True)) index_rule = {'below': 'klmno', 'above': 'abcdefg'} sig12 = substitute_dummies(sig12, new_indices=True, pretty_indices=index_rule) sig12 = simplify_index_permutations(sig12, PermutList) if flavor == "DEA": PermutList = [ PermutationOperator(a, b), PermutationOperator(b, c), PermutationOperator(a, c) ] sig12 = evaluate_deltas( wicks((L2 * cc) * Fd(a) * Fd(b), keep_only_fully_contracted=True)) index_rule = {'below': 'ijklmno', 'above': 'cdefg'} sig12 = substitute_dummies(sig12, new_indices=True, pretty_indices=index_rule) sig12 = simplify_index_permutations(sig12, PermutList) sigma_12 = Symbol('(L_{2}\overline{H}_{DS})') final_eq = Eq(sigma_12, sig12) display(final_eq) if flavor == "IP": sig21 = evaluate_deltas( wicks((L1 * cc) * Fd(a) * F(j) * F(i), keep_only_fully_contracted=True)) index_rule = {'below': 'klmno', 'above': 'bcdefgh'} sig21 = substitute_dummies(sig21, new_indices=True, pretty_indices=index_rule) if flavor == "EA": sig21 = evaluate_deltas( wicks((L1 * cc) * Fd(a) * Fd(b) * F(i), keep_only_fully_contracted=True)) index_rule = {'below': 'jklmno', 'above': 'cdefgh'} sig21 = substitute_dummies(sig21, new_indices=True, pretty_indices=index_rule) if flavor == "DIP": PermutList = [PermutationOperator(i, j)] sig21 = evaluate_deltas( wicks(L1 * cc * Fd(a) * F(k) * F(j) * F(i), keep_only_fully_contracted=True)) index_rule = {'below': 'lmno', 'above': 'bcdefgh'} sig21 = substitute_dummies(sig21, new_indices=True, pretty_indices=index_rule) sig21 = simplify_index_permutations(sig21, PermutList) if flavor == "DEA": PermutList = [PermutationOperator(a, b)] sig21 = evaluate_deltas( wicks((L1 * cc) * Fd(a) * Fd(b) * Fd(c) * F(i), keep_only_fully_contracted=True)) index_rule = {'below': 'jklmno', 'above': 'defgh'} sig21 = substitute_dummies(sig21, new_indices=True, pretty_indices=index_rule) sig21 = simplify_index_permutations(sig21, PermutList) sigma_21 = Symbol('(L_{1}\overline{H}_{SD})') final_eq = Eq(sigma_21, sig21) display(final_eq) if flavor == "IP": PermutList = [PermutationOperator(i, j)] sig22 = evaluate_deltas( wicks(L2 * (cc - E_cc) * Fd(a) * F(j) * F(i), keep_only_fully_contracted=True)) index_rule = {'below': 'klmno', 'above': 'bcdefgh'} sig22 = substitute_dummies(sig22, new_indices=True, pretty_indices=index_rule) sig22 = simplify_index_permutations(sig22, PermutList) if flavor == "EA": PermutList = [PermutationOperator(a, b)] sig22 = evaluate_deltas( wicks(L2 * (cc - E_cc) * Fd(a) * Fd(b) * F(i), keep_only_fully_contracted=True)) index_rule = {'below': 'jklmno', 'above': 'cdefgh'} sig22 = substitute_dummies(sig22, new_indices=True, pretty_indices=index_rule) sig22 = simplify_index_permutations(sig22, PermutList) if flavor == "DIP": PermutList = [ PermutationOperator(i, j), PermutationOperator(j, k), PermutationOperator(i, k) ] sig22 = evaluate_deltas( wicks(L2 * (cc - E_cc) * Fd(a) * F(k) * F(j) * F(i), keep_only_fully_contracted=True)) index_rule = {'below': 'lmno', 'above': 'bcdefgh'} sig22 = substitute_dummies(sig22, new_indices=True, pretty_indices=index_rule) sig22 = simplify_index_permutations(sig22, PermutList) if flavor == "DEA": PermutList = [ PermutationOperator(a, b), PermutationOperator(b, c), PermutationOperator(a, c) ] sig22 = evaluate_deltas( wicks(L2 * (cc - E_cc) * Fd(a) * Fd(b) * Fd(c) * F(i), keep_only_fully_contracted=True)) index_rule = {'below': 'jklmno', 'above': 'defgh'} sig22 = substitute_dummies(sig22, new_indices=True, pretty_indices=index_rule) sig22 = simplify_index_permutations(sig22, PermutList) sigma_22 = Symbol('(L_{2}(\overline{H}_{DD}-E_{cc}))') final_eq = Eq(sigma_22, sig22) display(final_eq)
def get_energy_equation(equation_h, equation_u): energy = wicks(equation_h + equation_u, **wicks_kwargs) energy = substitute_dummies(energy, **sub_kwargs) return energy
from sympy import symbols, latex, WildFunction, collect, Rational, simplify from sympy.physics.secondquant import F, Fd, wicks, AntiSymmetricTensor, substitute_dummies, NO, evaluate deltas """ Define Hamiltonian and the second-quantized representation of a three-body Slater determinant. """ # Define Hamiltonian p, q, r, s = symbols("p q r s", dummy=True) f = AntiSymmetricTensor("f", (p,), (q,)) pr = Fd(p) * F(q) v = AntiSymmetricTensor("v", (p, q), (r, s)) pqsr = Fd(p) * Fd(q) * F(s) * F(r) Hamiltonian = f * pr + Rational(1) / Rational(4) * v * pqsr a, b, c, d, e, f = symbols("a, b, c, d, e, f", above_fermi=True) # Create teh representatoin expression = wicks(F(c) * F(b) * F(a) * Hamiltonian * Fd(d) * Fd(e) * Fd(f), keep_only_fully_contracted=True, simplify_kronecker_deltas=True) expression = evaluate_deltas(expression) expression = simplify(expression) print(latex(expression))
def TPDM(L, R, flavor): display( Markdown( rf""" Computing TPDM for {flavor} (skipping summation for dummy variables)""" )) i, j, k, l = symbols('i,j,k,l', below_fermi=True) a, b, c, d = symbols('a,b,c,d', above_fermi=True) oooo = Fd(i) * Fd(j) * F(l) * F(k) cc = BCH.level(oooo, "SD") g_oooo = evaluate_deltas(wicks(L * cc * R, keep_only_fully_contracted=True)) PermutList = [PermutationOperator(i,j),PermutationOperator(i,k), \ PermutationOperator(i,l),PermutationOperator(j,k), \ PermutationOperator(j,l),PermutationOperator(k,l)] g_oooo = simplify_index_permutations(g_oooo, PermutList) index_rule = {'below': 'mnop', 'above': 'abcde'} g_oooo = substitute_dummies(g_oooo, new_indices=True, pretty_indices=index_rule) gamma = Symbol('\gamma_{ijkl}') final_eq = Eq(gamma, g_oooo) display(final_eq) ooov = Fd(i) * Fd(j) * F(a) * F(k) cc = BCH.level(ooov, "SD") g_ooov = evaluate_deltas(wicks(L * cc * R, keep_only_fully_contracted=True)) PermutList = [PermutationOperator(i,j),PermutationOperator(i,k), \ PermutationOperator(j,k)] g_ooov = simplify_index_permutations(g_ooov, PermutList) index_rule = {'below': 'lmnop', 'above': 'bcdef'} g_ooov = substitute_dummies(g_ooov, new_indices=True, pretty_indices=index_rule) gamma = Symbol('\gamma_{ijka}') final_eq = Eq(gamma, g_oo) display(final_eq) ooov = Fd(i) * Fd(a) * F(k) * F(j) cc = BCH.level(ooov, "SD") g_ovoo = evaluate_deltas(wicks(L * cc * R, keep_only_fully_contracted=True)) PermutList = [PermutationOperator(i,j),PermutationOperator(i,k), \ PermutationOperator(j,k)] g_ovoo = simplify_index_permutations(g_ovoo, PermutList) index_rule = {'below': 'lmnop', 'above': 'bcdef'} g_ovoo = substitute_dummies(g_ovoo, new_indices=True, pretty_indices=index_rule) gamma = Symbol('\gamma_{iajk}') final_eq = Eq(gamma, g_ovoo) display(final_eq) ovov = Fd(i) * Fd(a) * F(b) * F(j) cc = BCH.level(ovov, "SD") g_ovov = evaluate_deltas(wicks(L * cc * R, keep_only_fully_contracted=True)) PermutList = [PermutationOperator(i, j), PermutationOperator(a, b)] g_ovov = simplify_index_permutations(g_ovov, PermutList) index_rule = {'below': 'klmno', 'above': 'cdef'} g_ovov = substitute_dummies(g_ovov, new_indices=True, pretty_indices=index_rule) gamma = Symbol('\gamma_{iajb}') final_eq = Eq(gamma, g_ovov) display(final_eq) ovvv = Fd(i) * Fd(a) * F(c) * F(b) cc = BCH.level(ovvv, "SD") g_ovvv = evaluate_deltas(wicks(L * cc * R, keep_only_fully_contracted=True)) PermutList = [PermutationOperator(a,b),PermutationOperator(a,c), \ PermutationOperator(b,c)] g_ovvv = simplify_index_permutations(g_ovvv, PermutList) index_rule = {'below': 'jklmn', 'above': 'defg'} g_ovvv = substitute_dummies(g_ovvv, new_indices=True, pretty_indices=index_rule) gamma = Symbol('\gamma_{iabc}') final_eq = Eq(gamma, g_ovvv) display(final_eq) oovv = Fd(i) * Fd(j) * F(b) * F(a) cc = BCH.level(oovv, "SD") g_oovv = evaluate_deltas(wicks(L * cc * R, keep_only_fully_contracted=True)) PermutList = [PermutationOperator(i, j), PermutationOperator(a, b)] g_oovv = simplify_index_permutations(g_oovv, PermutList) index_rule = {'below': 'klmn', 'above': 'cdefg'} g_oovv = substitute_dummies(g_oovv, new_indices=True, pretty_indices=index_rule) gamma = Symbol('\gamma_{ijab}') final_eq = Eq(gamma, g_oovv) display(final_eq)
def eval_equation(eq): eq = wicks(eq, **wicks_kwargs) eq = evaluate_deltas(eq.expand()) eq = substitute_dummies(eq, **sub_kwargs) return eq