Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Jonas Plewinski
pystencils
Commits
3acbdbe8
Commit
3acbdbe8
authored
Aug 04, 2017
by
Martin Bauer
Browse files
Generalization of Chapman Enskog analysis
parent
96781a96
Changes
1
Hide whitespace changes
Inline
Side-by-side
sympyextensions.py
View file @
3acbdbe8
...
...
@@ -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
)
paramList
.
append
(
replacedExpr
)
if
s
:
substituted
=
True
if
not
paramList
:
return
expr
,
False
else
:
if
substituted
:
result
,
_
=
visit
(
normalizeFunc
(
expr
.
func
(
*
paramList
)))
return
result
,
True
else
:
return
expr
.
func
(
*
paramList
),
False
if
len
(
subsDict
)
==
0
:
return
term
else
:
res
,
_
=
visit
(
term
)
return
res
def
replaceAdditive
(
expr
,
replacement
,
subExpression
,
requiredMatchReplacement
=
0.5
,
requiredMatchOriginal
=
None
):
"""
Transformation for replacing a given subexpression inside a sum
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment