Refactor and fix MAD-NG interface - #834
Open
jgray-19 wants to merge 1 commit into
Open
Conversation
Refactors xtrack/madng_interface.py around readable Lua programs and explicit data exchange through pymadng. The refactor centralizes MAD-NG model setup, Twiss ranges, target construction, tracking, R-matrix evaluation, Jacobian extraction, and cleanup while preserving TPSA variables correctly. Updates the interface for pymadng==0.9.6, meaning that phix and phiy needs to be rename dto wxp and wyp. MADX.option.rbarc is configured before loading the generated MAD-NG sequence (rbends had the wrong length - additional test) Fixed the mapdef usage and docstring. Fixes Line.match(..., use_tpsa=True) with TargetRmatrixTerm by retrieving results through unique internal range-term keys. Adds coverage for TPSA R-matrix matching.
jgray-19
marked this pull request as ready for review
August 2, 2026 01:03
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.
Description
Refactors xtrack/madng_interface.py around readable MAD-NG program string blocks and explicit data exchange through pymadng. Updates the interface for pymadng==0.9.6, meaning that
phixandphiyneeds to be renamed towxpandwyp.In the current conversion - the RBends have the wrong length, therefore
MADX.option.rbarcis configured before loading the generated MAD-NG sequence, rather than after, which has no effect.Fixed the mapdef usage and docstring.
Fixes
Line.match(..., use_tpsa=True)withTargetRmatrixTermby retrieving results through unique internal range-term keys. Adds coverage for TPSA R-matrix matching.Checklist
Mandatory:
Optional: