Skip to content

Commit 3ad212a

Browse files
docs: use @brownian in the stochastic_diffeq tutorial
1 parent c4f5aec commit 3ad212a

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

docs/src/tutorials/stochastic_diffeq.md

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ to the model: randomness. This is a
55
[stochastic differential equation](https://en.wikipedia.org/wiki/Stochastic_differential_equation)
66
which has a deterministic (drift) component and a stochastic (diffusion)
77
component. Let's take the Lorenz equation from the first tutorial and extend
8-
it to have multiplicative noise.
8+
it to have multiplicative noise by creating `@brownian` variables in the equations.
99

1010
```@example SDE
1111
using ModelingToolkit, StochasticDiffEq
@@ -14,16 +14,12 @@ using ModelingToolkit: t_nounits as t, D_nounits as D
1414
# Define some variables
1515
@parameters σ ρ β
1616
@variables x(t) y(t) z(t)
17+
@brownian a
18+
eqs = [D(x) ~ σ * (y - x) + 0.1a * x,
19+
D(y) ~ x * (ρ - z) - y + 0.1a * y,
20+
D(z) ~ x * y - β * z + 0.1a * z]
1721
18-
eqs = [D(x) ~ σ * (y - x),
19-
D(y) ~ x * (ρ - z) - y,
20-
D(z) ~ x * y - β * z]
21-
22-
noiseeqs = [0.1 * x,
23-
0.1 * y,
24-
0.1 * z]
25-
26-
@mtkbuild de = SDESystem(eqs, noiseeqs, t, [x, y, z], [σ, ρ, β])
22+
@mtkbuild de = System(eqs, t)
2723
2824
u0map = [
2925
x => 1.0,
@@ -38,5 +34,5 @@ parammap = [
3834
]
3935
4036
prob = SDEProblem(de, u0map, (0.0, 100.0), parammap)
41-
sol = solve(prob, SOSRI())
37+
sol = solve(prob, LambdaEulerHeun())
4238
```

0 commit comments

Comments
 (0)