vmec_jax.vmec_residueΒΆ

VMEC residue/getfsq-style scalar residuals for parity work.

VMEC2000 reports scalar force residual measures:

  • fsqr : R-equation residual norm

  • fsqz : Z-equation residual norm

  • fsql : lambda-equation residual norm

Internally these are computed from Fourier-space force arrays produced by tomnsps and normalized by the force norms fnorm and fnormL computed in bcovar.

This module implements the scalar pieces needed for output-parity tests against bundled VMEC2000 wout files.

Functions

vmec_apply_m1_constraints(*, frzl[, lconm1])

Apply VMEC's converged-iteration m=1 polar constraints to Fourier forces.

vmec_apply_scalxc_to_tomnsps(*, frzl, s)

Apply VMEC's post-tomnsps scalxc scaling to force coefficient blocks.

vmec_force_norms_from_bcovar(*, bc, trig, ...)

Compute (fnorm, fnormL) using VMEC's bcovar normalization formulas.

vmec_force_norms_from_bcovar_dynamic(*, bc, ...)

Compute (fnorm, fnormL) using VMEC's bcovar normalization formulas without wout.

vmec_fsq_from_tomnsps(*, frzl, norms[, ...])

Compute (fsqr,fsqz,fsql) from VMEC-style tomnsps outputs.

vmec_fsq_from_tomnsps_dynamic(*, frzl, norms)

Compute (fsqr,fsqz,fsql) as JAX scalars from VMEC-style tomnsps outputs.

vmec_fsq_sums_from_tomnsps(*, frzl[, ...])

Return the sum-of-squares components used in vmec_fsq_from_tomnsps.

vmec_gcx2_from_tomnsps(*, frzl[, lconm1, ...])

Return VMEC-style (gcr2, gcz2, gcl2) sum-of-squares as JAX scalars.

vmec_gcx2_from_tomnsps_np(*, frzl[, ...])

NumPy-only version of vmec_gcx2_from_tomnsps.

vmec_pwint_from_trig(trig, *, ns, nzeta)

Return VMEC's pwint weights as a (ns,ntheta3,nzeta) array.

vmec_rz_decompose_signed(state, static, *[, ...])

Return (rcc, rss, zsc, zcs) in signed (m,n>=0) storage.

vmec_rz_norm_from_state(*, state, static[, ...])

Compute rzNorm from Fourier coefficients (n>=0 storage convention).

vmec_scalxc_from_s(*, s, mpol[, cache])

Reproduce VMEC's scalxc(js,m) factors used to scale forces before residue.

vmec_wint_from_trig(trig, *, nzeta)

Return VMEC's angular integration weights as a (ntheta3,nzeta) array.

vmec_zero_m1_zforce(*, frzl[, enabled])

Zero the m=1 Z-force blocks used by the axis constraint.

Classes

VmecForceNorms(fnorm, fnormL, r1)

VMEC normalization constants used by getfsq and residue.

VmecFsqScalars(fsqr, fsqz, fsql)

VmecFsqScalarsDynamic(fsqr, fsqz, fsql)

JAX-traceable scalar residuals (fsqr, fsqz, fsql).

VmecFsqSums(gcr2, gcz2, gcl2, gcr2_blocks, ...)

Unnormalized sum-of-squares pieces used by getfsq-style scalars.