Correct no-GS coupling norms and preserve timescale selection - #94
Merged
Conversation
kpentland
approved these changes
Aug 11, 2026
kpentland
reviewed
Aug 19, 2026
Collaborator
There was a problem hiding this comment.
Nice clear updates.
I've also added a few extra details to the Portone and Leuer stability parameters to help users interpret their meaning (not sure why I didn't add this before...)
kpentland
reviewed
Aug 19, 2026
Collaborator
There was a problem hiding this comment.
Changes make the mode selection much clearer - how to do this is now reflected in Example10.
kpentland
approved these changes
Aug 19, 2026
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
mode_selectionpolicy separating coupling-based reduction from timescale-only reduction;maininc38b910.Merge order
This PR should be merged after #93. That PR corrects the normal-mode Green maps used when evaluating the no-GS plasma responses; this PR then corrects how those responses are normalised and used for mode selection. After #93 lands, this branch must be updated and the mode-selection and dynamics regressions rerun. The shared growth-rate notebook and test should retain both #93's Green-map correction and this PR's explicit timescale-selection policy.
Coupling-norm correction
prepare_build_dIydI_j()returns a finite-difference columndIydInoGS = delta_Iy / delta_I_used.It also prepares
delta_I_nextfor the later full Jacobian. Previously,build_dIydI_noGS()divided the already normalised column bydelta_I_next, mixing two finite-difference evaluations. The stored coupling metric is now simply:self.ndIydI_no_GS[j] = np.linalg.norm(dIydInoGS)This correction does not change perturbation calibration or the subsequent full-GS Jacobian calculation.
Mode-selection policies
The new keyword argument is appended to the constructor signature, preserving positional compatibility. Its default is
mode_selection="coupling", which preserves existing behavior.mode_selection="coupling"(default)The no-GS calculation both calibrates finite-difference perturbations and estimates plasma coupling.
fix_n_vessel_modes=N, retain theNstrongest-coupled passive modes.fix_n_vessel_modes=-1, combinemax_mode_frequencywith the no-GS coupling thresholds.mode_removalmay subsequently remove weakly coupled modes using the full-GS Jacobian.The norm correction in this PR affects this policy, as intended.
Scope and caution: the coupling ranking is calculated about the equilibrium supplied at initialisation. Passive-mode coupling can evolve with plasma position and shape, so an initially selected reduced basis may cease to be representative during a substantially evolving trajectory. For such cases, the retained set should be validated across representative equilibria, or
mode_selection="timescale"should be used for equilibrium-independent selection. This caveat is now stated in the solver API, lower-level mask documentation, growth-rate example, and pulse-design example.mode_selection="timescale"The no-GS calculation is still used to calibrate finite-difference perturbation sizes, but its coupling norms do not affect which modes are retained.
fix_n_vessel_modes=N, retain exactly theNlowest-frequency (longest-timescale) passive modes.fix_n_vessel_modes=-1, retain only modes belowmax_mode_frequency.The lower-level selector rejects attempts to combine a fixed timescale count with coupling masks.
Dynamics regression
The review discussion exposed that the growth-rate fixture's intended policy was ambiguous. Under the previous implicit coupling policy, correcting the norm swapped seven of the 50 selected passive modes and changed the instability timescale from
0.05857045 sto0.05900355 s.The fixture now requests
mode_selection="timescale", asserts that passive modes0..49are retained, and obtains0.05899346 s(reference0.05900 sat the existing 0.1% tolerance). This reference is independent of the corrected coupling ranking.Validation
3 passed;39 passed, 4 skipped;black --checkandisort --check-onlypass for all modified files;4/4checks passed, including the full notebook workflow (virtual circuits, growth rates, and pulse design).