Help with twiss file

Hi Luigi, All

I have some confusion on the twiss file format required to use Linebuilder.
I looked at the example file and understood some of the contents but got lost as I scrolled down.

The manual says I can create a twiss file using Mad-X but the URL for that says that it is frozen and recommends migrating to Xsuite.

Do you have any documentation or explanation on the contents that need to be dumped? I plan to seek the help of the accelerator physicists to create such a file for me but need to know what information I should request.

Many thanks
Sunil

Hi Sunil,

Thank you for your question, and for kickstarting the discussions in the LineBuilder category!

To directly answer your question, the very minimum contents that must be present in the twiss files are:

  • NAME (element name)
  • KEYWORD (element type)
  • S (longitudinal coordinate in the curvilinear reference frame) [meters]
  • L (element length) [meters]

This is the minimum that LineBuilder requires to compute the position of the elements and build the line. Of course, to build any realistic accelerator, one needs to provide further parameters, such as magnetic strengths, orbit offsets, etc. Please see below a more complete list of quantities which may also be used by LineBuilder:

For historical reasons, the MAD-X generated twiss files have become something of a standard format. The first lines of the file typically contain multiple flags marked by the β€˜@’ character which are properly documented in the MAD-X manual. These are not required by LineBuilder and are ignored by the parser. Parsing starts when the line beginning with the β€˜*’ character is found, which identifies the columns names. The subsequent lines contain the respective data for each column.

While a global shift from MAD-X to Xsuite has been encouraged and indeed observed for certain purposes, MAD-X is still a perfectly reliable and widely used software, which can easily be installed and used from python by simply doing pip install cpymad. The twiss parser of LineBuilder has been developed based on the format of the MAD-X generated twiss tables, so naturally this path would be the most straightforward. This being said, if other options such as Xsuite, elegant, etc., are preferred among your accelerator physicists colleagues, it is also possible to define the optical lattice with it, and then export the twiss table according to the MAD-X format. Both are viable possibilities and the most appropriate will depend on your context.

In the future we may integrate an automatized conversion of the twiss table if particularly relevant for the community. Your feedback on this would actually be much appreciated.

I hope this clarifies the expected twiss format and information. Please don’t hesitate to get in touch if you have any further questions.

Best regards,
Nuno Duarte

1 Like