Skip to content

Make supplied linearisation reuse deterministic - #112

Open
nicamo wants to merge 2 commits into
mainfrom
reuse-timescale-linearisation
Open

Make supplied linearisation reuse deterministic#112
nicamo wants to merge 2 commits into
mainfrom
reuse-timescale-linearisation

Conversation

@nicamo

@nicamo nicamo commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Closes #92.

Motivation

Issue #92 identified that a bare cached dIydI does not record the passive-mode basis used to build it. Coupling-based selection and post-Jacobian mode removal can change that basis, making reuse brittle or dimensionally inconsistent.

Changes

  • Accept a supplied dIydI only with mode_selection="timescale".
  • Reject coupling-based reuse immediately, including when mode_removal=False.
  • Apply the same validation to constructor input and later initialize_from_ICs(..., dIydI=...) calls.
  • Validate supplied dIydI and dIydtheta dimensions against the selected basis, grid, and profile parameterisation.
  • Copy supplied arrays so subsequent solver operations cannot mutate the caller's cached matrices.
  • Document the compatibility contract in the solver API.
  • Add executed Example 05d showing how to cache and reuse a linearisation, run a GS-backed linear step, and recognize unsupported configurations.

Scope

This does not remove mode_removal. Fresh coupling-based linearisations can continue to use it. Timescale selection continues to disable post-Jacobian mode removal automatically. The restriction applies specifically to externally supplied current-response Jacobians, whose column basis must be deterministic.

Validation

  • freegsnke/tests/test_mode_selection.py: 6 passed.
  • Example 05d executed end to end with six linearisation workers and no error outputs.
  • The reused and source solvers produced matching cached matrices, current updates, and GS-backed jtor after a linear evolution step.

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.

[Bug] Re-using previous linearisation matrices (dIydI, dIydtheta, and dvdId) in evolutive solves

1 participant