Skip to content

Commit fee343a

Browse files
not depwarns from problem library
1 parent 538de31 commit fee343a

File tree

5 files changed

+60
-44
lines changed

5 files changed

+60
-44
lines changed

src/DiffEqProblemLibrary.jl

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,43 @@ __precompile__(true)
33
module DiffEqProblemLibrary
44

55
module ODEProblemLibrary
6-
importodeproblems() =
7-
@isdefined(prob_ode_linear) || include(joinpath(@__DIR__, "ode/ode_premade_problems.jl"))
6+
function importodeproblems()
7+
@isdefined(prob_ode_linear) ||
8+
include(joinpath(@__DIR__, "ode/ode_premade_problems.jl"));
9+
nothing
10+
end
811
end # module
912

1013
module DAEProblemLibrary
11-
importdaeproblems() =
12-
@isdefined(prob_dae_resrob) || include(joinpath(@__DIR__, "dae_premade_problems.jl"))
14+
function importdaeproblems()
15+
@isdefined(prob_dae_resrob) ||
16+
include(joinpath(@__DIR__, "dae_premade_problems.jl"));
17+
nothing
18+
end
1319
end # module
1420

1521
module DDEProblemLibrary
16-
importddeproblems() =
17-
@isdefined(prob_dde_1delay) || include(joinpath(@__DIR__, "dde_premade_problems.jl"))
22+
function importddeproblems()
23+
@isdefined(prob_dde_1delay) ||
24+
include(joinpath(@__DIR__, "dde_premade_problems.jl"));
25+
nothing
26+
end
1827
end # module
1928

2029
module SDEProblemLibrary
21-
importsdeproblems() =
22-
@isdefined(prob_sde_wave) || include(joinpath(@__DIR__, "sde_premade_problems.jl"))
30+
function importsdeproblems()
31+
@isdefined(prob_sde_wave) ||
32+
include(joinpath(@__DIR__, "sde_premade_problems.jl"));
33+
nothing
34+
end
2335
end # module
2436

2537
module JumpProblemLibrary
26-
importjumpproblems() =
27-
@isdefined(prob_jump_dnarepressor) || include(joinpath(@__DIR__, "jump_premade_problems.jl"))
38+
function importjumpproblems()
39+
@isdefined(prob_jump_dnarepressor) ||
40+
include(joinpath(@__DIR__, "jump_premade_problems.jl"));
41+
nothing
42+
end
2843
end # module
2944

3045
end # module

src/ode/filament_prob.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,9 @@ end
217217

218218
function filament_prob(::SolverDiffEq; N=20, Cm=32, ω=200, time_end=1.)
219219
f = FilamentCache(N, Solver=SolverDiffEq, Cm=Cm, ω=ω)
220+
jac = (J, r, p, t) -> f(Val{:jac}, J, r, p, t)
220221
r0 = initialize!(:StraightX, f)
221222
stiffness_matrix!(f)
222-
prob = ODEProblem(f, r0, (0., time_end))
223+
prob = ODEProblem(ODEFunction(f,jac=jac), r0, (0., time_end))
223224
end
224225
prob_ode_filament = filament_prob(SolverDiffEq())

src/ode/ode_linear_prob.jl

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Linear ODE
2-
linear = (u,p,t) -> (1.01*u)
3-
(f::typeof(linear))(::Type{Val{:analytic}},u0,p,t) = u0*exp(1.01*t)
2+
linear = (u,p,t) -> (p*u)
3+
linear_analytic = (u0,p,t) -> u0*exp(p*t)
44
"""
55
Linear ODE
66
@@ -14,13 +14,12 @@ with initial condition ``u0=1/2``, ``α=1.01``, and solution
1414
u(t) = u0e^{αt}
1515
```
1616
17-
with Float64s
17+
with Float64s. The parameter is ``α``
1818
"""
19-
prob_ode_linear = ODEProblem(linear,1/2,(0.0,1.0))
19+
prob_ode_linear = ODEProblem(
20+
ODEFunction(linear,analytic=linear_analytic),
21+
1/2,(0.0,1.0),1.01)
2022

21-
const linear_bigα = parse(BigFloat,"1.01")
22-
f_linearbig = (u,p,t) -> (linear_bigα*u)
23-
(f::typeof(f_linearbig))(::Type{Val{:analytic}},u0,p,t) = u0*exp(linear_bigα*t)
2423
"""
2524
Linear ODE
2625
@@ -36,14 +35,12 @@ u(t) = u0e^{αt}
3635
3736
with BigFloats
3837
"""
39-
prob_ode_bigfloatlinear = ODEProblem(f_linearbig,parse(BigFloat,"0.5"),(0.0,1.0))
40-
41-
f_2dlinear = (du,u,p,t) -> begin
42-
for i in 1:length(u)
43-
du[i] = 1.01*u[i]
44-
end
45-
end
46-
(f::typeof(f_2dlinear))(::Type{Val{:analytic}},u0,p,t) = u0*exp.(linear_bigα*t)
38+
prob_ode_bigfloatlinear = ODEProblem(
39+
ODEFunction(linear,analytic=linear_analytic),
40+
big(0.5),(0.0,1.0),big(1.01))
41+
42+
f_2dlinear = (du,u,p,t) -> (@. du = p*u)
43+
f_2dlinear_analytic = (u0,p,t) -> @. u0*exp(p*t)
4744
"""
4845
4x2 version of the Linear ODE
4946
@@ -59,7 +56,9 @@ u(t) = u0e^{αt}
5956
6057
with Float64s
6158
"""
62-
prob_ode_2Dlinear = ODEProblem(f_2dlinear,rand(4,2),(0.0,1.0))
59+
prob_ode_2Dlinear = ODEProblem(
60+
ODEFunction(f_2dlinear,analytic=f_2dlinear_analytic),
61+
rand(4,2),(0.0,1.0),1.01)
6362

