Skip to content

Commit 7cac054

Browse files
committed
merge master
2 parents b64a3a7 + bc6d339 commit 7cac054

30 files changed

+916
-782
lines changed

docs/make.jl

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,17 @@ include("pages.jl")
3131
# pages = pages)
3232

3333
makedocs(sitename = "Catalyst.jl",
34-
authors = "Samuel Isaacson",
35-
format = Documenter.HTML(; analytics = "UA-90474609-3",
36-
prettyurls = (get(ENV, "CI", nothing) == "true"),
37-
assets = ["assets/favicon.ico"],
38-
canonical = "https://docs.sciml.ai/Catalyst/stable/"),
39-
modules = [Catalyst, ModelingToolkit],
40-
doctest = false,
41-
clean = true,
42-
pages = pages,
43-
pagesonly = true,
44-
warnonly = true)
34+
authors = "Samuel Isaacson",
35+
format = Documenter.HTML(; analytics = "UA-90474609-3",
36+
prettyurls = (get(ENV, "CI", nothing) == "true"),
37+
assets = ["assets/favicon.ico"],
38+
canonical = "https://docs.sciml.ai/Catalyst/stable/"),
39+
modules = [Catalyst, ModelingToolkit],
40+
doctest = false,
41+
clean = true,
42+
pages = pages,
43+
pagesonly = true,
44+
warnonly = [:missing_docs])
4545

4646
deploydocs(repo = "github.com/SciML/Catalyst.jl.git";
47-
push_preview = true)
47+
push_preview = true)

docs/pages.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pages = Any[
2727
"model_simulation/simulation_plotting.md",
2828
"model_simulation/simulation_structure_interfacing.md",
2929
"model_simulation/ensemble_simulations.md",
30-
"model_simulation/ode_simulation_performance.md",
30+
"model_simulation/ode_simulation_performance.md"
3131
],
3232
"Steady state analysis" => Any[
3333
"steady_state_functionality/homotopy_continuation.md",

docs/src/introduction_to_catalyst/introduction_to_catalyst.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ We first import the basic packages we'll need:
1212

1313
```@example tut1
1414
# If not already installed, first hit "]" within a Julia REPL. Then type:
15-
# add Catalyst DifferentialEquations Plots Latexify
15+
# add Catalyst OrdinaryDiffEq Plots Latexify
1616
17-
using Catalyst, DifferentialEquations, Plots, Latexify
17+
using Catalyst, OrdinaryDiffEq, Plots, Latexify
1818
```
1919

2020
We now construct the reaction network. The basic types of arrows and predefined
@@ -160,7 +160,7 @@ underlying problem.
160160

161161
At this point we are all set to solve the ODEs. We can now use any ODE solver
162162
from within the
163-
[DifferentialEquations.jl](https://docs.sciml.ai/DiffEqDocs/stable/solvers/ode_solve/)
163+
[OrdinaryDiffEq.jl](https://docs.sciml.ai/DiffEqDocs/stable/solvers/ode_solve/)
164164
package. We'll use the recommended default explicit solver, `Tsit5()`, and then
165165
plot the solutions:
166166

@@ -169,7 +169,7 @@ sol = solve(oprob, Tsit5(), saveat=10.)
169169
plot(sol)
170170
```
171171
We see the well-known oscillatory behavior of the repressilator! For more on the
172-
choices of ODE solvers, see the [DifferentialEquations.jl
172+
choices of ODE solvers, see the [OrdinaryDiffEq.jl
173173
documentation](https://docs.sciml.ai/DiffEqDocs/stable/solvers/ode_solve/).
174174

175175
---
@@ -182,6 +182,9 @@ Gillespie's `Direct` method, and then solve it to generate one realization of
182182
the jump process:
183183

184184
```@example tut1
185+
# imports the JumpProcesses packages
186+
using JumpProcesses
187+
185188
# redefine the initial condition to be integer valued
186189
u₀map = [:m₁ => 0, :m₂ => 0, :m₃ => 0, :P₁ => 20, :P₂ => 0, :P₃ => 0]
187190
@@ -237,6 +240,9 @@ model by creating an `SDEProblem` and solving it similarly to what we did for OD
237240
above:
238241

239242
```@example tut1
243+
# imports the StochasticDiffEq package for SDE simulations
244+
using StochasticDiffEq
245+
240246
# SDEProblem for CLE
241247
sprob = SDEProblem(bdp, u₀, tspan, p)
242248

docs/src/model_creation/constraint_equations.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ creating these two systems.
2828
Here, to create differentials with respect to time (for our differential equations), we must import the time differential operator from Catalyst. We do this through `D = default_time_deriv()`. Here, `D(V)` denotes the differential of the variable `V` with respect to time.
2929

3030
```@example ceq1
31-
using Catalyst, DifferentialEquations, Plots
31+
using Catalyst, OrdinaryDiffEq, Plots
3232
t = default_t()
3333
D = default_time_deriv()
3434
@@ -58,6 +58,7 @@ We can now merge the two systems into one complete `ReactionSystem` model using
5858
[`ModelingToolkit.extend`](@ref):
5959
```@example ceq1
6060
@named growing_cell = extend(osys, rn)
61+
growing_cell = complete(growing_cell)
6162
```
6263

6364
We see that the combined model now has both the reactions and ODEs as its
@@ -72,7 +73,7 @@ plot(sol)
7273
As an alternative to the previous approach, we could have constructed our
7374
`ReactionSystem` all at once by directly using the symbolic interface:
7475
```@example ceq2
75-
using Catalyst, DifferentialEquations, Plots
76+
using Catalyst, OrdinaryDiffEq, Plots
7677
t = default_t()
7778
D = default_time_deriv()
7879
@@ -83,6 +84,7 @@ rx1 = @reaction $V, 0 --> P
8384
rx2 = @reaction 1.0, P --> 0
8485
@named growing_cell = ReactionSystem([rx1, rx2, eq], t)
8586
setdefaults!(growing_cell, [:P => 0.0])
87+
growing_cell = complete(growing_cell)
8688
8789
oprob = ODEProblem(growing_cell, [], (0.0, 1.0))
8890
sol = solve(oprob, Tsit5())
@@ -100,12 +102,11 @@ the associated [ModelingToolkit
100102
tutorial](https://docs.sciml.ai/ModelingToolkit/stable/basics/Events/) for more
101103
details on the types of events that can be represented symbolically. A
102104
lower-level approach for creating events via the DifferentialEquations.jl
103-
callback interface is illustrated in the [Advanced Simulation Options](@ref
104-
advanced_simulations) tutorial.
105+
callback interface is illustrated [here](https://docs.sciml.ai/DiffEqDocs/stable/features/callback_functions/) tutorial.
105106

106107
Let's first create our equations and unknowns/species again
107108
```@example ceq3
108-
using Catalyst, DifferentialEquations, Plots
109+
using Catalyst, OrdinaryDiffEq, Plots
109110
t = default_t()
110111
D = default_time_deriv()
111112
@@ -124,6 +125,7 @@ continuous_events = [V ~ 2.0] => [V ~ V/2, P ~ P/2]
124125
We can now create and simulate our model
125126
```@example ceq3
126127
@named rs = ReactionSystem([rx1, rx2, eq], t; continuous_events)
128+
rs = complete(rs)
127129
128130
oprob = ODEProblem(rs, [], (0.0, 10.0))
129131
sol = solve(oprob, Tsit5())
@@ -148,6 +150,7 @@ p = [k_on => 100.0, switch_time => 2.0, k_off => 10.0]
148150
Simulating our model,
149151
```@example ceq3
150152
@named osys = ReactionSystem(rxs, t, [A, B], [k_on, k_off, switch_time]; discrete_events)
153+
osys = complete(osys)
151154
152155
oprob = ODEProblem(osys, u0, tspan, p)
153156
sol = solve(oprob, Tsit5(); tstops = 2.0)

ext/CatalystBifurcationKitExtension.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ import BifurcationKit as BK
77
# Creates and exports hc_steady_states function.
88
include("CatalystBifurcationKitExtension/bifurcation_kit_extension.jl")
99

10-
end
10+
end

ext/CatalystBifurcationKitExtension/bifurcation_kit_extension.jl

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,30 @@
22

33
# Creates a BifurcationProblem, using a ReactionSystem as an input.
44
function BK.BifurcationProblem(rs::ReactionSystem, u0_bif, ps, bif_par, args...;
5-
plot_var=nothing, record_from_solution=BK.record_sol_default, jac=true, u0=[], kwargs...)
6-
if !isautonomous(rs)
5+
plot_var = nothing, record_from_solution = BK.record_sol_default, jac = true, u0 = [], kwargs...)
6+
if !isautonomous(rs)
77
error("Attempting to create a `BifurcationProblem` for a non-autonomous system (e.g. where some rate depend on $(rs.iv)). This is not possible.")
88
end
99

1010
# Converts symbols to symbolics.
1111
(bif_par isa Symbol) && (bif_par = ModelingToolkit.get_var_to_name(rs)[bif_par])
1212
(plot_var isa Symbol) && (plot_var = ModelingToolkit.get_var_to_name(rs)[plot_var])
13-
((u0_bif isa Vector{<:Pair{Symbol,<:Any}}) || (u0_bif isa Dict{Symbol, <:Any})) && (u0_bif = symmap_to_varmap(rs, u0_bif))
14-
((ps isa Vector{<:Pair{Symbol,<:Any}}) || (ps isa Dict{Symbol, <:Any})) && (ps = symmap_to_varmap(rs, ps))
15-
((u0 isa Vector{<:Pair{Symbol,<:Any}}) || (u0 isa Dict{Symbol, <:Any})) && (u0 = symmap_to_varmap(rs, u0))
13+
if (u0_bif isa Vector{<:Pair{Symbol, <:Any}}) || (u0_bif isa Dict{Symbol, <:Any})
14+
u0_bif = symmap_to_varmap(rs, u0_bif)
15+
end
16+
if (ps isa Vector{<:Pair{Symbol, <:Any}}) || (ps isa Dict{Symbol, <:Any})
17+
ps = symmap_to_varmap(rs, ps)
18+
end
19+
if (u0 isa Vector{<:Pair{Symbol, <:Any}}) || (u0 isa Dict{Symbol, <:Any})
20+
u0 = symmap_to_varmap(rs, u0)
21+
end
1622

1723
# Creates NonlinearSystem.
1824
Catalyst.conservationlaw_errorcheck(rs, vcat(ps, u0))
19-
nsys = complete(convert(NonlinearSystem, rs; remove_conserved=true, defaults=Dict(u0)))
25+
nsys = convert(NonlinearSystem, rs; remove_conserved = true, defaults = Dict(u0))
26+
nsys = complete(nsys)
2027

2128
# Makes BifurcationProblem (this call goes through the ModelingToolkit-based BifurcationKit extension).
22-
return BK.BifurcationProblem(nsys, u0_bif, ps, bif_par, args...; plot_var=plot_var,
23-
record_from_solution=record_from_solution, jac=jac, kwargs...)
24-
end
29+
return BK.BifurcationProblem(nsys, u0_bif, ps, bif_par, args...; plot_var,
30+
record_from_solution, jac, kwargs...)
31+
end

ext/CatalystHomotopyContinuationExtension.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ import Symbolics: unwrap, wrap, Rewriters, symtype, issym, istree
1111
# Creates and exports hc_steady_states function.
1212
include("CatalystHomotopyContinuationExtension/homotopy_continuation_extension.jl")
1313

14-
end
14+
end

ext/CatalystHomotopyContinuationExtension/homotopy_continuation_extension.jl

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@ Notes:
3535
- Homotopy-based steady state finding only works when all rates are rational polynomials (e.g. constant, linear, mm, or hill functions).
3636
```
3737
"""
38-
function Catalyst.hc_steady_states(rs::ReactionSystem, ps; filter_negative=true, neg_thres=-1e-20, u0=[], kwargs...)
39-
if !isautonomous(rs)
38+
function Catalyst.hc_steady_states(rs::ReactionSystem, ps; filter_negative = true,
39+
neg_thres = -1e-20, u0 = [], kwargs...)
40+
if !isautonomous(rs)
4041
error("Attempting to compute steady state for a non-autonomous system (e.g. where some rate depend on $(rs.iv)). This is not possible.")
4142
end
4243
ss_poly = steady_state_polynomial(rs, ps, u0)
@@ -49,10 +50,11 @@ end
4950
function steady_state_polynomial(rs::ReactionSystem, ps, u0)
5051
rs = Catalyst.expand_registered_functions(rs)
5152
ns = complete(convert(NonlinearSystem, rs; remove_conserved = true))
52-
pre_varmap = [symmap_to_varmap(rs,u0)..., symmap_to_varmap(rs,ps)...]
53+
pre_varmap = [symmap_to_varmap(rs, u0)..., symmap_to_varmap(rs, ps)...]
5354
Catalyst.conservationlaw_errorcheck(rs, pre_varmap)
54-
p_vals = ModelingToolkit.varmap_to_vars(pre_varmap, parameters(ns); defaults = ModelingToolkit.defaults(ns))
55-
p_dict = Dict(parameters(ns) .=> p_vals)
55+
p_vals = ModelingToolkit.varmap_to_vars(pre_varmap, parameters(ns);
56+
defaults = ModelingToolkit.defaults(ns))
57+
p_dict = Dict(parameters(ns) .=> p_vals)
5658
eqs_pars_funcs = vcat(equations(ns), conservedequations(rs))
5759
eqs = map(eq -> substitute(eq.rhs - eq.lhs, p_dict), eqs_pars_funcs)
5860
eqs_intexp = make_int_exps.(eqs)
@@ -61,12 +63,14 @@ function steady_state_polynomial(rs::ReactionSystem, ps, u0)
6163
end
6264

6365
# Parses and expression and return a version where any exponents that are Float64 (but an int, like 2.0) are turned into Int64s.
64-
make_int_exps(expr) = wrap(Rewriters.Postwalk(Rewriters.PassThrough(___make_int_exps))(unwrap(expr))).val
66+
function make_int_exps(expr)
67+
wrap(Rewriters.Postwalk(Rewriters.PassThrough(___make_int_exps))(unwrap(expr))).val
68+
end
6569
function ___make_int_exps(expr)
6670
!istree(expr) && return expr
67-
if (operation(expr) == ^)
71+
if (operation(expr) == ^)
6872
if isinteger(arguments(expr)[2])
69-
return arguments(expr)[1] ^ Int64(arguments(expr)[2])
73+
return arguments(expr)[1]^Int64(arguments(expr)[2])
7074
else
7175
error("An non integer ($(arguments(expr)[2])) was found as a variable exponent. Non-integer exponents are not supported for homotopy continuation based steady state finding.")
7276
end
@@ -95,7 +99,7 @@ function reorder_sols!(sols, ss_poly, rs::ReactionSystem)
9599
end
96100

97101
# Filters away solutions with negative species concentrations (and for neg_thres < val < 0.0, sets val=0.0).
98-
function filter_negative_f(sols; neg_thres=-1e-20)
102+
function filter_negative_f(sols; neg_thres = -1e-20)
99103
for sol in sols, idx in 1:length(sol)
100104
(neg_thres < sol[idx] < 0) && (sol[idx] = 0)
101105
end
@@ -104,9 +108,13 @@ end
104108

105109
# Sometimes (when polynomials are created from coupled CRN/DAEs), the steady state polynomial have the wrong type.
106110
# This converts it to the correct type, which homotopy continuation can handle.
107-
const WRONG_POLY_TYPE = Vector{DynamicPolynomials.Polynomial{DynamicPolynomials.Commutative{DynamicPolynomials.CreationOrder}, DynamicPolynomials.Graded{DynamicPolynomials.LexOrder}}}
108-
const CORRECT_POLY_TYPE = Vector{DynamicPolynomials.Polynomial{DynamicPolynomials.Commutative{DynamicPolynomials.CreationOrder}, DynamicPolynomials.Graded{DynamicPolynomials.LexOrder}, Float64}}
111+
const WRONG_POLY_TYPE = Vector{DynamicPolynomials.Polynomial{
112+
DynamicPolynomials.Commutative{DynamicPolynomials.CreationOrder},
113+
DynamicPolynomials.Graded{DynamicPolynomials.LexOrder}}}
114+
const CORRECT_POLY_TYPE = Vector{DynamicPolynomials.Polynomial{
115+
DynamicPolynomials.Commutative{DynamicPolynomials.CreationOrder},
116+
DynamicPolynomials.Graded{DynamicPolynomials.LexOrder}, Float64}}
109117
function poly_type_convert(ss_poly)
110118
(typeof(ss_poly) == WRONG_POLY_TYPE) && return convert(CORRECT_POLY_TYPE, ss_poly)
111119
return ss_poly
112-
end
120+
end

ext/CatalystStructuralIdentifiabilityExtension.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ import StructuralIdentifiability as SI
77
# Creates and exports hc_steady_states function.
88
include("CatalystStructuralIdentifiabilityExtension/structural_identifiability_extension.jl")
99

10-
end
10+
end

0 commit comments

Comments
 (0)