Skip to content

Safeguard steady-state steps during fast transient growth - #211

Merged
jc-macdonald merged 2 commits into
mainfrom
fix/209-steady-state-safeguards
Oct 14, 2026
Merged

jc-macdonald merged 2 commits into
mainfrom
fix/209-steady-state-safeguards

Conversation

@jc-macdonald

@jc-macdonald jc-macdonald commented Oct 14, 2026 •

Copy link
Copy Markdown
Member

steady_state previously accepted every candidate and reduced the next pseudo-time step during fast transient growth. The #209 reproduction either exhausted its iteration budget or diverged after entering negative compartments. Reject non-finite or excessively growing candidates, retain the previous state, and halve the step; accepted transient growth now holds the step.

Adds optional nonnegative=True or a boolean mask. Infeasible candidates, including the final Newton correction, are rejected without clipping conserved totals or evaluating the RHS outside the guarded domain. Singular NumPy solves use the same rejection path, and acceptance remains array-valued under JAX jit/vmap.

With non-negativity enabled, the three reproduction cases reach their analytic endemic equilibria in 66, 30, and 33 attempts, with relative invariant drift below 2e-16. Signs remain unrestricted by default, and rejected attempts count toward the iteration budget.

Algorithm research favored safeguarded pseudo-transient continuation for this coupled, namespace-portable solver. Brent/bisection require a scalar sign-changing bracket, while the existing curvature utilities generate spatial grids. The guide links the primary SciPy documentation, projected PTC research, and PETSc timestep-verification documentation.

Closes #209.

Validation:

  • 35 steady-state tests pass on this isolated branch.
  • Ruff preview format/lint, strict core mypy, and strict documentation build pass.
  • Regressions cover the analytic reproduction, JAX jit/vmap, residual-growth and non-finite rejection, singular-step recovery, selected bound masks, guarded RHS evaluation, and the final Newton correction.
  • GitHub CI passes on the final commit against current main: Python 3.11–3.14, CPU Torch, package builds, and documentation.

@jc-macdonald
jc-macdonald force-pushed the fix/209-steady-state-safeguards branch from 11891d8 to 5aa8ba5 Compare October 14, 2026 00:06
@jc-macdonald
jc-macdonald merged commit 8289d5e into main Oct 14, 2026
7 checks passed
@jc-macdonald
jc-macdonald deleted the fix/209-steady-state-safeguards branch October 14, 2026 16:52
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.

steady_state: no step rejection or non-negativity guard; a fast take-off from near the disease-free state stalls or diverges

1 participant