Skip to content

Commit ebf91fe

Browse files
Add Float64 convergence tests for DPRKN methods
Add regression tests to ensure CompiledFloats coefficients match the expected convergence order for DPRKN4, DPRKN5, DPRKN6, DPRKN6FM, and DPRKN8. These tests specifically target the Float64 code path (CompiledFloats) which was the source of the DPRKN5 bug fixed in this PR. The existing BigFloat tests only exercise the rational coefficient path. Note: DPRKN12 is too accurate for Float64 testing (hits machine precision even at dt=1.0), so it's only tested with BigFloat. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 2df85c3 commit ebf91fe

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

lib/OrdinaryDiffEqRKN/test/nystrom_convergence_tests.jl

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,36 @@ sim = test_convergence(dts, prob_big, ERKN7(), dense_errors = true)
4747
@test sim.𝒪est[:l2]7 rtol=1e-1
4848
@test sim.𝒪est[:L2]4 rtol=1e-1
4949

50+
# Float64 convergence tests for DPRKN methods
51+
# These tests ensure the CompiledFloats coefficients match the rational coefficients
52+
# (Regression test for https://github.com/SciML/OrdinaryDiffEq.jl/issues/1938)
53+
@testset "Float64 DPRKN convergence" begin
54+
# Use longer integration time to keep errors above machine precision
55+
prob_f64 = DynamicalODEProblem(ff_harmonic, ones(2), fill(0.0, 2), (0.0, 20.0))
56+
dts_f64 = 1.0 ./ 2.0 .^ (2:5)
57+
58+
sim = test_convergence(dts_f64, prob_f64, DPRKN4())
59+
@test sim.𝒪est[:l2]4 rtol=1e-1
60+
61+
sim = test_convergence(dts_f64, prob_f64, DPRKN5())
62+
@test sim.𝒪est[:l2]5 rtol=1e-1
63+
64+
sim = test_convergence(dts_f64, prob_f64, DPRKN6())
65+
@test sim.𝒪est[:l2]6 rtol=1e-1
66+
67+
sim = test_convergence(dts_f64, prob_f64, DPRKN6FM())
68+
@test sim.𝒪est[:l2]6 rtol=1e-1
69+
70+
# DPRKN8 needs larger timesteps and longer integration to avoid hitting machine precision
71+
prob_f64_long = DynamicalODEProblem(ff_harmonic, ones(2), fill(0.0, 2), (0.0, 50.0))
72+
dts_f64_large = [1.0, 0.5, 0.25, 0.125]
73+
sim = test_convergence(dts_f64_large, prob_f64_long, DPRKN8())
74+
@test sim.𝒪est[:l2]8 rtol=1e-1
75+
76+
# DPRKN12 is too accurate for Float64 convergence testing (hits machine precision
77+
# even at dt=1.0), so we only test it with BigFloat (see tests above)
78+
end
79+
5080
sol = solve(prob, Nystrom4(), dt = 1 / 1000)
5181

5282
# Nyström method

0 commit comments

Comments
 (0)