Skip to content

Commit 694c3e0

Browse files
Merged common_interface into master
2 parents 02c440d + 4283554 commit 694c3e0

File tree

6 files changed

+77
-77
lines changed

6 files changed

+77
-77
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.2.0
3-
OrdinaryDiffEq
3+
DiffEqBase
44
StochasticDiffEq
55
FiniteElementDiffEq
66
AlgebraicDiffEq

src/DiffEqProblemLibrary.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
module DiffEqProblemLibrary
22

3-
using OrdinaryDiffEq, StochasticDiffEq, ParameterizedFunctions,
3+
using DiffEqBase, StochasticDiffEq, ParameterizedFunctions,
44
FiniteElementDiffEq, AlgebraicDiffEq, JLD
5-
5+
66
include("ode_premade_problems.jl")
77
include("dae_premade_problems.jl")
88
include("sde_premade_problems.jl")

src/dae_premade_problems.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ f = function (tres, y, yp, r)
66
r[1] -= yp[1]
77
r[3] = y[1] + y[2] + y[3] - 1.0
88
end
9-
u₀ = [1.0, 0, 0]
10-
du₀ = [-0.04, 0.04, 0.0]
9+
u0 = [1.0, 0, 0]
10+
du0 = [-0.04, 0.04, 0.0]
1111
"DAE residual form for the Robertson model"
12-
prob_dae_resrob = DAEProblem(f,u₀,du₀)
12+
prob_dae_resrob = DAEProblem(f,u0,du0)

src/fem_premade_problems.jl

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -34,43 +34,43 @@ prob_femheat_diffuse = HeatProblem(analytic_diffuse,Du,f)
3434

3535

3636
f = (t,x) -> zeros(size(x,1))
37-
u₀ = (x) -> float((abs.(x[:,1]-.5) .< 1e-6) & (abs.(x[:,2]-.5) .< 1e-6)) #Only mass at middle of (0,1)^2
37+
u0 = (x) -> float((abs.(x[:,1]-.5) .< 1e-6) & (abs.(x[:,2]-.5) .< 1e-6)) #Only mass at middle of (0,1)^2
3838
"""
3939
Example problem which starts with a Dirac δ cenetered at (0.5,0.5) and solves with ``f=gD=0``.
4040
This gives the Green's function solution.
4141
"""
42-
prob_femheat_pure = HeatProblem(u₀,f)
42+
prob_femheat_pure = HeatProblem(u0,f)
4343

4444

4545
f = (t,x,u) -> ones(size(x,1)) - .5u
46-
u₀ = (x) -> zeros(size(x,1))
46+
u0 = (x) -> zeros(size(x,1))
4747
"""
4848
Homogenous reaction-diffusion problem which starts with 0 and solves with ``f(u)=1-u/2``
4949
"""
50-
prob_femheat_birthdeath = HeatProblem(u₀,f)
50+
prob_femheat_birthdeath = HeatProblem(u0,f)
5151

5252

5353
f = (t,x,u) -> [ones(size(x,1))-.5u[:,1] ones(size(x,1))-u[:,2]]
54-
u₀ = (x) -> ones(size(x,1),2).*[.5 .5] # size (x,2), 2 meaning 2 variables
54+
u0 = (x) -> ones(size(x,1),2).*[.5 .5] # size (x,2), 2 meaning 2 variables
5555
"""
5656
Homogenous reaction-diffusion which starts at 1/2 and solves the system ``f(u)=1-u/2`` and ``f(v)=1-v``
5757
"""
58-
prob_femheat_birthdeathsystem = HeatProblem(u₀,f)
58+
prob_femheat_birthdeathsystem = HeatProblem(u0,f)
5959

