-
-
Notifications
You must be signed in to change notification settings - Fork 79
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
Creation of a ReactionSystem from a reaction involving compounds and only_use_rate=true #1151
Comments
So I have been able to reproduce this in some cases. However, with only Status `~/Desktop/Julia Playground/Environment - Temporary/Project.toml`
[479239e8] Catalyst v14.4.1 `~/.julia/dev/Catalyst`
[961ee093] ModelingToolkit v9.59.0 on the latest julia version (1.11.2) this works. Could you try |
Thanks indeed it works by simply changing the release version of Catalyst by the dev one. However I have now another issue with events. Is this a temporary problem due to the dev version? using ModelingToolkit: t_nounits as t, D_nounits as D
using Catalyst
@species C(t) O(t) H(t)
@compounds begin
O₂ ~ 2O
H₂O ~ 2H + O
CO₂ ~ C + 2O
CH₄ ~ C + 4H
end
@parameters k
rx = Reaction(k*CH₄*O₂, [CH₄, O₂], [CO₂, H₂O], [1, 2], [1, 2]; only_use_rate=true)
event_CO₂ = [CO₂ ~ 1.] => [CO₂ ~ 0.5]
@named RS = ReactionSystem([rx], t; combinatoric_ratelaws=false, continuous_events = [event_CO₂]) which outputs ERROR: ArgumentError: Variable CO₂ is not a function of independent variable t.
Stacktrace:
[1] check_variables(dvs::Vector{SymbolicUtils.BasicSymbolic}, iv::SymbolicUtils.BasicSymbolic{Real})
@ ModelingToolkit C:\Users\jf.barthelemy\.julia\packages\ModelingToolkit\klLLV\src\utils.jl:151
[2] ReactionSystem(eqs::Vector{…}, rxs::Vector{…}, iv::SymbolicUtils.BasicSymbolic{…}, sivs::Vector{…}, unknowns::Vector{…}, spcs::Vector{…}, ps::Vector{…}, var_to_name::Dict{…}, observed::Vector{…}, name::Symbol, systems::Vector{…}, defaults::Dict{…}, connection_type::Nothing, nps::Catalyst.NetworkProperties{…}, cls::Bool, cevs::Vector{…}, devs::Vector{…}, metadata::Nothing, complete::Bool, parent::Nothing; checks::Bool)
@ Catalyst C:\Users\jf.barthelemy\.julia\dev\Catalyst\src\reactionsystem.jl:348
[3] ReactionSystem
@ C:\Users\jf.barthelemy\.julia\dev\Catalyst\src\reactionsystem.jl:335 [inlined]
[4] ReactionSystem(eqs::Vector{…}, iv::SymbolicUtils.BasicSymbolic{…}, unknowns::Vector{…}, ps::Vector{…}; observed::Vector{…}, systems::Vector{…}, name::Symbol, default_u0::Dict{…}, default_p::Dict{…}, defaults::Dict{…}, connection_type::Nothing, checks::Bool, networkproperties::Nothing, combinatoric_ratelaws::Bool, balanced_bc_check::Bool, spatial_ivs::Nothing, continuous_events::Vector{…}, discrete_events::Vector{…}, metadata::Nothing)
@ Catalyst C:\Users\jf.barthelemy\.julia\dev\Catalyst\src\reactionsystem.jl:466
[5] make_ReactionSystem_internal(rxs_and_eqs::Vector{…}, iv::Num, us_in::Vector{…}, ps_in::Vector{…}; spatial_ivs::Nothing, continuous_events::Vector{…}, discrete_events::Vector{…}, observed::Vector{…}, kwargs::@Kwargs{…})
@ Catalyst C:\Users\jf.barthelemy\.julia\dev\Catalyst\src\reactionsystem.jl:564
[6] make_ReactionSystem_internal
@ C:\Users\jf.barthelemy\.julia\dev\Catalyst\src\reactionsystem.jl:489 [inlined]
[7] #ReactionSystem#66
@ C:\Users\jf.barthelemy\.julia\dev\Catalyst\src\reactionsystem.jl:475 [inlined]
[8] top-level scope
@ C:\Users\jf.barthelemy\.julia\packages\ModelingToolkit\klLLV\src\systems\abstractsystem.jl:2060
Some type information was truncated. Use `show(err)` to see complete types. |
Can confirm this second one is a bug. Have gotten partially though where it is, think it should be straightforward to fix. |
I will continue looking tomorrow, but in summary for anyone who is interested, this is the core problem: using Catalyst
t = default_t()
@species C(t) O(t)
@compounds begin
CO ~ C + O
end
vars = []
ModelingToolkit.get_variables!(vars, C + 1)
vars # [C(t)]
vars = []
ModelingToolkit.get_variables!(vars, CO + 1)
vars # [CO, t] I.e. MTK's Another thing I found, which I thought was the problem (but isn't) is that compounds are not wrapped: CO |> typeof # SymbolicUtils.BasicSymbolic{Real}
C |> typeof # Num Fixing this doesn't;t actually solve the original problem (but should be fixed though). |
Does the |
That seems like a good guess, will have a look at it |
Fix is up here: #1154 Should be available in the next release (unclear when that drops though) |
Hi,
After an update the following MRE doesn't work anymore whereas it worked in a set of previous versions of libraries (unfortunately I haven't kept the version numbers). Thank you very much for your help.
Minimal Reproducible Example 👇
Error & Stacktrace⚠️
Not Working Environment:
using Pkg; Pkg.status()
using Pkg; Pkg.status(; mode = PKGMODE_MANIFEST)
Click to open
versioninfo()
The text was updated successfully, but these errors were encountered: