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/catalyst_applications/advanced_simulations.md
+49-19Lines changed: 49 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -306,7 +306,7 @@ tspan = (0.0, 10.0)
306
306
p_1 = [:k1 => 1.0, :k2 => 1.0]
307
307
308
308
sprob_1 = SDEProblem(rn_1, u0, tspan, p_1)
309
-
sol_1 = solve(sprob_1)
309
+
sol_1 = solve(sprob_1, ImplicitEM())
310
310
plot(sol_1; idxs = :X1, ylimit = (0.0, 20.0))
311
311
```
312
312
Here we can see that the `X` concentration fluctuates around a steady state of $X≈10.0$.
@@ -319,46 +319,76 @@ Setting $η<1.0$ will reduce noise and $η>1.0$ will increase noise. The syntax
319
319
for setting a noise scaling parameter `η` is
320
320
```@example ex3
321
321
rn_2 = @reaction_network begin
322
-
@parameters η
322
+
@noise_scaling_parameters η
323
323
(k1,k2), X1 <--> X2
324
324
end
325
+
```
326
+
The `@noise_scaling_parameter` option is equivalent to the `@parameters` option, but also designates subsequent parameter as a *noise scaling parameter*. *η* becomes a parameter of the system, and we can now modualte its value to scale simualtion noise:
Here, we first need to add `η` as a parameter to the system using the
332
-
`@parameters η` option. Next, we pass the `noise_scaling = (@parameters η)[1]`
333
-
argument to the `SDEProblem`. We can now simulate our system and confirm that
334
-
noise is reduced:
335
-
```@example ex3
336
-
sol_2 = solve(sprob_2)
332
+
sprob_2 = SDEProblem(rn_2, u0, tspan, p_2)
333
+
sol_2 = solve(sprob_2, ImplicitEM())
337
334
plot(sol_2; idxs = :X1, ylimit = (0.0, 20.0))
338
335
```
339
336
340
-
Finally, it is possible to set individual noise scaling parameters for each
341
-
reaction of the system. Our model has two reactions (`X1 --> X2` and `X2 -->
342
-
X1`) so we will use two noise scaling parameters, `η1` and `η2`. We use the
343
-
following syntax:
337
+
It is worth noting that in the CLE, nosie is tied to *reactions* (and not species, which is a common missperception). If only a single noise scaling parameter is given, it will scale the noise for all reaction. However, it is also possible to set several nosie scaling parameters, with each scaling the noise of a single reaction. Our model has two reactions (`X1 --> X2` and `X2 --> X1`) so we will use two noise scaling parameters (`η1` and `η2`):
plotting the results, we see that we have less fluctuation than for the first
356
-
simulation, but more as compared to the second one (which is as expected):
349
+
Both the noise scaling parameters and the reaction are ordered (these orders can be seen by calling `reactions(rn_3)` and `noise_scaling_parameters(rn_3)`, respectively). The i'th noise scaling parameter scales the noise of the i'th reaction. Plotting the results, we see that we have less fluctuation than for the first simulation, but more as compared to the second one (which is as expected):
357
350
```@example ex3
358
-
sol_3 = solve(sprob_3)
351
+
sol_3 = solve(sprob_3, ImplicitEM())
359
352
plot(sol_3; idxs = :X1, ylimit = (0.0, 20.0))
360
353
```
361
354
355
+
For systems with many reactions, the `η[1:n]` (where `n` is equal to the number of reactions) notation can be useful (this however, requires `@unpack`'ing the system's parameters):
which is equivalent to `rn_2`. In this example, calling `@noise_scaling_parameters η` is equivalent to calling `parameters η` with the `noise_scaling_parameter` metadata:
387
+
```@example ex3
388
+
@parameters η [noise_scaling_parameter=true]
389
+
nothing # hide
390
+
```
391
+
362
392
## Useful plotting options
363
393
Catalyst, just like DifferentialEquations, uses the Plots package for all
364
394
plotting. For a detailed description of differential equation plotting, see
0 commit comments