You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/introduction_to_catalyst/introduction_to_catalyst.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -182,7 +182,7 @@ Gillespie's `Direct` method, and then solve it to generate one realization of
182
182
the jump process:
183
183
184
184
```@example tut1
185
-
# imports the JumpProcesses packages
185
+
# imports the JumpProcesses packages
186
186
using JumpProcesses
187
187
188
188
# redefine the initial condition to be integer valued
@@ -361,4 +361,4 @@ and the ODE model
361
361
362
362
---
363
363
## References
364
-
[^1]:[Torkel E. Loman, Yingbo Ma, Vasily Ilin, Shashi Gowda, Niklas Korsbo, Nikhil Yewale, Chris Rackauckas, Samuel A. Isaacson, *Catalyst: Fast and flexible modeling of reaction networks*, PLOS Computational Biology (2023).](https://journals.plos.org/ploscompbiol/article?id=10.1371/journal.pcbi.1011530)
364
+
1.[Torkel E. Loman, Yingbo Ma, Vasily Ilin, Shashi Gowda, Niklas Korsbo, Nikhil Yewale, Chris Rackauckas, Samuel A. Isaacson, *Catalyst: Fast and flexible modeling of reaction networks*, PLOS Computational Biology (2023).](https://journals.plos.org/ploscompbiol/article?id=10.1371/journal.pcbi.1011530)
[^2]: Scott, W. T. (1968). Analytic Studies of Cloud Droplet Coalescence I, Journal of Atmospheric Sciences, 25(1), 54-65. Retrieved Feb 18, 2021, from https://journals.ametsoc.org/view/journals/atsc/25/1/1520-0469\_1968\_025\_0054\_asocdc\_2\_0\_co\_2.xml
152
-
[^3]: Ian J. Laurenzi, John D. Bartels, Scott L. Diamond, A General Algorithm for Exact Simulation of Multicomponent Aggregation Processes, Journal of Computational Physics, Volume 177, Issue 2, 2002, Pages 418-449, ISSN 0021-9991, https://doi.org/10.1006/jcph.2002.7017.
2. Scott, W. T. (1968). Analytic Studies of Cloud Droplet Coalescence I, Journal of Atmospheric Sciences, 25(1), 54-65. Retrieved Feb 18, 2021, from https://journals.ametsoc.org/view/journals/atsc/25/1/1520-0469\_1968\_025\_0054\_asocdc\_2\_0\_co\_2.xml
152
+
3. Ian J. Laurenzi, John D. Bartels, Scott L. Diamond, A General Algorithm for Exact Simulation of Multicomponent Aggregation Processes, Journal of Computational Physics, Volume 177, Issue 2, 2002, Pages 418-449, ISSN 0021-9991, https://doi.org/10.1006/jcph.2002.7017.
Copy file name to clipboardExpand all lines: docs/src/model_creation/parametric_stoichiometry.md
+28-22Lines changed: 28 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,12 +9,18 @@ is a parameter, and the number of products is the product of two parameters.
9
9
```@example s1
10
10
using Catalyst, Latexify, OrdinaryDiffEq, ModelingToolkit, Plots
11
11
revsys = @reaction_network revsys begin
12
+
@parameters m::Int64 n::Int64
12
13
k₊, m*A --> (m*n)*B
13
14
k₋, B --> A
14
15
end
15
16
reactions(revsys)
16
17
```
17
-
Note, as always the `@reaction_network` macro defaults to setting all symbols
18
+
Notice, as described in the [Reaction rate laws used in simulations](@ref introduction_to_catalyst_ratelaws)
19
+
section, the default rate laws involve factorials in the stoichiometric
20
+
coefficients. For this reason we explicitly specify `m` and `n` as integers (as
21
+
otherwise ModelingToolkit will implicitly assume they are floating point).
22
+
23
+
As always the `@reaction_network` macro defaults to setting all symbols
18
24
neither used as a reaction substrate nor a product to be parameters. Hence, in
19
25
this example we have two species (`A` and `B`) and four parameters (`k₊`, `k₋`,
20
26
`m`, and `n`). In addition, the stoichiometry is applied to the rightmost symbol
@@ -36,21 +42,21 @@ We could have equivalently specified our systems directly via the Catalyst
36
42
API. For example, for `revsys` we would could use
37
43
```@example s1
38
44
t = default_t()
39
-
@parameters k₊, k₋, m, n
45
+
@parameters k₊ k₋ m::Int n::Int
40
46
@species A(t), B(t)
41
47
rxs = [Reaction(k₊, [A], [B], [m], [m*n]),
42
48
Reaction(k₋, [B], [A])]
43
49
revsys2 = ReactionSystem(rxs,t; name=:revsys)
44
50
revsys2 == revsys
45
51
```
46
-
which can be simplified using the `@reaction` macro to
52
+
or
47
53
```@example s1
48
-
rxs2 = [(@reaction k₊, m*A --> (m*n)*B),
54
+
rxs2 = [(@reaction k₊, $m*A --> ($m*$n)*B),
49
55
(@reaction k₋, B --> A)]
50
56
revsys3 = ReactionSystem(rxs2,t; name=:revsys)
51
57
revsys3 == revsys
52
58
```
53
-
Note, the `@reaction` macro again assumes all symbols are parameters except the
59
+
Here we interpolate in the pre-declared `m` and `n` symbolic variables using `$m` and `$n` to ensure the parameter is known to be integer-valued. The`@reaction` macro again assumes all symbols are parameters except the
54
60
substrates or reactants (i.e. `A` and `B`). For example, in
55
61
`@reaction k, F*A + 2(H*G+B) --> D`, the substrates are `(A,G,B)` with
*If we had used a vector to store parameters, `m` and `n` would be converted to
81
-
floating point giving an error when solving the system.***Note, currently a [bug](https://github.com/SciML/ModelingToolkit.jl/issues/2296) in ModelingToolkit has broken this example by converting to floating point when using tuple parameters, see the alternative approach below for a workaround.**
82
83
83
84
An alternative approach to avoid the issues of using mixed floating point and
84
85
integer variables is to disable the rescaling of rate laws as described in
85
-
[Reaction rate laws used in simulations](@ref) section. This requires passing
86
-
the `combinatoric_ratelaws=false` keyword to `convert` or to `ODEProblem` (if
87
-
directly building the problem from a `ReactionSystem` instead of first
88
-
converting to an `ODESystem`). For the previous example this gives the following
89
-
(different) system of ODEs
86
+
[Reaction rate laws used in simulations](@ref introduction_to_catalyst_ratelaws)
87
+
section. This requires passing the `combinatoric_ratelaws=false` keyword to
88
+
`convert` or to `ODEProblem` (if directly building the problem from a
89
+
`ReactionSystem` instead of first converting to an `ODESystem`). For the
90
+
previous example this gives the following (different) system of ODEs where we
91
+
now let `m` and `n` be floating point valued parameters (the default):
0 commit comments