6060
f = (t,x,u) -> [zeros(size(x,1)) zeros(size(x,1))]
61-
u₀ = (x) -> [float((abs.(x[:,1]-.5) .< 1e-6) & (abs.(x[:,2]-.5) .< 1e-6)) float((abs.(x[:,1]-.5) .< 1e-6) & (abs.(x[:,2]-.5) .< 1e-6))] # size (x,2), 2 meaning 2 variables
61+
u0 = (x) -> [float((abs.(x[:,1]-.5) .< 1e-6) & (abs.(x[:,2]-.5) .< 1e-6)) float((abs.(x[:,1]-.5) .< 1e-6) & (abs.(x[:,2]-.5) .< 1e-6))] # size (x,2), 2 meaning 2 variables
6262
"""
6363
Example problem which solves the homogeneous Heat equation with all mass starting at (1/2,1/2) with two different diffusion constants,
6464
``D₁=0.01`` and ``D₂=0.001``. Good animation test.
6565
"""
66-
prob_femheat_diffusionconstants = HeatProblem(u₀,f,D=[.01 .001])
66+
prob_femheat_diffusionconstants = HeatProblem(u0,f,D=[.01 .001])
6767

6868
f = (t,x,u) -> [ones(size(x,1))-.5u[:,1] .5u[:,1]-u[:,2]]
69-
u₀ = (x) -> ones(size(x,1),2).*[.5 .5] # size (x,2), 2 meaning 2 variables
69+
u0 = (x) -> ones(size(x,1),2).*[.5 .5] # size (x,2), 2 meaning 2 variables
7070
"""
7171
Homogenous reaction-diffusion which starts with 1/2 and solves the system ``f(u)=1-u/2`` and ``f(v)=.5u-v``
7272
"""
73-
prob_femheat_birthdeathinteractingsystem = HeatProblem(u₀,f)
73+
prob_femheat_birthdeathinteractingsystem = HeatProblem(u0,f)
7474

7575
"""
7676
`heatProblemExample_grayscott(;ρ=.03,k=.062,D=[1e-3 .5e-3])`
@@ -89,9 +89,9 @@ function heatProblemExample_grayscott(;ρ=.03,k=.062,D=[1e-3 .5e-3])
8989
f₁(t,x,u) = u[:,1].*u[:,2].*u[:,2] + ρ*(1-u[:,2])
9090
f₂(t,x,u) = u[:,1].*u[:,2].*u[:,2] -+k).*u[:,2]
9191
f(t,x,u) = [f₁(t,x,u) f₂(t,x,u)]
92-
u₀(x) = [ones(size(x,1))+rand(size(x,1)) .25.*float(((.2.<x[:,1].<.6) &
92+
u0(x) = [ones(size(x,1))+rand(size(x,1)) .25.*float(((.2.<x[:,1].<.6) &
9393
(.2.<x[:,2].<.6)) | ((.85.<x[:,1]) & (.85.<x[:,2])))] # size (x,2), 2 meaning 2 variables
94-
return(HeatProblem(u₀,f,D=D))
94+
return(HeatProblem(u0,f,D=D))
9595
end
9696

9797
"""
@@ -124,18 +124,18 @@ function heatProblemExample_gierermeinhardt(;a=1,α=1,D=[0.01 1.0],ubar=1,vbar=0
124124
f(t,x,u) = [f₁(t,x,u) f₂(t,x,u)]
125125
uss = (ubar +β)/α
126126
vss =/β)*uss.^2
127-
u₀(x) = [uss*ones(size(x,1))+startNoise*rand(size(x,1)) vss*ones(size(x,1))] # size (x,2), 2 meaning 2 variables
128-
return(HeatProblem(u₀,f,D=D))
127+
u0(x) = [uss*ones(size(x,1))+startNoise*rand(size(x,1)) vss*ones(size(x,1))] # size (x,2), 2 meaning 2 variables
128+
return(HeatProblem(u0,f,D=D))
129129
end
130130

131131
f = (t,x,u) -> ones(size(x,1)) - .5u
132-
u₀ = (x) -> zeros(size(x,1))
132+
u0 = (x) -> zeros(size(x,1))
133133
σ = (t,x,u) -> 1u.^2
134134
"""
135135
Homogenous stochastic reaction-diffusion problem which starts with 0
136136
and solves with ``f(u)=1-u/2`` with noise ``σ(u)=10u^2``
137137
"""
138-
prob_femheat_stochasticbirthdeath = HeatProblem(u₀,f,σ=σ)
138+
prob_femheat_stochasticbirthdeath = HeatProblem(u0,f,σ=σ)
139139

140140
## Poisson
141141

@@ -163,21 +163,21 @@ with the same ``f``.
163163
prob_poisson_birthdeath = PoissonProblem(f,numvars=1)
164164

165165
f = (x,u) -> [ones(size(x,1))-.5u[:,1] ones(size(x,1))-u[:,2]]
166-
u₀ = (x) -> .5*ones(size(x,1),2) # size (x,2), 2 meaning 2 variables
166+
u0 = (x) -> .5*ones(size(x,1),2) # size (x,2), 2 meaning 2 variables
167167

168168
"""
169169
Nonlinear Poisson equation with ``f(u)=1-u/2`` and ``f(v)=1-v`` and initial
170170
condition homogenous 1/2. Corresponds to the steady state of a humogenous
171171
reaction-diffusion equation with the same ``f``.
172172
"""
173-
prob_poisson_birthdeathsystem = PoissonProblem(f,u₀=u₀)
173+
prob_poisson_birthdeathsystem = PoissonProblem(f,u0=u0)
174174

175175
f = (x,u) -> [ones(size(x,1))-.5u[:,1] .5u[:,1]-u[:,2]]
176-
u₀ = (x) -> ones(size(x,1),2).*[.5 .5] # size (x,2), 2 meaning 2 variables
176+
u0 = (x) -> ones(size(x,1),2).*[.5 .5] # size (x,2), 2 meaning 2 variables
177177

178178
"""
179179
Nonlinear Poisson equation with ``f(u)=1-u/2`` and ``f(v)=.5u-v`` and initial
180180
condition homogenous 1/2. Corresponds to the steady state of a humogenous
181181
reaction-diffusion equation with the same ``f``.
182182
"""
183-
prob_poisson_birthdeathinteractingsystem = PoissonProblem(f,u₀=u₀)
183+
prob_poisson_birthdeathinteractingsystem = PoissonProblem(f,u0=u0)

src/ode_premade_problems.jl

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

55
# Linear ODE
66
linear = (t,u) -> (1.01*u)
7-
analytic_linear = (t,u₀) -> u₀*exp(1.01*t)
7+
analytic_linear = (t,u0) -> u0*exp(1.01*t)
88
"""
99
Linear ODE
1010
1111
```math
1212
\\frac{du}{dt} = αu
1313
```
1414
15-
with initial condition ``u₀=1/2``, ``α=1.01``, and solution
15+
with initial condition ``u0=1/2``, ``α=1.01``, and solution
1616
1717
```math
18-
u(t) = u₀e^{αt}
18+
u(t) = u0e^{αt}
1919
```
2020
2121
with Float64s
2222
"""
23-
prob_ode_linear = ODEProblem(linear,1/2,analytic=analytic_linear)
23+
prob_ode_linear = ODETestProblem(linear,1/2,analytic_linear)
2424

2525
const linear_bigα = parse(BigFloat,"1.01")
2626
f_linearbig = (t,u) -> (linear_bigα*u)
27-
analytic_linearbig = (t,u₀) -> u₀*exp(linear_bigα*t)
27+
analytic_linearbig = (t,u0) -> u0*exp(linear_bigα*t)
2828
"""
2929
Linear ODE
3030
3131
```math
3232
\\frac{du}{dt} = αu
3333
```
3434
35-
with initial condition ``u₀=1/2``, ``α=1.01``, and solution
35+
with initial condition ``u0=1/2``, ``α=1.01``, and solution
3636
3737
```math
38-
u(t) = u₀e^{αt}
38+
u(t) = u0e^{αt}
3939
```
4040
4141
with BigFloats
4242
"""
43-
prob_ode_bigfloatlinear = ODEProblem(f_linearbig,parse(BigFloat,"0.5"),analytic=analytic_linearbig)
43+
prob_ode_bigfloatlinear = ODETestProblem(f_linearbig,parse(BigFloat,"0.5"),analytic_linearbig)
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,u₀) -> u₀*exp.(1.01*t)
50+
analytic_2dlinear = (t,u0) -> u0*exp.(1.01*t)
5151
"""
5252
4x2 version of the Linear ODE
5353
5454
```math
5555
\\frac{du}{dt} = αu
5656
```
5757
58-
with initial condition ``u₀=1/2``, ``α=1.01``, and solution
58+
with initial condition ``u0=1/2``, ``α=1.01``, and solution
5959
6060
```math
61-
u(t) = u₀e^{αt}
61+
u(t) = u0e^{αt}
6262
```
6363
6464
with Float64s
6565
"""
66-
prob_ode_2Dlinear = ODEProblem(f_2dlinear,rand(4,2),analytic=analytic_2dlinear)
66+
prob_ode_2Dlinear = ODETestProblem(f_2dlinear,rand(4,2),analytic_2dlinear)
6767

6868
"""
6969
100x100 version of the Linear ODE
@@ -72,15 +72,15 @@ prob_ode_2Dlinear = ODEProblem(f_2dlinear,rand(4,2),analytic=analytic_2dlinear)
7272
\\frac{du}{dt} = αu
7373
```
7474
75-
with initial condition ``u₀=1/2``, ``α=1.01``, and solution
75+
with initial condition ``u0=1/2``, ``α=1.01``, and solution
7676
7777
```math
78-
u(t) = u₀e^{αt}
78+
u(t) = u0e^{αt}
7979
```
8080
8181
with Float64s
8282
"""
83-
prob_ode_large2Dlinear = ODEProblem(f_2dlinear,rand(100,100),analytic=analytic_2dlinear)
83+
prob_ode_large2Dlinear = ODETestProblem(f_2dlinear,rand(100,100),analytic_2dlinear)
8484

8585
f_2dlinearbig = (t,u,du) -> begin
8686
for i in 1:length(u)
@@ -94,15 +94,15 @@ end
9494
\\frac{du}{dt} = αu
9595
```
9696
97-
with initial condition ``u₀=1/2``, ``α=1.01``, and solution
97+
with initial condition ``u0=1/2``, ``α=1.01``, and solution
9898
9999
```math
100-
u(t) = u₀e^{αt}
100+
u(t) = u0e^{αt}
101101
```
102102
103103
with BigFloats
104104
"""
105-
prob_ode_bigfloat2Dlinear = ODEProblem(f_2dlinearbig,map(BigFloat,rand(4,2)).*ones(4,2)/2,analytic=analytic_2dlinear)
105+
prob_ode_bigfloat2Dlinear = ODETestProblem(f_2dlinearbig,map(BigFloat,rand(4,2)).*ones(4,2)/2,analytic_2dlinear)
106106
f_2dlinear_notinplace = (t,u) -> 1.01*u
107107
"""
108108
4x2 version of the Linear ODE
@@ -111,15 +111,15 @@ f_2dlinear_notinplace = (t,u) -> 1.01*u
111111
\\frac{du}{dt} = αu
112112
```
113113
114-
with initial condition ``u₀=1/2``, ``α=1.01``, and solution
114+
with initial condition ``u0=1/2``, ``α=1.01``, and solution
115115
116116
```math
117-
u(t) = u₀e^{αt}
117+
u(t) = u0e^{αt}
118118
```
119119
120120
on Float64. Purposefully not in-place as a test.
121121
"""
122-
prob_ode_2Dlinear_notinplace = ODEProblem(f_2dlinear_notinplace,rand(4,2),analytic=analytic_2dlinear)
122+
prob_ode_2Dlinear_notinplace = ODETestProblem(f_2dlinear_notinplace,rand(4,2),analytic_2dlinear)
123123

124124
## Lotka-Volterra
125125

@@ -139,7 +139,7 @@ Lotka-Voltera Equations
139139
140140
with initial condition ``x=y=1``
141141
"""
142-
prb_ode_lotkavoltera = ODEProblem(lotka,[1;1])
142+
prb_ode_lotkavoltera = ODEProblem(lotka,[1;1],(0.0,1.0))
143143

144144
## Fitzhugh-Nagumo
145145

