Skip to content

Commit b5d68c4

Browse files
Fix some tests
The justification for this flip is rather deep... it's documented in EnzymeAD/Enzyme.jl#2360 . Basically `using Enzyme` first causes some behavioral changes in the nonlinear solver. The fact that it matters is almost random here, so I am just isolating the solver tests from this for now.
1 parent 84eab3e commit b5d68c4

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

lib/OrdinaryDiffEqBDF/test/dae_ad_tests.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@ differential_vars = [true, true, false]
1919
prob = DAEProblem(f, du₀, u₀, tspan, p, differential_vars = differential_vars)
2020
prob_oop = DAEProblem{false}(f, du₀, u₀, tspan, p, differential_vars = differential_vars)
2121
sol1 = solve(prob, DFBDF(), dt = 1e-5, abstol = 1e-8, reltol = 1e-8)
22+
sol2 = solve(prob_oop, DFBDF(), dt = 1e-5, abstol = 1e-8, reltol = 1e-8)
2223

2324
# These tests flex differentiation of the solver and through the initialization
2425
# To only test the solver part and isolate potential issues, set the initialization to consistent
25-
@testset "Inplace: $(isinplace(_prob)), DAEProblem: $(_prob isa DAEProblem), BrownBasic: $(initalg isa BrownFullBasicInit), Autodiff: $autodiff" for _prob in [
26+
@testset "Inplace: $(isinplace(_prob)), DAEProblem: $(_prob isa DAEProblem), BrownBasic: $(initalg isa BrownFullBasicInit), Autodiff: $autodiff" for _prob in [
2627
prob, prob_oop],
2728
initalg in [BrownFullBasicInit(), ShampineCollocationInit()], autodiff in [true, false]
2829

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
using SafeTestsets
22

3-
@time @safetestset "BDF Convergence Tests" include("bdf_convergence_tests.jl")
4-
@time @safetestset "BDF Regression Tests" include("bdf_regression_tests.jl")
5-
63
@time @safetestset "DAE Convergence Tests" include("dae_convergence_tests.jl")
74
@time @safetestset "DAE AD Tests" include("dae_ad_tests.jl")
85
@time @safetestset "DAE Event Tests" include("dae_event.jl")
96
@time @safetestset "DAE Initialization Tests" include("dae_initialization_tests.jl")
7+
8+
@time @safetestset "BDF Convergence Tests" include("bdf_convergence_tests.jl")
9+
@time @safetestset "BDF Regression Tests" include("bdf_regression_tests.jl")

lib/OrdinaryDiffEqNonlinearSolve/src/initialize_dae.jl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -616,16 +616,18 @@ function _initialize_dae!(integrator, prob::DAEProblem,
616616
end
617617

618618
nlequation = @closure (x, _) -> begin
619-
du = ifelse.(differential_vars, x, du)
620-
u = ifelse.(differential_vars, u, x)
621-
f(du, u, p, t)
619+
du_ = ifelse.(differential_vars, x, du)
620+
u_ = ifelse.(differential_vars, u, x)
621+
f.f(du_, u_, p, t)
622622
end
623623

624624
nlfunc = NonlinearFunction(nlequation; jac_prototype = f.jac_prototype)
625625
nlprob = NonlinearProblem(nlfunc, ifelse.(differential_vars, du, u))
626626

627627
nlsolve = default_nlsolve(alg.nlsolve, isinplace, nlprob, integrator.u)
628628

629+
@show nlsolve
630+
629631
nlsol = solve(nlprob, nlsolve)
630632

631633
du = ifelse.(differential_vars, nlsol.u, du)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
using SafeTestsets
22

3-
@time @safetestset "Rosenbrock Convergence Tests" include("ode_rosenbrock_tests.jl")
43
@time @safetestset "DAE Rosenbrock AD Tests" include("dae_rosenbrock_ad_tests.jl")
4+
@time @safetestset "Rosenbrock Convergence Tests" include("ode_rosenbrock_tests.jl")

0 commit comments

Comments
 (0)