8
8
Given a [`ReactionSystem`](@ref), return a vector of species `Variable`s.
9
9
10
10
Notes:
11
- - If `network.systems ` is not empty, may allocate. Otherwise returns
12
- `network.states `.
11
+ - If `ModelingToolkit.get_systems(network) ` is not empty, may allocate. Otherwise returns
12
+ `ModelingToolkit.ModelingToolkit.get_states(network) `.
13
13
"""
14
14
function species (network)
15
- isempty (network . systems) ? network . states : states (network)
15
+ isempty (ModelingToolkit . get_systems (network)) ? ModelingToolkit . ModelingToolkit . get_states (network) : states (network)
16
16
end
17
17
18
18
"""
21
21
Given a [`ReactionSystem`](@ref), return a vector of parameter `Variable`s.
22
22
23
23
Notes:
24
- - If `network.systems ` is not empty, may allocate. Otherwise returns
25
- `network.ps `.
24
+ - If `ModelingToolkit.get_systems(network) ` is not empty, may allocate. Otherwise returns
25
+ `ModelingToolkit.get_ps(network) `.
26
26
"""
27
27
function params (network)
28
- isempty (network . systems) ? network . ps : parameters (network)
28
+ isempty (ModelingToolkit . get_systems (network)) ? ModelingToolkit . get_ps (network) : parameters (network)
29
29
end
30
30
31
31
"""
34
34
Given a [`ReactionSystem`](@ref), return a vector of all `Reactions` in the system.
35
35
36
36
Notes:
37
- - If `network.systems ` is not empty, may allocate. Otherwise returns
38
- `network.eqs `.
37
+ - If `ModelingToolkit.get_systems(network) ` is not empty, may allocate. Otherwise returns
38
+ `ModelingToolkit.get_eqs(network) `.
39
39
"""
40
40
function reactions (network)
41
- isempty (network . systems) ? network . eqs : equations (network)
41
+ isempty (ModelingToolkit . get_systems (network)) ? ModelingToolkit . get_eqs (network) : equations (network)
42
42
end
43
43
44
44
"""
67
67
Return the number of species within the given [`ReactionSystem`](@ref).
68
68
"""
69
69
function numspecies (network)
70
- ns = length (network . states )
71
- for sys in network . systems
70
+ ns = length (ModelingToolkit . ModelingToolkit . get_states (network) )
71
+ for sys in ModelingToolkit . get_systems (network)
72
72
ns += numspecies (ns)
73
73
end
74
74
ns
80
80
Return the number of reactions within the given [`ReactionSystem`](@ref).
81
81
"""
82
82
function numreactions (network)
83
- nr = length (network . eqs )
84
- for sys in network . systems
83
+ nr = length (ModelingToolkit . get_eqs (network) )
84
+ for sys in ModelingToolkit . get_systems (network)
85
85
nr += numreactions (sys)
86
86
end
87
87
nr
93
93
Return the number of parameters within the given [`ReactionSystem`](@ref).
94
94
"""
95
95
function numparams (network)
96
- np = length (network . ps )
97
- for sys in network . systems
96
+ np = length (ModelingToolkit . get_ps (network) )
97
+ for sys in ModelingToolkit . get_systems (network)
98
98
np += numparams (ns)
99
99
end
100
100
np
@@ -201,7 +201,7 @@ Notes:
201
201
function (== )(rn1:: ReactionSystem , rn2:: ReactionSystem )
202
202
issetequal (species (rn1), species (rn2)) || return false
203
203
issetequal (params (rn1), params (rn2)) || return false
204
- isequal (rn1 . iv, rn2 . iv ) || return false
204
+ isequal (ModelingToolkit . independent_variable (rn1), ModelingToolkit . independent_variable (rn2) ) || return false
205
205
(numreactions (rn1) == numreactions (rn2)) || return false
206
206
207
207
# the following fails for some reason, so need to use issubset
@@ -244,10 +244,10 @@ Notes:
244
244
function addspecies! (network:: ReactionSystem , s:: Symbolic ; disablechecks= false )
245
245
246
246
# we don't check subsystems since we will add it to the top-level system...
247
- curidx = disablechecks ? nothing : findfirst (S -> isequal (S, s), network . states )
247
+ curidx = disablechecks ? nothing : findfirst (S -> isequal (S, s), ModelingToolkit . ModelingToolkit . get_states (network) )
248
248
if curidx === nothing
249
- push! (network . states , s)
250
- return length (network . states )
249
+ push! (ModelingToolkit . ModelingToolkit . get_states (network) , s)
250
+ return length (ModelingToolkit . ModelingToolkit . get_states (network) )
251
251
else
252
252
return curidx
253
253
end
@@ -287,10 +287,10 @@ function addparam!(network::ReactionSystem, p::Symbolic; disablechecks=false)
287
287
if istree (p) && ! (operation (p) isa Sym)
288
288
error (" If the passed in parameter is an expression, it must correspond to an underlying Variable." )
289
289
end
290
- curidx = disablechecks ? nothing : findfirst (S -> isequal (S, p), network . ps )
290
+ curidx = disablechecks ? nothing : findfirst (S -> isequal (S, p), ModelingToolkit . get_ps (network) )
291
291
if curidx === nothing
292
- push! (network . ps , p)
293
- return length (network . ps )
292
+ push! (ModelingToolkit . get_ps (network) , p)
293
+ return length (ModelingToolkit . get_ps (network) )
294
294
else
295
295
return curidx
296
296
end
@@ -323,8 +323,8 @@ Notes:
323
323
`network` using [`addspecies!`](@ref) and [`addparam!`](@ref).
324
324
"""
325
325
function addreaction! (network:: ReactionSystem , rx:: Reaction )
326
- push! (network . eqs , rx)
327
- length (network . eqs )
326
+ push! (ModelingToolkit . get_eqs (network) , rx)
327
+ length (ModelingToolkit . get_eqs (network) )
328
328
end
329
329
330
330
@@ -343,7 +343,8 @@ Notes:
343
343
- Does not currently handle pins.
344
344
"""
345
345
function merge! (network1:: ReactionSystem , network2:: ReactionSystem )
346
- isequal (network1. iv, network2. iv) || error (" Reaction networks must have the same independent variable to be mergable." )
346
+ isequal (ModelingToolkit. independent_variable (network1),
347
+ ModelingToolkit. independent_variable (network2)) || error (" Reaction networks must have the same independent variable to be mergable." )
347
348
union! (network1. states, network2. states)
348
349
union! (network1. ps, network2. ps)
349
350
append! (network1. eqs, network2. eqs)
0 commit comments