Skip to content

Commit 7ab32b5

Browse files
committed
Add integr. test for 'balanced'; reduce test accuracy
1 parent 7f2bd9c commit 7ab32b5

File tree

6 files changed

+23
-8
lines changed

6 files changed

+23
-8
lines changed

test/L96m/data/dp5.npy

-26 KB
Binary file not shown.

test/L96m/data/dp5_bal.npy

7.18 KB
Binary file not shown.

test/L96m/data/dp5_full.npy

64 KB
Binary file not shown.

test/L96m/data/tsitpap8.npy

-26 KB
Binary file not shown.

test/L96m/data/tsitpap8_full.npy

64 KB
Binary file not shown.

test/L96m/runtests.jl

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ const z0 = NPZ.npzread(joinpath(data_dir, "ic.npy"))
1616
const Yk_test = NPZ.npzread(joinpath(data_dir, "Yk.npy"))
1717
const full_test = NPZ.npzread(joinpath(data_dir, "full.npy"))
1818
const balanced_test = NPZ.npzread(joinpath(data_dir, "balanced.npy"))
19-
const dp5_test = NPZ.npzread(joinpath(data_dir, "dp5.npy"))
20-
const tp8_test = NPZ.npzread(joinpath(data_dir, "tsitpap8.npy"))
19+
const dp5_test = NPZ.npzread(joinpath(data_dir, "dp5_full.npy"))
20+
const tp8_test = NPZ.npzread(joinpath(data_dir, "tsitpap8_full.npy"))
21+
const bal_test = NPZ.npzread(joinpath(data_dir, "dp5_bal.npy"))
2122

2223
################################################################################
2324
# unit testing #################################################################
@@ -37,26 +38,40 @@ println("")
3738
################################################################################
3839
# integration testing ##########################################################
3940
################################################################################
40-
const T = 4
41-
pb = DE.ODEProblem(full, z0, (0.0, T), l96)
41+
const T = 1.0
42+
const dtmax = 1e-4
43+
const saveat = 1e-2
44+
pb_full = DE.ODEProblem(full, z0, (0.0, T), l96)
45+
pb_bal = DE.ODEProblem(balanced, z0[1:l96.K], (0.0, T), l96)
4246

47+
# full, DP5
4348
print(rpad("(full, DP5)", RPAD))
4449
elapsed_dp5 = @elapsed begin
45-
sol_dp5 = DE.solve(pb, DE.DP5(), reltol=1e-5, abstol=1e-9, saveat=0.1)
50+
sol_dp5 = DE.solve(pb_full, DE.DP5(), dtmax = dtmax, saveat = saveat)
4651
end
4752
println("steps:", lpad(length(sol_dp5.t), LPAD_INTEGER),
4853
"\telapsed:", lpad(elapsed_dp5, LPAD_FLOAT))
4954

55+
# full, TsitPap8
5056
print(rpad("(full, TsitPap8)", RPAD))
5157
elapsed_tp8 = @elapsed begin
52-
sol_tp8 = DE.solve(pb, DE.TsitPap8(), reltol=1e-5, abstol=1e-9, saveat=0.1)
58+
sol_tp8 = DE.solve(pb_full, DE.TsitPap8(), dtmax = dtmax, saveat = saveat)
5359
end
5460
println("steps:", lpad(length(sol_tp8.t), LPAD_INTEGER),
5561
"\telapsed:", lpad(elapsed_tp8, LPAD_FLOAT))
5662

63+
# balanced, DP5
64+
print(rpad("(balanced, DP5)", RPAD))
65+
elapsed_bal = @elapsed begin
66+
sol_bal = DE.solve(pb_bal, DE.DP5(), dtmax = dtmax, saveat = saveat)
67+
end
68+
println("steps:", lpad(length(sol_bal.t), LPAD_INTEGER),
69+
"\telapsed:", lpad(elapsed_bal, LPAD_FLOAT))
70+
5771
@testset "integration testing" begin
58-
@test isapprox(sol_dp5[:,1:end], dp5_test, atol=5e-8)
59-
@test isapprox(sol_tp8[:,1:end], tp8_test, atol=5e-8)
72+
@test isapprox(sol_dp5[:,1:end], dp5_test, atol=1e-6)
73+
@test isapprox(sol_tp8[:,1:end], tp8_test, atol=1e-6)
74+
@test isapprox(sol_bal[:,1:end], bal_test, atol=1e-6)
6075
end
6176
println("")
6277

0 commit comments

Comments
 (0)