Reduce static GS boundary Green memory - #97
Merged
Conversation
kpentland
approved these changes
Aug 15, 2026
kpentland
force-pushed
the
static-gs-performance
branch
from
August 15, 2026 10:37
f509ae9 to
4f63987
Compare
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
This reduces the memory used by the static Grad-Shafranov solver's free-boundary Green operator.
Primary impact: memory
On the standard 65 x 129 static-solver test equilibrium:
This should be regarded primarily as a RAM optimization.
Secondary timing impact
The reduced allocation and contraction also provide a modest speed benefit in the same test:
These timing gains are secondary and will depend on grid resolution, limiter area, and nonlinear iteration count.
Merge dependency: no-X-point fallback
This branch should be rebased onto
limiter-only-plasma-domainbefore merging.The current
streamliningno-X-point path can setlimiter_core_mask=None. In that state,Jtor_part2may normalize and distribute current over the computational domain, including outside the limiter. During testing, one early Newton probe produced nonzero current in 5,245 outside-limiter cells, representing approximately 397 kA in absolute current, although the converged equilibrium returned to exactly zero outside.This PR deliberately assumes that plasma current is confined inside the limiter. Without the no-X-point fix, an exploratory state could retain outside current in the GS right-hand side while excluding it from the boundary integral. The
limiter-only-plasma-domainbranch resolves this at the profile level by constructing a limiter-constrained core mask when no relevant X-point is available, preserving both current confinement and profile normalization.After rebasing, the combined implementation should include a regression test asserting that no-X-point profile evaluations return zero current outside the limiter.
Verification
python -m pytest -q freegsnke/tests/test_static_solver.py2.2e-9 Wb/rad, or1.3e-8of the flux range