Repository navigation
Conversation
Trace field lines in phi with fixed-step RK4 alongside the magnetic axis and take a weighted Birkhoff average of the poloidal advance per field period. The axis is the fixed point of the field-period map, solved with Newton inside solvax.root_solve for implicit gradients. Includes tests (axis, VMEC agreement, gradient vs finite differences) and a convergence example. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
essos/rotational_transform.py: a concise (~110 lines), jit-able and differentiable computation of the rotational transform ι of the flux surfaces of a coil field (BiotSavart).rotational_transform(field, R0, Z0, nfp, axis=None, n_periods=64, steps=32): traces field lines in φ (dR/dφ = R B_R/B_φ,dZ/dφ = R B_Z/B_φ) with fixed-step RK4 alongside the magnetic axis, and returns ι = nfp/2π · Σ wₙ Δθₙ, a weighted Birkhoff average of the poloidal advance per field period. It converges faster than any power of N on regular surfaces (Das, Saiki, Sander & Yorke 2017; Sander & Meiss 2020; Ruth & Bindel 2024), while the plain winding-number average converges like 1/N. It accepts arrays of starting points, so one call gives a whole ι profile.magnetic_axis(field, RZ0, nfp): the fixed point of the field-period map. The guess is first refined with Poincaré-orbit centroids, because Newton diverges fromfield.r_axisfor the QA coils. Newton then polishes it inside SOLVAXroot_solve, so gradients use the implicit function theorem and never unroll the solver.field_period_map: a reusable Poincaré map.Context and alternatives
BoozerSurface(Giuliani et al. 2022), which solves for the surface and ι together, or from Poincaré tracing. DESC computes ι from the equilibrium's current and λ. Both are heavier than needed when you only have coils.B(xyz), and is differentiable with respect to coil DOFs and currents. None of the open PRs compute ι from coils. QFM #27 (QFM) is related work on surfaces.Verification
examples/rotational_transform/iota_from_coils_convergence.py(≈30 s on CPU) produces the figure below:tests/test_rotational_transform.py(3 tests, ~13 s) checks the axis fixed point (1e-10), agreement with the VMEC ι range and convergence in N, andjax.gradof ι with respect to all coil DOFs against central finite differences (rtol 1e-4).🤖 Generated with Claude Code