Track Methods¶
Utility functions for creating transfer maps for elements.
- track_methods.base_rmatrix(length: Tensor, k1: Tensor, hx: Tensor, species: Species, energy: Tensor | None = None) Tensor¶
Create a first order universal transfer map for a beamline element.
- Parameters:
length – Length of the element in m.
k1 – Quadrupole strength in 1/m**2.
hx – Curvature (1/radius) of the element in 1/m.
species – Particle species of the beam.
energy – Beam energy in eV.
- Returns:
First order transfer map for the element.
- track_methods.base_ttensor(length: Tensor, k1: Tensor, k2: Tensor, hx: Tensor, species: Species, energy: Tensor | None = None) Tensor¶
Create a second order universal transfer map for a beamline element. Uses MAD convention.
- NOTE: It is possible that gradient components are missing when computing the
over second order T tensors or beams tracked with them in very few highly specific scenarios. Even when it happens, it is unlikely to have a meaningful impact. This comment is left here to make sure this caveat is known.
- Parameters:
length – Length of the element in m.
k1 – Quadrupole strength in 1/m**2.
k2 – Sextupole strength in 1/m**3.
hx – Curvature (1/radius) of the element in 1/m.
species – Particle species of the beam.
energy – Beam energy in eV.
- Returns:
Second order transfer map for the element.
- track_methods.combined_rotation_misalignment_matrix(angle: Tensor, misalignment: Tensor) Tensor¶
Apply misalignment and then rotation in the x-y plane.
- Parameters:
angle – Rotation angle in rad, for example angle = np.pi/2 for vertical = dipole.
misalignment – Misalignment vector [dx, dy] in m.
- Returns:
Combined rotation and misalignment matrix.
- track_methods.drift_matrix(length: Tensor, energy: Tensor, species: Species) Tensor¶
Create a first order transfer map for a drift space.
- track_methods.misalignment_matrix(misalignment: Tensor) tuple[Tensor, Tensor]¶
Shift the beam for tracking beam through misaligned elements.
- track_methods.rotation_matrix(angle: Tensor) Tensor¶
Rotate the coordinate system in the x-y plane.
- Parameters:
angle – Rotation angle in rad, for example angle = np.pi/2 for vertical = dipole.
- Returns:
Rotation matrix to be multiplied to the element’s transfer matrix.