Catalyst.jl icon indicating copy to clipboard operation
Catalyst.jl copied to clipboard

[WIP] - allow multivariable states

Open isaacsas opened this issue 2 years ago • 3 comments

See https://github.com/SciML/Catalyst.jl/pull/557/files#diff-3790c7b56be464b7ef6ce09f21fe4016c36ef785961317751d9282e6ccca15ff for example usage.

This adds a separate sivs field, and associated get_sivs(rn) accessor, to store spatial independent variables, as we need to be able to distinguish the spatial and time variables internally (with time still stored in iv).

isaacsas avatar Sep 27 '22 20:09 isaacsas

Seems to be working now. pdes.md shows how one can currently create and solve a PDE system from a ReactionSystem (without adding spatial transport info into the ReactionSystem to enable a convert routine).

I got the BPM pattern formation model to work, though the time to get the solution is quite long for a small 32x32 grid (maybe 20 minutes? -- I assume this is from compilation taking a long time):

bpm

This just needs tests and should be good to go.

isaacsas avatar Sep 29 '22 21:09 isaacsas

I wonder if there is some good way to define spatial events that can both be used on a continuous space and on a discrete graph? In https://github.com/SciML/Catalyst.jl/pull/558 I try to define reactions just as normal, but with the extra that it involves substrates and products from two cells.

First-order reactions seem easy, e.g. diffusion of a single component in continuous space, or a single molecule moving between two neighbouring containers. But not sure if it is easy to generalise higher order stuff like e.g. X[1] + Y[2] --> X[2] + Y[2] or 2X[1] + Y[2] --> X2[2] + Y[2] (X[1] denotes an X molecule in container one). to the continuous case.

99% of all cases will likely be single-molecule transport/diffusion though.

If we could have something like this, it would be possible for someone to define a ReactionSystem, and a set of spatial events, and then from that either generate spatial PDEs, or something on a discrete grid.

TorkelE avatar Sep 30 '22 22:09 TorkelE

Well, the continuous space generalization for a bimolecular reaction is two molecules react with a probability per time based on their spatial positions. One of my longer-term goals is to get solvers into JumpProcesses for such reactions on lattices, which can be derived as discretizations of the continuous space model. So you’d replace the lattice indices by spatial positions, A(x,t) + B(y,t) —> C(z,t) with a rate k(x,y,z).

In contrast, thinking of spatial transport as a “reaction” is a bit less clear to me in the continuous case.

isaacsas avatar Oct 01 '22 02:10 isaacsas

If tests pass this should be good to go, and is the minimum perturbation to a ReactionSystem that supports symbolically building PDE models. Next we could consider something like @TorkelE did and make an analogous SpatialReactionSystem to encapsulate continuous space problems (with the associated converts to make a PDESystem).

isaacsas avatar Oct 02 '22 18:10 isaacsas

@ChrisRackauckas did you want to take a look? Otherwise I’ll merge. Thanks

isaacsas avatar Oct 07 '22 13:10 isaacsas