2
2
3
3
"""
4
4
stability(u::Vector{T}, rs::ReactionSystem, p; tol = 10*sqrt(eps())
5
- sparse = false, ss_jac = steady_state_jac(u, rs, p; sparse=sparse ))
5
+ ss_jac = steady_state_jac(u, rs, p))
6
6
7
7
Compute the stability of a steady state (Returned as a `Bool`, with `true` indicating stability).
8
8
@@ -16,8 +16,7 @@ stable if the corresponding Jacobian's maximum eigenvalue real part is < 0. Howe
16
16
eigenvalue is in the range `-tol< eig < tol`, and error is throw, as we do not deem that stability
17
17
can be ensured with enough certainty. The choice `tol = 10*sqrt(eps())` has *not* been subject
18
18
to much analysis.
19
- - `sparse = false`: If we wish to create a sparse Jacobian for the stability computation.
20
- - `ss_jac = steady_state_jac(u, rs; sparse = sparse)`: It is possible to pre-compute the
19
+ - `ss_jac = steady_state_jac(u, rs)`: It is possible to pre-compute the
21
20
Jacobian used for stability computation using `steady_state_jac`. If stability is computed
22
21
for many states, precomputing the Jacobian may speed up evaluation.
23
22
@@ -47,7 +46,7 @@ however, have not been subject to further analysis (and can be changed through t
47
46
```
48
47
"""
49
48
function steady_state_stability (u:: Vector , rs:: ReactionSystem , ps; tol = 10 * sqrt (eps (ss_val_type (u))),
50
- sparse = false , ss_jac = steady_state_jac (rs; u0 = u, sparse = sparse ))
49
+ ss_jac = steady_state_jac (rs; u0 = u))
51
50
# Warning checks.
52
51
if ! is_autonomous (rs)
53
52
error (" Attempting to compute stability for a non-autonomous system (e.g. where some rate depend on $(rs. iv) ). This is not possible." )
@@ -62,6 +61,11 @@ function steady_state_stability(u::Vector, rs::ReactionSystem, ps; tol = 10*sqrt
62
61
63
62
# Computes stability (by checking that the real part of all eigenvalues are negative).
64
63
# Here, `ss_jac` is a `ODEProblem` with dummy values for `u0` and `p`.
64
+
65
+ if isdefined (Main, :Infiltrator )
66
+ Main. infiltrate (@__MODULE__ , Base. @locals , @__FILE__ , @__LINE__ )
67
+ end
68
+
65
69
J = zeros (length (u), length (u))
66
70
ss_jac = remake (ss_jac; u0 = u, p = ps)
67
71
ss_jac. f. jac (J, ss_jac. u0, ss_jac. p, Inf )
@@ -79,15 +83,14 @@ ss_val_type(u::Vector{Pair{S,T}}) where {S,T} = T
79
83
ss_val_type (u:: Dict{S,T} ) where {S,T} = T
80
84
81
85
"""
82
- steady_state_jac(rs::ReactionSystem; u0 = [], sparse = false )
86
+ steady_state_jac(rs::ReactionSystem; u0 = [])
83
87
84
88
Creates the Jacobian function which can be used as input to `steady_state_stability`. Useful when
85
89
a large number of stability computation has to be carried out in a performant manner.
86
90
87
91
Arguments:
88
92
- `rs`: The reaction system model for which we want to compute stability.
89
93
- `u0 = []`: For systems with conservation laws, a `u` is required to compute the conserved quantities.
90
- - `sparse = false`: If we wish to create a sparse Jacobian for the stability computation.
91
94
92
95
Example:
93
96
```julia
@@ -110,7 +113,7 @@ Notes:
110
113
```
111
114
"""
112
115
function steady_state_jac (rs:: ReactionSystem ; u0 = [sp => 0.0 for sp in unknowns (rs)],
113
- sparse = false , combinatoric_ratelaws = get_combinatoric_ratelaws (rs))
116
+ combinatoric_ratelaws = get_combinatoric_ratelaws (rs))
114
117
# If u0 is a vector of values, must be converted to something MTK understands.
115
118
116
119
# Converts u0 to values MTK understands, and checks that potential conservation laws are accounted for.
@@ -119,7 +122,7 @@ function steady_state_jac(rs::ReactionSystem; u0 = [sp => 0.0 for sp in unknowns
119
122
120
123
# Creates an `ODEProblem` with a Jacobian. Dummy values for `u0` and `ps` must be provided.
121
124
ps = [p => 0.0 for p in parameters (rs)]
122
- return ODEProblem (rs, u0, 0 , ps; jac = true , remove_conserved = true , sparse = sparse,
125
+ return ODEProblem (rs, u0, 0 , ps; jac = true , remove_conserved = true ,
123
126
combinatoric_ratelaws = combinatoric_ratelaws)
124
127
end
125
128
0 commit comments