mbtrack2.tracking.element module

This module defines the most basic elements for tracking, including Element, an abstract base class which is to be used as mother class to every elements included in the tracking.

class Element[source]

Bases: object

Abstract Element class used for subclass inheritance to define all kinds of objects which intervene in the tracking.

abstract track(bunch: Beam | Bunch)[source]

Track a Beam or Bunch object through this Element. This method needs to be overloaded in each Element subclass.

Parameters

beam : Beam or Bunch object

static parallel(track: Callable) Callable[source]

Defines the decorator @parallel which handles the embarrassingly parallel case which happens when there is no bunch to bunch interaction in the tracking routine.

Adding @Element.parallel allows to write the track method of the Element subclass for a Bunch object instead of a Beam object.

Parameters

trackfunction, method of an Element subclass

track method of an Element subclass which takes a Bunch object as input

Returns

track_wrapper: function, method of an Element subclass

track method of an Element subclass which takes a Beam object or a Bunch object as input

static track_bunch_if_non_empty(track: Callable) Callable[source]

Defines the decorator @track_bunch_if_non_empty which handles the case where a track method should not be called if the bunch is empty.

Should be added only the track method defined for Bunch elements.

Parameters

trackfunction, method of an Element subclass

track method of an Element subclass which takes a Bunch object as input

Returns

track_wrapper: function, method of an Element subclass

track method of an Element subclass which takes a Bunch object as input

_abc_impl = <_abc._abc_data object>
class LongitudinalMap(ring: Synchrotron)[source]

Bases: Element

Longitudinal map for a single turn in the synchrotron.

Parameters

ring : Synchrotron object

__init__(ring: Synchrotron)[source]
track(bunch: Bunch | Beam)[source]

Tracking method for the element. No bunch to bunch interaction, so written for Bunch objects and @Element.parallel is used to handle Beam objects.

Parameters

bunch : Bunch or Beam object

_abc_impl = <_abc._abc_data object>
class SynchrotronRadiation(ring: Synchrotron, switch: ndarray[tuple[int, ...], dtype[_ScalarType_co]] = array([True, True, True]), qexcitation: bool = True)[source]

Bases: Element

Element to handle synchrotron radiation, radiation damping and quantum excitation, for a single turn in the synchrotron.

Parameters

ring : Synchrotron object switch : bool array of shape (3,), optional

If False in one plane (long, x, y), the synchrotron radiation is turned off. The default is True, in all three planes.

qexcitationbool, optional

If False, the quantum excitation is turned off. The default is True.

__init__(ring: Synchrotron, switch: ndarray[tuple[int, ...], dtype[_ScalarType_co]] = array([True, True, True]), qexcitation: bool = True)[source]
track(bunch: Bunch | Beam)[source]

Tracking method for the element. No bunch to bunch interaction, so written for Bunch objects and @Element.parallel is used to handle Beam objects.

Parameters

bunch : Bunch or Beam object

_abc_impl = <_abc._abc_data object>
class SkewQuadrupole(strength: float)[source]

Bases: Element

Thin skew quadrupole element used to introduce betatron coupling (the length of the quadrupole is neglected).

Parameters

strengthfloat

Integrated strength of the skew quadrupole [m].

__init__(strength: float)[source]
track(bunch: Bunch | Beam)[source]

Tracking method for the element. No bunch to bunch interaction, so written for Bunch objects and @Element.parallel is used to handle Beam objects.

Parameters

bunch : Bunch or Beam object

_abc_impl = <_abc._abc_data object>
class TransverseMapSector(ring: Synchrotron, alpha0: ndarray[tuple[int, ...], dtype[_ScalarType_co]], beta0: ndarray[tuple[int, ...], dtype[_ScalarType_co]], dispersion0: ndarray[tuple[int, ...], dtype[_ScalarType_co]], alpha1: ndarray[tuple[int, ...], dtype[_ScalarType_co]], beta1: ndarray[tuple[int, ...], dtype[_ScalarType_co]], dispersion1: ndarray[tuple[int, ...], dtype[_ScalarType_co]], phase_diff: ndarray[tuple[int, ...], dtype[_ScalarType_co]], chro_diff: ndarray[tuple[int, ...], dtype[_ScalarType_co]], adts: ndarray[tuple[int, ...], dtype[_ScalarType_co]] | None)[source]

Bases: Element

Transverse map for a sector of the synchrotron, from an initial position s0 to a final position s1.

Parameters

ringSynchrotron object

Ring parameters.

alpha0array of shape (2,)

Alpha Twiss function at the initial location of the sector.

beta0array of shape (2,)

Beta Twiss function at the initial location of the sector.

dispersion0array of shape (4,)

Dispersion function at the initial location of the sector.

alpha1: array of shape (2,)

Alpha Twiss function at the final location of the sector.

beta1array of shape (2,)

Beta Twiss function at the final location of the sector.

dispersion1array of shape (4,)

Dispersion function at the final location of the sector.

phase_diffarray of shape (2,)

Phase difference between the initial and final location of the sector.

chro_diffarray of shape (2,)

Chromaticity difference between the initial and final location of the sector.

adtsarray of shape (4,), optional

Amplitude-dependent tune shift of the sector, see Synchrotron class for details. The default is None.

__init__(ring: Synchrotron, alpha0: ndarray[tuple[int, ...], dtype[_ScalarType_co]], beta0: ndarray[tuple[int, ...], dtype[_ScalarType_co]], dispersion0: ndarray[tuple[int, ...], dtype[_ScalarType_co]], alpha1: ndarray[tuple[int, ...], dtype[_ScalarType_co]], beta1: ndarray[tuple[int, ...], dtype[_ScalarType_co]], dispersion1: ndarray[tuple[int, ...], dtype[_ScalarType_co]], phase_diff: ndarray[tuple[int, ...], dtype[_ScalarType_co]], chro_diff: ndarray[tuple[int, ...], dtype[_ScalarType_co]], adts: ndarray[tuple[int, ...], dtype[_ScalarType_co]] | None)[source]
_compute_chromatic_tune_advances(bunch: Beam | Bunch) tuple[float, float][source]
_compute_new_coords(bunch, tune_advance, plane)[source]
track(bunch: Bunch | Beam)[source]

Tracking method for the element. No bunch to bunch interaction, so written for Bunch objects and @Element.parallel is used to handle Beam objects.

Parameters

bunch : Bunch or Beam object

_abc_impl = <_abc._abc_data object>
class TransverseMap(ring: Synchrotron)[source]

Bases: TransverseMapSector

Transverse map for a single turn in the synchrotron.

Parameters

ring : Synchrotron object

__init__(ring: Synchrotron)[source]
_abc_impl = <_abc._abc_data object>
transverse_map_sector_generator(ring: Synchrotron, positions: ndarray[tuple[int, ...], dtype[_ScalarType_co]], **kwargs) list[TransverseMapSector][source]

Convenience function which generate a list of TransverseMapSector elements from a ring:

  • if an AT lattice is loaded, the optics functions and chromaticity is

computed at the given positions. - if no AT lattice is loaded, the local optics are used everywhere.

Tracking through all the sectors is equivalent to a full turn (and thus to the TransverseMap object).

Parameters

ringSynchrotron object

Ring parameters.

positionsarray

list of longitudinal positions in [m] to use as starting and end points of the TransverseMapSector elements. The array should contain the initial position (s=0) but not the end position (s=ring.L), so like position = np.array([0, pos1, pos2, …]).

See at.physics.nonlinear.chromaticity for **kwargs

Returns

sectorslist

list of TransverseMapSector elements.