forked from SciML/OrdinaryDiffEq.jl
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathodeinterface_regression.jl
More file actions
78 lines (56 loc) · 2.42 KB
/
Copy pathodeinterface_regression.jl
File metadata and controls
78 lines (56 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
using OrdinaryDiffEq, DiffEqDevTools, DiffEqBase, Test,
ODEInterface, ODEInterfaceDiffEq
import ODEProblemLibrary: prob_ode_bigfloatlinear,
prob_ode_linear,
prob_ode_2Dlinear,
prob_ode_bigfloat2Dlinear
probbig = prob_ode_bigfloat2Dlinear
probnum = prob_ode_linear
probnumbig = prob_ode_bigfloatlinear
prob = prob_ode_2Dlinear
dts = (1 / 2) .^ (7:-1:4)
testTol = 0.2
bools = Vector{Bool}(undef, 0)
## DP5()
sim = test_convergence(dts, probnum, DP5())
@test abs.(sim.𝒪est[:l2] - 5) < testTol
sim = test_convergence(dts, prob, DP5())
@test abs.(sim.𝒪est[:l2] - 5) < testTol
tabalg = ExplicitRK()
sol1 = solve(probnum, DP5(), dt = 1 / 2^6, adaptive = false, save_everystep = false)
sol2 = solve(probnum, tabalg, dt = 1 / 2^6, adaptive = false, save_everystep = false)
@test sol1.u[end] - sol2.u[end] < 1.0e-10
sol1 = solve(prob, DP5(), dt = 1 / 2^6, adaptive = false, save_everystep = false)
sol2 = solve(prob, tabalg, dt = 1 / 2^6, adaptive = false, save_everystep = false)
@test minimum(sol1.u[end] - sol2.u[end] .< 3.0e-10)
sol1 = solve(probnum, DP5(), dt = 1 / 2^6, controller = PIController(0.14, 0.04))
sol2 = solve(probnum, tabalg, dt = 1 / 2^6, controller = PIController(0.14, 0.04))
# Should be identical
sol1 = solve(probnum, DP5())
sol2 = solve(probnum, tabalg, controller = PIController(0.17, 0.04))
sol3 = solve(probnum, dopri5())
@test sol1.t ≈ sol2.t
@test sol1.t ≈ sol3.t atol = 1.0e-6
sol1 = solve(prob, DP5(), dt = 1 / 8)
sol2 = solve(prob, tabalg, controller = PIController(0.17, 0.04), dt = 1 / 8)
sol3 = solve(prob, dopri5(), dt = 1 / 8)
@test sol1.t ≈ sol2.t
@test sol1.t ≈ sol3.t atol = 1.0e-5
sol4 = solve(prob, DP5(), dt = 1 / 8, calck = false)
@test sol1.t == sol4.t
### DP8()
dts = (1 / 2) .^ (3:-1:1)
sim = test_convergence(dts, probnumbig, DP8())
@test abs.(sim.𝒪est[:l2] - 8) < testTol
sim = test_convergence(dts, probbig, DP8())
@test abs.(sim.𝒪est[:l2] - 8) < testTol
sol1 = solve(probnum, DP8(), dt = 1 / 2^6, adaptive = false, save_everystep = false)
sol2 = solve(probnum, DP8(), dt = 1 / 2^6)
# DP8() uses qmax_first_step=10000 on the first step (Sundials CVODE behavior)
# while dop853() (Fortran) does not, so adaptive solves may differ slightly
sol1 = solve(probnum, DP8())
sol2 = solve(probnum, dop853())
@test sol1.u[end] ≈ sol2.u[end] atol = 1.0e-6
sol1 = solve(prob, DP8(), dt = 1 / 2^6)
sol2 = solve(prob, dop853(), dt = 1 / 2^6)
@test sol1.u[end] ≈ sol2.u[end] atol = 1.0e-6