Skip to content

Add Boozer/SFL chart gate tests and signed chartmap Jacobian#398

Open
krystophny wants to merge 2 commits into
mainfrom
feat/boozer-chart-gates
Open

Add Boozer/SFL chart gate tests and signed chartmap Jacobian#398
krystophny wants to merge 2 commits into
mainfrom
feat/boozer-chart-gates

Conversation

@krystophny

Copy link
Copy Markdown
Member

Follow-up to #397 (the intended base branch fix/395-boozer-cold-inverse was 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_tensor returns sqrtg = sqrt(abs(det g)), which cannot distinguish a consistent chart orientation from a sign flip across a seam. New type-bound cs%jacobian_det(u) returns the signed det(dx/du) from the analytic covariant basis; metric_tensor is 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| == sqrtg to 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 production neo_circular_tokamak_field lie exactly on circular tori and are straight in the geometric angles; a tangency self-check verifies the closed-form trace against compute_bfield at 1e-12 first. 27 launches x 50 toroidal transits x 12 samples are pulled back through the warm invert_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_tor in 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_cart computed a seed-refinement residual and error code (ierr_seed) that nothing read; chartmap_refine_cart_seed loses 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_field on 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 writer chartmap_gate_fixtures, self-contained NetCDF in the style of test_chartmap_invert_cart). Full local ctest: 98/98 pass (Debug preset, gfortran), including all existing chartmap/Boozer inverse tests against the cleaned-up cold inverse.

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.

1 participant