Skip to content
Snippets Groups Projects
Commit 0ead004b authored by Martin Bauer's avatar Martin Bauer
Browse files

Grandchem generalization WIP

- started with generalized free energy formulation
parent f925f890
No related merge requests found
...@@ -275,8 +275,9 @@ def grad(var, dim=3): ...@@ -275,8 +275,9 @@ def grad(var, dim=3):
This function takes a symbol and creates the gradient symbols according to convention above This function takes a symbol and creates the gradient symbols according to convention above
:param var: symbol to take the gradient of Args:
:param dim: dimension (length) of the gradient vector var: symbol to take the gradient of
dim: dimension (length) of the gradient vector
""" """
if hasattr(var, "__getitem__"): if hasattr(var, "__getitem__"):
return [[sp.Symbol("%s^Delta^%d" % (v.name, i)) for v in var] for i in range(dim)] 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): ...@@ -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 Expects term that contains given symbols and gradient components of these symbols and replaces them
by field accesses. Gradients are replaced by centralized approximations: by field accesses. Gradients are replaced by centralized approximations:
``(upper neighbor - lower neighbor ) / ( 2*dx)`` ``(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 Args:
:param dx: width and height of one cell term: term where symbols and gradient(symbol) should be replaced
:param dim: dimension symbols_to_field_dict: mapping of symbols to Field
dx: width and height of one cell
dim: dimension
Example: Example:
>>> x = sp.Symbol("x") >>> x = sp.Symbol("x")
......
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