File tree Expand file tree Collapse file tree 2 files changed +10
-9
lines changed Expand file tree Collapse file tree 2 files changed +10
-9
lines changed Original file line number Diff line number Diff 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)
5858rxs = [
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
7878input = light_in(t)
7979rs_dsl = @reaction_network rs begin
80- (kA* $input, kD), Pᵢ <--> Pₐ
80+ ($input*kA , kD), Pᵢ <--> Pₐ
8181end
8282```
8383We 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())
116116inf_rate = I_rate(I)
117117sir = @reaction_network rs begin
118- k1*$( inf_rate) , S --> I
118+ k1*$inf_rate, S --> I
119119 k2, I --> R
120120end
121+ nothing # hide
121122```
122123Finally, we can simualte our model.
123124``` @example functional_parameters_sir
Original file line number Diff line number Diff 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 )
15541554end
You can’t perform that action at this time.
0 commit comments