def renameDummyIndex(exp): 'renames all Dummy indecis in the expression, in a clever way' tl=lists.makeTermList(exp) ttl=lists.makeTensorTermList(tl) lists.sortTensorTermList(ttl) renameDummyIndex_TensorTermList(ttl) return lists.rebuildAdd(ttl,tl)
def tensorSimplify(exp, **kw): ''' Tyres to simplify a tensor expresion by writing it on a normal form If you do not like the result you can try simplifying by had using e.g subsIndex, contractDeltas, renameDummyIndex, epsAsDeltas, allEpsAsDeltas ''' termList = delta.contractDeltas_termList( lists.makeTermList( sympy.expand( eps.epsAsDeltas(exp,**kw) ) ), **kw) ttl = lists.makeTensorTermList(termList) lists.sortTensorTermList(ttl) renameDummyIndex_TensorTermList(ttl) return lists.rebuildAdd(ttl, termList)