Repository navigation
NordsieckBDF: rebase dense output when a callback truncates the step - #4540
Merged
ChrisRackauckas merged 1 commit intoSep 12, 2026
Merged
ChrisRackauckas merged 1 commit into
ChrisRackauckas merged 1 commit into
Conversation
The Nordsieck `_ode_addsteps!` was a no-op, so after a continuous callback shortened an accepted step the stored columns stayed centred on the original endpoint with the original scaling while the interpolant evaluated them with the truncated dt. sol(t) over that step was off by ~1e-2 at reltol 1e-8 and did not pass through the saved event value, for both NordsieckBDF and DNordsieckBDF. Rebuild k from the committed Nordsieck array, Taylor-shift by (dt - h)/h and rescale by (dt/h)^j so the same polynomial is expressed about the new endpoint. Rebuilding from zn rather than k keeps repeated calls (e.g. a subsequent u_modified reevaluation) idempotent. Co-Authored-By: Chris Rackauckas <[email protected]> Co-Authored-By: Claude Fable 5.1 <[email protected]> Agent-Harness: Claude Code 2.1.270 Agent-Model: claude-fable-5-1 Agent-Session: https://claude.ai/code/session_01A1EvyhqnXh4tSeovg5e8y8 Claude-Session: https://claude.ai/code/session_01A1EvyhqnXh4tSeovg5e8y8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed and why
_ode_addsteps!for the four Nordsieck caches (NordsieckBDF,DNordsieckBDF, in-place and constant) was a literalreturn nothing. When aContinuousCallbacklocates a root inside an accepted step,OrdinaryDiffEqCoreshortensintegrator.dtto the root and callsode_addsteps!(…, always_calc_begin = true)so the solver can rebuildintegrator.kfor the truncated interval. QNDF, FBDF and DFBDF do this instiff_addsteps.jl; Nordsieck ignored it, sokkept the columns centred on the original endpoint and scaled by the original step while the interpolant evaluateds = Θ - 1with Θ computed from the truncateddt. Dense output over the event step was wrong by ~1e-2 atreltol = 1e-8and did not pass through the saved event value, for both the ODE and DAE solvers.The fix rebuilds
kfrom the committed Nordsieck arraycache.zn(columns abouttprev + h,h = cache.hscale), then re-expresses the same polynomial about the new endpoint: withb = dt / handa = b - 1,s = a + b s', which is an in-place Taylor shift byafollowed by scaling columnjbyb^(j-1). Rebuilding fromznrather than fromkkeeps repeated calls idempotent (a followingu_modified!reevaluation callsode_addsteps!again with the samedt). The constant-cache method allocates new columns becausek[j]aliaseszn[j]there.No public API change.
OrdinaryDiffEqBDFis at 2.4.9 on master, which is not yet registered, so no version bump.Failing before / passing after
Test added to
lib/OrdinaryDiffEqBDF/test/nordsieck_tests.jl:u' = -u(scalar out-of-place and vector in-place) and the index-1 DAEu1' = -u1, 0 = u2 - u1, with aContinuousCallbackatu = 0.5whose affect does nothing. It checks that the event step was really truncated, thatsol(t_event)matches the saved value, and thatsol(τ)at interior points of the event step is within 1e-6 ofexp(-τ).On unmodified
master(75adf30) with only the test added:With this PR:
All other testsets in
nordsieck_tests.jlpass in both runs.Verification
Run from
lib/OrdinaryDiffEqBDFon Julia 1.12.4.GROUP=QA julia --project -e 'using Pkg; Pkg.test()':(the
Brokenentries are pre-existing markers in the QA suite; none were added.)GROUP=Core julia --project -e 'using Pkg; Pkg.test()':Formatting checked with Runic 1.9.0 (
--checkclean) andtyposon the changed files.Not verified
Found while testing, deliberately left out of this PR
An out-of-place
DAEProblemwith anyContinuousCallbackerrors on master, independent of this change:reached from
DiffEqBase.find_callback_time → get_condition → get_tmp. The regression test here therefore covers the in-place DAE only. The missingget_tmp_cache(::Any, ::DAEAlgorithm, ::OrdinaryDiffEqConstantCache)method is a one-lineOrdinaryDiffEqCorefix with its own test and will go in a separate PR.🤖 Generated with Claude Code (Claude Code 2.1.270, model: claude-fable-5-1)
https://claude.ai/code/session_01A1EvyhqnXh4tSeovg5e8y8