Coordinates¶
Phase Space Coordinate System¶
The phase space coordinates of a particle are the six coordinates x, px, y, py, z,
pz of Bmad, with the position s along the reference curve as the independent variable. They
are defined in Track. The positions x and y are measured in the coordinate systems
described below: the branch coordinates, or the element body coordinates inside a misaligned
element.
Nomenclature¶
A bend element is any element that has a non-zero reference bend strength g_ref.
A patch element is any element that has non-zero PatchParams parameters.
An element cannot be both a bend and a patch: no tracking method accepts such an element.
Coordinate Systems Used to Describe a Machine¶
Fig. 22 The coordinate systems to describe a machine: The “branch” curvilinear coordinate system follows the bends of the accelerator. The “branch reference curve” is the \(x = y = 0\) curve of the curvilinear coordinate system. Each lattice element has “element body” coordinates which, if the element has no alignment shifts (not “misaligned”), is the same as the branch coordinates.¶
SciBmad uses two coordinate systems to describe a machine as illustrated in the figure above.
For each beamline (a branch of a lattice), a branch coordinate system is used. This curvilinear coordinate
system defines the nominal position of the lattice elements.
The branch reference curve is the \(x = y = 0\) curve of the curvilinear coordinate system.
The branch reference curve does not have to be continuous and, in particular, the coordinate
system through an element with PatchParams parameters will generally be discontinuous.
If there are no BendParams parameters with a finite
tilt_ref, the branch reference curve will be in the \((x,z)\) plane with \(y = 0\). Since
most machines are essentially horizontal, the \(x\) coordinate is typically thought of as the
“horizontal” coordinate and the \(y\) coordinate is typically thought of as the “vertical”
coordinate.
The “nominal” position of a lattice element is the position of the element without any
alignment shifts
(these position and orientation shifts which are sometimes referred to as “misalignments”).
Each lattice element has “element body”
coordinates which are attached to the physical element, and the electric and magnetic
fields of an element are described with respect to body coordinates.
If an element has no
alignment shifts, the body coordinates of the element are aligned with the
branch coordinates.
The transformation between branch and body coordinates is given in
Transformation Between Branch and Element Body Coordinates.
Element Entrance and Exit Coordinates¶
Fig. 23 Lattice elements can be imagined as “LEGO blocks” which
fit together to form the branch coordinate system. How elements
join together is determined in part by their entrance and exit coordinate frames. A) For
straight line elements the entrance and exit frames are colinear. B) For elements with a
BendParams parameter group, the
transformation from entrance to exit coordinates is a rotation about the bend center of curvature.
C) For elements with PatchParams parameters, the
exit frame may be arbitrarily positioned with respect to the entrance frame.¶
As discussed in the next section, the branch coordinate system is constructed starting with the first
element in a branch and then building up the coordinate system element-by-element.
Elements have an “entrance” and an “exit” coordinate frame as
illustrated in the above figure.
These coordinate frames are attached to the element and are part of the element body coordinates.
Most element kinds have a “straight” geometry as shown in
Fig. 23A. That is, the reference curve through the element is a straight line
segment with the \(x\) and \(y\) axes always pointing in the same direction.
For an element with BendParams parameters,
the reference curve is a segment of a circular arc as shown in
Fig. 23B. With the tilt_ref parameter set to zero, the rotation axis
between the entrance and exit frames is parallel to the \(y\)-axis (see
Lattice Element Positioning).
For Patch
elements (Fig. 23C), the exit face can be
arbitrarily oriented with respect to the entrance end.
For elements with a PatchParams group, the interior reference curve
is dependent upon the patch parameter settings (see PatchParams) and, in
general, will have a discontinuity.
Branch Coordinate Construction¶
The construction of a branch coordinate system starts at the first element of the branch, where \(s\) is zero.
Starting from the beginning element, succeeding elements are concatenated together
to form the branch coordinate system. All elements have an “upstream” and a “downstream”
end.
The downstream end of an element is always farther (at greater \(s\)-position)
from the beginning element than the upstream end of the element. Normally, particles will travel
in the \(+s\) direction, so particles will enter an element at the upstream end and exit at the
downstream end.
The element’s upstream end is the same as the element’s entrance end
(Fig. 23) and the downstream end is the same
as the element’s exit.
The procedure to connect elements together to form the branch coordinates is to ignore
element body alignment shifts and mate the downstream reference frame of
the element with the upstream reference frame of the next element in
the branch so that the \((x,y,z)\) coordinate axes coincide.
If there are body alignment shifts, the entrance and exit frames will move with the element.
However, this does not affect the branch coordinate system.
Coordinate Frames¶
Following MAD, the position of a coordinate frame within a fixed Cartesian coordinate system with axes \((X, Y, Z)\) is characterized by a vector \(\bf V\)
The orientation of a coordinate frame is described by a unitary rotation matrix \(\bf W\). The column vectors of \(\bf W\) are the unit vectors spanning the branch coordinate axes in the order \((x, y, z)\). \(\bf W\) can be expressed in terms of the three angles \(\theta\), \(\phi\), and \(\psi\) via the formula
where
Notice that these are Tait-Bryan angles and not Euler angles.
An alternative representation of the \(\bf W\) matrix (or any other rotation matrix) is to specify the axis \(\bf u\) (normalized to 1) and angle of rotation \(\beta\)
Lattice Element Positioning¶
Again following MAD, \(\bf V\) and \(\bf W\) follow from those at the start of the beamline by iteratively using the equations
where \(({\bf V}_0, {\bf W}_0)\) and \(({\bf V}_1, {\bf W}_1)\) are respectively the position and orientation of the branch coordinates at the entrance and exit ends of an element, \({\bf L}\) is the displacement vector through the element, and matrix \({\bf S}\) is the rotation of the branch coordinate system through the element. For all elements whose reference curve through them is a straight line, the corresponding \(\bf L\) and \(\bf S\) are
Where \(L\) is the length of the element.
Fig. 24 A) Rotation axes (bold arrows) for four different tilt_ref angles of \(\theta_{tr} = 0\),
\(\pm \pi/2\), and \(\pi\).
\((x_0, y_0, z_0)\) are the branch coordinates at the entrance end of the bend with
the \(z_0\) axis being directed into the page. Any rotation axis will be displaced by a distance of
the bend radius rho from the origin. B) The \((x, y, z)\) coordinates at the exit end of the bend
for the same four tilt_ref angles. In this case the bend angle is taken to be \(\pi/2\).¶
For a bend, the axis of rotation is dependent upon the bend’s tilt_ref angle
as shown in Fig. 24A. The axis of rotation points in the negative \(y_0\)
direction for tilt_ref = 0 and is offset by the bend radius rho. Here \((x_0, y_0, z_0)\)
are the branch coordinates at the entrance end of the bend with the \(z_0\) axis being directed into
the page in the figure. For a non-zero tilt_ref, the rotation axis is itself rotated about the
z_0 axis by the value of tilt_ref. Fig. 24B shows the exit coordinates for four
different values of tilt_ref and for a bend angle angle of \(\pi/2\).
For a bend, \(\bf S\) is given using Eq. (3) with
where \(\theta_{tr}\) is the tilt_ref angle. The \(\bf L\) vector for a bend is given by
where \(\alpha_b\) is the bend angle and \(\rho\) being the bend radius (\(\rho\)). Notice that since \(\bf u\) is perpendicular to \(z\), the curvilinear reference coordinate system has no “torsion”. Note: The branch coordinate system can be related to a Frenet-Serret coordinate system, but the two coordinate systems do not coincide. Frenet-Serret coordinates use the radial direction in a bend as a coordinate axis while with branch coordinates the radial direction can point anywhere in the \((x,y)\) plane.
Note: An alternative equation for \(\bf S\) for a bend is
The bend transformation above is so constructed that the transformation is equivalent to rotating the branch coordinate system around an axis that is perpendicular to the plane of the bend. This rotation axis is invariant under the bend transformation. For example, for \(\theta_{tr} = 0\) (or \(\pi\)) the \(y\)-axis is the rotation axis and the \(y\)-axis of the branch coordinates before the bend will be parallel to the \(y\)-axis of the branch coordinates after the bend as shown in Fig. 24. That is, a lattice with only bends with \(\theta_{tr} = 0\) or \(\pi\) will lie in the horizontal plane (this assuming that the \(y\)-axis starts out pointing along the \(Y\)-axis as it does by default). For \(\theta_{tr} = \pm\pi/2\), the bend axis is the \(x\)-axis. A value of \(\theta_{tr} = +\pi/2\) represents a downward pointing bend.
Particle Position Transformation¶
A point \({\bf Q}_g = (X, Y, Z)\) defined in the global coordinate system, when expressed in the coordinate system defined by \(({\bf V}, {\bf W})\) is
This is essentially the inverse of Eq. (4). That is, position vectors transform inversely to the transformation of the coordinate system.
Using Eq. (9) with Eqs. (4), the transformation of a particle’s position \({\bf q} = (x,y,z)\) and momentum \({\bf P} = (P_x, P_y, P_z)\) when the coordinate frame is transformed from frame \(({\bf V}_{i-1}, {\bf W}_{i-1})\) to frame \(({\bf V}_i, {\bf W}_i)\) is
Notice that since \({\bf S}\) (and \({\bf W}\)) is the product of orthogonal rotation matrices, \({\bf S}\) is itself orthogonal and its inverse is just the transpose
Transformation Between Branch and Element Body Coordinates¶
The element body coordinate system is the coordinate system attached to an element. Without any
alignment shifts, the branch coordinates and element body coordinates
are the same. With alignment shifts, the transformation between branch and element body
coordinates depends upon whether the branch coordinate system is straight or
bent.
When tracking a particle through an element, the particle starts at the nominal
upstream end of the element with the particle’s position expressed in branch
coordinates. Tracking from the nominal upstream end to the actual upstream face of the element
involves first transforming to element body coordinates (with \(s = 0\) in the equations below) and
then propagating the particle as in a field free drift space from the particle’s starting position
to the actual element face. Depending upon the element’s orientation, this tracking may involve
tracking backwards. Similarly, after a particle has been tracked through the physical element to the
actual downstream face, the tracking to the nominal downstream end involves transforming to
branch coordinates (using \(s = L\) in the equations below) and then propagating the particle as
in a field free drift space to the nominal downstream edge.
Straight Element Misalignment Transformation¶
For straight line elements, given a branch coordinate frame \(\Lambda_s\) with an origin a distance \(s\) from the beginning of the element, misalignments will shift the coordinates to a new reference frame denoted \(E_s\). Since misalignments are defined with respect to the middle of the element, the transformation from \(\Lambda_s\) and \(E_s\) can be accomplished using a three step process:
where \(\Lambda_\text{mid}\) and \(E_\text{mid}\) are the branch and element reference frames at the center of the element. All transformations use Eqs. (4).
The transformations are:
\(\Lambda_s \longrightarrow \Lambda_\text{mid} \): Translation to the element midpoint. For this transformation, \(\bf S\) is the unit matrix and \({\bf L} = (0, 0, L/2 - s)\).
\(\Lambda_\text{mid} \longrightarrow E_\text{mid}\): Misalignment transformation with
\(E_\text{mid} \longrightarrow E_s\): Translation to body coordinates \(E_s\). For this transformation, \(\bf S\) is the unit matrix and \({\bf L} = (0, 0, s - L/2)\).
Notice that with this definition of how elements are misaligned, the position of the center of a non-bend misaligned element depends only on the offsets, and is independent of the pitches and tilt.
Bend Element Misalignment Transformation¶
For Bend element positioning, besides the standard AlignmentParams parameters, there is the
tilt_ref (\(\theta_{tr}\)) parameter (see BendParams).
The latter affects both the reference orbit and the bend position.
Furthermore, tilt_ref is calculated with respect to
the coordinates at the beginning of the bend while, like straight elements, tilt, offsets, and
pitches are calculated with respect to the center of the bend. The different reference frame used
for tilt_ref versus everything else means that six transformations are needed to get from the
branch frame to the element body frame (see Eq. (11)). Symbolically:
All transformations use Eqs. (4).
The transformations are:
\(\Lambda_s \longrightarrow \Lambda_\text{mid-arc}\): Transformation from the starting branch coordinate system at a longitudinal position along the bend arc of \(s\) from the upstream end of the bend to the branch coordinates at the center point of the arc. This is a rotation around the center of curvature of the bend and is given by Eq. (6) and Eq. (7) with the substitution \(\alpha_b \rightarrow (L/2 - s)/\rho\).
\(\Lambda_\text{mid-arc} \longrightarrow \Omega_\text{mid-chord}\): This translates (no rotation) the origin of \(\Lambda_\text{mid-arc}\) to the center of the bend chord. For this transformation, \(\bf S\) is the unit matrix and \({\bf L} = \rho(\cos(\alpha_b/2) - 1) \, (\cos\theta_{tr}, \sin\theta_{tr}, 0)\)
\(\Omega_\text{mid-chord} \longrightarrow \Omega_\text{offset}\): Element misalignment. This transformation uses Eqs. (12).
\(\Omega_\text{offset} \longrightarrow \Omega_\text{tilt_ref}\): Rotation by
tilt_refto get the coordinate system aligned with body coordinates. This transformation uses \({\bf L} = 0\) and \({\bf S} = {\bf R}_z(\theta_{tr})\).\(\Omega_\text{tilt_ref} \longrightarrow E_\text{mid-arc}\): Translation to the mid point on the arc. For this transformation, \(\bf S\) is the unit matrix and \({\bf L} = \rho(1 - \cos(\alpha_b/2)) \, (1, 0, 0)\)
\( E_\text{mid-arc} \longrightarrow E_s\): Transformation along the bend arc to \(E_s\). This is a rotation around the center of curvature of the bend and is given by Eq. (6) and Eq. (7) with the substitution \(\alpha_b = (s - L/2)/\rho\) and \(\theta_{tr} = 0\).
Notice that with this definition of how elements are misaligned, the position of the center of the chord of a misaligned bend depends only on the offsets and is independent of the rotations.