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

Conversion to non-linear system does not handle presence of differential equations:

Open TorkelE opened this issue 2 years ago • 3 comments

This code:

@parameters v1 K1 v2=1.0 K2=0.4 d
@variables t Y(t)
@species X(t)
eq = Differential(Y) ~ v1*Y/(Y+K1) - d*Y
rx1 = @reaction v1*$Y/($Y+K1), 0 --> X
rx2 = @reaction d, X --> 0
@named rn = ReactionSystem([rx1, rx2, eq], t)

ns = convert(NonlinearSystem, rn);
println.(ns.eqs)

returns

0 ~ (v1*Y(t)) / (K1 + Y(t)) - d*X(t)
Differential(Y(t)) ~ (v1*Y(t)) / (K1 + Y(t)) - d*Y(t)

However, the Differential(Y(t)) should be set to 0.

TorkelE avatar Nov 14 '23 14:11 TorkelE

We don't handle conversion of non-reactions currently, but assume the user has input them as they desired in their model. So that would need to be added by someone, presumably it can reuse what is done in MTK.

isaacsas avatar Nov 14 '23 16:11 isaacsas

It feels fairly obvious that if someone has made a mixed ReactionSystem/Differential equation ODE, that if they want to convert it to a NonlinearSystem they want those derivatives to be 0 as well. I think we should make this the case (ideally put a warning until we have fixed this), and then maybe put in a kwarg to disable this automatic conversion.

TorkelE avatar Nov 14 '23 16:11 TorkelE

Yes, I agree. Feel free to PR if you want to add that. You can probably reuse what is in MTK for the conversion to make sure the derivatives are on the correct side and such.

isaacsas avatar Nov 14 '23 16:11 isaacsas

@TorkelE this is handled now? (Modulo recent bugs via Symbolics changes?)

isaacsas avatar May 13 '24 16:05 isaacsas

yes, this is handled now

TorkelE avatar May 14 '24 15:05 TorkelE