Skip to content

Commit c3f60e8

Browse files
committed
fix bidirectional math and completion of ODESystems
1 parent 2dd2102 commit c3f60e8

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

src/reactions.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Infer forward and reverse components of bidirectional kineticLaw
3030
"""
3131
function get_unidirectional_components(bidirectional_math)
3232
bm = ModelingToolkit.value(bidirectional_math) # Symbolics.tosymbol(bidirectional_math)
33-
bm = simplify(bm; expand = true)
33+
bm = expand(simplify(bm))
3434
if !SymbolicUtils.isadd(bm)
3535
@warn "Cannot separate bidirectional kineticLaw `$bidirectional_math` to forward and reverse part. Setting forward to `$bidirectional_math` and reverse to `0`. Stochastic simulations will be inexact."
3636
return (bidirectional_math, Num(0))

src/systems.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ See also [`Model`](@ref) and [`ODESystemImporter`](@ref).
3939
"""
4040
function SBML.readSBML(sbmlfile::String, ::ODESystemImporter;
4141
include_zero_odes::Bool = true, kwargs...) # Returns an MTK.ODESystem
42-
convert(ODESystem, readSBML(sbmlfile, ReactionSystemImporter(), kwargs...),
42+
odesys = convert(ODESystem, readSBML(sbmlfile, ReactionSystemImporter(), kwargs...),
4343
include_zero_odes = include_zero_odes)
44+
complete(odesys)
4445
end
4546

4647
"""
@@ -108,7 +109,8 @@ See also [`ReactionSystem`](@ref).
108109
function ModelingToolkit.ODESystem(model::SBML.Model; include_zero_odes::Bool = true,
109110
kwargs...)
110111
rs = ReactionSystem(model; kwargs...)
111-
convert(ODESystem, rs; include_zero_odes = include_zero_odes)
112+
odesys = convert(ODESystem, rs; include_zero_odes = include_zero_odes)
113+
complete(odesys)
112114
end
113115

114116
function get_mappings(model::SBML.Model)

test/systems.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ isequal(nameof(odesys), :odesys)
9393

9494
odesys = ODESystem(readSBML(sbmlfile))
9595
m = readSBML(sbmlfile)
96-
trueeqs = Equation[Differential(IV)(s1) ~ -(k1 * s1 * s2) / c1,
96+
trueeqs = Equation[Differential(IV)(s1) ~ -((k1 * s1 * s2) / c1),
9797
Differential(IV)(s1s2) ~ (k1 * s1 * s2) / c1,
98-
Differential(IV)(s2) ~ -(k1 * s1 * s2) / c1]
98+
Differential(IV)(s2) ~ -((k1 * s1 * s2) / c1)]
9999
@test isequal(Catalyst.get_eqs(odesys), trueeqs)
100100
@test isequal(Catalyst.get_iv(odesys), IV)
101101
@test isequal(Catalyst.get_unknowns(odesys), [s1, s1s2, s2])

0 commit comments

Comments
 (0)