at.lattice.elements.element_object#
Base Element
object
Classes
|
Base class for AT elements |
- class Element(family_name, **kwargs)[source]#
Bases:
object
Base class for AT elements
- Parameters:
family_name (str) – Name of the element
All keywords will be set as attributes of the element
- classmethod get_subclasses()[source]#
Iterator over the subclasses of this element
Because of multiple inheritance, some classes may appear several times
- static from_dict(elem_dict, index=None, check=True, quiet=False)#
Builds an
Element
from a dictionary of attributes
- divide(frac)[source]#
split the element in len(frac) pieces whose length is frac[i]*self.Length
- Parameters:
frac – length of each slice expressed as a fraction of the initial length.
sum(frac)
may differ from 1.- Returns:
elem_list – a list of elements equivalent to the original.
Example
>>> Drift("dr", 0.5).divide([0.2, 0.6, 0.2]) [Drift('dr', 0.1), Drift('dr', 0.3), Drift('dr', 0.1)]
- equals(other)[source]#
Whether an element is equivalent to another.
This implementation was found to be too slow for the generic __eq__ method when comparing lattices.
- to_dict(encoder=<function _no_encoder>)#
- track(r_in, in_place=False, **kwargs)#
element_track()
tracks particles through one element of a calling the element-specific tracking function specified in the Element’s PassMethod field- Usage:
>>> element_track(element, r_in) >>> element.track(r_in)
- Parameters:
element (Element) – element to track through
r_in – (6, N) array: input coordinates of N particles. For the best efficiency, r_in should be given as F_CONTIGUOUS numpy array.
- Keyword Arguments:
in_place (bool) – If True r_in is modified in-place and reports the coordinates at the end of the element. (default: False)
omp_num_threads (int) – Number of OpenMP threads (default: automatic)
particle (Optional[Particle]) – circulating particle. Default:
lattice.particle
if existing, otherwiseParticle('relativistic')
energy (Optiona[float]) – lattice energy. Default 0.
- Returns:
r_out – (6, N, R, T) array containing output coordinates of N particles at R reference points for T turns
- transform(reference=ReferencePoint.CENTRE, dx=None, dy=None, dz=None, tilt=None, pitch=None, yaw=None, *, relative=False)#
Set the translations and rotations of an
Element
.The tilt is a rotation around the s-axis, the pitch is a rotation around the x-axis, and the yaw is a rotation around the y-axis.
A positive angle represents a clockwise rotation when looking in the direction of the rotation axis.
The transformations are not all commutative. The translations are applied before the rotations. The rotations are applied in the order Z -> Y -> X (tilt -> yaw -> pitch). The element is rotated around its mid-point. The mid-point can either be the element entrance or its centre (axis joining the entry and exit points of the element).
If relative is
True
, the previous translations and angles are rebuilt from the r3d matrix and incremented by the input arguments.PyAT describes the ultra-relativistic beam dynamics in 6D phase space coordinates, which differ from 3D spatial angles in an expansion with respect to the energy to first order by a factor \((1 + \delta)\), where \(\delta\) is the relative momentum deviation. This introduces spurious dispersion (angle proportional to \(\delta\)).
The implementation follows the one described in: https://doi.org/10.1016/j.nima.2022.167487 All the comments featuring ‘Eq’ point to the paper’s equations.
- Parameters:
elem (Element) – Element to be transformed.
reference (ReferencePoint) – Transformation reference, either
ReferencePoint.CENTRE
orReferencePoint.ENTRANCE
.dx (float | None) – Horizontal shift [m]. Default: no change.
dy (float | None) – Vertical shift [m]. Default: no change.
dz (float | None) – Longitudinal shift [m]. Default: no change.
tilt (float | None) – Tilt angle [rad]. Default: no change.
pitch (float | None) – Pitch angle [rad]. Default: no change.
yaw (float | None) – Yaw angle [rad]. Default: no change
relative (bool) – If
True
, the input values are added to the previous ones.
Attention
When combining several transformations by using multiple calls to
transform_elem()
, the reference argument must be identical for all. Otherwise, the result is unpredictable.See also
get_offsets_rotations()