Skip to content

Commit e80eb70

Browse files
Fix BDF allocation tests to use correct problem types
Properly separated BDF solvers by their required problem types: - Standard BDF methods (ABDF2, QNDF, QBDF, FBDF, SBDF, MEBDF2): use ODEProblem - IMEX methods (IMEXEuler, IMEXEulerARK): use SplitODEProblem - DAE methods (DABDF2, DImplicitEuler, DFBDF): use DAEProblem This matches the LowOrderRK test structure and ensures each solver is tested with the appropriate problem type it was designed for. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 508a40b commit e80eb70

File tree

1 file changed

+41
-4
lines changed

1 file changed

+41
-4
lines changed

lib/OrdinaryDiffEqBDF/test/allocation_tests.jl

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Currently, many BDF solvers are allocating and marked with @test_broken.
1010
"""
1111

1212
@testset "BDF Allocation Tests" begin
13-
# Test problem for BDF methods
13+
# Test problem for standard ODE BDF methods
1414
function simple_system!(du, u, p, t)
1515
du[1] = -0.5 * u[1]
1616
du[2] = -1.5 * u[2]
@@ -28,14 +28,26 @@ Currently, many BDF solvers are allocating and marked with @test_broken.
2828
end
2929
split_prob = SplitODEProblem(f1!, f2!, [1.0, 1.0], (0.0, 1.0))
3030

31+
# DAE problem for DAE solvers
32+
function dae_f!(du, u, p, t)
33+
du[1] = -0.5 * u[1] + u[2]
34+
du[2] = u[1] - u[2]
35+
end
36+
du0 = zeros(2)
37+
differential_vars = [true, false]
38+
dae_prob = DAEProblem(dae_f!, du0, [1.0, 1.0], (0.0, 1.0), differential_vars=differential_vars)
39+
3140
# Test all exported BDF solvers for allocation-free behavior
41+
# Standard ODE BDF methods
3242
bdf_solvers = [ABDF2(), QNDF1(), QBDF1(), QNDF2(), QBDF2(), QNDF(), QBDF(), FBDF(),
33-
SBDF(order=2), SBDF2(), SBDF3(), SBDF4(), MEBDF2(),
34-
DABDF2(), DImplicitEuler(), DFBDF()]
43+
SBDF(order=2), SBDF2(), SBDF3(), SBDF4(), MEBDF2()]
3544

36-
# IMEX methods need special handling with split problem
45+
# IMEX methods need SplitODEProblem
3746
imex_solvers = [IMEXEuler(), IMEXEulerARK()]
3847

48+
# DAE methods need DAEProblem
49+
dae_solvers = [DABDF2(), DImplicitEuler(), DFBDF()]
50+
3951
@testset "BDF Solver Allocation Analysis" begin
4052
for solver in bdf_solvers
4153
@testset "$(typeof(solver)) allocation check" begin
@@ -85,4 +97,29 @@ Currently, many BDF solvers are allocating and marked with @test_broken.
8597
end
8698
end
8799
end
100+
101+
@testset "DAE Solver Allocation Analysis" begin
102+
for solver in dae_solvers
103+
@testset "$(typeof(solver)) allocation check" begin
104+
integrator = init(dae_prob, solver, dt=0.1, save_everystep=false, abstol=1e-6, reltol=1e-6)
105+
step!(integrator) # Setup step may allocate
106+
107+
# Use AllocCheck to verify step! is allocation-free
108+
allocs = check_allocs(step!, (typeof(integrator),))
109+
110+
# These solvers should be allocation-free, but mark as broken for now
111+
# to verify with AllocCheck (more accurate than @allocated)
112+
@test length(allocs) == 0 broken=true
113+
114+
if length(allocs) > 0
115+
println("AllocCheck found $(length(allocs)) allocation sites in $(typeof(solver)) step!:")
116+
for (i, alloc) in enumerate(allocs[1:min(3, end)]) # Show first 3
117+
println(" $i. $alloc")
118+
end
119+
else
120+
println("$(typeof(solver)) appears allocation-free with AllocCheck")
121+
end
122+
end
123+
end
124+
end
88125
end

0 commit comments

Comments
 (0)