Skip to content

Commit 2a86c01

Browse files
Merge pull request #117 from ErikQQY/qqy/refactor_sde
Refactor SDEProblem constructor
2 parents bf3b582 + 89d3b69 commit 2a86c01

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

lib/SDEProblemLibrary/src/SDEProblemLibrary.jl

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,12 @@ u(u_0,p,t,W_t)=u_0\exp((α-\frac{β^2}{2})t+βW_t)
3333
3434
"""
3535
prob_sde_linear = SDEProblem(SDEFunction(f_linear, σ_linear,
36-
analytic = linear_analytic), σ_linear, 1 / 2,
36+
analytic = linear_analytic), 1 / 2,
3737
(0.0, 1.0))
3838

3939
linear_analytic_strat(u0, p, t, W) = @.(u0*exp(1.01t + 0.87W))
4040
prob_sde_linear_stratonovich = SDEProblem(SDEFunction(f_linear, σ_linear,
41-
analytic = linear_analytic_strat),
42-
σ_linear, 1 / 2, (0.0, 1.0))
41+
analytic = linear_analytic_strat), 1 / 2, (0.0, 1.0))
4342
f_linear_iip(du, u, p, t) = @.(du=1.01 * u)
4443
σ_linear_iip(du, u, p, t) = @.(du=0.87 * u)
4544
@doc doc"""
@@ -55,11 +54,9 @@ u(u_0,p,t,W_t)=u_0\exp((α-\frac{β^2}{2})t+βW_t)
5554
```
5655
"""
5756
prob_sde_2Dlinear = SDEProblem(SDEFunction(f_linear_iip, σ_linear_iip,
58-
analytic = linear_analytic),
59-
σ_linear_iip, ones(4, 2) / 2, (0.0, 1.0))
57+
analytic = linear_analytic), ones(4, 2) / 2, (0.0, 1.0))
6058
prob_sde_2Dlinear_stratonovich = SDEProblem(SDEFunction(f_linear_iip, σ_linear_iip,
61-
analytic = linear_analytic_strat),
62-
σ_linear_iip, ones(4, 2) / 2, (0.0, 1.0))
59+
analytic = linear_analytic_strat), ones(4, 2) / 2, (0.0, 1.0))
6360

6461
f_cubic(u, p, t) = -0.25 * u * (1 - u^2)
6562
σ_cubic(u, p, t) = 0.5 * (1 - u^2)
@@ -76,7 +73,7 @@ and initial condition ``u_0=\frac{1}{2}``, with solution
7673
u(u0,p,t,W_t)=\frac{(1+u_0)\exp(W_t)+u)0-1}{(1+u_0)\exp(W_t)+1-u_0}
7774
```
7875
"""
79-
prob_sde_cubic = SDEProblem(ff_cubic, σ_cubic, 1 / 2, (0.0, 1.0))
76+
prob_sde_cubic = SDEProblem(ff_cubic, 1 / 2, (0.0, 1.0))
8077

8178
f_wave(u, p, t) = @. -0.01 * sin(u) * cos(u)^3
8279
σ_wave(u, p, t) = @. 0.1 * cos(u)^2
@@ -93,7 +90,7 @@ and initial condition ``u_0=1`` with solution
9390
u(u_0,p,t,W_t)=\arctan(\frac{W_t}{10} + \tan(u_0))
9491
```
9592
"""
96-
prob_sde_wave = SDEProblem(ff_wave, σ_wave, 1.0, (0.0, 1.0))
93+
prob_sde_wave = SDEProblem(ff_wave, 1.0, (0.0, 1.0))
9794

9895
f_additive(u, p, t) = @. p[2] / sqrt(1 + t) - u / (2 * (1 + t))
9996
σ_additive(u, p, t) = @. p[1] * p[2] / sqrt(1 + t)
@@ -113,7 +110,7 @@ and initial condition ``u_0=1`` with ``α=0.1`` and ``β=0.05``, with solution
113110
u(u_0,p,t,W_t)=\frac{u_0}{\sqrt{1+t}} + \frac{β(t+αW_t)}{\sqrt{1+t}}
114111
```
115112
"""
116-
prob_sde_additive = SDEProblem(ff_additive, σ_additive, 1.0, (0.0, 1.0), p)
113+
prob_sde_additive = SDEProblem(ff_additive, 1.0, (0.0, 1.0), p)
117114

118115
f_additive_iip(du, u, p, t) = @.(du=p[2] / sqrt(1 + t) - u / (2 * (1 + t)))
119116
σ_additive_iip(du, u, p, t) = @.(du=p[1] * p[2] / sqrt(1 + t))
@@ -123,7 +120,7 @@ p = ([0.1; 0.1; 0.1; 0.1], [0.5; 0.25; 0.125; 0.1115])
123120
A multiple dimension extension of `additiveSDEExample`
124121
125122
"""
126-
prob_sde_additivesystem = SDEProblem(ff_additive_iip, σ_additive_iip, [1.0; 1.0; 1.0; 1.0],
123+
prob_sde_additivesystem = SDEProblem(ff_additive_iip, [1.0; 1.0; 1.0; 1.0],
127124
(0.0, 1.0), p)
128125

129126
function f_lorenz(du, u, p, t)
@@ -157,7 +154,7 @@ ff_nltest = SDEFunction(f_nltest, σ_nltest, analytic = analytic_nltest)
157154
Runge–Kutta methods for numerical solution of stochastic differential equations
158155
Tocino and Ardanuy
159156
"""
160-
prob_sde_nltest = SDEProblem(ff_nltest, σ_nltest, 1.0, (0.0, 10.0))
157+
prob_sde_nltest = SDEProblem(ff_nltest, 1.0, (0.0, 10.0))
161158

162159
@doc doc"""
163160
oval2ModelExample(;largeFluctuations=false,useBigs=false,noiseLevel=1)
@@ -404,7 +401,7 @@ Stiffness of Euler is determined by α+β²<1
404401
Higher α or β is stiff, with α being deterministic stiffness and
405402
β being noise stiffness (and grows by square).
406403
"""
407-
prob_sde_stiffquadito = SDEProblem(ff_stiff_quad_ito, stiff_quad_g, 0.5, (0.0, 3.0),
404+
prob_sde_stiffquadito = SDEProblem(ff_stiff_quad_ito, 0.5, (0.0, 3.0),
408405
(1.0, 1.0))
409406

410407
@doc doc"""
@@ -424,7 +421,7 @@ Stiffness of Euler is determined by α+β²<1
424421
Higher α or β is stiff, with α being deterministic stiffness and
425422
β being noise stiffness (and grows by square).
426423
"""
427-
prob_sde_stiffquadstrat = SDEProblem(ff_stiff_quad_strat, stiff_quad_g, 0.5, (0.0, 3.0),
424+
prob_sde_stiffquadstrat = SDEProblem(ff_stiff_quad_strat, 0.5, (0.0, 3.0),
428425
(1.0, 1.0))
429426

430427
@doc doc"""

0 commit comments

Comments
 (0)