Repository navigation
Accept and document the opt-out of PyFMI's maximum-step cap (maxh = None or 0.0) - #423
Open
hubertus65 wants to merge 1 commit into
Open
hubertus65 wants to merge 1 commit into
hubertus65 wants to merge 1 commit into
Conversation
… None or 0.0) PyFMI caps the solver's step at (final_time - start_time)/ncp by default, which forces at least ncp steps regardless of the model (and already used 0.0 = no cap when ncp = 0). The opt-out was undocumented and None was not accepted. Now 'maxh' = None or 0.0 removes the cap for every Assimulo solver and the docstring says what the default does. The default itself is unchanged: measured on the reference FMUs the cap costs stiff solvers 15-30 % more steps on smooth plant models and nothing on event-dominated ones; changing the default is a separate decision. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
hubertus65
marked this pull request as ready for review
October 16, 2026 14:00
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.
Summary
One commit. PyFMI caps the solver's maximum step at
(final_time - start_time) / ncpwhenevermaxhis left at"Default". There was no documented way to say no cap — and passingNoneraised, while
0.0(Assimulo's "no limit") worked only by accident of the comparison.This accepts and documents both:
maxh = Noneandmaxh = 0.0mean "no maximum step", andncp = 0already meant that. The"Default"comparison is guarded with anisinstancecheck sothat
Noneno longer raises before it is looked at.Why it matters
The cap is invisible in the options but decides the step sequence. On models where the solver
would like long steps between events — the step-size controller is doing its job, the output grid
is fine only because the user wants many communication points — the cap silently forces extra
steps and extra rhs evaluations that buy no accuracy. Users need a way to separate "how often I
want output" from "how large a step the solver may take".
Change
maxhdocumented in the options help for the solvers that take it, with theNone/0.0/ncp = 0equivalences spelled out.tests/test_fmi2.py::test_maxh_optioncovers the matrix forCVodeandRadau5ODE:"Default"caps at(tf-t0)/ncp;ncp = 0,Noneand0.0all give 0.0 (no cap); anexplicit value passes through.
Review notes
Documentation and input validation; no default changes, so no existing run changes its results.
🤖 Generated with Claude Code
https://claude.ai/code/session_01PyrxGeWuwCmAH9LishMW6p