Repository navigation
Radau5ODE: complete models whose callbacks fail at trial points (CVode-like recovery policy) - #138
Open
hubertus65 wants to merge 3 commits into
Open
hubertus65 wants to merge 3 commits into
hubertus65 wants to merge 3 commits into
Conversation
…not per call
radau5.c counted "unexpected" (recoverable) callback failures in `nunexpect`,
reset only at the start of a radau5 call, and aborted with
RADAU_ERROR_REP_STEP_REJECT ("Repeated unexpected step rejections") once the
total reached 10. For an FMU whose rhs rejects trial points regularly
(e.g. IF97 steam-table region errors on a 318-state power-plant model, or
Modelica.Fluid pipe models), that budget is exhausted within the first
millisecond even though every individual failure is recoverable by halving
the step; CVode handles the same model by shrinking the step each time.
Reset the counter on every accepted step so the limit applies to
consecutive failures only, matching the error message. No other behaviour
changes; tests/ still 330 passed, 5 skipped.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…ter step, budget 40)
When the model rejects a trial point (a recoverable error from the rhs or the
Jacobian callback), Radau5 halved the step and gave up after 10 consecutive
failures, i.e. after reducing the step by 1024x. CVode quarters the step on a
recoverable rhs failure. On a 318-state combined-cycle plant whose steam-table
functions fail in a region the stage points step into during the first
milliseconds, Radau5 died at t = 0.5-4 ms ("Repeated unexpected step
rejections") in every configuration, while CVode passes.
This makes the factor 0.25 and the budget 40 consecutive failures (both as
named constants). With it, and a finite-difference Jacobian that does not
call the FMU's directional derivatives in that region, Radau5ODE completes
the plant: 1422 steps, 557 Jacobians, 322 s, and the most accurate plant
trajectory of any solver measured against an rtol 1e-8 reference (max
6.7e-4 over 308 plant states, none beyond 1e-3; CVode at the same rtol
3.1e-3). Every other reference model is bit-for-bit unchanged (the path is
only taken on recoverable failures); the Assimulo test suite passes (330).
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PyrxGeWuwCmAH9LishMW6p
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PyrxGeWuwCmAH9LishMW6p
hubertus65
marked this pull request as ready for review
September 22, 2026 21:47
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.
Problem
Radau5ODE gives up with
Radau5Error: ... flag -8 ... Repeated unexpected step rejectionson models whose rhs (or Jacobian) callback returns a recoverable error at trial points — typically thermofluid models whose property functions (IAPWS-IF97 steam tables) are evaluated outside their region at the stage points during the first milliseconds. CVode completes the same models. Two reasons inradau5.c:radau5_solve, so the retries of the whole simulation were budgeted together (10), not the consecutive failures of one step;ETACF = 0.25).Change (two commits, cherry-pickable)
145c026counter per consecutive run of failures (reset on the next successful step), not per call.ace4515step factor 0.25 (named constantRADAU_CALLBACK_FAILURE_STEP_FACTOR) and budget 40 (RADAU_MAX_CONSECUTIVE_CALLBACK_FAILURES). Both only take effect on the recoverable-failure path; every other model is bit-for-bit unchanged.92af965CHANGELOG.Measured (PyFMI, OCT FMUs, rtol 1e-6, compared with rtol 1e-8 references)
The plant run uses a finite-difference Jacobian; with the FMU's directional derivatives the DD evaluation itself fails inside the FMU in the same region (an FMU-side issue, unrelated to this change).
Tests:
pytest tests/330 passed, 5 skipped (Python 3.11, conda-forge SUNDIALS/SuperLU_MT).Review notes
bit-for-bit unchanged.
the same policy.
🤖 Generated with Claude Code
https://claude.ai/code/session_01PyrxGeWuwCmAH9LishMW6p