Skip to content

Drop legacy chartmap file support; fix chartmap example and README#368

Merged
krystophny merged 1 commit into
mainfrom
fix/chartmap-drop-legacy-and-example
Jun 8, 2026
Merged

Drop legacy chartmap file support; fix chartmap example and README#368
krystophny merged 1 commit into
mainfrom
fix/chartmap-drop-legacy-and-example

Conversation

@krystophny

Copy link
Copy Markdown
Member

Follow-up to the review comments on #334 (cc @Rykath — this is now changed).

Risk tier

  • T2: local numerical logic

Correctness contract

Intended behavior change

  • read_boozer_chartmap no longer supports legacy chartmap files. It now requires:
    • the rmajor global attribute (previously optional via a has_rmajor flag that defaulted rmajor to 0.0), and
    • the endpoint-included theta_field/zeta_field Bmod grid (previously fell back to the geometry grid).
      GVEC-exported chartmaps (tools/gvec_to_boozer_chartmap.py) always write both, so current files are unaffected. Pre-converter legacy files now abort with a clear NetCDF error instead of being silently accepted with rmajor = 0.

Behavior that must not change

  • map2disc-based chartmaps: unaffected. They are read through the libneo coordinate reader (make_chartmap_coordinate_system), not read_boozer_chartmap.
  • Field values, scaling, and the symplectic/Boozer paths for valid current-format files.

Coordinate / unit conventions

  • Unchanged. Bmod stays on the endpoint-included field grid spanning the full 2pi (poloidal) and 2pi/nfp (toroidal) period.

Numerical invariants

  • Unchanged.

Tests added

  • unit: updated generate_test_boozer_chartmap.c to emit the current format (rmajor + field-grid Bmod); updated test_chartmap_aphi_abscissa.f90 (the rmajor-present check is now covered by mandatory read + value assertion).

Golden-record impact

  • unchanged

Failure modes considered

  • Legacy file fed to the strict reader: now aborts with NetCDF error at att rmajor / inq_dim theta_field, by design.

Manual validation

Also addresses the two doc comments on #334:

  • examples/simple_chartmap.in: dropped the forced startmode = 2 (the comment was incorrect, and it required a start.dat). The default startmode = 1 samples the sbeg flux surface and needs no start.dat.
  • README.md: removed the incorrect "startmode = 2 means particle coordinates are in chartmap Boozer space" bullet (startmode is field-type independent).

Verification

Failing before (strict reader against the old legacy-format test generator):

read_boozer_chartmap: NetCDF error at att rmajor: NetCDF: Attribute not found
ERROR STOP read_boozer_chartmap failed
0% tests passed, 1 tests failed out of 1
	 20 - test_boozer_chartmap (Failed)

Passing after (generator updated to current format):

1/5 Test #18: test_chartmap_aphi_abscissa ......   Passed
2/5 Test #20: test_boozer_chartmap .............   Passed
3/5 Test #21: test_chartmap_startmode1 .........   Passed
4/5 Test #22: test_chartmap_scaling ............   Passed
5/5 Test #23: test_boozer_chartmap_roundtrip ...   Passed
100% tests passed, 0 tests failed out of 5

Pre-existing, unrelated to this PR: the *_map2disc chartmap tests fail on a clean main in this environment because the optional libneo Python binding _efit_to_boozer is not built (ModuleNotFoundError: No module named '_efit_to_boozer'). This PR introduces no new failures relative to that baseline.

@krystophny krystophny added tier/T2 local numerical logic size/S review size up to 100 changed lines labels Jun 8, 2026
PR 334 review follow-up.

- read_boozer_chartmap now requires the rmajor attribute and the
  endpoint-included theta_field/zeta_field Bmod grid. Remove the
  has_rmajor flag, its 0.0 default consumers, and the geometry-grid
  Bmod fallback. GVEC-exported chartmaps always carry these fields;
  pre-converter legacy files are no longer supported. map2disc-based
  chartmaps go through the libneo coordinate reader and are unaffected.
- Update the C test generator to emit rmajor and Bmod on the field grid.
- examples/simple_chartmap.in: drop the forced startmode = 2. The
  default startmode = 1 samples the sbeg flux surface and needs no
  start.dat; the removed comment was also incorrect about startmode.
- README: drop the incorrect "startmode = 2 means particle coordinates
  are in chartmap Boozer space" bullet (startmode is field-independent).
@krystophny krystophny force-pushed the fix/chartmap-drop-legacy-and-example branch from 9b02923 to 191ba53 Compare June 8, 2026 15:37
@krystophny krystophny enabled auto-merge (squash) June 8, 2026 15:40
@krystophny krystophny merged commit 042958c into main Jun 8, 2026
7 checks passed
@krystophny krystophny deleted the fix/chartmap-drop-legacy-and-example branch June 8, 2026 16:18
@Rykath

Rykath commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Looks good to me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/S review size up to 100 changed lines tier/T2 local numerical logic

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants