def simplify_all(result, deltas, cumulantE4=False, cumulantE3=False): for t in result: t.contractDeltaFuncs_new() sqa.removeVirtOps_sf(result) sqa.termChop(result) sqa.combineTerms(result) extendedR = [] for t in result: extendedR += sqa.contractCoreOps_sf(t) for t in extendedR: t.contractDeltaFuncs_new() sqa.termChop(extendedR) sqa.combineTerms(extendedR) result = [] for r in extendedR: item1 = replaceRepeatIndicesWithDeltas(r, deltas) item2 = replaceSingleKdeltaWithDeltas(item1, deltas) result.append(replaceAllKdeltaWithDeltas(item2, deltas)) if (cumulantE4): x1 = sqa.index('Ax1', [sqa.options.active_type], True) x2 = sqa.index('Ax2', [sqa.options.active_type], True) x3 = sqa.index('Ax3', [sqa.options.active_type], True) x4 = sqa.index('Ax4', [sqa.options.active_type], True) x5 = sqa.index('Ax5', [sqa.options.active_type], True) x6 = sqa.index('Ax6', [sqa.options.active_type], True) sqa.decomp_4rdms_to_3rdms_sf(result, 'E4', sqa.sfExOp([x1, x2]), sqa.sfExOp([x1, x2, x3, x4]), sqa.sfExOp([x1, x2, x3, x4]), sqa.sfExOp([x1, x2, x3, x4]), sqa.sfExOp([x1, x2, x3, x4, x5, x6])) if (cumulantE3): x1 = sqa.index('Ax1', [sqa.options.active_type], True) x2 = sqa.index('Ax2', [sqa.options.active_type], True) x3 = sqa.index('Ax3', [sqa.options.active_type], True) x4 = sqa.index('Ax4', [sqa.options.active_type], True) sqa.decomp_3rdms_to_2rdms_sf(result, 'E3', sqa.sfExOp([x1, x2]), sqa.sfExOp([x1, x2, x3, x4])) return result
[gimme('vc'), gimme('vc')], # vvcc [gimme('vc'), gimme('va')], # vvca [gimme('ac'), gimme('vc')], # ccav [gimme('va'), gimme('va')], # vvaa [gimme('ac'), gimme('ac')], # ccaa [gimme('vc'), gimme('aa')], # vaca [gimme('ac'), gimme('va')], # avca [gimme('va'), gimme('aa')], # vaaa [gimme('ac'), gimme('aa')] ] # caaa # Construct |Psi_1> and <Psi_1| psi1_right = [] psi1_left = [] for i in range(9): basis1 = sqa.sfExOp(basis[i][0]) basis2 = sqa.sfExOp(basis[i][1]) unique = unique_tensor(reorga_two_to_one(basis1, basis2)) tensor = sqa.tensor('D' + class_names[i], unique, []) #symm(unique)) #NO! psi1_right.append(sqa.term(1.0, [''], [tensor, basis1, basis2])) basis1 = sqa.sfExOp([basis[i][1][t] for t in [1, 0]]) basis2 = sqa.sfExOp([basis[i][0][t] for t in [1, 0]]) unique = unique_tensor(reorga_two_to_one(basis1, basis2)) tensor = sqa.tensor('D' + class_names[i], unique, []) #symm(unique)) #NO! psi1_left.append(sqa.term(1.0, [''], [tensor, basis1, basis2])) # (LOG if want to debug) if print_log: print '//' print '// With the unique tensors found, |Psi1> is:'
# definitions tg_c = sqa.options.core_type tg_a = sqa.options.active_type tg_v = sqa.options.virtual_type tg_t = tg_c + tg_a + tg_v i = [sqa.index('i%i' %j, [tg_c], True) for j in range(8)] r = [sqa.index('r%i' %j, [tg_a], True) for j in range(8)] a = [sqa.index('a%i' %j, [tg_v], True) for j in range(8)] m = [sqa.index('m%i' %j, [tg_t], True) for j in range(8)] t_sym = [ sqa.symmetry((1,0,3,2),1) ] W_sym = [ sqa.symmetry((1,0,3,2),1), sqa.symmetry((0,3,2,1),1) ] t_ts_ket_1 = [ sqa.tensor('t2', [a[0], a[3], i[0], i[1]], t_sym) ] t_ops_ket_1= [ sqa.sfExOp([i[0], i[1], a[0], a[3]]) ] W_ts_ket_1 = [ sqa.tensor('W', [a[1], a[2], a[3], i[2]], W_sym) ] W_ops_ket_1= [ sqa.sfExOp([a[3], i[2], a[1], a[2]]) ] t_ts_ket_2 = [ sqa.tensor('t2', [a[0], a[1], i[0], i[3]], t_sym) ] t_ops_ket_2= [ sqa.sfExOp([i[0], i[3], a[0], a[1]]) ] W_ts_ket_2 = [ sqa.tensor('W', [i[3], a[2], i[1], i[2]], W_sym) ] W_ops_ket_2= [ sqa.sfExOp([i[1], i[2], i[3], a[2]]) ] t_ts_bra_1 = [ sqa.tensor('t2', [i[4], i[5], a[4], a[7]], t_sym) ] t_ops_bra_1= [ sqa.sfExOp([a[4], a[7], i[4], i[5]]) ] W_ts_bra_1 = [ sqa.tensor('W', [a[7], i[6], a[5], a[6]], W_sym) ] W_ops_bra_1= [ sqa.sfExOp([a[5], a[6], a[7], i[6]]) ] t_ts_bra_2 = [ sqa.tensor('t2', [i[4], i[7], a[4], a[5]], t_sym) ] t_ops_bra_2= [ sqa.sfExOp([a[4], a[5], i[4], i[7]]) ]
Dsym_a = sqa.symmetry((2, 1, 0, 3), 1) Dsym_b = sqa.symmetry((0, 3, 2, 1), 1) Dsym_c = sqa.symmetry((1, 0, 3, 2), 1) # Define tensors K_C = sqa.tensor('int1c', [i1, i2], [hsym]) K_A = sqa.tensor('int1a', [x1, x2], [hsym]) K_V = sqa.tensor('int1v', [a1, a2], [hsym]) V_Al = sqa.tensor('int2Laa', [L, x1, x3], []) V_Ar = sqa.tensor('int2Laa', [L, x2, x4], []) deltaC = sqa.tensor('deltac', [i1, i2], [hsym]) deltaA = sqa.tensor('deltaa', [x1, x2], [hsym]) deltaV = sqa.tensor('deltav', [a1, a2], [hsym]) # Define Hamilonian terms T_C = sqa.term(1.0, [''], [K_C, sqa.sfExOp([i1, i2])]) T_A = sqa.term(1.0, [''], [K_A, sqa.sfExOp([x1, x2])]) T_V = sqa.term(1.0, [''], [K_V, sqa.sfExOp([a1, a2])]) HD_A = sqa.term(0.5, [''], [V_Al, V_Ar, sqa.sfExOp([x1, x2, x3, x4])]) # Define the normal-ordered A matrix: # Apvec_nu = < O^T_nu [H,O_mu] >.pvec_mu pvec = sqa.tensor('p', [i, p, q, r], []) Apvec = sqa.tensor('Ap', [j, u, v, w], []) Omu = sqa.term(1.0, [''], [pvec, sqa.sfExOp([q, i]), sqa.sfExOp([p, r])]) Onu = sqa.term(1.0, [''], [Apvec, sqa.sfExOp([w, u]), sqa.sfExOp([j, v])]) commutator = [] commutator += sqa.commutator(T_C, Omu) commutator += sqa.commutator(T_A, Omu) commutator += sqa.commutator(T_V, Omu) commutator += sqa.commutator(HD_A, Omu)
import secondQuantizationAlgebra as sqa from tools_for_sqa import * from tools_for_pt import * sqa.options.verbose = False # Make H0 H=h0('MRLCC',df=True) # Define Omu list1=gimme('caav') list2=[list1[i] for i in [3,0]] list3=[list1[i] for i in [1,2]] pvec1 = sqa.tensor('p1', list1, symm(list1)) OmuA = sqa.term(1.0, [''], [pvec1, sqa.sfExOp(list2), sqa.sfExOp(list3)]) list2=[list1[i] for i in [1,0]] list3=[list1[i] for i in [3,2]] pvec2 = sqa.tensor('p2', list1, symm(list1)) OmuB = sqa.term(1.0, [''], [pvec2, sqa.sfExOp(list2), sqa.sfExOp(list3)]) # Define Onu list1=gimme('caav') list2=[list1[i] for i in [2,1]] list3=[list1[i] for i in [0,3]] Apvec1 = sqa.tensor('Ap1', list1, symm(list1)) OnuA = sqa.term(1.0, [''], [Apvec1, sqa.sfExOp(list2), sqa.sfExOp(list3)]) list2=[list1[i] for i in [2,3]] list3=[list1[i] for i in [0,1]] Apvec2 = sqa.tensor('Ap2', list1, symm(list1)) OnuB = sqa.term(1.0, [''], [Apvec2, sqa.sfExOp(list2), sqa.sfExOp(list3)]) # Define the normal-ordered A matrix:
import secondQuantizationAlgebra as sqa import geraldCode import mussardCode sqa.options.verbose = False # Define needed indexes as being core,active,virtual tag_core = sqa.options.core_type tag_active = sqa.options.active_type tag_virtual = sqa.options.virtual_type x1 = sqa.index('Ax1', [tag_active], True) x2 = sqa.index('Ax2', [tag_active], True) x3 = sqa.index('Ax3', [tag_active], True) x4 = sqa.index('Ax4', [tag_active], True) x5 = sqa.index('Ax5', [tag_active], True) x6 = sqa.index('Ax6', [tag_active], True) x7 = sqa.index('Ax7', [tag_active], True) x8 = sqa.index('Ax8', [tag_active], True) result = sqa.normalOrder( sqa.term(1.0, [''], [sqa.sfExOp([x1, x2, x3, x4, x5, x6, x7, x8])])) result += sqa.normalOrder( sqa.term(1.0, [''], [sqa.sfExOp([x1, x2, x3, x6, x7, x8])])) result += sqa.normalOrder(sqa.term(1.0, [''], [sqa.sfExOp([x1, x2, x7, x8])])) result += sqa.normalOrder(sqa.term(1.0, [''], [sqa.sfExOp([x1, x8])])) for t in result: print t
print "Test 3 output:" print test3_string_output if test3_string_output == test3_correct_answer: print "Test 3 passed", else: print "Test 3 failed", print " (%.3f seconds)\n" % (time.time() - startTime) # Test 4: Normal ordering of the spin free operator string E(i0,i1) E(i2,i3,i4,i5) E(i6,i7,i8,i9) print "" print "Starting test 4" print "" startTime = time.time() test4_indices = [sqa.index('i%i' % i) for i in range(10)] test4_term = sqa.term(1.0, [], [ sqa.sfExOp(test4_indices[0:2]), sqa.sfExOp(test4_indices[2:6]), sqa.sfExOp(test4_indices[6:10]) ]) test4_output = sqa.normalOrder(test4_term) sqa.combineTerms(test4_output) test4_string_output = "" for t in test4_output: test4_string_output += str(t) + '\n' test4_correct_answer = " ( 1.00000) kdelta(i1,i2) kdelta(i4,i6) kdelta(i5,i7) E2(i0,i3,i8,i9) \n" + \ " ( 1.00000) kdelta(i1,i2) kdelta(i4,i7) kdelta(i5,i6) E2(i0,i3,i9,i8) \n" + \ " ( 1.00000) kdelta(i1,i3) kdelta(i4,i6) kdelta(i5,i7) E2(i0,i2,i9,i8) \n" + \ " ( 1.00000) kdelta(i1,i3) kdelta(i4,i7) kdelta(i5,i6) E2(i0,i2,i8,i9) \n" + \ " ( 1.00000) kdelta(i1,i2) kdelta(i4,i6) E3(i0,i3,i7,i8,i5,i9) \n" + \ " ( 1.00000) kdelta(i1,i2) kdelta(i4,i7) E3(i0,i3,i6,i9,i5,i8) \n" + \ " ( 1.00000) kdelta(i1,i2) kdelta(i5,i6) E3(i0,i3,i7,i4,i8,i9) \n" + \
tag_core = sqa.options.core_type tag_active = sqa.options.active_type tag_virtual = sqa.options.virtual_type k = sqa.index('Ak', [tag_active], True) l = sqa.index('Al', [tag_active], True) m = sqa.index('Am', [tag_active], True) c = sqa.index('Vc', [tag_virtual], True) hsym = sqa.symmetry((1, 0), 1) Dsym_a = sqa.symmetry((2, 1, 0, 3), 1) Dsym_b = sqa.symmetry((0, 3, 2, 1), 1) Dsym_c = sqa.symmetry((1, 0, 3, 2), 1) Tsym = sqa.symmetry((0, 1, 2, 3), 1) E_cmlk = [sqa.sfExOp([c, m, l, k])] T_klmc = [sqa.tensor('T2', [k, l, m, c], [Tsym])] print "" print "Evaluation of the IC-MRCI Hamiltonian elements" print "based on the spin-free generator" print "" print "!!!!! The operator space is L: <Psi|", E_cmlk[0], "|Psi>: R !!!!!" print "@@@ SIGMA_0 <-- sum_{klcd} H(0; Vd, Vc, Al, Ak) T(Ak, Al, Vc, Vd)" print "" result = [] for tag_h1_p in [tag_active, tag_virtual]: for tag_h1_q in [tag_active, tag_virtual]: p = sqa.index('p', [tag_h1_p], True)
a4 = sqa.index('Vf', [tag_virtual], True) #h0 one body term hsym = sqa.symmetry((1,0), 1) Dsym_a = sqa.symmetry((2,1, 0,3), 1) Dsym_b = sqa.symmetry((0,3, 2,1), 1) Dsym_c = sqa.symmetry((1,0, 3,2), 1) K_C = sqa.tensor('int1', [i1,i2], [hsym]) K_A = sqa.tensor('int1', [x1,x2], [hsym]) K_V = sqa.tensor('int1', [a1,a2], [hsym]) V_A = sqa.tensor('int2', [x1,x2, x3,x4], [Dsym_a, Dsym_b, Dsym_c]) HD_A = sqa.term( 0.5, [""], [V_A, sqa.sfExOp([x1,x2,x3,x4])] ) T_C = sqa.term( 1.0, [""], [K_C, sqa.sfExOp([i1,i2])] ) T_A = sqa.term( 1.0, [""], [K_A, sqa.sfExOp([x1,x2])] ) T_V = sqa.term( 1.0, [""], [K_V, sqa.sfExOp([a1,a2])] ) #first excitation E_aiEbj = sqa.term( 1.0, [""], [sqa.sfExOp([a, i]) , sqa.sfExOp([b,q])]) E_aiEbj2 = sqa.term( 1.0, [""], [sqa.sfExOp([r, d]) , sqa.sfExOp([j,c])]) commutator = [] commutator += sqa.commutator(HD_A, E_aiEbj) commutator += sqa.commutator(T_C, E_aiEbj) commutator += sqa.commutator(T_A, E_aiEbj) commutator += sqa.commutator(T_V, E_aiEbj) result = []
a1 = sqa.index('Vg', [tag_virtual], True) a2 = sqa.index('Vh', [tag_virtual], True) a3 = sqa.index('Ve', [tag_virtual], True) a4 = sqa.index('Vf', [tag_virtual], True) #h0 one body term hsym = sqa.symmetry((1, 0), 1) Dsym_a = sqa.symmetry((2, 1, 0, 3), 1) Dsym_b = sqa.symmetry((0, 3, 2, 1), 1) Dsym_c = sqa.symmetry((1, 0, 3, 2), 1) K_C = sqa.tensor('int1', [i1, i2], [hsym]) K_A = sqa.tensor('int1', [x1, x2], [hsym]) K_V = sqa.tensor('int1', [a1, a2], [hsym]) V_A = sqa.tensor('int2', [x1, x2, x3, x4], [Dsym_a, Dsym_b, Dsym_c]) HD_A = sqa.term(0.5, [""], [V_A, sqa.sfExOp([x1, x2, x3, x4])]) T_C = sqa.term(1.0, [""], [K_C, sqa.sfExOp([i1, i2])]) T_A = sqa.term(1.0, [""], [K_A, sqa.sfExOp([x1, x2])]) T_V = sqa.term(1.0, [""], [K_V, sqa.sfExOp([a1, a2])]) #first excitation E_aiEbj = sqa.term(1.0, [""], [sqa.sfExOp([p, i]), sqa.sfExOp([a, j])]) E_aiEbj2 = sqa.term(1.0, [""], [sqa.sfExOp([l, b]), sqa.sfExOp([k, q])]) commutator = [] commutator += sqa.commutator(HD_A, E_aiEbj) commutator += sqa.commutator(T_C, E_aiEbj) commutator += sqa.commutator(T_A, E_aiEbj) commutator += sqa.commutator(T_V, E_aiEbj) result = []
hsym = sqa.symmetry((1, 0), 1) Dsym_a = sqa.symmetry((2, 1, 0, 3), 1) Dsym_b = sqa.symmetry((0, 3, 2, 1), 1) Dsym_c = sqa.symmetry((1, 0, 3, 2), 1) # Define tensors K_C = sqa.tensor('Wcc', [i1, i2], [hsym]) K_A = sqa.tensor('Waa', [x1, x2], [hsym]) K_V = sqa.tensor('Wvv', [a1, a2], [hsym]) V_A = sqa.tensor('Waaaa', [x1, x2, x3, x4], [Dsym_a, Dsym_b, Dsym_c]) deltaC = sqa.tensor('deltac', [i1, i2], [hsym]) deltaA = sqa.tensor('deltaa', [x1, x2], [hsym]) deltaV = sqa.tensor('deltav', [a1, a2], [hsym]) # Define Hamilonian terms T_C = sqa.term(1.0, [''], [K_C, sqa.sfExOp([i1, i2])]) T_A = sqa.term(1.0, [''], [K_A, sqa.sfExOp([x1, x2])]) T_V = sqa.term(1.0, [''], [K_V, sqa.sfExOp([a1, a2])]) HD_A = sqa.term(0.5, [''], [V_A, sqa.sfExOp([x1, x2, x3, x4])]) # Define the normal-ordered A matrix: # Apvec_nu = < O^T_nu [H,O_mu] >.pvec_mu pvec1 = sqa.tensor('p1', [i, p, q, a], []) pvec2 = sqa.tensor('p2', [i, p, q, a], []) Apvec1 = sqa.tensor('Ap1', [j, r, s, b], []) Apvec2 = sqa.tensor('Ap2', [j, r, s, b], []) OmuA = sqa.term(1.0, [''], [pvec1, sqa.sfExOp([a, i]), sqa.sfExOp([p, q])]) OmuB = sqa.term(1.0, [''], [pvec2, sqa.sfExOp([p, i]), sqa.sfExOp([a, q])]) OnuA = sqa.term(1.0, [''], [Apvec1, sqa.sfExOp([s, r]), sqa.sfExOp([j, b])]) OnuB = sqa.term(1.0, [''], [Apvec2, sqa.sfExOp([s, b]), sqa.sfExOp([j, r])]) commutator1 = []
# definitions tg_c = sqa.options.core_type tg_a = sqa.options.active_type tg_v = sqa.options.virtual_type tg_t = tg_c + tg_a + tg_v i = [sqa.index('i%i' %j, [tg_c], True) for j in range(8)] r = [sqa.index('r%i' %j, [tg_a], True) for j in range(8)] a = [sqa.index('a%i' %j, [tg_v], True) for j in range(8)] m = [sqa.index('m%i' %j, [tg_t], True) for j in range(8)] t_sym = [ sqa.symmetry((1,0,3,2),1) ] W_sym = [ sqa.symmetry((1,0,3,2),1), sqa.symmetry((0,3,2,1),1) ] tW_ts_ket_1 = [ sqa.tensor('t2Wk', [a[0], a[1], a[2], i[0], i[1], i[2]], []) ] tW_ops_ket_1= [ sqa.sfExOp([i[0], i[1], i[2], a[0], a[1], a[2]]) ] tW_ts_bra_1 = [ sqa.tensor('t2Wb', [i[3], i[4], i[5], a[3], a[4], a[5]], []) ] tW_ops_bra_1= [ sqa.sfExOp([a[3], a[4], a[5], i[3], i[4], i[5]]) ] # #t_ts_ket_2 = [ sqa.tensor('t2', [a[0], a[1], i[0], i[3]], []) ] #t_ops_ket_2= [ sqa.sfExOp([i[0], i[3], a[0], a[1]]) ] #W_ts_ket_2 = [ sqa.tensor('W', [i[3], a[2], i[1], i[2]], W_sym) ] #W_ops_ket_2= [ sqa.sfExOp([i[1], i[2], i[3], a[2]]) ] # #t_ts_bra_1 = [ sqa.tensor('t2', [i[4], i[5], a[4], a[7]], t_sym) ] #t_ops_bra_1= [ sqa.sfExOp([a[4], a[7], i[4], i[5]]) ] #W_ts_bra_1 = [ sqa.tensor('W', [a[7], i[6], a[5], a[6]], W_sym) ] #W_ops_bra_1= [ sqa.sfExOp([a[5], a[6], a[7], i[6]]) ] #
j = sqa.index('Aj', [tag_active], False) a = sqa.index('Va', [tag_virtual], False) b = sqa.index('Vb', [tag_virtual], False) k = sqa.index('Ak', [tag_active], True) l = sqa.index('Al', [tag_active], True) c = sqa.index('Vc', [tag_virtual], True) d = sqa.index('Vd', [tag_virtual], True) hsym = sqa.symmetry((1, 0), 1) Dsym_a = sqa.symmetry((2, 1, 0, 3), 1) Dsym_b = sqa.symmetry((0, 3, 2, 1), 1) Dsym_c = sqa.symmetry((1, 0, 3, 2), 1) Tsym = sqa.symmetry((0, 1, 2, 3), 1) E_ijab = [sqa.sfExOp([i, j, a, b])] E_dclk = [sqa.sfExOp([d, c, l, k])] T_dclk = [sqa.tensor('T2', [k, l, c, d], [Tsym])] print "" print "Evaluation of the IC-MRCI Hamiltonian elements" print "based on the spin-free generator" print "" print "!!!!! The operator space is L: <Psi|", E_ijab[0], "|Psi>: R !!!!!" print "@@@ SIGMA(Ai, Aj, Va, Vb) <-- H(Ai, Aj, Va, Vb;0) T(0)" print "" result = [] for tag_h1_p in [tag_active, tag_virtual]: for tag_h1_q in [tag_active, tag_virtual]:
tag_core = sqa.options.core_type tag_active = sqa.options.active_type tag_virtual = sqa.options.virtual_type i = sqa.index('Ai', [tag_active], False) j = sqa.index('Aj', [tag_active], False) k = sqa.index('Ak', [tag_active], False) a = sqa.index('Va', [tag_virtual], False) hsym = sqa.symmetry((1,0), 1) Dsym_a = sqa.symmetry((2,1, 0,3), 1) Dsym_b = sqa.symmetry((0,3, 2,1), 1) Dsym_c = sqa.symmetry((1,0, 3,2), 1) Tsym = sqa.symmetry((0,1, 2,3), 1) E_ijka = [sqa.sfExOp([i, j, k, a])] print "" print "Evaluation of the IC-MRCI Hamiltonian elements" print "based on the spin-free generator" print "" print "!!!!! The operator space is L: <Psi|", E_ijka , "|Psi>: R !!!!!" print "@@@ SIGMA(Ai, Aj, Ak, Va) <-- H(Ai, Aj, Ak, Va;0) T(0)" print "" result = [] for tag_h1_p in [tag_active, tag_virtual]: for tag_h1_q in [tag_active, tag_virtual]: p = sqa.index('p', [tag_h1_p], True) q = sqa.index('q', [tag_h1_q], True)
Dsym_a = sqa.symmetry((2,1, 0,3), 1) Dsym_b = sqa.symmetry((0,3, 2,1), 1) Dsym_c = sqa.symmetry((1,0, 3,2), 1) # Define tensors K_C = sqa.tensor('int1c', [i1,i2], [hsym]) K_A = sqa.tensor('int1a', [x1,x2], [hsym]) K_V = sqa.tensor('int1v', [a1,a2], [hsym]) V_Al = sqa.tensor('int2Laa', [L,x1,x3], []) V_Ar = sqa.tensor('int2Laa', [L,x2,x4], []) deltaC = sqa.tensor('deltac', [i1,i2], [hsym]) deltaA = sqa.tensor('deltaa', [x1,x2], [hsym]) deltaV = sqa.tensor('deltav', [a1,a2], [hsym]) # Define Hamilonian terms T_C = sqa.term( 1.0, [''], [K_C, sqa.sfExOp([i1,i2])] ) T_A = sqa.term( 1.0, [''], [K_A, sqa.sfExOp([x1,x2])] ) T_V = sqa.term( 1.0, [''], [K_V, sqa.sfExOp([a1,a2])] ) HD_A = sqa.term( 0.5, [''], [V_Al,V_Ar, sqa.sfExOp([x1,x2,x3,x4])] ) # Define the normal-ordered A matrix: # Apvec_nu = < O^T_nu [H,O_mu] >.pvec_mu pvec = sqa.tensor('p', [a,b,i,q], []) Apvec = sqa.tensor('Ap', [c,d,j,r], []) Omu = sqa.term( 1.0, [''], [pvec, sqa.sfExOp([a, i]) , sqa.sfExOp([b, q])]) Onu = sqa.term( 1.0, [''], [Apvec, sqa.sfExOp([r, d]) , sqa.sfExOp([j, c])]) commutator = [] commutator += sqa.commutator(T_C, Omu) commutator += sqa.commutator(T_A, Omu) commutator += sqa.commutator(T_V, Omu) commutator += sqa.commutator(HD_A, Omu)
import secondQuantizationAlgebra as sqa from tools_for_sqa import * from tools_for_pt import * sqa.options.verbose = False # Make H0 H = h0('NEVPT', df=True) # Define Omu list1 = gimme('vaaa') list2 = [list1[i] for i in [0, 2]] list3 = [list1[i] for i in [1, 3]] pvec = sqa.tensor('p', list1, []) #symm(list1)) Omu = sqa.term(1.0, [''], [pvec, sqa.sfExOp(list2), sqa.sfExOp(list3)]) # Define Onu list1 = gimme('vaaa') list2 = [list1[i] for i in [3, 1]] list3 = [list1[i] for i in [2, 0]] Apvec = sqa.tensor('Ap', list1, []) #symm(list1)) Onu = sqa.term(1.0, [''], [Apvec, sqa.sfExOp(list2), sqa.sfExOp(list3)]) # Define the normal-ordered A matrix: # Apvec_nu = < O^T_nu [H,O_mu] >.pvec_mu commutator = [] for Hterm in H: commutator += sqa.commutator(Hterm, Omu) result = [] for t in commutator: result += sqa.normalOrder(sqa.multiplyTerms(Onu, t)) result = simplify_all(result, [deltaC, deltaA, deltaV], cumulantE4=True)
# Define symmetry classes hsym = sqa.symmetry((1, 0), 1) Dsym_a = sqa.symmetry((2, 1, 0, 3), 1) Dsym_b = sqa.symmetry((0, 3, 2, 1), 1) Dsym_c = sqa.symmetry((1, 0, 3, 2), 1) # Define tensors deltaC = sqa.tensor('deltac', [i1, i2], [hsym]) deltaA = sqa.tensor('deltaa', [x1, x2], [hsym]) deltaV = sqa.tensor('deltav', [a1, a2], [hsym]) # Define the normal-ordered overlap Cin = sqa.tensor('V', [a, p, q, r], []) Cout = sqa.tensor('b', [b, u, v, w], []) if (withC): Op1 = sqa.term(1.0, [''], [Cin, sqa.sfExOp([a, q]), sqa.sfExOp([p, r])]) Op2 = sqa.term(1.0, [''], [Cout, sqa.sfExOp([w, u]), sqa.sfExOp([v, b])]) else: Op1 = sqa.term(1.0, [''], [sqa.sfExOp([a, q]), sqa.sfExOp([p, r])]) Op2 = sqa.term(1.0, [''], [sqa.sfExOp([w, u]), sqa.sfExOp([v, b])]) result = sqa.normalOrder(sqa.multiplyTerms(Op2, Op1)) # Simplify the result for t in result: t.contractDeltaFuncs_new() sqa.removeVirtOps_sf(result) sqa.termChop(result) sqa.combineTerms(result) extendedR = [] for t in result: extendedR += sqa.contractCoreOps_sf(t)
tag_core = sqa.options.core_type tag_active = sqa.options.active_type tag_virtual = sqa.options.virtual_type i = sqa.index('Ai', [tag_active], False) j = sqa.index('Aj', [tag_active], False) k = sqa.index('Ak', [tag_active], False) a = sqa.index('Va', [tag_virtual], False) hsym = sqa.symmetry((1,0), 1) Dsym_a = sqa.symmetry((2,1, 0,3), 1) Dsym_b = sqa.symmetry((0,3, 2,1), 1) Dsym_c = sqa.symmetry((1,0, 3,2), 1) E_ijka = [sqa.sfExOp([i, j, k, a])] E_bnml = [sqa.sfExOp([a, k, j, i])] print "" print "Evaluation of the IC-MRCI Hamiltonian elements based on" print "the spin-free generator and the commutator technique" print "" print "!!!!! The operator space is L: <Psi|", E_ijka[0],", ",E_bnml[0], "|Psi>: R !!!!!" print "@@@ SIGMA(Ai, Aj, Ak, Va) <-- H(Ai, Aj, Ak, Va; Vb, Am, Al, Ak) T(Ak, Al, Am, Vb)" print "" result = [] # One-body part .... for tag_h1_p in [tag_active, tag_virtual]: for tag_h1_q in [tag_active, tag_virtual]:
a1 = sqa.index('Vg', [tag_virtual], True) a2 = sqa.index('Vh', [tag_virtual], True) a3 = sqa.index('Ve', [tag_virtual], True) a4 = sqa.index('Vf', [tag_virtual], True) #h0 one body term hsym = sqa.symmetry((1, 0), 1) Dsym_a = sqa.symmetry((2, 1, 0, 3), 1) Dsym_b = sqa.symmetry((0, 3, 2, 1), 1) Dsym_c = sqa.symmetry((1, 0, 3, 2), 1) K_C = sqa.tensor('int1', [i1, i2], [hsym]) K_A = sqa.tensor('int1', [x1, x2], [hsym]) K_V = sqa.tensor('int1', [a1, a2], [hsym]) V_A = sqa.tensor('int2', [x1, x2, x3, x4], [Dsym_a, Dsym_b, Dsym_c]) HD_A = sqa.term(0.5, [""], [V_A, sqa.sfExOp([x1, x2, x3, x4])]) T_C = sqa.term(1.0, [""], [K_C, sqa.sfExOp([i1, i2])]) T_A = sqa.term(1.0, [""], [K_A, sqa.sfExOp([x1, x2])]) T_V = sqa.term(1.0, [""], [K_V, sqa.sfExOp([a1, a2])]) #first excitation E_aiEbj1a = sqa.term(1.0, [""], [sqa.sfExOp([a, i]), sqa.sfExOp([p, q])]) E_aiEbj1b = sqa.term(1.0, [""], [sqa.sfExOp([p, i]), sqa.sfExOp([a, q])]) E_aiEbj2a = sqa.term(1.0, [""], [sqa.sfExOp([s, r]), sqa.sfExOp([j, b])]) E_aiEbj2b = sqa.term(1.0, [""], [sqa.sfExOp([s, b]), sqa.sfExOp([j, r])]) commutator = [] commutator += sqa.commutator(HD_A, E_aiEbj1a) commutator += sqa.commutator(T_C, E_aiEbj1a) commutator += sqa.commutator(T_A, E_aiEbj1a) commutator += sqa.commutator(T_V, E_aiEbj1a)
sqa.options.verbose = False # definitions tg_core = sqa.options.core_type tg_active = sqa.options.active_type tg_virtual = sqa.options.virtual_type a1 = sqa.index('a1', [tg_active], False) b1 = sqa.index('b1', [tg_active], False) a2 = sqa.index('a2', [tg_active], False) b2 = sqa.index('b2', [tg_active], False) a3 = sqa.index('a3', [tg_active], False) b3 = sqa.index('b3', [tg_active], False) a4 = sqa.index('a4', [tg_active], False) b4 = sqa.index('b4', [tg_active], False) a = sqa.index('a', [tg_active], True) result = [] term = sqa.term(1.0, [], [sqa.sfExOp([a1, b1])] + [sqa.sfExOp([a2, b2])] + [sqa.sfExOp([a3, b3])]) result += sqa.normalOrder(term) for t in result: t.contractDeltaFuncs() sqa.combineTerms(result) print "results" for t in result: print t
i = sqa.index('Ai', [tag_active], False) j = sqa.index('Aj', [tag_active], False) k = sqa.index('Ak', [tag_active], False) a = sqa.index('Va', [tag_virtual], False) l = sqa.index('Al', [tag_active], True) m = sqa.index('Am', [tag_active], True) n = sqa.index('An', [tag_active], True) b = sqa.index('Vb', [tag_virtual], True) hsym = sqa.symmetry((1, 0), 1) Dsym_a = sqa.symmetry((2, 1, 0, 3), 1) Dsym_b = sqa.symmetry((0, 3, 2, 1), 1) Dsym_c = sqa.symmetry((1, 0, 3, 2), 1) E_ijka = [sqa.sfExOp([i, j, k, a])] E_bnml = [sqa.sfExOp([b, n, m, l])] T_bnml = [sqa.tensor('T2', [l, m, n, b])] print "" print "Evaluation of the IC-MRCI Hamiltonian elements based on" print "the spin-free generator and the commutator technique" print "" print "!!!!! The operator space is L: <Psi|", E_ijka[0], ", ", E_bnml[ 0], "|Psi>: R !!!!!" print "@@@ SIGMA(Ai, Aj, Ak, Va) <-- H(Ai, Aj, Ak, Va; Vb, Am, Al, Ak) T(Ak, Al, Am, Vb)" print "" result = [] # One-body part
K_V = sqa.tensor('int1v', [a1, a2], [hsym]) V_A = sqa.tensor('int2a', [x1, x2, x3, x4], [Dsym_a, Dsym_b, Dsym_c]) V_C = sqa.tensor('int2c', [i1, i2, i3, i4], [Dsym_a, Dsym_b, Dsym_c]) V_V = sqa.tensor('int2v', [a1, a2, a3, a4], [Dsym_a, Dsym_b, Dsym_c]) V_CA1 = sqa.tensor('int2ca1', [i1, x1, i2, x2], [Dsym_a, Dsym_b]) V_CA2 = sqa.tensor('int2ca2', [i1, x1, x2, i2], []) V_CV1 = sqa.tensor('int2cv1', [i1, a1, i2, a2], [Dsym_a, Dsym_b]) V_CV2 = sqa.tensor('int2cv2', [i1, a1, a2, i2], []) V_AV1 = sqa.tensor('int2av1', [x1, a1, x2, a2], [Dsym_a, Dsym_b]) V_AV2 = sqa.tensor('int2av2', [x1, a1, a2, x2], []) deltaC = sqa.tensor('deltac', [i1, i2], [hsym]) deltaA = sqa.tensor('deltaa', [x1, x2], [hsym]) deltaV = sqa.tensor('deltav', [a1, a2], [hsym]) # Define Hamilonian terms T_C = sqa.term(1.0, [''], [K_C, sqa.sfExOp([i1, i2])]) T_A = sqa.term(1.0, [''], [K_A, sqa.sfExOp([x1, x2])]) T_V = sqa.term(1.0, [''], [K_V, sqa.sfExOp([a1, a2])]) HD_A = sqa.term(0.5, [''], [V_A, sqa.sfExOp([x1, x2, x3, x4])]) HD_C = sqa.term(0.5, [''], [V_C, sqa.sfExOp([i1, i2, i3, i4])]) HD_V = sqa.term(0.5, [''], [V_V, sqa.sfExOp([a1, a2, a3, a4])]) HD_CA1 = sqa.term(1.0, [''], [V_CA1, sqa.sfExOp([i1, x1, i2, x2])]) HD_CA2 = sqa.term(1.0, [''], [V_CA2, sqa.sfExOp([i1, x1, x2, i2])]) HD_CV1 = sqa.term(1.0, [''], [V_CV1, sqa.sfExOp([i1, a1, i2, a2])]) HD_CV2 = sqa.term(1.0, [''], [V_CV2, sqa.sfExOp([i1, a1, a2, i2])]) HD_AV1 = sqa.term(1.0, [''], [V_AV1, sqa.sfExOp([x1, a1, x2, a2])]) HD_AV2 = sqa.term(1.0, [''], [V_AV2, sqa.sfExOp([x1, a1, a2, x2])]) # Define the normal-ordered A matrix: # Apvec_nu = < O^T_nu [H,O_mu] >.pvec_mu pvec1 = sqa.tensor('p1', [i, p, q, a], [])
# Define symmetry classes hsym = sqa.symmetry((1,0), 1) Dsym_a = sqa.symmetry((2,1, 0,3), 1) Dsym_b = sqa.symmetry((0,3, 2,1), 1) Dsym_c = sqa.symmetry((1,0, 3,2), 1) # Define tensors deltaC = sqa.tensor('deltac', [i1,i2], [hsym]) deltaA = sqa.tensor('deltaa', [x1,x2], [hsym]) deltaV = sqa.tensor('deltav', [a1,a2], [hsym]) # Define the normal-ordered overlap Cin = sqa.tensor('V', [a,b,i,q], []) Cout = sqa.tensor('b', [c,d,j,r], []) if (withC): Op1 = sqa.term( 1.0, [''], [Cin, sqa.sfExOp([a, i]) , sqa.sfExOp([b, q])]) Op2 = sqa.term( 1.0, [''], [Cout, sqa.sfExOp([r, d]) , sqa.sfExOp([j, c])]) else: Op1 = sqa.term( 1.0, [''], [sqa.sfExOp([a, i]) , sqa.sfExOp([b, q])]) Op2 = sqa.term( 1.0, [''], [sqa.sfExOp([r, d]) , sqa.sfExOp([j, c])]) result = sqa.normalOrder(sqa.multiplyTerms(Op2, Op1)) # Simplify the result for t in result: t.contractDeltaFuncs_new() sqa.removeVirtOps_sf(result) sqa.termChop(result) sqa.combineTerms(result) extendedR=[] for t in result: extendedR += sqa.contractCoreOps_sf(t)
tag_core = sqa.options.core_type tag_active = sqa.options.active_type tag_virtual = sqa.options.virtual_type i = sqa.index('Ai', [tag_active], False) j = sqa.index('Aj', [tag_active], False) k = sqa.index('Ak', [tag_active], False) a = sqa.index('Va', [tag_virtual], False) hsym = sqa.symmetry((1, 0), 1) Dsym_a = sqa.symmetry((2, 1, 0, 3), 1) Dsym_b = sqa.symmetry((0, 3, 2, 1), 1) Dsym_c = sqa.symmetry((1, 0, 3, 2), 1) E_ijka = [sqa.sfExOp([i, j, k, a])] E_bnml = [sqa.sfExOp([a, k, j, i])] print "" print "Evaluation of the IC-MRCI Hamiltonian elements based on" print "the spin-free generator and the commutator technique" print "" print "!!!!! The operator space is L: <Psi|", E_ijka[0], ", ", E_bnml[ 0], "|Psi>: R !!!!!" print "@@@ SIGMA(Ai, Aj, Ak, Va) <-- H(Ai, Aj, Ak, Va; Vb, Am, Al, Ak) T(Ak, Al, Am, Vb)" print "" result = [] # One-body part .... for tag_h1_p in [tag_active, tag_virtual]: for tag_h1_q in [tag_active, tag_virtual]:
i = sqa.index('Ai', [tag_active], False) j = sqa.index('Aj', [tag_active], False) k = sqa.index('Ak', [tag_active], False) l = sqa.index('Al', [tag_active], False) a = sqa.index('Va', [tag_virtual], False) b = sqa.index('Vb', [tag_virtual], False) c = sqa.index('Vc', [tag_virtual], False) d = sqa.index('Vd', [tag_virtual], False) hsym = sqa.symmetry((1,0), 1) Dsym_a = sqa.symmetry((2,1, 0,3), 1) Dsym_b = sqa.symmetry((0,3, 2,1), 1) Dsym_c = sqa.symmetry((1,0, 3,2), 1) E_iajb = [sqa.sfExOp([i, j, a, b])] E_dlck = [sqa.sfExOp([b, a, j, i])] print "" print "Evaluation of the IC-MRCI Hamiltonian elements" print "based on the spin-free generator" print "" print "!!!!! The operator space is L: <Psi|", E_iajb[0], E_dlck[0], "|Psi>: R !!!!!" print "" result = [] for tag_h1_p in [tag_active, tag_virtual]: for tag_h1_q in [tag_active, tag_virtual]: p = sqa.index('p', [tag_h1_p], True) q = sqa.index('q', [tag_h1_q], True)
"A", "A", "H"] pDomains = "\tint f(int i) {\n" pDomains += "\t\treturn 2*i;\n" pDomains += "\t}\n" pDomains += "\tFDomainDecl DomainDecls[1] = {\n" pDomains += "\t\t{\"A\", \"a\", f}\n" pDomains += "\t};" CommentKey = {} print "namespace MRLCC_CAAV {\n" for tc in list(zip(AllTensors, CommentTensors)): CommentKey[tc[0]] = tc[1] geraldCode.writeTensors(AllTensors, CommentKey, Domains, Usage) HD_C = sqa.term( 0.5, [""], [V_C, sqa.sfExOp([i1,i2,i3,i4])] ) HD_A = sqa.term( 0.5, [""], [V_A, sqa.sfExOp([x1,x2,x3,x4])] ) HD_V = sqa.term( 0.5, [""], [V_V, sqa.sfExOp([a1,a2,a3,a4])] ) HD_CA1 = sqa.term( 1.0, [""], [V_CA1, sqa.sfExOp([i1,x1,i2,x2])] ) HD_CA2 = sqa.term( 1.0, [""], [V_CA2, sqa.sfExOp([i1,x1,x2,i2])] ) HD_CV1 = sqa.term( 1.0, [""], [V_CV1, sqa.sfExOp([i1,a1,i2,a2])] ) HD_CV2 = sqa.term( 1.0, [""], [V_CV2, sqa.sfExOp([i1,a1,a2,i2])] ) HD_AV1 = sqa.term( 1.0, [""], [V_AV1, sqa.sfExOp([x1,a1,x2,a2])] ) HD_AV2 = sqa.term( 1.0, [""], [V_AV2, sqa.sfExOp([x1,a1,a2,x2])] ) T_C = sqa.term( 1.0, [""], [K_C, sqa.sfExOp([i1,i2])] ) T_A = sqa.term( 1.0, [""], [K_A, sqa.sfExOp([x1,x2])] ) T_V = sqa.term( 1.0, [""], [K_V, sqa.sfExOp([a1,a2])] )
listnu = indExOp_Psi1[nu][4:8] if is_non_zero(code(listnu) + code_rearrange(listtau)): # H if indExOp_H4[tau][-1] == 'other' or indExOp_H4[tau][ -1] == 'h0': name = 'WO' + indTens_H4[tau][-1] elif indExOp_H4[tau][-1] == 'heff4': name = 'WE' + indTens_H4[tau][-1] else: name = 'WC' + indTens_H4[tau][-1] Wtau = sqa.tensor(name, indTens_H4[tau][:4], symm(indTens_H4[tau][:4])) Vtau = sqa.term(factor[code(listtau)] * 0.5, [''], [Wtau, sqa.sfExOp(listtau)]) # <Psi1| bnu = sqa.tensor('b' + indTens_Psi1[nu][-1], indTens_Psi1[nu][4:8], symm(indTens_Psi1[nu][4:8])) Onu = sqa.term( 1.0, [''], [bnu, sqa.sfExOp(listnu[:2]), sqa.sfExOp(listnu[2:4])]) #Onu = sqa.term( 1.0, [''], [bnu, sqa.sfExOp([listnu[i] for i in [0,2,3,1]])]) # Define the normal-ordered: W_nu = <O^T_nu V_tau> W_tau term = sqa.multiplyTerms(Onu, Vtau) #print term result = sqa.normalOrder(term)
j = sqa.index('Aj', [tag_active], False) a = sqa.index('Va', [tag_virtual], False) b = sqa.index('Vb', [tag_virtual], False) k = sqa.index('Ak', [tag_active], True) l = sqa.index('Al', [tag_active], True) c = sqa.index('Vc', [tag_virtual], True) d = sqa.index('Vd', [tag_virtual], True) hsym = sqa.symmetry((1,0), 1) Dsym_a = sqa.symmetry((2,1, 0,3), 1) Dsym_b = sqa.symmetry((0,3, 2,1), 1) Dsym_c = sqa.symmetry((1,0, 3,2), 1) Tsym = sqa.symmetry((0,1, 2,3), 1) E_ijab = [sqa.sfExOp([i, j, a, b])] E_dclk = [sqa.sfExOp([d, c, l, k])] T_dclk = [sqa.tensor('T2', [k, l, c, d], [Tsym])] print "" print "Evaluation of the IC-MRCI Hamiltonian elements" print "based on the spin-free generator" print "" print "!!!!! The operator space is L: <Psi|", E_ijab[0], E_dclk[0], "|Psi>: R !!!!!" print "@@@ SIGMA(Ai, Aj, Va, Vb) <-- sum_{klcd} H(Ai, Aj, Va, Vb; Vd, Vc, Al, Ak) T(Ak, Al, Vc, Vd)" print "" result = [] for tag_h1_p in [tag_active, tag_virtual]: for tag_h1_q in [tag_active, tag_virtual]:
# Define symmetry classes hsym = sqa.symmetry((1, 0), 1) Dsym_a = sqa.symmetry((2, 1, 0, 3), 1) Dsym_b = sqa.symmetry((0, 3, 2, 1), 1) Dsym_c = sqa.symmetry((1, 0, 3, 2), 1) # Define tensors deltaC = sqa.tensor('deltac', [i1, i2], [hsym]) deltaA = sqa.tensor('deltaa', [x1, x2], [hsym]) deltaV = sqa.tensor('deltav', [a1, a2], [hsym]) # Define the normal-ordered overlap Cin = sqa.tensor('V', [a, b, i, j], [Dsym_c]) Cout = sqa.tensor('b', [c, d, l, k], [Dsym_c]) if (withC): Op1 = sqa.term(1.0, [''], [Cin, sqa.sfExOp([a, i]), sqa.sfExOp([b, j])]) Op2 = sqa.term(1.0, [''], [Cout, sqa.sfExOp([k, d]), sqa.sfExOp([l, c])]) else: Op1 = sqa.term(1.0, [''], [sqa.sfExOp([a, i]), sqa.sfExOp([b, j])]) Op2 = sqa.term(1.0, [''], [sqa.sfExOp([k, d]), sqa.sfExOp([l, c])]) result = sqa.normalOrder(sqa.multiplyTerms(Op2, Op1)) # Simplify the result for t in result: t.contractDeltaFuncs_new() sqa.removeVirtOps_sf(result) sqa.termChop(result) sqa.combineTerms(result) extendedR = [] for t in result: extendedR += sqa.contractCoreOps_sf(t)
tag_core = sqa.options.core_type tag_active = sqa.options.active_type tag_virtual = sqa.options.virtual_type k = sqa.index('Ak', [tag_active], True) l = sqa.index('Al', [tag_active], True) m = sqa.index('Am', [tag_active], True) c = sqa.index('Vc', [tag_virtual], True) hsym = sqa.symmetry((1,0), 1) Dsym_a = sqa.symmetry((2,1, 0,3), 1) Dsym_b = sqa.symmetry((0,3, 2,1), 1) Dsym_c = sqa.symmetry((1,0, 3,2), 1) Tsym = sqa.symmetry((0,1, 2,3), 1) E_cmlk = [sqa.sfExOp([c, m, l, k])] T_klmc = [sqa.tensor('T2', [k, l, m, c], [Tsym])] print "" print "Evaluation of the IC-MRCI Hamiltonian elements" print "based on the spin-free generator" print "" print "!!!!! The operator space is L: <Psi|", E_cmlk[0], "|Psi>: R !!!!!" print "@@@ SIGMA_0 <-- sum_{klcd} H(0; Vd, Vc, Al, Ak) T(Ak, Al, Vc, Vd)" print "" result = [] for tag_h1_p in [tag_active, tag_virtual]: for tag_h1_q in [tag_active, tag_virtual]: p = sqa.index('p', [tag_h1_p], True)
sqa.options.verbose = False # definitions tg_core = sqa.options.core_type tg_active = sqa.options.active_type tg_virtual = sqa.options.virtual_type a1 = sqa.index('a1', [tg_active], False) b1 = sqa.index('b1', [tg_active], False) a2 = sqa.index('a2', [tg_active], False) b2 = sqa.index('b2', [tg_active], False) a3 = sqa.index('a3', [tg_active], False) b3 = sqa.index('b3', [tg_active], False) a4 = sqa.index('a4', [tg_active], False) b4 = sqa.index('b4', [tg_active], False) a = sqa.index('a', [tg_active], True) result = [] term = sqa.term(1.0, [], [sqa.sfExOp([a1,b1])] + [sqa.sfExOp([a2,b2])] + [sqa.sfExOp([a3,b3])]) result += sqa.normalOrder(term) for t in result: t.contractDeltaFuncs() sqa.combineTerms(result) print "results" for t in result: print t
"A", "A", "A", "H", "D", "D", "D", "A"] pDomains = "\tint f(int i) {\n" pDomains += "\t\treturn 2*i;\n" pDomains += "\t}\n" pDomains += "\tFDomainDecl DomainDecls[1] = {\n" pDomains += "\t\t{\"A\", \"a\", f}\n" pDomains += "\t};" CommentKey = {} print "namespace MRLCC_CCVV {\n" for tc in list(zip(AllTensors, CommentTensors)): CommentKey[tc[0]] = tc[1] geraldCode.writeTensors(AllTensors, CommentKey, Domains, Usage) HD_C = sqa.term( 0.5, [""], [V_C, sqa.sfExOp([i1,i2,i3,i4])] ) HD_A = sqa.term( 0.5, [""], [V_A, sqa.sfExOp([x1,x2,x3,x4])] ) HD_V = sqa.term( 0.5, [""], [V_V, sqa.sfExOp([a1,a2,a3,a4])] ) HD_CA1 = sqa.term( 1.0, [""], [V_CA1, sqa.sfExOp([i1,x1,i2,x2])] ) HD_CA2 = sqa.term( 1.0, [""], [V_CA2, sqa.sfExOp([i1,x1,x2,i2])] ) HD_CV1 = sqa.term( 1.0, [""], [V_CV1, sqa.sfExOp([i1,a1,i2,a2])] ) HD_CV2 = sqa.term( 1.0, [""], [V_CV2, sqa.sfExOp([i1,a1,a2,i2])] ) HD_AV1 = sqa.term( 1.0, [""], [V_AV1, sqa.sfExOp([x1,a1,x2,a2])] ) HD_AV2 = sqa.term( 1.0, [""], [V_AV2, sqa.sfExOp([x1,a1,a2,x2])] ) T_C = sqa.term( 1.0, [""], [K_C, sqa.sfExOp([i1,i2])] ) T_A = sqa.term( 1.0, [""], [K_A, sqa.sfExOp([x1,x2])] ) T_V = sqa.term( 1.0, [""], [K_V, sqa.sfExOp([a1,a2])] )
V_AV1l = sqa.tensor('int2Laa', [L,x1,x2], []) V_AV1r = sqa.tensor('int2Lvv', [L,a1,a2], []) V_AV2l = sqa.tensor('int2Lav', [L,x1,a2], []) V_AV2r = sqa.tensor('int2Lva', [L,a1,x2], []) V_Cl = sqa.tensor('int2Lcc', [L,i1,i3], []) V_Cr = sqa.tensor('int2Lcc', [L,i2,i4], []) V_Al = sqa.tensor('int2Laa', [L,x1,x3], []) V_Ar = sqa.tensor('int2Laa', [L,x2,x4], []) V_Vl = sqa.tensor('int2Lvv', [L,a1,a3], []) V_Vr = sqa.tensor('int2Lvv', [L,a2,a4], []) deltaC = sqa.tensor('deltac', [i1,i2], [hsym]) deltaA = sqa.tensor('deltaa', [x1,x2], [hsym]) deltaV = sqa.tensor('deltav', [a1,a2], [hsym]) # Define Hamilonian terms T_C = sqa.term( 1.0, [''], [K_C, sqa.sfExOp([i1,i2])] ) T_A = sqa.term( 1.0, [''], [K_A, sqa.sfExOp([x1,x2])] ) T_V = sqa.term( 1.0, [''], [K_V, sqa.sfExOp([a1,a2])] ) HD_C = sqa.term( 0.5, [''], [V_Cl,V_Cr, sqa.sfExOp([i1,i2,i3,i4])] ) HD_A = sqa.term( 0.5, [''], [V_Al,V_Ar, sqa.sfExOp([x1,x2,x3,x4])] ) HD_V = sqa.term( 0.5, [''], [V_Vl,V_Vr, sqa.sfExOp([a1,a2,a3,a4])] ) HD_CA1 = sqa.term( 1.0, [''], [V_CA1l,V_CA1r, sqa.sfExOp([i1,x1,i2,x2])] ) HD_CA2 = sqa.term( 1.0, [''], [V_CA2l,V_CA2r, sqa.sfExOp([i1,x1,x2,i2])] ) HD_CV1 = sqa.term( 1.0, [''], [V_CV1l,V_CV1r, sqa.sfExOp([i1,a1,i2,a2])] ) HD_CV2 = sqa.term( 1.0, [''], [V_CV2l,V_CV2r, sqa.sfExOp([i1,a1,a2,i2])] ) HD_AV1 = sqa.term( 1.0, [''], [V_AV1l,V_AV1r, sqa.sfExOp([x1,a1,x2,a2])] ) HD_AV2 = sqa.term( 1.0, [''], [V_AV2l,V_AV2r, sqa.sfExOp([x1,a1,a2,x2])] ) # Define the normal-ordered A matrix: # Apvec_nu = < O^T_nu [H,O_mu] >.pvec_mu pvec = sqa.tensor('p', [a,b,p,q], [Dsym_c])
K_V = sqa.tensor('Wvv', [a1, a2], [hsym]) V_A = sqa.tensor('Waaaa', [x1, x2, x3, x4], [Dsym_a, Dsym_b, Dsym_c]) V_C = sqa.tensor('Wcccc', [i1, i2, i3, i4], [Dsym_a, Dsym_b, Dsym_c]) V_V = sqa.tensor('Wvvvv', [a1, a2, a3, a4], [Dsym_a, Dsym_b, Dsym_c]) V_CA1 = sqa.tensor('Wcaca', [i1, x1, i2, x2], [Dsym_a, Dsym_b]) V_CA2 = sqa.tensor('Wcaac', [i1, x1, x2, i2], []) V_CV1 = sqa.tensor('Wcvcv', [i1, a1, i2, a2], [Dsym_a, Dsym_b]) V_CV2 = sqa.tensor('Wcvvc', [i1, a1, a2, i2], []) V_AV1 = sqa.tensor('Wavav', [x1, a1, x2, a2], [Dsym_a, Dsym_b]) V_AV2 = sqa.tensor('Wavva', [x1, a1, a2, x2], []) deltaC = sqa.tensor('deltac', [i1, i2], [hsym]) deltaA = sqa.tensor('deltaa', [x1, x2], [hsym]) deltaV = sqa.tensor('deltav', [a1, a2], [hsym]) # Define Hamilonian terms T_C = sqa.term(1.0, [''], [K_C, sqa.sfExOp([i1, i2])]) T_A = sqa.term(1.0, [''], [K_A, sqa.sfExOp([x1, x2])]) T_V = sqa.term(1.0, [''], [K_V, sqa.sfExOp([a1, a2])]) HD_A = sqa.term(0.5, [''], [V_A, sqa.sfExOp([x1, x2, x3, x4])]) HD_C = sqa.term(0.5, [''], [V_C, sqa.sfExOp([i1, i2, i3, i4])]) HD_V = sqa.term(0.5, [''], [V_V, sqa.sfExOp([a1, a2, a3, a4])]) HD_CA1 = sqa.term(1.0, [''], [V_CA1, sqa.sfExOp([i1, x1, i2, x2])]) HD_CA2 = sqa.term(1.0, [''], [V_CA2, sqa.sfExOp([i1, x1, x2, i2])]) HD_CV1 = sqa.term(1.0, [''], [V_CV1, sqa.sfExOp([i1, a1, i2, a2])]) HD_CV2 = sqa.term(1.0, [''], [V_CV2, sqa.sfExOp([i1, a1, a2, i2])]) HD_AV1 = sqa.term(1.0, [''], [V_AV1, sqa.sfExOp([x1, a1, x2, a2])]) HD_AV2 = sqa.term(1.0, [''], [V_AV2, sqa.sfExOp([x1, a1, a2, x2])]) # Define the normal-ordered A matrix: # Apvec_nu = < O^T_nu [H,O_mu] >.pvec_mu pvec = sqa.tensor('p', [i, p, q, r], [])
tg_c = sqa.options.core_type tg_a = sqa.options.active_type tg_v = sqa.options.virtual_type tg_t = tg_c + tg_a + tg_v i = [sqa.index('i%i' % j, [tg_c], True) for j in range(8)] r = [sqa.index('r%i' % j, [tg_a], True) for j in range(8)] a = [sqa.index('a%i' % j, [tg_v], True) for j in range(8)] m = [sqa.index('m%i' % j, [tg_t], True) for j in range(8)] n = [sqa.index('n%i' % j, [tg_t], True) for j in range(8)] t_sym = [sqa.symmetry((1, 0, 3, 2), 1)] W_sym = [sqa.symmetry((1, 0, 3, 2), 1), sqa.symmetry((0, 3, 2, 1), 1)] W_ts_ket = [sqa.tensor('W', [a[2], a[3], i[2], i[3]], W_sym)] W_ops_ket = [sqa.sfExOp([i[2], i[3], a[2], a[3]])] t_ts_bra = [sqa.tensor('t2', [i[0], i[1], a[0], a[1]], t_sym)] t_ops_bra = [sqa.sfExOp([a[0], a[1], i[0], i[1]])] terms = [] #Op1 = t_ts_ket_1 + t_ops_ket_1 + W_ts_ket_1 + W_ops_ket_1 + W_ts_bra_1 + W_ops_bra_1 + t_ts_bra_1 + t_ops_bra_1 #terms.append( sqa.term( 1.0, [], Op1) ) #Op2 = t_ts_ket_2 + t_ops_ket_2 + W_ts_ket_2 + W_ops_ket_2 + W_ts_bra_1 + W_ops_bra_1 + t_ts_bra_1 + t_ops_bra_1 #terms.append( sqa.term( 1.0, [], Op2) ) #Op3 = t_ts_ket_1 + t_ops_ket_1 + W_ts_ket_1 + W_ops_ket_1 + W_ts_bra_2 + W_ops_bra_2 + t_ts_bra_2 + t_ops_bra_2 #terms.append( sqa.term( 1.0, [], Op3) ) #Op4 = t_ts_ket_2 + t_ops_ket_2 + W_ts_ket_2 + W_ops_ket_2 + W_ts_bra_2 + W_ops_bra_2 + t_ts_bra_2 + t_ops_bra_2 #Op4 = t_ops_ket_2 + W_ops_ket_2 + W_ops_bra_2 + t_ops_bra_2 #Op4 = t_ops_ket_2 + W_ops_ket_2 Op4 = W_ts_ket + W_ops_ket + t_ts_bra + t_ops_bra
# Define symmetry classes hsym = sqa.symmetry((1,0), 1) Dsym_a = sqa.symmetry((2,1, 0,3), 1) Dsym_b = sqa.symmetry((0,3, 2,1), 1) Dsym_c = sqa.symmetry((1,0, 3,2), 1) # Define tensors deltaC = sqa.tensor('deltac', [i1,i2], [hsym]) deltaA = sqa.tensor('deltaa', [x1,x2], [hsym]) deltaV = sqa.tensor('deltav', [a1,a2], [hsym]) # Define the normal-ordered overlap Cin = sqa.tensor('V', [i,j,p,a], []) Cout = sqa.tensor('b', [k,l,q,b], []) if (withC): Op1 = sqa.term( 1.0, [''], [Cin, sqa.sfExOp([p, i]) , sqa.sfExOp([a, j])]) Op2 = sqa.term( 1.0, [''], [Cout, sqa.sfExOp([l, b]) , sqa.sfExOp([k, q])]) else: Op1 = sqa.term( 1.0, [''], [sqa.sfExOp([p, i]) , sqa.sfExOp([a, j])]) Op2 = sqa.term( 1.0, [''], [sqa.sfExOp([l, b]) , sqa.sfExOp([k, q])]) result = sqa.normalOrder(sqa.multiplyTerms(Op2, Op1)) # Simplify the result for t in result: t.contractDeltaFuncs_new() sqa.removeVirtOps_sf(result) sqa.termChop(result) sqa.combineTerms(result) extendedR=[] for t in result: extendedR += sqa.contractCoreOps_sf(t)
tag_core = sqa.options.core_type tag_active = sqa.options.active_type tag_virtual = sqa.options.virtual_type k = sqa.index('Ak', [tag_active], True) l = sqa.index('Al', [tag_active], True) c = sqa.index('Vc', [tag_virtual], True) d = sqa.index('Vd', [tag_virtual], True) hsym = sqa.symmetry((1,0), 1) Dsym_a = sqa.symmetry((2,1, 0,3), 1) Dsym_b = sqa.symmetry((0,3, 2,1), 1) Dsym_c = sqa.symmetry((1,0, 3,2), 1) Tsym = sqa.symmetry((0,1, 2,3), 1) E_dclk = [sqa.sfExOp([d, c, l, k])] T_klcd = [sqa.tensor('T2', [k, l, c, d], [Tsym])] print "" print "Evaluation of the IC-MRCI Hamiltonian elements" print "based on the spin-free generator" print "" print "!!!!! The operator space is L: <Psi|", E_dclk[0], "|Psi>: R !!!!!" print "@@@ SIGMA_0 <-- sum_{klcd} H(0; Vd, Vc, Al, Ak) T(Ak, Al, Vc, Vd)" print "" result = [] for tag_h1_p in [tag_active, tag_virtual]: for tag_h1_q in [tag_active, tag_virtual]: p = sqa.index('p', [tag_h1_p], True)