Defined functions in initial conditions and equation's coefficient #227
-
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
Dear Daniela, yes, both aspects should be possible! a) I just updated the package (so please use the latest version from GitHub for now), so you can initialize a field from a piecewise expression. The syntax is determined by sympy: grid = CartesianGrid([[0, 4]], 32)
field = ScalarField.from_expression(grid, "Piecewise((x**2, x>2), (1+x, x<=2))") The field will now be linear in b) Coefficients that depend on field values are certainly possible. You can simply use mathematical expressions in the definitions of general PDEs using the |
Beta Was this translation helpful? Give feedback.
-
Dear David, I tried to implement your suggestion: grid = CartesianGrid([[0, 4]], 32) But I get the following error: Traceback (most recent call last): I use the latest version (pip install git+https://github.com/zwicker-group/py-pde.git I will appreciate very much your help. Best, Daniela |
Beta Was this translation helpful? Give feedback.
-
I must admit I have never seen a package from GitHub installed via |
Beta Was this translation helpful? Give feedback.
Dear Daniela,
yes, both aspects should be possible!
a) I just updated the package (so please use the latest version from GitHub for now), so you can initialize a field from a piecewise expression. The syntax is determined by sympy:
The field will now be linear in
x
forx<2
and quadratic inx
for larger values.b) Coefficients that depend on field values are certainly possible. You can simply use mathematical expressions in the definitions of general PDEs using the
PDE
class. If you need more flexibility, you might need to implement your own model class by subclassingPDEBase
.…