6463
"""
6564
100x100 version of the Linear ODE
@@ -76,14 +75,10 @@ u(t) = u0e^{αt}
7675
7776
with Float64s
7877
"""
79-
prob_ode_large2Dlinear = ODEProblem(f_2dlinear,rand(100,100),(0.0,1.0))
80-
81-
f_2dlinearbig = (du,u,p,t) -> begin
82-
for i in 1:length(u)
83-
du[i] = linear_bigα*u[i]
84-
end
85-
end
86-
(f::typeof(f_2dlinearbig))(::Type{Val{:analytic}},u0,p,t) = u0*exp.(linear_bigα*t)
78+
prob_ode_large2Dlinear = ODEProblem(
79+
ODEFunction(f_2dlinear,analytic=f_2dlinear_analytic),
80+
rand(100,100),(0.0,1.0),1.01)
81+
8782
"""
8883
4x2 version of the Linear ODE
8984
@@ -99,9 +94,11 @@ u(t) = u0e^{αt}
9994
10095
with BigFloats
10196
"""
102-
prob_ode_bigfloat2Dlinear = ODEProblem(f_2dlinearbig,map(BigFloat,rand(4,2)).*ones(4,2)/2,(0.0,1.0))
103-
f_2dlinear_notinplace = (u,p,t) -> 1.01*u
104-
(f::typeof(f_2dlinear_notinplace))(::Type{Val{:analytic}},u0,p,t) = u0*exp.(1.01*t)
97+
prob_ode_bigfloat2Dlinear = ODEProblem(
98+
ODEFunction(f_2dlinear,analytic=f_2dlinear_analytic),
99+
BigFloat.(rand(4,2)).*ones(4,2)/2,(0.0,1.0),big(1.01))
100+
101+
f_2dlinear_notinplace = (u,p,t) -> p*u
105102
"""
106103
4x2 version of the Linear ODE
107104
@@ -117,4 +114,6 @@ u(t) = u0e^{αt}
117114
118115
on Float64. Purposefully not in-place as a test.
119116
"""
120-
prob_ode_2Dlinear_notinplace = ODEProblem(f_2dlinear_notinplace,rand(4,2),(0.0,1.0))
117+
prob_ode_2Dlinear_notinplace = ODEProblem(
118+
ODEFunction(f_2dlinear_notinplace,analytic=f_2dlinear_analytic),
119+
rand(4,2),(0.0,1.0),1.01)

src/ode/ode_simple_nonlinear_prob.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,9 @@ const mm_A = rand(4,4)
247247
mm_linear = function (du,u,p,t)
248248
mul!(du,mm_A,u)
249249
end
250-
const MM_linear =full(Diagonal(0.5ones(4)))
251-
(::typeof(mm_linear))(::Type{Val{:analytic}},u0,p,t) = exp(inv(MM_linear)*mm_A*t)*u0
252-
prob_ode_mm_linear = ODEProblem(mm_linear,rand(4),(0.0,1.0),mass_matrix=MM_linear)
250+
const MM_linear =Matrix(Diagonal(0.5ones(4)))
251+
mm_f = ODEFunction(mm_linear,analytic = (u0,p,t) -> exp(inv(MM_linear)*mm_A*t)*u0)
252+
prob_ode_mm_linear = ODEProblem(mm_f,rand(4),(0.0,1.0),mass_matrix=MM_linear)
253253

254254
"""
255255
[Hires Problem](http://nbviewer.jupyter.org/github/JuliaDiffEq/DiffEqBenchmarks.jl/blob/master/StiffODE/Hires.ipynb) (Stiff)

src/ode/pollution_prob.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ function pollution(dy,y,p,t)
7474
dy[20] = -r25+r24
7575
end
7676

77-
function pollution(::Type{Val{:jac}},J,y,p,t)
77+
function pollution_jac(J,y,p,t)
7878
J .= 0.0
7979
J[1,1] = -k1-k10*y[11]-k14*y[6]-k23*y[4]-k24*y[19]
8080
J[1,11] = -k10*y[1]+k9*y[2]
@@ -232,4 +232,5 @@ y0 = (0, 0.2, 0, 0.04, 0, 0, 0.1, 0.3, 0.01, 0, 0, 0, 0 ,0, 0, 0, 0.007, 0, 0, 0
232232
233233
https://archimede.dm.uniba.it/~testset/report/pollu.pdf
234234
"""
235-
prob_ode_pollution = ODEProblem(pollution,u0,(0.0,60.0))
235+
prob_ode_pollution = ODEProblem(ODEFunction(pollution,jac=pollution_jac),
236+
u0,(0.0,60.0))

0 commit comments

Comments
 (0)