Skip to content

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
modelon-community:masterfrom
hubertus65:pr-maxh-optout
Open

hubertus65 wants to merge 1 commit into
modelon-community:masterfrom
hubertus65:pr-maxh-optout

Conversation

@hubertus65

Copy link
Copy Markdown

Summary

One commit. PyFMI caps the solver's maximum step at (final_time - start_time) / ncp whenever
maxh is left at "Default". There was no documented way to say no cap — and passing None
raised, while 0.0 (Assimulo's "no limit") worked only by accident of the comparison.

This accepts and documents both: maxh = None and maxh = 0.0 mean "no maximum step", and
ncp = 0 already meant that. The "Default" comparison is guarded with an isinstance check so
that None no 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

  • maxh documented in the options help for the solvers that take it, with the None / 0.0 /
    ncp = 0 equivalences spelled out.
  • tests/test_fmi2.py::test_maxh_option covers the matrix for CVode and Radau5ODE:
    "Default" caps at (tf-t0)/ncp; ncp = 0, None and 0.0 all give 0.0 (no cap); an
    explicit 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

… 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
hubertus65 marked this pull request as ready for review October 16, 2026 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant