Skip to content

New MAD-X Parser#1295

Open
ax3l wants to merge 47 commits intoBLAST-ImpactX:developmentfrom
ax3l:new-madx-parser
Open

New MAD-X Parser#1295
ax3l wants to merge 47 commits intoBLAST-ImpactX:developmentfrom
ax3l:new-madx-parser

Conversation

@ax3l
Copy link
Copy Markdown
Member

@ax3l ax3l commented Feb 5, 2026

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

  • sudo Vibe me a MAD-X parser in Python
    • iterate, test, iterate, test, ...
  • Existing MAD-X examples still work.
  • Do more complex examples parse now?
    • simple booster
    • Nov 2024 Booster file ring_seq_bb_spch_thin (2).madx (GDrive)
    • Eric's pretty complete pip-ii-booster-combined.madx
    • IOTA v8.3 / v84_2 (2019-01-01)
    • LHC: acc-models-lhc/scenarios/cycle/pp/ramp/1178/model.madx (gitlab)
  • How do we want to control element models (linear, paraxial, hamiltonian)?
    • for MAD-X and PALS as a start, we could have a model option in from_file(...)
  • Tests: MAD-X input language
  • Tests: more MAD-X physics files?
  • Close MAD-X input reader: constants, elements, lines, segments #104: MAD-X input reader: constants, elements, lines, segments
  • Close MAD-X: Call, FILENAME Support #512: MAD-X: Call, FILENAME Support
  • Close MAD-X Reader: RBEND #709: MAD-X Reader: RBEND

@ax3l ax3l requested review from cemitch99 and egstern February 5, 2026 23:15
@ax3l ax3l added changes input scripts / defaults Changes the syntax or meaning of input scripts and/or defaults component: python Python bindings labels Feb 5, 2026
@ax3l ax3l added this to the Advanced Methods (SciDAC-5) milestone Feb 5, 2026
@ax3l ax3l force-pushed the new-madx-parser branch from 324f69a to 6713e2a Compare March 25, 2026 18:02
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Mar 25, 2026

Merging this PR will not alter performance

✅ 37 untouched benchmarks


Comparing ax3l:new-madx-parser (003c057) with development (4aadf29)

Open in CodSpeed

@ax3l ax3l changed the title [WIP] New MAD-X Parser New MAD-X Parser Mar 26, 2026
@ax3l ax3l force-pushed the new-madx-parser branch from 9c34110 to aa1b320 Compare March 27, 2026 08:20
ax3l added 7 commits March 27, 2026 01:22
Very common and universally accepted to be 0
- search more eager for include files: current file dir, root dir of top-level file, pwd
- `mqxa.1r1, k1 := kqx.r1+ktqx1.r1, polarity=+1`
Not implemented, but used in LHC lattice for a loop
afterwards.
Before we hard-coded monitors in MAD-X to read "monitor".
Now we honor their true name in the MAD-X file.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changes input scripts / defaults Changes the syntax or meaning of input scripts and/or defaults component: python Python bindings

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MAD-X Reader: RBEND MAD-X: Call, FILENAME Support MAD-X input reader: constants, elements, lines, segments

2 participants