Skip to content

Commit e01ed75

Browse files
authored
Merge pull request #1231 from isaacsas/drop_symmap_in_docs
Drop symmap in docs
2 parents ab266f9 + 001a0c2 commit e01ed75

File tree

3 files changed

+8
-44
lines changed

3 files changed

+8
-44
lines changed

docs/src/faqs.md

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -188,38 +188,11 @@ nothing # hide
188188
while using ModelingToolkit symbolic variables we have
189189
```@example faq4
190190
t = default_t()
191-
@parameters α β
192-
@species S(t) I(t) R(t)
193-
u0 = [S => 999.0, I => 1.0, R => 0.0]
194-
p = (α => 1e-4, β => .01)
191+
u0 = [rn.S => 999.0, rn.I => 1.0, rn.R => 0.0]
192+
p = (rn.α => 1e-4, rn.β => .01)
195193
op2 = ODEProblem(rn, u0, (0.0, 250.0), p)
196194
nothing # hide
197195
```
198-
*Note,* while symbolic mappings as in the last example will work with *any*
199-
`ModelingToolkit.AbstractSystem`, for example if one `convert`s `rn` to an
200-
`ODESystem`, `Symbol`-based mappings only work when passing a `ReactionSystem`
201-
directly into a problem type. That is, the following does not work
202-
```@julia
203-
osys = convert(ODESystem, rn)
204-
205-
# this fails
206-
u0 = [:S => 999.0, :I => 1.0, :R => 0.0]
207-
p = (:α => 1e-4, :β => .01)
208-
op = ODEProblem(osys, u0, (0.0, 250.0), p)
209-
```
210-
In this case one must either use a symbolic mapping as was used to make `op2` in
211-
the second example, or one can use the `symmap_to_varmap` function to convert the
212-
`Symbol` mapping to a symbolic mapping. I.e. this works
213-
```@example faq4
214-
osys = convert(ODESystem, rn)
215-
osys = complete(osys)
216-
217-
# this works
218-
u0 = symmap_to_varmap(rn, [:S => 999.0, :I => 1.0, :R => 0.0])
219-
p = symmap_to_varmap(rn, (:α => 1e-4, :β => .01))
220-
op = ODEProblem(osys, u0, (0.0, 250.0), p)
221-
nothing # hide
222-
```
223196

224197
## How to include non-reaction terms in equations for a chemical species?
225198
One method to add non-reaction terms into an ODE or algebraic equation for a

docs/src/introduction_to_catalyst/introduction_to_catalyst.md

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ Let's now use our `ReactionSystem` to generate and solve a corresponding mass
117117
action ODE model. We first convert the system to a `ModelingToolkit.ODESystem`
118118
by
119119
```@example tut1
120-
rn = complete(rn)
121120
odesys = convert(ODESystem, rn)
122121
```
123122
(Here Latexify is used automatically to display `odesys` in Latex within Markdown
@@ -144,7 +143,8 @@ u₀symmap = [rn.m₁ => 0., rn.m₂ => 0., rn.m₃ => 0., rn.P₁ => 20.,
144143
rn.P₂ => 0., rn.P₃ => 0.]
145144
nothing # hide
146145
```
147-
Knowing these mappings we can set up the `ODEProblem` we want to solve:
146+
Knowing one of the preceding mappings we can set up the `ODEProblem` we want to
147+
solve:
148148

149149
```@example tut1
150150
# time interval to solve on
@@ -159,22 +159,14 @@ By passing `rn` directly to the `ODEProblem`, Catalyst has to
159159
symbolic ODEs. We could instead pass `odesys` directly like
160160
```@example tut1
161161
odesys = complete(odesys)
162-
oprob2 = ODEProblem(odesys, u₀symmap, tspan, psymmap)
162+
oprob2 = ODEProblem(odesys, u₀map, tspan, pmap)
163163
nothing # hide
164164
```
165165
`oprob` and `oprob2` are functionally equivalent, each representing the same
166166
underlying problem.
167167

168168
!!! note
169-
When passing `odesys` to `ODEProblem` we needed to use the symbolic
170-
variable-based parameter mappings, `u₀symmap` and `psymmap`, while when
171-
directly passing `rn` we could use either those or the
172-
`Symbol`-based mappings, `u₀map` and `pmap`. `Symbol`-based mappings can
173-
always be converted to `symbolic` mappings using [`symmap_to_varmap`](@ref).
174-
175-
176-
!!! note
177-
Above we have used `rn = complete(rn)` and `odesys = complete(odesys)` to mark these systems as *complete*, indicating to Catalyst and ModelingToolkit that these models are finalized. This must be done before any system is given as input to a `convert` call or some problem type. `ReactionSystem` models created through the `@reaction_network` DSL (which is introduced elsewhere, and primarily used throughout these documentation) are always marked as complete when generated. Hence `complete` does not need to be called on them. Symbolically generated `ReactionSystem`s, `ReactionSystem`s generated via the `@network_component` macro, and any ModelingToolkit system generated by `convert` always needs to be manually marked as `complete` as we do for `odesys` above. An expanded description on *completeness* can be found [here](@ref completeness_note).
169+
Above we have used `odesys = complete(odesys)` to mark the `ODESystem` as *complete*, indicating to Catalyst and ModelingToolkit that these models are finalized. This must be done before any system is given as input to a `convert` call or some problem type. `ReactionSystem` models created through the `@reaction_network` DSL, like `rn` above, are always marked as complete when generated. Hence `complete` does not need to be called on them. Symbolically generated `ReactionSystem`s, `ReactionSystem`s generated via the `@network_component` macro, and any ModelingToolkit system generated by `convert` always needs to be manually marked as `complete` as we do for `odesys` above. An expanded description on *completeness* can be found [here](@ref completeness_note).
178170

179171
At this point we are all set to solve the ODEs. We can now use any ODE solver
180172
from within the

docs/src/model_creation/parametric_stoichiometry.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,8 @@ bval = 70
173173
k₋val = 0.001
174174
k₊val = 0.05
175175
kₚval = pmean * γₚval * (k₋val * pmean^2 + k₊val) / (k₊val * bval)
176-
p = symmap_to_varmap(jsys, (:k₊ => k₊val, :k₋ => k₋val, :kₚ => kₚval,
177-
:γₚ => γₚval, :b => bval))
178-
u₀ = symmap_to_varmap(jsys, [:G₊ => 1, :G₋ => 0, :P => 1])
176+
p = (:k₊ => k₊val, :k₋ => k₋val, :kₚ => kₚval, :γₚ => γₚval, :b => bval)
177+
u₀ = [:G₊ => 1, :G₋ => 0, :P => 1]
179178
tspan = (0., 6.0) # time interval to solve over
180179
dprob = DiscreteProblem(jsys, u₀, tspan, p)
181180
jprob = JumpProblem(jsys, dprob, Direct())

0 commit comments

Comments
 (0)