vmec_jax.field¶
Magnetic field representation utilities.
This module implements the contravariant magnetic-field components used by VMEC:
bsupu: B^u (poloidal-angle contravariant component)
bsupv: B^v (toroidal-angle contravariant component)
- in terms of:
the Jacobian
sqrtg(signed),flux functions
phipf(s) = dPhi/dsandchipf(s) = dChi/ds,and the VMEC
lambdafield (stored in a scaled form; seelamscale).
Important convention¶
VMEC’s public wout files store the lambda coefficients in a scaled form, and VMEC
multiplies lambda-derivatives by a scalar lamscale before using them in B.
We follow that convention here so we can validate against the bundled wout reference.
The formulas implemented here match VMEC’s bcovar + add_fluxes logic:
bsupv = overg * (phipf + lamscale * lam_u) bsupu = overg * (chipf + lamscale * lam_v)
where overg = 1 / (signgs * sqrtg) following VMEC’s bcovar convention.
Functions
|
Compute B^2 from contravariant components and the covariant metric. |
|
Compute Cartesian B=(Bx,By,Bz) from contravariant components. |
|
Compute Cartesian magnetic field from a solved VMEC state. |
|
Compute covariant components (B_u, B_v) from contravariant (B^u, B^v). |
|
Compute (bsupu, bsupv) from a |
|
Compute (bsupu, bsupv) from a Jacobian and lambda derivatives. |
|
Reconstruct VMEC's chips(js) (full-mesh poloidal flux function) from chipf(js). |
|
Resolve full-mesh |
|
Invert VMEC's 1D half-mesh averaging map. |
|
VMEC half-mesh averaging map used for several radial 1D arrays. |
|
Compute VMEC's lamscale from phips and the radial grid s. |
|
Infer VMEC's signgs (+1 or -1) from a signed Jacobian array. |