Skip to content

QL: preserve full-step endpoints after mode-3 refinement#126

Open
krystophny wants to merge 10 commits into
mainfrom
fix/flux-pumping/helcore-grid-parity
Open

QL: preserve full-step endpoints after mode-3 refinement#126
krystophny wants to merge 10 commits into
mainfrom
fix/flux-pumping/helcore-grid-parity

Conversation

@krystophny

Copy link
Copy Markdown
Member

Closes #123. This child is stacked on #125, #119, #121, and #124 and remains open against main.

Summary

  • keep both mode-3 field-line endpoints on full Runge-Kutta points
  • when the requested subdivision count is odd, double the complete subdivision vector before constructing the refined grid
  • test endpoint parity, original-node retention, ordering, and field-line reversal equivariance through the production divider

Invariants

The repair leaves the second-order source stencils and their 5/12, 2/3, and -1/12 weights unchanged. It preserves all requested points, local refinement ratios, coordinate orientation, trapped/passing mapping inputs, source signs, Fourier convention, CGS units, field-line boundary conditions, ABI, and storage layout. Even-count grids are bitwise unchanged. An odd-count retry grid uses twice the requested intervals, so both endpoints are full points and every istep +/- 2 access remains inside the solve range.

The added resolution is limited to mode-3 retries whose requested interval count is odd. No branch in this stack is authorized to merge before the programme-wide gate.

Verification

Test fails before fix

With the production divider unchanged:

$ ctest --test-dir build -R '^phi_divider_parity_test$' --output-on-failure
0% tests passed, 1 tests failed out of 1
FAIL: refinement made the final Runge-Kutta point a half step

The production mapping for [2,1,2,2] ended at index 7. Original-node retention, ordering, and reversal checks already passed, isolating the endpoint contract.

Test passes after fix

$ fo
Static: OK (331 modules)
Build: OK
Tests: OK
Lint: OK
All stages passed

$ make test
100% tests passed, 0 tests failed out of 10

$ ctest --test-dir build -R '^phi_divider_parity_test$' --output-on-failure
100% tests passed, 0 tests failed out of 1

$ git diff --check
<no output>

The odd request maps to [4,2,4,4], ending at full-step index 14. The reversed request produces the reflected mapping, and every original point remains ordered and represented.

The 16 separately managed external-data regressions remain registered under regression;external-data; this branch does not mark that unavailable-data gate passed. A bounds-checked HELCORE production run and golden-record comparison remain integration gates.

isw_qflux_NA=1 with in_file_pert='none' assembles an identically zero
non-axisymmetric source. That zero vector is the Arnoldi seed, so its
normalization divides by zero (0/0 -> NaN) and zhseqr then fails to
converge at every step, spinning without qflux output. Reject the
configuration in check() with a clear message instead.
Add an optional right-hand side to the non-axisymmetric solve: the
drive of a single-helicity perturbation given by a radial corrugation
field (delta B^s/B_0^phi)_mn and an electrostatic potential harmonic
Phi_mn. The vpar corrugation piece enters the A1/A2 force channels
with velocity weights a3m and x^2 (sigma-odd), the ExB piece with
weights x^-1 and a1m (sigma-even); the two new velocity moments are
computed in compute_sources. Input via new &ntv_input variables
(isw_hel_drive, m_theta_hel, hel_brad_re/im, hel_phim_re/im), default
off. Band profiles, moments and dimensional prefactors follow a
CAS-checked derivation (see issue #118).

Off by default: golden-record QL summary.h5 is reproduced to 1e-15
against a main build.
Review findings on the drive commit: fold the x^(3k-4) weight into a
single power so the x=0 quadrature node stays finite; skip the moment
quadrature on the precomputed-matrix-element path and reject
isw_hel_drive at run time when the moments are unavailable; reject the
unvalidated relativistic branch, reconstruction mode and unset species
data; deallocate asource_hel in collop_unload.
The zero-source guard added upstream rejects isw_qflux_NA=1 with
in_file_pert='none'. With the misalignment drive, that configuration is
valid: the drive supplies the non-axisymmetric source. Relax the guard
so it fires only when the drive is off or all its amplitudes are zero.
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.

QL: source_flux reads npl(istep+-2) past bounds -> heap corruption on helical-axis geometries

1 participant