Beispiel #1
0
commutator +=  sqa.commutator(HD_C, E_aiEbj)
commutator +=  sqa.commutator(HD_A, E_aiEbj)
commutator +=  sqa.commutator(HD_V, E_aiEbj)
commutator +=  sqa.commutator(HD_CA1, E_aiEbj)
commutator +=  sqa.commutator(HD_CA2, E_aiEbj)
commutator +=  sqa.commutator(HD_CV1, E_aiEbj)
commutator +=  sqa.commutator(HD_CV2, E_aiEbj)
commutator +=  sqa.commutator(HD_AV1, E_aiEbj)
commutator +=  sqa.commutator(HD_AV2, E_aiEbj)
commutator +=  sqa.commutator(T_C, E_aiEbj)
commutator +=  sqa.commutator(T_A, E_aiEbj)
commutator +=  sqa.commutator(T_V, E_aiEbj)
result = []

for t in commutator:
    result += sqa.normalOrder(sqa.multiplyTerms(E_aiEbj2, t))

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)
Beispiel #2
0
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)
commutator += sqa.commutator(HD_C, Omu)
commutator += sqa.commutator(HD_V, Omu)
commutator += sqa.commutator(HD_CA1, Omu)
commutator += sqa.commutator(HD_CA2, Omu)
commutator += sqa.commutator(HD_CV1, Omu)
commutator += sqa.commutator(HD_CV2, Omu)
commutator += sqa.commutator(HD_AV1, Omu)
commutator += sqa.commutator(HD_AV2, Omu)
result = []
for t in commutator:
    result += sqa.normalOrder(sqa.multiplyTerms(Onu, t))

result = simplify_all(result, [deltaC, deltaA, deltaV], cumulantE4=cumulantE4)

# Perturber-dependent stuff
Class = 'AAAC'
tensors = common_tensors(result, 'caaa', pttype='MRLCC')
tensors = order_tensors(tensors)
nbrTensors = write_tensors('MRLCC_' + Class, tensors)
nbrEqs = write_code('MRLCC_' + Class, tensors, result)
nbr_bVec = bVec(Class, tensors)

# Write out GetMethodInfo
print '  static void GetMethodInfo(FMethodInfo &Out) {'
print '    Out = FMethodInfo();'
print '    Out.pName = "MRLCC_' + Class + '";'
Beispiel #3
0
        elif pattern(h_term) in pattern_of.values()\
        or code(indices_of_ExOp(h_term)) in exop_h0:
            continue

        # Loop over Emu and Enu terms of Eq.(1)
        for left_term in psi1_left:
            for right_term in psi1_right:

                # Continue only is total pattern is neutral
                if is_non_zero([left_term, h_term, right_term]):
                    log_H[H.index(h_term)] = 'evaluated'

                    # Define the normal-ordered A_tau of Eq.(1)
                    Atau = sqa.multiplyTerms(
                        sqa.multiplyTerms(left_term, h_term), right_term)
                    result_for_class = sqa.normalOrder(Atau)
                    result_for_class = simplify_all(result_for_class,
                                                    [deltaC, deltaA, deltaV])
                    result += result_for_class

                    # Write out a message about this contribution
                    #if (len(result_for_class)!=0):
                    if print_log:
                        print '// <E_{:3}E_{:3} | E_{:5} | E_{:3}E_{:3}> ={:5}    Class:{:6}'.format(\
                                  code(indices_of_ExOp(left_term )[0]),\
                                  code(indices_of_ExOp(left_term )[1]),\
                                  code(indices_of_ExOp(h_term    )),\
                                  code(indices_of_ExOp(right_term)[0]),\
                                  code(indices_of_ExOp(right_term)[1]),\
                                  len(result_for_class),\
                                  this_class)
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)
        q = sqa.index('q', [tag_h1_q], True)
        E_pq = [sqa.sfExOp([p, q])]
        h_pq = sqa.tensor('h', [p, q], [hsym])
        
        term1 = sqa.term( 1.0, [], [h_pq] + E_pq + T_klmc + E_cmlk)
        
        batch1 = sqa.normalOrder(term1)

        sqa.removeVirtOps_sf(batch1)

        for t in batch1:
            t.contractDeltaFuncs_new()

        sqa.combineTerms(batch1)
        sqa.termChop(batch1)
                
        result += batch1

        sqa.combineTerms(result)
        sqa.termChop(result)                

for tag_h2_p in [tag_active, tag_virtual]:
Beispiel #5
0
commutator2 +=  sqa.commutator(HD_CA1, E_aiEbj1b)
commutator2 +=  sqa.commutator(HD_CA2, E_aiEbj1b)
commutator2 +=  sqa.commutator(HD_CV1, E_aiEbj1b)
commutator2 +=  sqa.commutator(HD_CV2, E_aiEbj1b)
commutator2 +=  sqa.commutator(HD_AV1, E_aiEbj1b)
commutator2 +=  sqa.commutator(HD_AV2, E_aiEbj1b)
commutator2 +=  sqa.commutator(T_C, E_aiEbj1b)
commutator2 +=  sqa.commutator(T_A, E_aiEbj1b)
commutator2 +=  sqa.commutator(T_V, E_aiEbj1b)
result1 = []
result2 = []
result3 = []
result4 = []

for t in commutator1:
    result1 += sqa.normalOrder(sqa.multiplyTerms(E_aiEbj2a, t))
    result2 += sqa.normalOrder(sqa.multiplyTerms(E_aiEbj2b, t))
for t in commutator2:
    result3 += sqa.normalOrder(sqa.multiplyTerms(E_aiEbj2a, t))
    result4 += sqa.normalOrder(sqa.multiplyTerms(E_aiEbj2b, t))

for t in result1+result2+result3+result4:
    t.contractDeltaFuncs_new()
sqa.removeVirtOps_sf(result1)
sqa.termChop(result1)
sqa.combineTerms(result1)
sqa.removeVirtOps_sf(result2)
sqa.termChop(result2)
sqa.combineTerms(result2)
sqa.removeVirtOps_sf(result3)
sqa.termChop(result3)
Beispiel #6
0
#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
terms.append( sqa.term( 1.0, [], Op4) )

print "pure"
for t in terms:
    print t
print ""

print "normal order form"
Nterms = []
for t in terms:
    Nterm = sqa.normalOrder( t )
    for tn in Nterm:
        print tn
    Nterms += Nterm
print ""

print "re-obtain spin-free operator"
Nterms2 = []
for t in Nterms:
    tmp = sqa.SpinFree( t )
    Nterms2.append( tmp )
    print tmp
print ""

print "HF Fermi expectation form"
result = []
Beispiel #7
0
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
Beispiel #8
0
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])])

Cin = sqa.tensor("p", [a, b, c, d], [Dsym_c])
Cout = sqa.tensor("Ap", [c, d, r, s], [Dsym_c])

#first excitation
E_aiEbj = sqa.term(1.0, [""], [sqa.sfExOp([a, p]), sqa.sfExOp([b, q])])
E_aiEbj2 = sqa.term(1.0, [""], [sqa.sfExOp([s, d]), sqa.sfExOp([r, c])])

result = []

result += sqa.normalOrder(
    sqa.multiplyTerms(sqa.term(1.0, [""], [Cin]),
                      sqa.multiplyTerms(E_aiEbj2, E_aiEbj)))

for t in result:
    t.contractDeltaFuncs_new()

sqa.removeVirtOps_sf(result)
for t in result:
    print t
sqa.termChop(result)
sqa.combineTerms(result)

print result
for t in result:
    print t
exit(0)
Beispiel #9
0
fixedInd = []
for i in range(20):
    fixedInd.append(sqa.index('j%i' % i, [], False))

# Test 1: Normal ordering of a(j1) a(j2) a+(j3) a+(j4)
print ""
print "Starting test 1"
print ""
startTime = time.time()
test1_tensors = []
test1_tensors.append(sqa.desOp(fixedInd[1]))
test1_tensors.append(sqa.desOp(fixedInd[2]))
test1_tensors.append(sqa.creOp(fixedInd[3]))
test1_tensors.append(sqa.creOp(fixedInd[4]))
test1_term = sqa.term(1.0, [], test1_tensors)
test1_output = sqa.normalOrder(test1_term)
sqa.combineTerms(test1_output)
test1_string_output = ''
for t in test1_output:
    test1_string_output += str(t) + '\n'
test1_correct_answer = " (  -1.00000) kdelta(j1,j3) kdelta(j2,j4) \n" + \
                       " (   1.00000) kdelta(j1,j4) kdelta(j2,j3) \n" + \
                       " (   1.00000) kdelta(j1,j3) cre(j4) des(j2) \n" + \
                       " (  -1.00000) kdelta(j1,j4) cre(j3) des(j2) \n" + \
                       " (  -1.00000) kdelta(j2,j3) cre(j4) des(j1) \n" + \
                       " (   1.00000) kdelta(j2,j4) cre(j3) des(j1) \n" + \
                       " (   1.00000) cre(j3) cre(j4) des(j1) des(j2) \n"
print "Test 1 output:"
print test1_string_output
if test1_string_output == test1_correct_answer:
    print "Test 1 passed",
Beispiel #10
0
                    #  log_H[H.index(hTerm)]='evaluated'

                    # \\\\\\\\\\\\\\\\
                    # CAN MODIFY THIS
                    # ////////////////
                    # Define the normal-ordered:   A_tau = D^nu D^mu <E^T_nu E_tau E_mu>
                    term = sqa.multiplyTerms(
                        sqa.multiplyTerms(leftTerm, hTerm), rightTerm)
                    #term=sqa.multiplyTerms(leftTerm, rightTerm)
                    #term=hTerm
                    #term=sqa.multiplyTerms(leftTerm, hTerm)
                    #comm=sqa.commutator(hTerm, rightTerm)
                    #result=[]
                    #for t in comm:
                    #  result+=sqa.normalOrder(sqa.multiplyTerms(leftTerm, t))
                    result = sqa.normalOrder(term)
                    result = simplify_all(result, [deltaC, deltaA, deltaV])

                    # Write out a message about this contribution
                    #if (len(result)!=0):
                    global_result += result

                    # \\\\\\\\\\\\\\\\
                    # CAN MODIFY THIS
                    # ////////////////
                    print '// <E_{:3}E_{:3} | E_{:5} | E_{:3}E_{:3}> ={:5}    Class:{:6}'.format(\
                                code([i.indices for i in leftTerm.tensors  if isinstance(i,sqa.sfExOp)][0]),\
                                code([i.indices for i in leftTerm.tensors  if isinstance(i,sqa.sfExOp)][1]),\
                                code([i.indices for i in hTerm.tensors     if isinstance(i,sqa.sfExOp)]),\
                                code([i.indices for i in rightTerm.tensors if isinstance(i,sqa.sfExOp)][0]),\
                                code([i.indices for i in rightTerm.tensors if isinstance(i,sqa.sfExOp)][1]),\
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
Beispiel #12
0
commutator = []
commutator += sqa.commutator(HD_C, E_aiEbj)
commutator += sqa.commutator(HD_A, E_aiEbj)
commutator += sqa.commutator(HD_V, E_aiEbj)
commutator += sqa.commutator(HD_CA1, E_aiEbj)
commutator += sqa.commutator(HD_CA2, E_aiEbj)
commutator += sqa.commutator(HD_CV1, E_aiEbj)
commutator += sqa.commutator(HD_CV2, E_aiEbj)
commutator += sqa.commutator(HD_AV1, E_aiEbj)
commutator += sqa.commutator(HD_AV2, E_aiEbj)
commutator += sqa.commutator(T_C, E_aiEbj)
commutator += sqa.commutator(T_A, E_aiEbj)
commutator += sqa.commutator(T_V, E_aiEbj)

result = sqa.normalOrder(sqa.multiplyTerms(E_aiEbj2, E_aiEbj))

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)
Beispiel #13
0
Cout2b = sqa.tensor('b2', [j, s, r, b], [])
if (withC):
    Op1a = sqa.term(1.0, [''], [Cin1a, sqa.sfExOp([a, i]), sqa.sfExOp([p, q])])
    Op1b = sqa.term(1.0, [''], [Cin1b, sqa.sfExOp([p, i]), sqa.sfExOp([a, q])])
    Op2a = sqa.term(1.0, [''],
                    [Cout2a, sqa.sfExOp([s, r]),
                     sqa.sfExOp([j, b])])
    Op2b = sqa.term(1.0, [''],
                    [Cout2b, sqa.sfExOp([s, b]),
                     sqa.sfExOp([j, r])])
else:
    Op1a = sqa.term(1.0, [''], [sqa.sfExOp([a, i]), sqa.sfExOp([p, q])])
    Op1b = sqa.term(1.0, [''], [sqa.sfExOp([p, i]), sqa.sfExOp([a, q])])
    Op2a = sqa.term(1.0, [''], [sqa.sfExOp([s, r]), sqa.sfExOp([j, b])])
    Op2b = sqa.term(1.0, [''], [sqa.sfExOp([s, b]), sqa.sfExOp([j, r])])
result = sqa.normalOrder(sqa.multiplyTerms(Op2a, Op1a))
result += sqa.normalOrder(sqa.multiplyTerms(Op2b, Op1a))
result += sqa.normalOrder(sqa.multiplyTerms(Op2a, Op1b))
result += sqa.normalOrder(sqa.multiplyTerms(Op2b, Op1b))

# 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)
for t in extendedR:
    t.contractDeltaFuncs_new()
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)
        q = sqa.index('q', [tag_h1_q], True)
        E_pq = [sqa.sfExOp([p, q])]
        h_pq = sqa.tensor('h', [p, q], [hsym])

        term1 = sqa.term(1.0, [], [h_pq] + E_pq + T_klmc + E_cmlk)

        batch1 = sqa.normalOrder(term1)

        sqa.removeVirtOps_sf(batch1)

        for t in batch1:
            t.contractDeltaFuncs_new()

        sqa.combineTerms(batch1)
        sqa.termChop(batch1)

        result += batch1

        sqa.combineTerms(result)
        sqa.termChop(result)

for tag_h2_p in [tag_active, tag_virtual]:
Beispiel #15
0
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]:

        p = sqa.index('p', [tag_h1_p], True)
        q = sqa.index('q', [tag_h1_q], True)
        E_pq = [sqa.sfExOp([p, q])]
        h_pq = sqa.tensor('h', [p, q], [hsym])

        term1 = sqa.term(1.0, [], E_ijka + [h_pq] + E_pq + E_bnml)

        batch1 = sqa.normalOrder(term1)

        sqa.removeVirtOps_sf(batch1)

        for t in batch1:
            t.contractDeltaFuncs_new()

        sqa.combineTerms(batch1)
        sqa.termChop(batch1)

        result += batch1

        term2 = sqa.term(-1.0, [], E_ijka + E_bnml + [h_pq] + E_pq)

        batch2 = sqa.normalOrder(term2)
Beispiel #16
0
# 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)
for t in extendedR:
    t.contractDeltaFuncs_new()
sqa.termChop(extendedR)
sqa.combineTerms(extendedR)
result = []
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]:

        p = sqa.index('p', [tag_h1_p], True)
        q = sqa.index('q', [tag_h1_q], True)
        E_pq = [sqa.sfExOp([p, q])]
        h_pq = sqa.tensor('h', [p, q], [hsym])
        
        term1 = sqa.term( 1.0, [], E_ijka + [h_pq] + E_pq + E_bnml)
        
        batch1 = sqa.normalOrder(term1)

        sqa.removeVirtOps_sf(batch1)

        for t in batch1:
            t.contractDeltaFuncs_new()

        sqa.combineTerms(batch1)
        sqa.termChop(batch1)
                
        result += batch1

        term2 = sqa.term(-1.0, [], E_ijka + E_bnml + [h_pq] + E_pq)
    
        batch2 = sqa.normalOrder(term2)