Skip to content

Commit 9bd45a5

Browse files
Merge branch 'test'
2 parents ea5ff75 + 45f3ed0 commit 9bd45a5

File tree

3 files changed

+24
-21
lines changed

3 files changed

+24
-21
lines changed

REQUIRE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
julia 0.5
22
ParameterizedFunctions 0.5.0
3-
DiffEqBase 0.2.0
3+
DiffEqBase 0.15.0
44
FiniteElementDiffEq 0.0.5
55
JLD 0.6.5
66
DiffEqPDEBase

src/ode_premade_problems.jl

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ srand(100)
44

55
# Linear ODE
66
linear = (t,u) -> (1.01*u)
7-
analytic_linear = (t,u0) -> u0*exp(1.01*t)
7+
(f::typeof(linear))(::Type{Val{:analytic}},t,u0) = u0*exp(1.01*t)
88
"""
99
Linear ODE
1010
@@ -20,11 +20,11 @@ u(t) = u0e^{αt}
2020
2121
with Float64s
2222
"""
23-
prob_ode_linear = ODETestProblem(linear,1/2,analytic_linear)
23+
prob_ode_linear = ODEProblem(linear,1/2,(0.0,1.0))
2424

2525
const linear_bigα = parse(BigFloat,"1.01")
2626
f_linearbig = (t,u) -> (linear_bigα*u)
27-
analytic_linearbig = (t,u0) -> u0*exp(linear_bigα*t)
27+
(f::typeof(f_linearbig))(::Type{Val{:analytic}},t,u0) = u0*exp(linear_bigα*t)
2828
"""
2929
Linear ODE
3030
@@ -40,14 +40,14 @@ u(t) = u0e^{αt}
4040
4141
with BigFloats
4242
"""
43-
prob_ode_bigfloatlinear = ODETestProblem(f_linearbig,parse(BigFloat,"0.5"),analytic_linearbig)
43+
prob_ode_bigfloatlinear = ODEProblem(f_linearbig,parse(BigFloat,"0.5"),(0.0,1.0))
4444

4545
f_2dlinear = (t,u,du) -> begin
4646
for i in 1:length(u)
4747
du[i] = 1.01*u[i]
4848
end
4949
end
50-
analytic_2dlinear = (t,u0) -> u0*exp.(1.01*t)
50+
(f::typeof(f_2dlinear))(::Type{Val{:analytic}},t,u0) = u0*exp.(1.01*t)
5151
"""
5252
4x2 version of the Linear ODE
5353
@@ -63,7 +63,7 @@ u(t) = u0e^{αt}
6363
6464
with Float64s
6565
"""
66-
prob_ode_2Dlinear = ODETestProblem(f_2dlinear,rand(4,2),analytic_2dlinear)
66+
prob_ode_2Dlinear = ODEProblem(f_2dlinear,rand(4,2),(0.0,1.0))
6767

6868
"""
6969
100x100 version of the Linear ODE
@@ -80,13 +80,14 @@ u(t) = u0e^{αt}
8080
8181
with Float64s
8282
"""
83-
prob_ode_large2Dlinear = ODETestProblem(f_2dlinear,rand(100,100),analytic_2dlinear)
83+
prob_ode_large2Dlinear = ODEProblem(f_2dlinear,rand(100,100),(0.0,1.0))
8484

8585
f_2dlinearbig = (t,u,du) -> begin
8686
for i in 1:length(u)
8787
du[i] = linear_bigα*u[i]
8888
end
8989
end
90+
(f::typeof(f_2dlinearbig))(::Type{Val{:analytic}},t,u0) = u0*exp.(1.01*t)
9091
"""
9192
4x2 version of the Linear ODE
9293
@@ -102,8 +103,9 @@ u(t) = u0e^{αt}
102103
103104
with BigFloats
104105
"""
105-
prob_ode_bigfloat2Dlinear = ODETestProblem(f_2dlinearbig,map(BigFloat,rand(4,2)).*ones(4,2)/2,analytic_2dlinear)
106+
prob_ode_bigfloat2Dlinear = ODEProblem(f_2dlinearbig,map(BigFloat,rand(4,2)).*ones(4,2)/2,(0.0,1.0))
106107
f_2dlinear_notinplace = (t,u) -> 1.01*u
108+
(f::typeof(f_2dlinear_notinplace))(::Type{Val{:analytic}},t,u0) = u0*exp.(1.01*t)
107109
"""
108110
4x2 version of the Linear ODE
109111
@@ -119,7 +121,7 @@ u(t) = u0e^{αt}
119121
120122
on Float64. Purposefully not in-place as a test.
121123
"""
122-
prob_ode_2Dlinear_notinplace = ODETestProblem(f_2dlinear_notinplace,rand(4,2),analytic_2dlinear)
124+
prob_ode_2Dlinear_notinplace = ODEProblem(f_2dlinear_notinplace,rand(4,2),(0.0,1.0))
123125

124126
## Lotka-Volterra
125127

src/sde_premade_problems.jl

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
f = (t,u) -> 1.01*u
44
σ = (t,u) -> 0.87*u
5-
analytic = (t,u0,W) -> u0.*exp.(0.63155*t+0.87*W)
5+
(p::typeof(f))(::Type{Val{:analytic}},t,u0,W) = u0.*exp.(0.63155*t+0.87*W)
66
"""
77
```math
88
du_t = βudt + αudW_t
@@ -14,7 +14,7 @@ u(t,u0,W_t)=u0\\exp((α-\\frac{β^2}{2})t+βW_t)
1414
```
1515
1616
"""
17-
prob_sde_linear = SDETestProblem(f,σ,1/2,analytic)
17+
prob_sde_linear = SDEProblem(f,σ,1/2,(0.0,1.0))
1818

1919
f = (t,u,du) -> begin
2020
for i = 1:length(u)
@@ -26,6 +26,7 @@ end
2626
du[i] = .87*u[i]
2727
end
2828
end
29+
(p::typeof(f))(::Type{Val{:analytic}},t,u0,W) = u0.*exp.(0.63155*t+0.87*W)
2930
"""
3031
8 linear SDEs (as a 4x2 matrix):
3132
@@ -38,12 +39,12 @@ where β=1.01, α=0.87, and initial condtion u0=1/2 with solution
3839
u(t,u0,W_t)=u0\\exp((α-\\frac{β^2}{2})t+βW_t)
3940
```
4041
"""
41-
prob_sde_2Dlinear = SDETestProblem(f,σ,ones(4,2)/2,analytic)
42+
prob_sde_2Dlinear = SDEProblem(f,σ,ones(4,2)/2,(0.0,1.0))
4243

4344

4445
f = (t,u) -> -.25*u*(1-u^2)
4546
σ = (t,u) -> .5*(1-u^2)
46-
analytic = (t,u0,W) -> ((1+u0).*exp.(W)+u0-1)./((1+u0).*exp.(W)+1-u0)
47+
(p::typeof(f))(::Type{Val{:analytic}},t,u0,W) = ((1+u0).*exp.(W)+u0-1)./((1+u0).*exp.(W)+1-u0)
4748
"""
4849
```math
4950
du_t = \\frac{1}{4}u(1-u^2)dt + \\frac{1}{2}(1-u^2)dW_t
@@ -55,11 +56,11 @@ and initial condtion u0=1/2, with solution
5556
u(t,u0,W_t)=\\frac{(1+u0)\\exp(W_t)+u0-1}{(1+u0)\\exp(W_t)+1-u0}
5657
```
5758
"""
58-
prob_sde_cubic = SDETestProblem(f,σ,1/2,analytic)
59+
prob_sde_cubic = SDEProblem(f,σ,1/2,(0.0,1.0))
5960

6061
f = (t,u) -> -0.01*sin.(u).*cos.(u).^3
6162
σ = (t,u) -> 0.1*cos.(u).^2
62-
analytic = (t,u0,W) -> atan.(0.1*W + tan.(u0))
63+
(p::typeof(f))(::Type{Val{:analytic}},t,u0,W) = atan.(0.1*W + tan.(u0))
6364
"""
6465
```math
6566
du_t = -\\frac{1}{100}\sin(u)\cos^3(u)dt + \\frac{1}{10}\cos^{2}(u_t) dW_t
@@ -71,13 +72,13 @@ and initial condition `u0=1.0` with solution
7172
u(t,u0,W_t)=\\arctan(\\frac{W_t}{10} + \\tan(u0))
7273
```
7374
"""
74-
prob_sde_wave = SDETestProblem(f,σ,1.,analytic)
75+
prob_sde_wave = SDEProblem(f,σ,1.,(0.0,1.0))
7576

7677
const sde_wave_α = 0.1
7778
const sde_wave_β = 0.05
7879
f = (t,u) -> sde_wave_β./sqrt.(1+t) - u./(2*(1+t))
7980
σ = (t,u) -> sde_wave_α*sde_wave_β./sqrt.(1+t)
80-
analytic = (t,u0,W) -> u0./sqrt.(1+t) + sde_wave_β*(t+sde_wave_α*W)./sqrt.(1+t)
81+
(p::typeof(f))(::Type{Val{:analytic}},t,u0,W) = u0./sqrt.(1+t) + sde_wave_β*(t+sde_wave_α*W)./sqrt.(1+t)
8182

8283
"""
8384
Additive noise problem
@@ -92,7 +93,7 @@ and initial condition u0=1.0 with α=0.1 and β=0.05, with solution
9293
u(t,u0,W_t)=\\frac{u0}{\\sqrt{1+t}} + \\frac{β(t+αW_t)}{\\sqrt{1+t}}
9394
```
9495
"""
95-
prob_sde_additive = SDETestProblem(f,σ,1.,analytic)
96+
prob_sde_additive = SDEProblem(f,σ,1.,(0.0,1.0))
9697

9798
const sde_wave_αvec = [0.1;0.1;0.1;0.1]
9899
const sde_wave_βvec = [0.5;0.25;0.125;0.1115]
@@ -107,13 +108,13 @@ end
107108
du[i] = sde_wave_αvec[i]*sde_wave_βvec[i]/sqrt(1+t)
108109
end
109110
end
110-
analytic = (t,u0,W) -> u0./sqrt(1+t) + sde_wave_βvec.*(t+sde_wave_αvec.*W)./sqrt(1+t)
111+
(p::typeof(f))(::Type{Val{:analytic}},t,u0,W) = u0./sqrt(1+t) + sde_wave_βvec.*(t+sde_wave_αvec.*W)./sqrt(1+t)
111112

112113
"""
113114
A multiple dimension extension of `additiveSDEExample`
114115
115116
"""
116-
prob_sde_additivesystem = SDETestProblem(f,σ,[1.;1.;1.;1.],analytic)
117+
prob_sde_additivesystem = SDEProblem(f,σ,[1.;1.;1.;1.],(0.0,1.0))
117118

118119
f = @ode_def_nohes LorenzSDE begin
119120
dx = σ*(y-x)

0 commit comments

Comments
 (0)