vmecpp.qs module¶
Quasisymmetry objectives built only from the public geometry API.
The metric is the one SIMSOPT’s QuasisymmetryRatioResidual implements: for
quasisymmetry the ratio (B x grad B . grad psi) / (B . grad B) is constant
on a flux surface, so
- f = sum_j w_j < [ (1/B^3) ( (N - iota M) B x grad B . grad psi
(M G + N I) B . grad B ) ]^2 >
with < . > the flux-surface average, G and I the poloidal and
toroidal current profiles, and (M, N) the desired helicity. Discretized on
a uniform (theta, phi) grid over one field period this is a sum of squares,
- R = sqrt( w_j nfp dtheta dphi / V’ * sqrt(g) ) / B^3
( (N - iota M) B x grad B . grad psi - (M G + N I) B . grad B ),
which is what quasisymmetry_residuals returns.
Everything is computed from the product-basis geometry contract in JAX. The
flux-surface measure sqrt(g) matters: dropping it changes the objective,
and its derivative is one of the two errors that only show up end to end.
- vmecpp.qs.magnetic_field_strength(geometry, coordinates)¶
Return
|B|reconstructed fromR,Z,lambda, and fluxes.- Parameters:
geometry (
Geometry)coordinates (
Array)
- Return type:
Array
- vmecpp.qs.quasisymmetry_residuals(geometry, surfaces=(0.5,), *, helicity_m=1, helicity_n=0, weights=None, ntheta=63, nphi=64)¶
Return the flat vector of quasisymmetry residuals
R.helicity_n = 0is quasi-axisymmetry. The residuals are normalized so that the sum of their squares is the objectivef; this matches SIMSOPT’sQuasisymmetryRatioResidual.residuals()term by term.