Add Boozer/SFL chart gate tests and signed chartmap Jacobian#398
Open
krystophny wants to merge 2 commits into
Open
Add Boozer/SFL chart gate tests and signed chartmap Jacobian#398krystophny wants to merge 2 commits into
krystophny wants to merge 2 commits into
Conversation
krystophny
force-pushed
the
feat/boozer-chart-gates
branch
from
July 17, 2026 11:28
0758d54 to
56a8b65
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.
Follow-up to #397 (the intended base branch
fix/395-boozer-cold-inversewas merged to main and deleted, so this stacks directly on main). Implements the ROADMAP straight-field-line/Boozer gauge gates as executable tests, ahead of the JOREK-sourced chart builder.What
Signed Jacobian accessor.
chartmap_metric_tensorreturnssqrtg = sqrt(abs(det g)), which cannot distinguish a consistent chart orientation from a sign flip across a seam. New type-boundcs%jacobian_det(u)returns the signeddet(dx/du)from the analytic covariant basis;metric_tensoris unchanged.Gate (a) — signed periodic Jacobian positivity (
test_chartmap_gate_jacobian): full-torus scan of a right-handed nfp = 3 rotating-frame fixture with probe pairs straddling every field-period seam, the theta seam, and the 2pi wrap; requires det > 0 everywhere (rho > 0), seam-pair continuity at solver-noise level, exact 2pi periodicity, and|jacobian_det| == sqrtgto 1e-9. A mirrored fixture must give det < 0 everywhere, proving the accessor is genuinely signed. Same positivity scan on the circular nfp = 1 fixture.Gate (b) — bounded flux-label drift (
test_chartmap_gate_fieldline): field lines of the productionneo_circular_tokamak_fieldlie exactly on circular tori and are straight in the geometric angles; a tangency self-check verifies the closed-form trace againstcompute_bfieldat 1e-12 first. 27 launches x 50 toroidal transits x 12 samples are pulled back through the warminvert_cart(orbit-pusher pattern, guess chained along the line). All 16 227 pullbacks must report LOCATED; max flux-label drift gate 1e-5 (measured 7.9e-7).Gate (c) — launch-independent rotational transform (same test): endpoint transform estimate from unwrapped chart angles for the 3 radii x 3 poloidal x 3 toroidal launch ensemble; ensemble spread and deviation from the analytic transform (
-B_pol/B_torin the right-handed chart) gated at 5e-4, the analytic worst-case bound from the bounded periodic angle offsets (measured error ~9e-6).Gate (d) — converged field reconstruction against the native evaluator (
test_chartmap_gate_reconstruction): the consumer pipeline — native field sampled on chart nodes, periodic batch splines of (B_R, B_phi, B_Z, |B|), physical probe ->invert_cart-> spline evaluation — compared against the native evaluator at three resolutions (9,16,8) -> (17,32,16) -> (33,64,32). Gates: monotone error decrease, contraction >= 4 per refinement (measured 33x/15x vector, 7.7x/31x |B|), finest max relative error < 8e-5, the WP3 analytic |B| gate bound (measured 3.2e-8 vector, 5.3e-9 |B|).Cleanup.
chartmap_invert_cartcomputed a seed-refinement residual and error code (ierr_seed) that nothing read;chartmap_refine_cart_seedloses the two dead outputs.Scope (honest limits)
Gate (d) runs against the analytic circular fixture, not JOREK: libneo has no JOREK-to-chartmap builder yet, so a JOREK-native gate (d) (against
jorek_fieldon an AUG restart) must land together with that builder. The fixtures are smooth nested-surface charts; shaped/X-point geometry, non-nested regions, toroidal ripple, and the Fourier Boozer-transform pipeline are not covered. The constant-transform field makes gate (c) a launch-independence and absolute-value check, not a radial-profile-ordering check.Tests
New:
test_chartmap_gate_jacobian,test_chartmap_gate_fieldline,test_chartmap_gate_reconstruction(shared fixture writerchartmap_gate_fixtures, self-contained NetCDF in the style oftest_chartmap_invert_cart). Full localctest: 98/98 pass (Debug preset, gfortran), including all existing chartmap/Boozer inverse tests against the cleaned-up cold inverse.