Handle VMEC axis events in particle tracing - #47
Draft
rogeriojorge wants to merge 1 commit into
Draft
Conversation
rogeriojorge
force-pushed
the
agent/handle-vmec-axis-events
branch
from
July 30, 2026 22:08
9f6291f to
d4edb1f
Compare
rogeriojorge
force-pushed
the
agent/handle-vmec-axis-events
branch
from
July 30, 2026 22:08
d4edb1f to
f219dd8
Compare
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.
What changed
s=1e-6for the two collisionless VMEC guiding-center models:GuidingCenterandGuidingCenterAdaptative.s=1loss event and retain its event mask separately from axis terminations.infsaves with the last finite sampled state for diagnostics and plotting.Tracinginstance as a static argument.Scope
This PR intentionally does not change solver limits, progress-meter defaults, rejected-step handling, or the public constructor API. Those generic controls belong in a separate PR.
The axis event is not applied to full-orbit models: VMEC guiding-center states use flux coordinates
(s, theta, phi, v_parallel), while full-orbit states use Cartesian(x, y, z, vx, vy, vz). Treating the first full-orbit coordinate asswould be physically incorrect. Collision and field-line models are also unchanged in this focused fix.Root cause
VMEC
(s, theta, phi)coordinates are singular ats=0. A QI test orbit crossed the magnetic axis, but ESSOS previously terminated only ats=1, so it extrapolated the VMEC representation to negative flux and the solve became increasingly stiff. Separately,loss_fractiontreated the completeTracinginstance as a static JIT argument, causing a long post-trace compilation for larger trajectory arrays.Validation
python -m pytest tests/test_dynamics.py -q: 15 passedtmax=5e-4, 10 CPU devices:GuidingCenter: 6.27 s, 0% lost, 1 axis-unresolvedGuidingCenterAdaptative: 12.98 s, 0% lost, 1 axis-unresolvedtrace_particles.pykeeps its original structure and completes without stalling.The full repository suite previously showed 81 passes and 13 unrelated pre-existing failures under JAX 0.11.