diff --git a/lib/OrdinaryDiffEqBDF/src/controllers.jl b/lib/OrdinaryDiffEqBDF/src/controllers.jl index cba5dcb56b..8ca920f813 100644 --- a/lib/OrdinaryDiffEqBDF/src/controllers.jl +++ b/lib/OrdinaryDiffEqBDF/src/controllers.jl @@ -45,7 +45,7 @@ function step_accept_controller!(integrator, alg::QNDF{max_order}, q) where {max Fₖ₋₁ = inv(zₖ₋₁) if zₖ₋₁ <= 0.1 hₖ₋₁ = 10 * h - elseif 1 / 10 < zₖ₋₁ <= 1.3 + elseif zₖ₋₁ <= 1.3 hₖ₋₁ = Fₖ₋₁ * h end if hₖ₋₁ > hₖ @@ -89,14 +89,6 @@ function step_accept_controller!(integrator, alg::QNDF{max_order}, q) where {max return integrator.dt / q end -function step_reject_controller!(integrator, ::QNDF) - bdf_step_reject_controller!(integrator, integrator.cache.EEst1) -end - -function step_reject_controller!(integrator, ::FBDF) - bdf_step_reject_controller!(integrator, integrator.cache.terkm1) -end - function bdf_step_reject_controller!(integrator, EEst1) k = integrator.cache.order h = integrator.dt @@ -122,7 +114,7 @@ function bdf_step_reject_controller!(integrator, EEst1) Fₖ₋₁ = inv(zₖ₋₁) if zₖ₋₁ <= 10 hₖ₋₁ = Fₖ₋₁ * h - elseif zₖ₋₁ > 10 + else # zₖ₋₁ > 10 hₖ₋₁ = 0.1 * h end if integrator.cache.consfailcnt > 2 || hₖ₋₁ > hₖ @@ -138,6 +130,14 @@ function bdf_step_reject_controller!(integrator, EEst1) integrator.cache.order = kₙ end +function step_reject_controller!(integrator, ::QNDF) + bdf_step_reject_controller!(integrator, integrator.cache.EEst1) +end + +function step_reject_controller!(integrator, ::FBDF) + bdf_step_reject_controller!(integrator, integrator.cache.terkm1) +end + function post_newton_controller!(integrator, alg::FBDF) (; cache) = integrator if cache.order > 1 && cache.nlsolver.nfails >= 3 diff --git a/lib/OrdinaryDiffEqBDF/test/dae_ad_tests.jl b/lib/OrdinaryDiffEqBDF/test/dae_ad_tests.jl index cdb037f45e..686d85bc88 100644 --- a/lib/OrdinaryDiffEqBDF/test/dae_ad_tests.jl +++ b/lib/OrdinaryDiffEqBDF/test/dae_ad_tests.jl @@ -36,12 +36,14 @@ f_mm = ODEFunction{true}(f_ode, mass_matrix = M) prob_mm = ODEProblem(f_mm, u₀, tspan, p) f_mm_oop = ODEFunction{false}(f_ode, mass_matrix = M) prob_mm_oop = ODEProblem(f_mm_oop, u₀, tspan, p) -@test_broken sol1 = @inferred solve( +if VERSION >= v"1.12" +sol1 = @inferred solve( prob, DFBDF(autodiff = afd_cs3), dt = 1e-5, abstol = 1e-8, reltol = 1e-8) -@test_broken sol2 = @inferred solve( +sol2 = @inferred solve( prob_oop, DFBDF(autodiff = afd_cs3), dt = 1e-5, abstol = 1e-8, reltol = 1e-8) -@test_broken sol3 = @inferred solve( +sol3 = @inferred solve( prob_mm, FBDF(autodiff = afd_cs3), dt = 1e-5, abstol = 1e-8, reltol = 1e-8) +end # These tests flex differentiation of the solver and through the initialization # To only test the solver part and isolate potential issues, set the initialization to consistent