Skip to content

Commit 1475d48

Browse files
committed
Add integrator parameters (dtmax etc.)
1 parent 4d4796e commit 1475d48

File tree

1 file changed

+22
-9
lines changed

1 file changed

+22
-9
lines changed

examples/L96m/main.jl

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,15 @@ const SOLVER = DE.Tsit5()
1818
const T = 4 # integration time
1919
const T_compile = 1e-10 # force JIT compilation
2020
const T_conv = 100 # converging integration time
21-
# const T_learn = 15 # time to gather training data for GP
22-
# const T_hist = 10000 # time to gather histogram statistics
21+
#const T_learn = 15 # time to gather training data for GP
22+
#const T_hist = 10000 # time to gather histogram statistics
2323

24-
# const dt = 0.010 # maximum step size
25-
# const tau = 1e-3 # maximum step size for histogram statistics
26-
# const dt_conv = 0.01 # maximum step size for converging to attractor
24+
# integrator parameters
25+
const dtmax = 1e-3 # maximum step size
26+
#const tau = 1e-3 # maximum step size for histogram statistics
27+
#const dt_conv = 0.01 # maximum step size for converging to attractor
28+
const reltol = 1e-3 # relative tolerance
29+
const abstol = 1e-6 # absolute tolerance
2730

2831
const k = 1 # index of the slow variable to save etc.
2932
const j = 1 # index of the fast variable to save/plot etc.
@@ -51,16 +54,21 @@ end
5154
print(rpad("(JIT compilation)", RPAD))
5255
elapsed_jit = @elapsed begin
5356
pb_jit = DE.ODEProblem(full, z00, (0.0, T_compile), l96)
54-
sol_jit = DE.solve(pb_jit, SOLVER, reltol = 1e-3, abstol = 1e-6)
57+
DE.solve(pb_jit, SOLVER, reltol = reltol, abstol = abstol, dtmax = dtmax)
5558
end
56-
println("steps:", lpad(length(sol_jit.t), LPAD_INTEGER),
59+
println(" " ^ (LPAD_INTEGER + 6),
5760
"\t\telapsed:", lpad(elapsed_jit, LPAD_FLOAT))
5861

5962
# full L96m integration (converging to attractor)
6063
print(rpad("(full, converging)", RPAD))
6164
elapsed_conv = @elapsed begin
6265
pb_conv = DE.ODEProblem(full, z00, (0.0, T_conv), l96)
63-
sol_conv = DE.solve(pb_conv, SOLVER, reltol = 1e-3, abstol = 1e-6)
66+
sol_conv = DE.solve(pb_conv,
67+
SOLVER,
68+
reltol = reltol,
69+
abstol = abstol,
70+
dtmax = dtmax
71+
)
6472
end
6573
println("steps:", lpad(length(sol_conv.t), LPAD_INTEGER),
6674
"\t\telapsed:", lpad(elapsed_conv, LPAD_FLOAT))
@@ -70,7 +78,12 @@ z0 = sol_conv[:,end]
7078
print(rpad("(full)", RPAD))
7179
elapsed_dns = @elapsed begin
7280
pb_dns = DE.ODEProblem(full, z0, (0.0, T), l96)
73-
sol_dns = DE.solve(pb_dns, SOLVER, reltol = 1e-3, abstol = 1e-6)
81+
sol_dns = DE.solve(pb_dns,
82+
SOLVER,
83+
reltol = reltol,
84+
abstol = abstol,
85+
dtmax = dtmax
86+
)
7487
end
7588
println("steps:", lpad(length(sol_dns.t), LPAD_INTEGER),
7689
"\t\telapsed:", lpad(elapsed_dns, LPAD_FLOAT))

0 commit comments

Comments
 (0)