ECP-WarpX / impactx

high-performance modeling of beam dynamics in particle accelerators with collective effects
https://impactx.readthedocs.io
Other
28 stars 20 forks source link

MAD-X input reader: constants, elements, lines, segments #104

Open ax3l opened 2 years ago

ax3l commented 2 years ago

We want to support reading accelerator lattices directly from MAD-X input files. For this, we will need to support at least the following syntax elements:

from MAD-X definitions.

For that, we could explore if @janfschmidt's palattice could be used as a library :) https://github.com/janfschmidt/palattice

References on MAD-X:

Example files for MAD-X lattices:

ax3l commented 2 years ago

@qianglbl and @cemitch99 mentioned: MAD-X also has an "optics" command that can output a simple CSV file with one element per row. IMPACT-Z can read this file in.

We might want to add support to:

Optics CSV file structure

Columns with names (column 1), type (column 2) and values: meaning of the column depends on the element type (column 2).

Values: note that parameters are not in that CSV file, e.g., fringe-field details.

ax3l commented 2 years ago

With the new Python layer, we could also implement the first MAD(-X) reader on the Python side.

Warp has some routines we can get logic from (@jlvay):

n01r commented 2 years ago

This is the link to the Python MADX parser that Andreas Adelmann wrote and pushed to a repo https://gitlab.psi.ch/adelmann/pymadxparser.git

Implemented via #214

np-eazy commented 2 years ago

https://github.com/MethodicalAcceleratorDesign/MAD-X/blob/master/src/mad_parse.c is the current source code where parsing seems to happen. I'll have to look closer to see what it is parsing into, and how that connects with any notion of a persistent structure of environments.

My planned approach right now is to mod the source code such that it reads MadX scripts normally, but instead of executing on LHC or some other particle accelerator the information is kept in some notion of an environment; upon script end or intended pause, the environment is DFS-traversed and dumped onto a general YAML or JSON.

Right now I intend on only a static implementation of an accelerator's initial state; anything and everything in the MadX file refers to t=0 for the simulation.

np-eazy commented 2 years ago

Mad-X Parser Notes.pdf I am no longer working on this issue. Here are my design notes and plans moving forward with implementing this issue.