-
-
Notifications
You must be signed in to change notification settings - Fork 232
Enable creation of JumpSystems from ReactionSystems #346
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable creation of JumpSystems from ReactionSystems #346
Conversation
TorkelE
commented
May 8, 2020
- convert(JumpSystem,rs::ReactionSystem) should now work.
- Type of Jump (Variable Rate, ConstantRate, MassAction) should now be correctly identified.
…mps. - Version of oderatelawy, jumpratelaw function (possibly unnecessary). - Added var2op utility function (possibly unnecessary).
Not done, but should be in a workable state now where one can try out the code. I haven't started on tests yet. Some irregularities:
|
A simple example of usage using DiffEqJump, ModelingToolkit
@parameters t p d
@variables X(t)
rxs = [Reaction(p, nothing, [X]),
Reaction(d, [X], nothing)
]
rs = ReactionSystem(rxs,t,[X],[p,d])
js = convert(JumpSystem,rs)
dprob = DiscreteProblem(js, [X => 10], (0,10.), [p =>20., d=>1.])
jprob = JumpProblem(js, dprob, Direct())
sol = solve(jprob, SSAStepper())
using Plots; plot(sol) |
It would be nice to figure out why that's necessary. Something probably isn't using the right expression generation from variable setup: https://github.com/SciML/ModelingToolkit.jl/blob/master/src/systems/diffeqs/abstractodesystem.jl#L23-L37 |
I think we can make this better, but let's iteratively improve it. |
There seems to be something fishy going on now. When I try the code again using DiffEqJump, ModelingToolkit
@parameters t p d
@variables X(t)
rxs = [Reaction(p, nothing, [X]),
Reaction(d, [X], nothing)
]
rs = ReactionSystem(rxs,t,[X],[p,d])
js = convert(JumpSystem,rs)
dprob = DiscreteProblem(js, [X => 10], (0,10.), [p =>20., d=>1.])
jprob = JumpProblem(js, dprob, Direct())
sol = solve(jprob, SSAStepper())
using Plots; plot(sol) I get an
when trying to create the In general, there seems to be a problem creating creating |
Yeah, something happened with the |
It's UnPack.jl bounds. Things need to propagate through. |
@ChrisRackauckas The JumpSystem crash seems to still be an issue. Also, @TorkelE the SSA rate law should be different from the ODE rate law; the former should use binomials (see |
Oh yeah, totally forgot about those. |
Ok, I will wait with correcting until the JumpSystems run, to avoid the risk of adding errors when errors already present. Also, @isaacsas for |
It should be the parameter that represents the rate constant, or any expression involving just parameters (i.e. |
Got, thanks. |
That’s what it should be! |
The full rate expression will be AX(X-1)/2. |
@TorkelE Just in case my answer wasn't completely clear, since I think I missed what you were actually getting at, the This is set by the constructor's |