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: HISTORY.md
+2-1Lines changed: 2 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,8 +22,9 @@ rn = @reaction_network begin
22
22
@parameters η
23
23
k, 2X --> X2, [noise_scaling=η]
24
24
end
25
-
getnoisescaling(rn)
25
+
get_noise_scaling(rn)
26
26
```
27
+
-`SDEProblem` no longer takes the `noise_scaling` argument (see above for new approach to handle noise scaling).
27
28
- Changed fields of internal `Reaction` structure. `ReactionSystems`s saved using `serialize` on previous Catalyst versions cannot be loaded using this (or later) versions.
28
29
- Simulation of spatial ODEs now supported. For full details, please see https://github.com/SciML/Catalyst.jl/pull/644 and upcoming documentation. Note that these methods are currently considered alpha, with the interface and approach changing even in non-breaking Catalyst releases.
29
30
- LatticeReactionSystem structure represents a spatial reaction network:
Copy file name to clipboardExpand all lines: docs/src/catalyst_applications/advanced_simulations.md
+38-34Lines changed: 38 additions & 34 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -292,8 +292,9 @@ plot(sol)
292
292
293
293
## Scaling the noise magnitude in the chemical Langevin equations
294
294
When using the CLE to generate SDEs from a CRN, it can sometimes be desirable to
295
-
scale the magnitude of the noise terms. This can be done by introducing a *noise
296
-
scaling parameter*. First, we simulate a simple two-state CRN model using the
295
+
scale the magnitude of the noise terms. Here, each reaction of the system generates a separate noise term in the CLE. If you require identical scaling for all reactions, the `@default_noise_scaling` option can be used. Else, you can supply a `noise_scaling` metadata for each individual reaction, describing how to scale the noise for that reaction.
296
+
297
+
We begin with considering the first approach. First, we simulate a simple two-state CRN model using the
297
298
CLE:
298
299
```@example ex3
299
300
using Catalyst, StochasticDiffEq, Plots
@@ -306,58 +307,61 @@ tspan = (0.0, 10.0)
306
307
p_1 = [:k1 => 1.0, :k2 => 1.0]
307
308
308
309
sprob_1 = SDEProblem(rn_1, u0, tspan, p_1)
309
-
sol_1 = solve(sprob_1)
310
+
sol_1 = solve(sprob_1, ImplicitEM())
310
311
plot(sol_1; idxs = :X1, ylimit = (0.0, 20.0))
311
312
```
312
-
Here we can see that the `X` concentration fluctuates around a steady state of $X≈10.0$.
313
-
314
-
Next, we wish to introduce a noise scaling parameter ,`η`. This will scale the
315
-
noise magnitude so that for $η=0.0$ the system lacks noise (and its SDE
316
-
simulations are identical to its ODE simulations) and for $η=1.0$ noise is not
317
-
scaled (and SDE simulations are identical to as if no noise scaling was used).
318
-
Setting $η<1.0$ will reduce noise and $η>1.0$ will increase noise. The syntax
319
-
for setting a noise scaling parameter `η` is
313
+
Here we can see that the $X$ concentration fluctuates around a steady state of $X≈10.0$.
314
+
315
+
Next, we wish increase the amount of noise by a factor 2. To do so, we use the `@default_noise_scaling` option, to which we provide the desired scaling
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:
322
+
If we re-simulate the system we see that the amount of noise have increased:
335
323
```@example ex3
336
-
sol_2 = solve(sprob_2)
337
-
plot(sol_2; idxs = :X1, ylimit = (0.0, 20.0))
324
+
sprob_1 = SDEProblem(rn_2, u0, tspan, p_1)
325
+
sol_1 = solve(sprob_1, ImplicitEM())
326
+
plot(sol_1; idxs = :X1, ylimit = (0.0, 20.0))
338
327
```
339
328
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:
329
+
It is possible to scale the amount of noise using any expression. A common use of this is to set a parameter which determines the amount of noise. Here we create a parameter $η$, and uses its value to scale the noise.
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):
346
+
Here we saw how, by setting a small $η$ value, the amount of noise was reduced.
347
+
348
+
It is possible to use a different noise scaling expression for each reaction. Here, each reaction's noise scaling expression is provided using the `noise_scaling` metadata. In the following example, we use this to tune the noise of for both reactions involving the species $Y$.
349
+
357
350
```@example ex3
358
-
sol_3 = solve(sprob_3)
359
-
plot(sol_3; idxs = :X1, ylimit = (0.0, 20.0))
351
+
rn_4 = @reaction_network begin
352
+
(p, d), 0 <--> X
353
+
(p, d), 0 <--> Y, ([noise_scaling=0.0, noise_scaling=0.0])
354
+
end
355
+
356
+
u0_4 = [:X => 10.0, :Y => 10.0]
357
+
tspan = (0.0, 10.0)
358
+
p_4 = [p => 10.0, d => 1.]
359
+
360
+
sprob_4 = SDEProblem(rn_4, u0_4, tspan, p_4)
361
+
sol_4 = solve(sprob_4, ImplicitEM())
362
+
plot(sol_4; ylimit = (0.0, 20.0))
360
363
```
364
+
Here, we not that there is n fluctuation in the value of $Y$. If the `@default_noise_scaling` option is used, its value is used for all reactions for which the `noise_scaling` metadata is unused. If `@default_noise_scaling` is not used, the default noise scaling value is `1.0` (i.e. no scaling).
361
365
362
366
## Useful plotting options
363
367
Catalyst, just like DifferentialEquations, uses the Plots package for all
0 commit comments