Commit 3acbdbe8 authored by Martin Bauer's avatar Martin Bauer
Browse files

Generalization of Chapman Enskog analysis

parent 96781a96
......@@ -97,6 +97,37 @@ def fastSubs(term, subsDict):
return visit(term)
def fastSubsWithNormalize(term, subsDict, normalizeFunc):
def visit(expr):
if expr in subsDict:
return subsDict[expr], True
if not hasattr(expr, 'args'):
return expr, False
paramList = []
substituted = False
for a in expr.args:
replacedExpr, s = visit(a)
if s:
substituted = True
if not paramList:
return expr, False
if substituted:
result, _ = visit(normalizeFunc(expr.func(*paramList)))
return result, True
return expr.func(*paramList), False
if len(subsDict) == 0:
return term
res, _ = visit(term)
return res
def replaceAdditive(expr, replacement, subExpression, requiredMatchReplacement=0.5, requiredMatchOriginal=None):
Transformation for replacing a given subexpression inside a sum
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment