New functionality: be able to directly load MAD-X files in Cheetah
Ways to do this
There are many ways of using MAD-X. If the lattice is small enough, everything can be defined directly within the MAD-X script .madx.
Other people have distinct .beam, .ele, .str, and .seq files, but not every user defines all of those. It is common that people only have a .seq and .madx file.
A way of circumventing this is by loading information from the TFS files produced by the twiss command in MAD-X, but it requires that the user has made sure to print out all the relevant attributes of each element (check here).
With direct TFS Twiss output
Loading with pyoptics
The TFS file needs to be loaded somehow. I am now using the tools from pyoptics, but it might not be a stable solution depending on the maintenance of that repository. Right now I get an error when using python 3.12 due to the deprecated imp module (substituted by importlib in 3.12) which limits the current version to 3.11.
Loading with cpymad
One can also use the cpymad functionalities like this:
One could load a line object from Xsuite that was saved as JSON, run the Twiss and get the values from there.
Nice feature to have, but since the majority of users across laboratories have old MAD-X script, the most useful functionality now would be to load from TFS.
Description
New functionality: be able to directly load MAD-X files in Cheetah
Ways to do this
There are many ways of using MAD-X. If the lattice is small enough, everything can be defined directly within the MAD-X script
.madx
.Other people have distinct
.beam
,.ele
,.str
, and.seq
files, but not every user defines all of those. It is common that people only have a.seq
and.madx
file.A way of circumventing this is by loading information from the TFS files produced by the
twiss
command in MAD-X, but it requires that the user has made sure to print out all the relevant attributes of each element (check here).With direct TFS Twiss output
Loading with
pyoptics
The TFS file needs to be loaded somehow. I am now using the tools from pyoptics, but it might not be a stable solution depending on the maintenance of that repository. Right now I get an error when using python 3.12 due to the deprecated
imp
module (substituted byimportlib
in 3.12) which limits the current version to 3.11.Loading with
cpymad
One can also use the cpymad functionalities like this:
With
Xsuite
objects or JSON outputOne could load a line object from Xsuite that was saved as JSON, run the Twiss and get the values from there.
Nice feature to have, but since the majority of users across laboratories have old MAD-X script, the most useful functionality now would be to load from TFS.
Current status
pyoptics
Future steps
cpymad
Motivation and Context
To be able to use Cheetah directly with MAD-X lattices, and start loading circular accelerators and see if problems arise with very large lattices.
Types of changes
Checklist
flake8
(required).pytest
tests pass (required).pytest
on a machine with a CUDA GPU and made sure all tests pass (required).Note: We are using a maximum length of 88 characters per line