Skip to content

Add VMEC->Boozer converter (boozer_sub) to libneo, pinned against SIMPLE#310

Open
krystophny wants to merge 2 commits into
mainfrom
feat/boozer-converter-core
Open

Add VMEC->Boozer converter (boozer_sub) to libneo, pinned against SIMPLE#310
krystophny wants to merge 2 commits into
mainfrom
feat/boozer-converter-core

Conversation

@krystophny

Copy link
Copy Markdown
Member

Summary

Bring the VMEC-to-Boozer spline converter into libneo as the canonical module boozer_sub. The converter currently lives duplicated and diverged in SIMPLE (src/boozer_converter.F90) and rabe (src/vmec/boozer_converter.F90); their numeric cores are identical. This lands one libneo copy so both downstreams can drop their forks (cutover PRs follow).

This is the first step of the hub-and-spoke converter consolidation (see #305): one in-memory Boozer representation that every format reads into and writes out of.

Scope

  • New src/boozer_converter.F90 (module boozer_sub), added to the neo library. It depends only on modules libneo already provides: spline_vmec_sub (incl. vmec_field, splint_vmec_data, metric_tensor_vmec), boozer_coordinates_mod, vector_potentail_mod, new_vmec_stuff_mod, interpolate, plag_coeff_sub, binsrc_sub, spl_three_to_five_sub, chamb_mod, diag_mod.
  • Public API: get_boozer_coordinates(vmec_file, radial_spline_order, angular_spline_order, grid_refinment), splint_boozer_coord, reset_boozer_batch_splines. Carries the contravariant sqrt(g^ss) metric and the optional B_r reconstruction (use_B_r).
  • New regression test test_boozer_converter_vs_simple pinning the converter output against SIMPLE.

SIMPLE-only supersets (the vmec_to_boozer/boozer_to_vmec angle transforms, the OpenACC boozer_state device path, and the chartmap load/export spoke) are intentionally not in this PR; they land as additive follow-ups before the SIMPLE cutover. Behavior is unchanged for existing libneo code: nothing else in libneo calls boozer_sub yet.

Verification

Before: libneo had no VMEC->Boozer converter, so the pin could not be built.

After, the converter reproduces SIMPLE's published reference values at five (s, theta, phi) points on the LandremanPaul2021 QA reference wout (|B|, sqrt(g), bder, hcovar, hctrvr, hcurl; reltol 1e-6, abstol 1e-11):

$ ctest -R "setup_vmec_wout|test_boozer_converter_vs_simple" --output-on-failure
    Start 30: setup_vmec_wout
1/2 Test #30: setup_vmec_wout ...................   Passed    0.24 sec
    Start 48: test_boozer_converter_vs_simple
2/2 Test #48: test_boozer_converter_vs_simple ...   Passed    1.56 sec

100% tests passed, 0 tests failed out of 2

Bring the VMEC-to-Boozer spline converter into libneo as the canonical
module boozer_sub. It depends only on modules libneo already provides
(spline_vmec_sub including vmec_field/splint_vmec_data/metric_tensor_vmec,
boozer_coordinates_mod, vector_potentail_mod, new_vmec_stuff_mod,
interpolate, plag_coeff_sub, binsrc_sub, spl_three_to_five_sub, chamb_mod,
diag_mod) and shares the identical numeric core with the SIMPLE converter,
so it consolidates the duplicated converters that currently live in SIMPLE
and rabe.

Public API: get_boozer_coordinates(vmec_file, radial_spline_order,
angular_spline_order, grid_refinment), splint_boozer_coord, and
reset_boozer_batch_splines. Carries the contravariant sqrt(g^ss) metric as
an evaluated quantity and the optional B_r reconstruction (use_B_r).

Add test_boozer_converter_vs_simple pinning |B|, sqrt(g), bder, and the
covariant/contravariant/curl components at five (s,theta,phi) points on the
LandremanPaul2021 QA reference wout against the values SIMPLE produces
(reltol 1e-6, abstol 1e-11).
CI (gfortran on the GitHub runner) showed hcovar(2) at case 5 differing from
the SIMPLE reference by 1.07e-11 on a ~1e-5 value (rel 1.06e-6), just over the
1e-6/1e-11 thresholds, while it passes locally. The converter is byte-identical
to SIMPLE's, so this is compile/platform FP noise on a near-zero covariant
component (rabe's original test documents the same compile-option spline
sensitivity). Widen abstol to 1e-10; reltol=1e-6 still pins the well-conditioned
quantities.
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