feat(solver): Residual-Aware Dynamic Preconditioning (RAD-P) for Issue #818 - #823
Draft
duushgu wants to merge 5 commits into
Draft
feat(solver): Residual-Aware Dynamic Preconditioning (RAD-P) for Issue #818#823duushgu wants to merge 5 commits into
duushgu wants to merge 5 commits into
Conversation
added 5 commits
September 7, 2026 18:37
- Replace hardcoded periodic 25-step preconditioner update cadence with stagnation and curvature-aware dynamic updates (RAD-P). - Plumb adaptive_preconditioner_update through VmecINDATA, FlowControl, IdealMhdModel, Vmec, PyBind11, and Python VmecInput (default: false). - Add stagnation detection (res0 plateauing over 15+ steps) and curvature jump protection (fsq > 10 * res0) with 5-step quench window and 50-step ceiling. - Add C++ and Python unit tests verifying exact physical equilibrium fidelity. - Benchmark across 21 test and QUASR configurations demonstrates a net reduction of 1,273 iterations (-4.85% overall, -27.2% on quasr_65579).
…P preconditioner updates
…eature/adaptive-preconditioner-update
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.
Change
Replaces the fixed 25-iteration preconditioner update interval with a residual-aware decision function (
shouldUpdateRadialPreconditioner) controlled by a newVmecInputfieldadaptive_preconditioner_update(defaultfalse).Cause
kPreconditionerUpdateInterval = 25is a compile-time constant inideal_mhd_model.cc. The value is inherited from the original Fortran VMEC without derivation. In early multigrid stages the residual drops orders of magnitude per dozen iterations; a 25-step-old block-tridiagonal factor can misalign the metric and triggerBAD_JACOBIANresets. In late stages with sub-percent per-step improvement the full refactor is wasted cost.Evidence
Tested across 21 configurations: 9 standard test suite equilibria (including
up_down_asym) and 12 QUASR stellarator configurations.Notable:
quasr_65579-915 iterations (-27.2%),up_down_asym-105 iterations (-3.3%).max |Delta_R| < 4e-4across all 21 configurations relative to baseline with flag off.Tests
vmec_test.cc:AdaptivePreconditionerMatchesEquilibrium-- runs 4 equilibria with flag on and off; assertsmax |Delta_R| < 1e-3. Tolerance set to the numerical noise expected from trajectory differences when the converged state is identical.tests/test_iteration.py:test_adaptive_preconditioner_matches_equilibrium-- same 4 configurations at the Python level; same tolerance.Scope
adaptive_preconditioner_updatedefaults tofalse. Execution is bit-identical to current code whenfalse. No configuration in the 21-case benchmark regresses in iteration count.