Skip to content

Commit 6f47e51

Browse files
committed
improve model display in docs
1 parent 22041fa commit 6f47e51

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

docs/src/model_creation/functional_parameters.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ in_type = typeof(interpolated_light)
5656
@parameters kA kD (light_in::in_type)(..)
5757
@species Pₐ(t) Pᵢ(t)
5858
rxs = [
59-
Reaction(kA*light_in(t), [Pᵢ], [Pₐ]),
59+
Reaction(light_in(t)*kA, [Pᵢ], [Pₐ]),
6060
Reaction(kD, [Pₐ], [Pᵢ])
6161
]
6262
@named rs = ReactionSystem(rxs, t)
@@ -77,7 +77,7 @@ It is possible to use time-dependent inputs when creating models [through the DS
7777
```@example functional_parameters_circ_rhythm
7878
input = light_in(t)
7979
rs_dsl = @reaction_network rs begin
80-
(kA*$input, kD), Pᵢ <--> Pₐ
80+
($input*kA, kD), Pᵢ <--> Pₐ
8181
end
8282
```
8383
We can confirm that this model is identical to our programmatic one (and should we wish to, we can simulate it using identical syntax syntax).
@@ -115,9 +115,10 @@ using Catalyst
115115
@species I(default_t())
116116
inf_rate = I_rate(I)
117117
sir = @reaction_network rs begin
118-
k1*$(inf_rate), S --> I
118+
k1*$inf_rate, S --> I
119119
k2, I --> R
120120
end
121+
nothing # hide
121122
```
122123
Finally, we can simualte our model.
123124
```@example functional_parameters_sir

src/reactionsystem.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -354,11 +354,11 @@ struct ReactionSystem{V <: NetworkProperties} <:
354354
end
355355

356356
if isempty(sivs) && (checks == true || (checks & MT.CheckUnits) > 0)
357-
#if !all(u == 1.0 for u in ModelingToolkit.get_unit([unknowns; ps; iv]))
358-
# for eq in eqs
359-
# (eq isa Equation) && check_units(eq)
360-
# end
361-
#end
357+
if !all(unitless_symvar(sym) for sym in [unknowns; ps; iv])
358+
for eq in eqs
359+
(eq isa Equation) && check_units(eq)
360+
end
361+
end
362362
end
363363

364364
rs = new{typeof(nps)}(
@@ -1549,6 +1549,6 @@ unitless_exp(u) = iscall(u) && (operation(u) == ^) && (arguments(u)[1] == 1)
15491549

15501550
# Checks if a symbolic variable is unitless. Also accounts for callable parameters (which
15511551
# should not have units but for which `get_unit` is undefined: https://github.com/SciML/ModelingToolkit.jl/issues/3420).
1552-
function unitless_symvar(sym)
1552+
function unitless_symvar(sym)
15531553
return (sym isa Symbolics.CallWithMetadata) || (ModelingToolkit.get_unit(sym) == 1)
15541554
end

0 commit comments

Comments
 (0)