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/model_creation/functional_parameters.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,7 +33,7 @@ plot(sol)
33
33
For this simple example, $(2 + t)/(1 + t)$ could have been used directly as a reaction rate, technically making the functional parameter approach unnecessary.
34
34
35
35
## [Inserting a customised, time-dependent, input](@id functional_parameters_circ_rhythm)
36
-
Let us now go through everything again, but providing some more details. Let us first consider the input parameter. We have previously described how a [time-dependent rate can model a circadian rhythm](@ef dsl_description_nonconstant_rates_time). For real applications, due to e.g. clouds, sunlight is not a perfect sine wave. Here, a common solution is to take real sunlight data from some location and use in the model. Here, we will create synthetic (noisy) data as our light input:
36
+
Let us now go through everything again, but providing some more details. Let us first consider the input parameter. We have previously described how a [time-dependent rate can model a circadian rhythm](@ref dsl_description_nonconstant_rates_time). For real applications, due to e.g. clouds, sunlight is not a perfect sine wave. Here, a common solution is to take real sunlight data from some location and use in the model. Here, we will create synthetic (noisy) data as our light input:
37
37
```@example functional_parameters_circ_rhythm
38
38
using Plots
39
39
tend = 120.0
@@ -75,9 +75,9 @@ plot(sol)
75
75
### [Interpolating the input into the DSL](@id functional_parameters_circ_rhythm_dsl)
76
76
It is possible to use time-dependent inputs when creating models [through the DSL](@ref dsl_description) as well. However, it can still be convenient to declare the input parameter programmatically as above. Next, we form an expression of it as a function of time, and then [interpolate](@ref dsl_advanced_options_symbolics_and_DSL_interpolation) it into our DSL-declaration:
77
77
```@example functional_parameters_circ_rhythm
78
-
input = pIn(t)
78
+
input = light_in(t)
79
79
rs_dsl = @reaction_network rs begin
80
-
(kA*$input, kI), Pᵢ <--> Pₐ
80
+
(kA*$input, kD), Pᵢ <--> Pₐ
81
81
end
82
82
```
83
83
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).
Previously we have demonstrated functional parameters that are a function of time. However, functional parameters can be functions of any variable (however, currently, more than one argument is not supported). Here we will demonstrate this using a [SIR model](@ref basic_CRN_library_sir), but instead of having the infection rate scale linearly with the number of infected individuals, we instead assume we have measured data of the infection rate (as dependent on the number of infected individuals) and wish to use this instead. Normally we use the following infection reaction in the SIR model:
90
-
```@examplejulia
90
+
```julia
91
91
@reaction k1, S + I -->2I
92
92
```
93
93
In practise, this is identical to
94
-
```@examplejulia
94
+
```julia
95
95
@reaction k1*I, S --> I
96
96
```
97
97
Due to performance reasons (especially for jump simulations) the former approach is *strongly* encouraged. Here, however, we will assume that we have measured real data of how the number of infected individuals affects the infection rate, and wish to use this in our model, i.e. something like this:
98
-
```@examplejulia
98
+
```julia
99
99
@reaction k1*i_rate(I), S --> I
100
100
```
101
101
This is a case where we can use a functional parameter, whose value depends on the value of $I$.
0 commit comments