@@ -157,7 +157,7 @@ Fitzhugh-Nagumo
157157
158158
with initial condition ``v=w=1``
159159
"""
160-
prob_ode_fitzhughnagumo = ODEProblem(fitz,[1;1])
160+
prob_ode_fitzhughnagumo = ODEProblem(fitz,[1;1],(0.0,1.0))
161161

162162
#Van der Pol Equations
163163
van = @ode_def_noinvhes VanDerPol begin
@@ -175,11 +175,11 @@ Van der Pol Equations
175175
\\end{align}
176176
```
177177
178-
with ``μ=1.0`` and ``u₀=[0,\\sqrt{3}]``
178+
with ``μ=1.0`` and ``u0=[0,\\sqrt{3}]``
179179
180180
Non-stiff parameters.
181181
"""
182-
prob_ode_vanderpol = ODEProblem(van,[0;sqrt(3)])
182+
prob_ode_vanderpol = ODEProblem(van,[0;sqrt(3)],(0.0,1.0))
183183

184184
van_stiff = VanDerPol=1e6)
185185
"""Van der Pol Equations
@@ -191,11 +191,11 @@ van_stiff = VanDerPol(μ=1e6)
191191
\\end{align}
192192
```
193193
194-
with ``μ=10^6`` and ``u₀=[0,\\sqrt{3}]``
194+
with ``μ=10^6`` and ``u0=[0,\\sqrt{3}]``
195195
196196
Stiff parameters.
197197
"""
198-
prob_ode_vanderpol_stiff = ODEProblem(van_stiff,[0;sqrt(3)])
198+
prob_ode_vanderpol_stiff = ODEProblem(van_stiff,[0;sqrt(3)],(0.0,1.0))
199199

200200
# ROBER
201201

@@ -222,7 +222,7 @@ Hairer Norsett Wanner Solving Ordinary Differential Euations I - Nonstiff Proble
222222
223223
Usually solved on `[0,1e11]`
224224
"""
225-
prob_ode_rober = ODEProblem(rober,[1.0;0.0;0.0])
225+
prob_ode_rober = ODEProblem(rober,[1.0;0.0;0.0],(0.0,1e11))
226226

227227
# Three Body
228228
const threebody_μ = parse(BigFloat,"0.012277471"); const threebody_μ′ = 1 - threebody_μ
@@ -258,7 +258,7 @@ From Hairer Norsett Wanner Solving Ordinary Differential Euations I - Nonstiff P
258258
Usually solved on `t₀ = 0.0`; `T = parse(BigFloat,"17.0652165601579625588917206249")`
259259
Periodic with that setup.
260260
"""
261-
prob_ode_threebody = ODEProblem(threebody,[0.994, 0.0, 0.0, parse(BigFloat,"-2.00158510637908252240537862224")])
261+
prob_ode_threebody = ODEProblem(threebody,[0.994, 0.0, 0.0, parse(BigFloat,"-2.00158510637908252240537862224")],(parse(BigFloat,"0.0"),parse(BigFloat,"17.0652165601579625588917206249")))
262262

263263
# Rigid Body Equations
264264

@@ -289,7 +289,7 @@ or Hairer Norsett Wanner Solving Ordinary Differential Euations I - Nonstiff Pro
289289
290290
Usually solved from 0 to 20.
291291
"""
292-
prob_ode_rigidbody = ODEProblem(rigid,[1.0,0.0,0.9])
292+
prob_ode_rigidbody = ODEProblem(rigid,[1.0,0.0,0.9],(0.0,20.0))
293293

294294
# Pleiades Problem
295295

@@ -363,4 +363,4 @@ From Hairer Norsett Wanner Solving Ordinary Differential Euations I - Nonstiff P
363363
364364
Usually solved from 0 to 3.
365365
"""
366-
prob_ode_pleides = ODEProblem(pleides,[3.0,3.0,-1.0,-3.0,2.0,-2.0,2.0,3.0,-3.0,2.0,0,0,-4.0,4.0,0,0,0,0,0,1.75,-1.5,0,0,0,-1.25,1,0,0])
366+
prob_ode_pleides = ODEProblem(pleides,[3.0,3.0,-1.0,-3.0,2.0,-2.0,2.0,3.0,-3.0,2.0,0,0,-4.0,4.0,0,0,0,0,0,1.75,-1.5,0,0,0,-1.25,1,0,0],(0.0,3.0))

0 commit comments

Comments
 (0)