You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
COMPLETENESS_ERROR ="A ReactionSystem must be complete before it can be converted to other system types. A ReactionSystem can be marked as complete using the `complete` function."
452
452
453
+
# Used to, when required, display a warning about conservation law removeal and remake.
error("Attempting to convert a non-autonomous `ReactionSystem` (e.g. where some rate depend on $(get_iv(rs))) to a `NonlinearSystem`. This is not possible. if you are intending to compute system steady states, consider creating and solving a `SteadyStateProblem.")
524
548
end
@@ -589,17 +613,19 @@ Notes:
589
613
- `remove_conserved=false`, if set to `true` will calculate conservation laws of the
590
614
underlying set of reactions (ignoring constraint equations), and then apply them to reduce
591
615
the number of equations.
592
-
- Does not currently support `ReactionSystem`s that include coupled algebraic or
593
-
differential equations.
616
+
- `remove_conserved_warn = true`: If `true`, if also `remove_conserved = true`, there will be
617
+
a warning regarding limitations of modifying problems generated from the created system.
594
618
"""
595
619
function Base.convert(::Type{<:SDESystem}, rs::ReactionSystem;
596
620
name =nameof(rs), combinatoric_ratelaws =get_combinatoric_ratelaws(rs),
# Checks that the correct parameters have the `conserved` metadata.
251
254
@test Catalyst.isconserved(osys.Γ[1])
252
255
@test Catalyst.isconserved(osys.Γ[2])
253
256
@test!Catalyst.isconserved(osys.k1)
254
257
@test!Catalyst.isconserved(osys.k2)
255
258
end
259
+
260
+
# Checks that conservation law elimination warnings are generated in the correct cases.
261
+
let
262
+
# Prepare model.
263
+
rn =@reaction_networkbegin
264
+
(k1,k2), X1 <--> X2
265
+
end
266
+
u0 = [:X1=>1.0, :X2=>2.0]
267
+
tspan = (0.0, 1.0)
268
+
ps = [:k1=>3.0, :k2=>4.0]
269
+
270
+
# Check warnings in system conversion.
271
+
for XSystem in [ODESystem, SDESystem, NonlinearSystem]
272
+
@test_nowarnconvert(XSystem, rn)
273
+
@test_logs (:warn, r"You are creating a system or problem while eliminating conserved quantities. Please *") convert(XSystem, rn; remove_conserved =true)
# Checks during problem creation (separate depending on whether they have a time span or not).
279
+
for XProblem in [ODEProblem, SDEProblem]
280
+
@test_nowarnXProblem(rn, u0, tspan, ps)
281
+
@test_logs (:warn, r"You are creating a system or problem while eliminating conserved quantities. Please *") XProblem(rn, u0, tspan, ps; remove_conserved =true)
for XProblem in [NonlinearProblem, SteadyStateProblem]
286
+
@test_nowarnXProblem(rn, u0, ps)
287
+
@test_logs (:warn, r"You are creating a system or problem while eliminating conserved quantities. Please *") XProblem(rn, u0, ps; remove_conserved =true)
0 commit comments