New MAD-X Parser#1295
Conversation
Sudo Vibe me a MAD-X parser.
Elements can specify at=X, FROM=other_element: position relative to another element, not absolute.
MAD-X fills gaps with drifts
|
@cemitch99 I added the warning to |
|
Discussed today: will also add a runtime warning when |
|
@cemitch99 I added runtime warnings when
|
|
Discussed in last two week's developer meeting: approved & ready for merge :) Will remove the one little merge conflict in |
351b443 to
0f97793
Compare
E.g., the FNAL booster files
ion_proton et al.
- Official MAD-X PARTICLE= species are covered explicitly: positron, electron, proton,
antiproton, posmuon, negmuon, ion.
- Fixed the muon mass calculation.
- Matched ION to the MAD-X source behavior, with an inline comment.
- read_beam() now passes explicit MAD-X MASS and CHARGE through, so unknown community
particle names can still work if the beam is fully specified.
|
The pyi stub generator shows some bug after this merge, I'll fix that upstream in the next day |
Summary
This PR overhauls two files:
MADXParser.py: a tokenizer and parser that tries to truthfully reimplement the MAD-X C parser, ultimately returning a flattened MAD-X lattice. This file is best written with a powerful LLM (mostly Claude 4.6 was used). It is covered by unit tests for central MAD-X input language features and should not require much updates in the future.madx_to_impactx.py: the actual translator from MAD-X element to ImpactX element(s). This file we need to be able to maintain "by hand" as we add new elements and handle physics translation corner-cases.To Do
ring_seq_bb_spch_thin (2).madx(GDrive)pip-ii-booster-combined.madxandsbbooster-cooked.madxroutine to instantiate an impactx lattice based on a synergia lattice #1271acc-models-lhc/scenarios/cycle/pp/ramp/1178/model.madx(gitlab)from_file(...)Call, FILENAMESupport #512: MAD-X: Call, FILENAME Support