Skip to content

Migrate compute_nabla_s to the direct VMEC metric and regenerate golden #103

Description

@krystophny

Context

PR #100 cut RABE over to the merged libneo boozer_sub. To keep the golden record valid with no logic change, libneo restored the splined sqrt_g_ss output gated on use_B_r (itpplasma/libneo#335), and compute_nabla_s reads that splined value, as before.

The more accurate alternative

nabla_s = |grad s| can be computed directly from the VMEC metric at the Boozer->VMEC back-mapped angles, bypassing the field3d spline interpolation of sqrt_g_ss:

call boozer_to_vmec(s, theta_B, phi_B, theta_V, phi_V)
call splint_vmec_data(s, theta_V, phi_V, ...)        ! R, dR/d*, dZ/d*
call metric_tensor_vmec(...)                          ! g_vmec, sqrt_g_vmec
nabla_s = sqrt(g(2,2)*g(3,3) - g(2,3)**2)/abs(sqrt_g_vmec)

All three calls are public in libneo boozer_sub / spline_vmec_sub. This drops a spline-interpolation layer, so it is strictly closer to the true metric.

Difference and tradeoff

  • At the golden grid (grid_refinement=6, multharm=6) the splined and direct values differ by ~1.5e-6 — the exact uniform drift seen on Use libneo boozer_sub; drop rabe local converter #100, since every output carries the dr_dAtheta proportional to 1/nabla_s prefactor.
  • At coarse grids the gap is larger (~1e-2 at multharm=3).
  • Cost: a boozer_to_vmec Newton solve per nabla_s evaluation.

Action when adopted

  1. Replace compute_nabla_s with the direct-metric path (already prototyped on Use libneo boozer_sub; drop rabe local converter #100 history).
  2. Regenerate the golden record (make golden_update) on the pinned nix toolchain — outputs shift by ~1.5e-6.
  3. Revisit boozer_sub: restore sqrt_g_ss output, gated on use_B_r libneo#335: if RABE is the only sqrt_g_ss consumer, the gated restore can be dropped from boozer_sub.

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