Skip to content

Latest commit

 

History

History
155 lines (108 loc) · 4.58 KB

twiss.rst

File metadata and controls

155 lines (108 loc) · 4.58 KB

Twiss

Xtrack provides a twiss method associated to the line that can be used to obtain the lattice functions and other quantities like tunes, chromaticities, slip factor, etc. This is illustrated in the following examples. For a complete description of all available options and output quantities, please refer to the :meth:`xtrack.Line.twiss` method documentation.

The following example shows how to use the twiss method to obtain the lattice functions and other quantities for a ring.

.. literalinclude:: generated_code_snippets/twiss.py
   :language: python

figures/twiss.png

Lattice functions and accelerator parameters as obtained by Xtrack twiss.

The twiss table has several access options as illustrated in the following example.

.. literalinclude:: generated_code_snippets/table_slicing.py
   :language: python

When the RF cavities are disabled or not included in the lattice (or when the longitudinal motion is artificially frozen) it is not possible to use the standard method for the twiss calculation. In these cases, the "4d" method can be used, as illustrated in the following examples:

.. literalinclude:: generated_code_snippets/method_4d.py
   :language: python

The 4d mode of the twiss can be used providing in input the initial momentum. This feature can be used to measure the non-linear momentum detuning of a ring as shown in the following example:

.. literalinclude:: generated_code_snippets/tune_vs_delta.py
   :language: python

figures/twiss_vs_delta.png

The twiss calculation can be performed with initial conditions provided by the users or extracted from an existing twiss table, as illustrated in the following example:

.. literalinclude:: generated_code_snippets/twiss_range.py
   :language: python

figures/twiss_range.png

Result of all twiss calculations with initial conditions shown in the example above.

The twiss method can also be used to find the periodic solution for a portion of a beam line, as illustrated in the following example:

.. literalinclude:: generated_code_snippets/twiss_range_periodic.py
   :language: python

figures/twiss_periodic.png

Result of the twiss with periodic boundary conditions.

The transverse and longitudinal beam sizes can be computed from the twiss table, as illustrated in the following example:

.. literalinclude:: generated_code_snippets/compute_beam_sizes.py
   :language: python

figures/twiss_beam_sizes.png

Beam sizes as obtained from twiss.

The twiss table holds the information to convert particle physical coordinates into normalized coordinates. This can be done with the method get_normalized_coordinates as illustrated in the following example:

.. literalinclude:: generated_code_snippets/compute_norm_coordinates.py
   :language: python

The reverse` flag, allows getting the output of the twiss in the counter-rotating reference system. When reverse is True, the ordering of the elements is reversed, the zero of the s` coordinate and of the phase advances is set at the new start, the sign of the coordinates s` and x` is inverted, while the sign of the coordinate y is unchanged. This is illustrated in the following example:

.. literalinclude:: generated_code_snippets/twiss_reverse.py
   :language: python

figures/twiss_reverse.png

Closed Orbit of the two LHC beams in the same reference frame. This is obtained setting reverse=True on the twiss of beam 2.

It is possible to change the default behavior of the twiss method for a given line using line.twiss_defaults, which is a dictionary with the desired default twiss arguments. This is illustrated in the following example:

.. literalinclude:: generated_code_snippets/twiss_default.py
   :language: python

See :doc:`synchrotron_radiation`.