fold alpha to improve convergence#2223
Open
unalmis wants to merge 16 commits into
Open
Conversation
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 PR takes the simple implementation of #2220 and adds folded-alpha handling for
Gamma_deltaandGamma_alpha.The core idea is that bounce wells are found on long field lines spanning
multiple field periods. The new code
maps long-field-line wells back to effective single-period alpha samples, then
applies the
Gamma_deltaandGamma_alphareductions on that folded alphagrid.
The implementation keeps the existing
Gamma_c Velascopath unchanged.Only
Gamma_deltaandGamma_alphacall the folded-alpha path.1. Folding Long-Field-Line Wells Into Alpha Samples
For each bounce well with endpoints
(zeta_1, zeta_2), the code assigns thewell to a field-period segment using the midpoint approximation
This is implemented in
_well_field_period(...).For a base field-line label
alpha_j, a well in field-period copykcorresponds to the effective single-period label
This follows the field-line map logic: moving along the long field line by one
field period shifts the equivalent single-period alpha label by
iota * 2*pi / NFP.The folded representation is indexed conceptually as
with optional surface or batch axes in front. A boolean
maskrecords whichfolded entries correspond to real wells.
2. Why Local Well Ranking Is Needed
The original well axis is sorted along the extended field line. After folding,
that is not the right branch index. We need the well index local to each
single-field-period copy.
Example:
_local_well_rank(...)computes this local indexr. This keeps one physicallocal branch coherent across the folded alpha grid. Without it, a single local
well branch could be split across different global long-line well slots, which
would make the alpha scans in
Gamma_alphainconsistent.3. Gamma_delta Reduction
The threshold is stored in tangent space, so the outward candidate condition is
implemented without forming
arctan:For folded alpha data, the reduction computes
In code:
The
maskremains essential for alpha quadrature weights, but it is not neededinside
has_alpha_out_candidate: dummy wells have zeroradialand zeropoloidal, so the strict candidate condition cannot be true for them.4. Gamma_alpha Reduction
Gamma_alphauses two signed branch scores:Positive
alpha_out_candidatemeans the radial drift is sufficiently outward.Positive
alpha_in_candidatemeans the radial drift is sufficiently inward.The loss interval orientation depends on the sign of the poloidal drift:
The edge-case logic is:
The folded path integrates
5. Loss-Cone Indicator And Fractional Cells
_LossConebuilds periodic intervals from two signed scores:A start crossing occurs when
S_startcrosses from nonpositive to positive.For adjacent samples with previous score
p <= 0, current scores > 0, andspacing
h, linear interpolation givesEquivalently, the distance backward from the current sample to the root is
That is the formula used by
_root(...)and_root_nonuniform(...).After roots are found, each start root is paired with the nearest downstream
stop root using forward periodic distance:
For
order=1, the output is a fractional generalized indicator, not just aboolean mask. Each alpha sample receives
For folded nonuniform alpha samples,
cell_iis a periodic Voronoi cell. Theneighbor distances and cell widths are computed by
_periodic_voronoi_widths.The final alpha contribution is
This improves the placement of the discontinuous loss-cone boundary without
interpolating
v_tau.