Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAD-X integration #197

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from
Draft

MAD-X integration #197

wants to merge 9 commits into from

Conversation

ansantam
Copy link
Collaborator

@ansantam ansantam commented Jun 27, 2024

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

from cpymad.madx import Madx

madx = Madx()
madx.call(file='general_tt43.madx')
twiss = madx.table.twiss
print(twiss.name, twiss.s, twiss.l)

With Xsuite objects or JSON output

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.

Current status

  • Loading TFS with pyoptics
  • Using AWAKE beamline from the official repository
  • Implementing only those elements

Future steps

  • Using cpymad
  • Loading a circular lattice (different sizes)

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

  • New feature (non-breaking change which adds functionality)
  • Documentation (update in the documentation)

Checklist

  • I have updated the changelog accordingly (required).
  • My change requires a change to the documentation.
  • I have updated the tests accordingly (required for a bug fix or a new feature).
  • I have updated the documentation accordingly.
  • I have reformatted the code and checked that formatting passes (required).
  • I have have fixed all issues found by flake8 (required).
  • I have ensured that all pytest tests pass (required).
  • I have run pytest on a machine with a CUDA GPU and made sure all tests pass (required).
  • I have checked that the documentation builds (required).

Note: We are using a maximum length of 88 characters per line

@ansantam ansantam added the enhancement New feature or request label Jun 27, 2024
@ansantam ansantam self-assigned this Jun 27, 2024
@jank324 jank324 mentioned this pull request Jul 10, 2024
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants