def cleanup_normalordered(result, deltas): t0 = time.clock() length = len(result) for t in result: t.contractDeltaFuncs_new() sqa.removeVirtOps_sf(result) sqa.termChop(result) sqa.combineTerms(result) result2 = [] for t in result: result2 += sqa.contractCoreOps_sf(t) for t in result2: t.contractDeltaFuncs_new() sqa.termChop(result2) sqa.combineTerms(result2) result = [] for r in result2: item1 = geraldCode.replaceRepeatIndicesWithDeltas(r, deltas) item2 = geraldCode.replaceSingleKdeltaWithDeltas(item1, deltas) result.append(geraldCode.replaceAllKdeltaWithDeltas(item2, deltas)) print 'cleanup time: (', length, '->', len(result), ')', time.clock() - t0 del result2
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 = [] rdmDelta = [deltaC, deltaA, deltaV] for r in extendedR: item1=geraldCode.replaceRepeatIndicesWithDeltas(r, rdmDelta) item2=geraldCode.replaceSingleKdeltaWithDeltas(item1, rdmDelta) result.append(geraldCode.replaceAllKdeltaWithDeltas(item2, rdmDelta)) # Write out the equation for A.p print '//Number of terms : ', nbrEqs print ' FEqInfo EqsRes[%i] = {\n'%(nbrEqs) geraldCode.WriteCodeSimple(result, AllTensors, CommentKey) print '\n };'
sqa.combineTerms(extendedR) resultO = [] rdmDelta = [deltaC, deltaA, deltaV] #********this adds delta funcstion when we have repeat indices****************# for r in extendedR: resultO.append(geraldCode.replaceSingleKdeltaWithDeltas(r, rdmDelta)) #print "\tFEqInfo "+EquationName+"[%i] = {\n"%(len(result)) print "\tFEqInfo Overlap[%i] = {\n"%(len(result)) geraldCode.WriteCode_lcc(resultO, AllTensors, ["Ci", "Cj", "Ap", "Aq"], "KLRS", CommentKey, "V", "b", "Overlap", 0.5) print "\n\t};" resultO = [] for r in extendedR: resultO.append(geraldCode.replaceAllKdeltaWithDeltas(r, rdmDelta)) # print resultO[-1] #geraldCode.WriteCode_lcc(resultO, AllTensors, [], "PQRS", CommentKey, "", "S1", "MakeS1") print" FEqInfo MakeS1[7] = {" print" {\"PQRS,PR,QS\", 4.0 , 3, {17,28,28}}, //S1[PQRS] += 4.0 delta[PR] delta[QS] delta[IK] delta[JL] []" print" {\"PQRS,PS,QR\", -2.0 , 3, {17,28,28}}, //S1[PQRS] += -2.0 delta[PR] delta[QS] delta[IL] delta[JK] []" print" {\"PQRS,QS,PR\", -2.0 , 3, {17,14,28}}, //S1[PQRS] += -2.0 E1[QS] delta[PR] delta[IK] delta[JL] []" print" {\"PQRS,QR,PS\", 1.0 , 3, {17,14,28}}, //S1[PQRS] += 1.0 E1[PR] delta[QS] delta[IL] delta[JK] []" print" {\"PQRS,PS,QR\", 1.0 , 3, {17,14,28}}, //S1[PQRS] += 1.0 E1[QS] delta[PR] delta[IL] delta[JK] []" print" {\"PQRS,PR,QS\", -2.0 , 3, {17,14,28}}, //S1[PQRS] += -2.0 E1[PR] delta[QS] delta[IK] delta[JL] []" print" {\"PQRS,PQRT,TS\", 1.0 , 3, {17,15,28}}, //S1[PQRS] += 1.0 E2[PQRS] delta[IK] delta[JL] []" print" };" print" FEqInfo MakeS2[14] = {" print" {\"PQRS,PR,QS\", 4.0 , 5, {18,28,28}}, //S1[PQRS] += 4.0 delta[PR] delta[QS] delta[IK] delta[JL] []" print" {\"PQRS,PR,QS\", -2.0 , 5, {18,28,28}}, //S1[PQRS] += -2.0 delta[PR] delta[QS] delta[IL] delta[JK] []"