Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
pystencils
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pycodegen
pystencils
Commits
0ead004b
Commit
0ead004b
authored
6 years ago
by
Martin Bauer
Browse files
Options
Downloads
Patches
Plain Diff
Grandchem generalization WIP
- started with generalized free energy formulation
parent
f925f890
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
fd/finitedifferences.py
+9
-6
9 additions, 6 deletions
fd/finitedifferences.py
with
9 additions
and
6 deletions
fd/finitedifferences.py
+
9
−
6
View file @
0ead004b
...
...
@@ -275,8 +275,9 @@ def grad(var, dim=3):
This function takes a symbol and creates the gradient symbols according to convention above
:param var: symbol to take the gradient of
:param dim: dimension (length) of the gradient vector
Args:
var: symbol to take the gradient of
dim: dimension (length) of the gradient vector
"""
if
hasattr
(
var
,
"
__getitem__
"
):
return
[[
sp
.
Symbol
(
"
%s^Delta^%d
"
%
(
v
.
name
,
i
))
for
v
in
var
]
for
i
in
range
(
dim
)]
...
...
@@ -289,10 +290,12 @@ def discretize_center(term, symbols_to_field_dict, dx, dim=3):
Expects term that contains given symbols and gradient components of these symbols and replaces them
by field accesses. Gradients are replaced by centralized approximations:
``(upper neighbor - lower neighbor ) / ( 2*dx)``
:param term: term where symbols and gradient(symbol) should be replaced
:param symbols_to_field_dict: mapping of symbols to Field
:param dx: width and height of one cell
:param dim: dimension
Args:
term: term where symbols and gradient(symbol) should be replaced
symbols_to_field_dict: mapping of symbols to Field
dx: width and height of one cell
dim: dimension
Example:
>>>
x
=
sp
.
Symbol
(
"
x
"
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment