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
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