vmec_jax.integrals

Angle and radial integrals.

This module computes simple derived quantities from geometric outputs, notably the volume profile from the Jacobian sqrtg.

Conventions

The geometry kernel in vmec_jax.geom computes sqrtg as the Jacobian for coordinates (s, theta, phi_phys), where phi_phys is the physical toroidal angle.

Most of vmec_jax works on one field period using the VMEC internal coordinate zeta in [0, 2π), related by:

phi_phys = zeta / NFP

Therefore, when integrating over the stored zeta grid, include the factor dphi = dzeta / NFP.

VMEC wout convention note

VMEC stores several 3D fields in wout_*.nc on the radial half mesh and with angles (theta, zeta) over one field period. In VMEC’s internal bookkeeping, many 1D radial integrals are computed using a simple rectangle rule:

V = Σ_{js=2..ns} (dV/ds)(js) * hs

This differs from a trapezoidal rule and matters at low radial resolution. For regression tests against wout, use the helpers in this module that implement the same conventions.

Functions

cumrect_s_halfmesh(y, s)

Cumulative rectangle-rule integral for half-mesh data.

cumtrapz_s(y, s)

Cumulative trapezoidal integral in s with V(0)=0.

dvds_from_sqrtg(sqrtg, theta, zeta, nfp)

Compute dV/ds from sqrtg by integrating over angles.

dvds_from_sqrtg_zeta(sqrtg, theta, zeta, *)

Compute dV/ds by integrating over (theta, zeta).

volume_from_sqrtg(sqrtg, s, theta, zeta, nfp)

Convenience wrapper: compute (dvds, V) from sqrtg.

volume_from_sqrtg_vmec(sqrtg, s, theta, zeta, *)

Compute (dvds, V) using VMEC-like (wout) conventions.