Skip to content

Commit e968c93

Browse files
committed
up
1 parent d671621 commit e968c93

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

docs/pages.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,6 @@ pages = Any[
6666
# # Contributor's guide.
6767
# # Repository structure.
6868
# ],
69-
#"FAQs" => "faqs.md",
69+
"FAQs" => "faqs.md",
7070
"API" => "api.md"
7171
]

docs/src/faqs.md

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,10 @@ One can directly use symbolic variables to index into SciML solution objects.
55
Moreover, observables can also be evaluated in this way. For example,
66
consider the system
77
```@example faq1
8-
using Catalyst, DifferentialEquations, Plots
8+
using Catalyst, OrdinaryDiffEq, Plots
99
rn = @reaction_network ABtoC begin
1010
(k₊,k₋), A + B <--> C
1111
end
12-
13-
# initial condition and parameter values
14-
setdefaults!(rn, [:A => 1.0, :B => 2.0, :C => 0.0, :k₊ => 1.0, :k₋ => 1.0])
1512
nothing # hide
1613
```
1714
Let's convert it to a system of ODEs, using the conservation laws of the system
@@ -29,33 +26,35 @@ observed(osys)
2926
Let's solve the system and see how to index the solution using our symbolic
3027
variables
3128
```@example faq1
29+
u0 = [rn.A => 1.0, rn.B => 2.0, rn.C => 0.0]
30+
ps = [rn.k₊ => 1.0, rn.k₋ => 1.0]
3231
oprob = ODEProblem(osys, [], (0.0, 10.0), [])
3332
sol = solve(oprob, Tsit5())
3433
```
3534
Suppose we want to plot just species `C`, without having to know its integer
3635
index in the unknown vector. We can do this using the symbolic variable `C`, which
3736
we can get at in several ways
38-
```@example faq1
37+
```julia
3938
sol[osys.C]
4039
```
4140
or
42-
```@example faq1
41+
```julia
4342
@unpack C = osys
4443
sol[C]
4544
```
4645
To evaluate `C` at specific times and plot it we can just do
47-
```@example faq1
46+
```julia
4847
t = range(0.0, 10.0, length=101)
4948
plot(t, sol(t, idxs = C), label = "C(t)", xlabel = "t")
5049
```
5150
If we want to get multiple variables we can just do
52-
```@example faq1
51+
```julia
5352
@unpack A, B = osys
5453
sol(t, idxs = [A, B])
5554
```
5655
Plotting multiple variables using the SciML plot recipe can be achieved
5756
like
58-
```@example faq1
57+
```julia
5958
plot(sol; idxs = [A, B])
6059
```
6160

@@ -66,7 +65,7 @@ constant, giving `k*X^2/2` instead of `k*X^2` for ODEs and `k*X*(X-1)/2` instead
6665
of `k*X*(X-1)` for jumps. This can be disabled when directly `convert`ing a
6766
[`ReactionSystem`](@ref). If `rn` is a generated [`ReactionSystem`](@ref), we can
6867
do
69-
```julia
68+
```@example faq1
7069
osys = convert(ODESystem, rn; combinatoric_ratelaws=false)
7170
```
7271
Disabling these rescalings should work for all conversions of `ReactionSystem`s
@@ -89,6 +88,7 @@ rx2 = Reaction(2*k, [B], [D], [1], [2.5])
8988
rx3 = Reaction(2*k, [B], [D], [2.5], [2])
9089
@named mixedsys = ReactionSystem([rx1, rx2, rx3], t, [A, B, C, D], [k, b])
9190
osys = convert(ODESystem, mixedsys; combinatoric_ratelaws = false)
91+
osys = complete(osys)
9292
```
9393
Note, when using `convert(ODESystem, mixedsys; combinatoric_ratelaws=false)` the
9494
`combinatoric_ratelaws=false` parameter must be passed. This is also true when
@@ -128,6 +128,7 @@ t = default_t()
128128
rx1 = Reaction(β, [S, I], [I], [1,1], [2])
129129
rx2 = Reaction(ν, [I], [R])
130130
@named sir = ReactionSystem([rx1, rx2], t)
131+
sir = complete(sir)
131132
oprob = ODEProblem(sir, [], (0.0, 250.0))
132133
sol = solve(oprob, Tsit5())
133134
plot(sol)
@@ -163,7 +164,7 @@ Julia `Symbol`s corresponding to each variable/parameter to their values, or
163164
from ModelingToolkit symbolic variables/parameters to their values. Using
164165
`Symbol`s we have
165166
```@example faq4
166-
using Catalyst, DifferentialEquations
167+
using Catalyst, OrdinaryDiffEq
167168
rn = @reaction_network begin
168169
α, S + I --> 2I
169170
β, I --> R
@@ -200,6 +201,7 @@ the second example, or one can use the `symmap_to_varmap` function to convert th
200201
`Symbol` mapping to a symbolic mapping. I.e. this works
201202
```@example faq4
202203
osys = convert(ODESystem, rn)
204+
osys = complete(osys)
203205
204206
# this works
205207
u0 = symmap_to_varmap(rn, [:S => 999.0, :I => 1.0, :R => 0.0])

0 commit comments

Comments
 (0)