-
-
Notifications
You must be signed in to change notification settings - Fork 26
/
cache.jl
55 lines (44 loc) · 1.51 KB
/
cache.jl
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
using DelayDiffEq, Test
using Random
Random.seed!(213)
const CACHE_TEST_ALGS = [Vern7(), Euler(), Midpoint(), RK4(), SSPRK22(), SSPRK33(),
ORK256(), CarpenterKennedy2N54(), SHLDDRK64(), DGLDDRK73_C(),
CFRLDDRK64(), TSLDDRK74(),
CKLLSRK43_2(),
ParsaniKetchesonDeconinck3S32(),
BS3(), BS5(), DP5(), DP8(), Feagin10(), Feagin12(), Feagin14(), TanYam7(),
Tsit5(), TsitPap8(), Vern6(), Vern7(), Vern8(), Vern9(), OwrenZen3(), OwrenZen4(),
OwrenZen5()]
function f(du, u, h, p, t)
for i in 1:length(u)
du[i] = (0.3 / length(u)) * u[i]
end
nothing
end
condition(u, t, integrator) = 1 - maximum(u)
function affect!(integrator)
u = integrator.u
resize!(integrator, length(u) + 1)
maxidx = findmax(u)[2]
Θ = rand() / 5 + 0.25
u[maxidx] = Θ
u[end] = 1 - Θ
nothing
end
const prob = DDEProblem(f, [0.2], nothing, (0.0, 10.0);
callback = ContinuousCallback(condition, affect!))
println("Check for stochastic errors")
for i in 1:10
@test_nowarn solve(prob, MethodOfSteps(Tsit5()); dt = 0.5)
end
println("Check some other integrators")
println("Rosenbrock23")
@test_nowarn solve(prob, MethodOfSteps(Rosenbrock23(chunk_size = 1)); dt = 0.5)
for alg in CACHE_TEST_ALGS
println(nameof(typeof(alg)))
@test_nowarn solve(prob, MethodOfSteps(alg); dt = 0.5)
end
println("Rodas4")
@test_nowarn solve(prob, MethodOfSteps(Rodas4(chunk_size = 1)); dt = 0.5)
println("Rodas5")
@test_nowarn solve(prob, MethodOfSteps(Rodas5(chunk_size = 1)); dt = 0.5)