Skip to content

Derive sign_sqrtg from the loaded field and reject mismatches #113

Description

@krystophny

Problem

sign_sqrtg is currently supplied independently in rabe.in and is used linearly in

dr/dA_theta = sign_sqrtg / (|grad s| psi_tor_edge).

Consequently a valid field file plus the wrong sign_sqrtg silently reverses every signed Lambda_A, Lambda_B, Lambda_S, lambda_LC_bB, and remainder output. The loaded Boozer field already has enough orientation metadata to determine this sign, so the duplicate user input can disagree with the field tuple.

This is separate from the intentional B_zeta + iota B_theta > 0 input-domain check.

Reproduction

At current main, run the bundled QH VMEC case twice with identical field and profiles, changing only

sign_sqrtg = -1

to

sign_sqrtg = +1

Both inputs are accepted, but the signed coefficient chain changes orientation even though the field did not.

Expected behavior

  • The default derives the signed Boozer-Jacobian orientation from the loaded VMEC, boozmn, or extended-chartmap field tuple.
  • An explicitly supplied +1 or -1 is accepted only if it agrees with the field and otherwise aborts before coefficients are evaluated.
  • A pure coordinate relabel such as theta'=-theta transforms the field metadata and all dependent inputs as one tuple; RABE must reproduce the corresponding coefficient-covector law.

Proposed one-PR scope

  • Carry signgs in boozer_field_t after every supported loader.
  • Make sign_sqrtg=0 mean automatic and use it as the default.
  • Retain explicit +1/-1 only as a checked assertion.
  • Add a negative mismatch test.
  • Add a native VMEC original/relabel regression that compares every emitted coefficient and scalar output.

The underlying VMEC signgs ingestion fix is tracked by libneo issue itpplasma/libneo#308.

Existing diagnostic implementation and evidence

Branch diag/cartesian-sign-gate, commit 7b012103c993cd6a824abe95c91e314646e467b7, implements the proposed behavior and pins the corresponding libneo diagnostic fix.

The native QH original/theta'=-theta pair passes with:

  • Lambda_A/B/S, lambda_LC_bB, and the non-omnigenous remainder reversing as poloidal covectors;
  • s_tor, nu_star_crit, major radius, and split_maxima invariant;
  • maximum signed relative residual 1.092e-7;
  • an explicit wrong sign rejected before coefficient evaluation.

Verification:

fo build
ctest --test-dir build \
  -R 'TestReadNamelist|GoldenRecord|VmecThetaRelabelCoefficients' \
  --output-on-failure

Non-goals

  • changing any coefficient formula;
  • bypassing or deciding the physical meaning of the positive-B_zeta+iota B_theta orientation gate;
  • adding asymmetric boozmn support;
  • auditing the work-in-progress precession branch.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions