8. Particle Phase Space Coordinates¶
Phase Space¶
Fig. 17 Particle coordinates are relative to the reference trajectory.¶
Fig. 18 Particle phase space.¶
The first figure shows the reference trajectory (the branch coordinate system), which was discussed in Machine Coordinates. The branch coordinates \((x, y, z)\) associated with a given point a distance \(s\) along the reference trajectory have their origin at that point and the \(z\) axis tangent to the reference trajectory.
A particle being simulated has its own trajectory, as shown in the figure. Given a particle at some point on its trajectory, there is a point at position \(s\) on the reference trajectory such that the \(z\) coordinate of the particle is zero in the \((x, y, z)\) coordinate frame associated with that point. With this, the particle’s position and momentum \(\mathbf{P}\) can be described using the coordinates
where \(t(s)\) is the time at which the particle is at the given point. From now on, to simplify the notation, the \(s\) dependence will be dropped.
For tracking, canonical phase space coordinates are used, with the convention that an upper case \(P\) denotes the (unnormalized) momentum and a lower case \(p\) the phase space momentum. The phase space coordinates are
where
with
\(P_0\) the reference momentum, see Reference Energy.
\(\beta c\) the velocity of the particle.
\(t_\mathrm{ref}(s)\) the time at which the reference particle reaches the point \(s\). The reference particle is a fictitious particle that can be imagined to travel on the reference trajectory. Frequently, this reference particle is thought of as describing the center of a bunch of particles.
Notes:
Do not confuse the canonical \(z\) coordinate with the \(z\) coordinate of the particle in the \((x, y, z)\) coordinate frame. By construction, the latter is always zero.
For a bunch of particles at a given \(s\) position, in general, the particles will have differing times \(t\).
If the reference particle has the same \(\beta\) as a particle, the canonical \(z\) is the longitudinal distance of the particle from the reference particle. Positive \(z\) means that the particle is in front of the reference particle.
\(p_z\) is also called \(\delta\).
Example¶
A beamline with a bend and a quadrupole, for positrons with 10 MeV total energy:
using SciBmad
@elements begin
b = SBend(L=0.5, angle=0.5) # g_ref = 1/bending radius = 1 1/m
q = Quadrupole(L=0.6, Kn1=10.0)
end
lat = Beamline([b, q], species_ref=Species("positron"), E_ref=10e6)
Beamline:
species_ref = positron
E_ref = 1.0e7
Index Name Kind L [m] s [m] s_downstream [m]
1 b SBend 0.5 0.0f0 0.5
2 q Quadrupole 0.6 0.5 1.1
A particle is tracked through it with track, starting with \(y\) = 1 cm, \(p_x\) = 0.06 and
\(p_z\) = −0.2, with spin tracking turned on (spin=true). The coordinates are saved at every
integration step (at=:), and, with more integration steps, also inside the
elements:
b.n_steps = 20
q.n_steps = 20
v0 = [0 0.06 0.01 0 0 -0.2] # x, px, y, py, z, pz
res = track(lat, v0=v0, spin=true, at=:)
TrackResult of 1 particle:
config:
n_turns = 1
save_every_n_turns = 1
in_body_coordinates = false
save_reference = false
scalar_params = false
rf_on = true
ramp_particle_energy_without_rf = false
ramp_update_each_particle = false
batch_start = 1
verbose = false
groupsize = 0
use_cpu_multithreading = false
use_KA = false
use_explicit_SIMD = true
elapsed_time = 0.000110015 seconds
start = 1
turns = [0, 1]
s, index, name, kind the saved locations: 41 locations, from b (s = 0.0) to the end of the beamline (s = 1.1)
state particle state codes, e.g. state[location, turn=n, particle=i]
x, px, y, py, z, pz the coordinates, e.g. x[location, turn=n, particle=i]
v all six coordinates, e.g. v[location, turn=n, particle=i]
q spin quaternions (track_spin turns them into spin 3-vectors)
data the internal, low-level data arrays:
state[1:1, 1:41, 1:2] [particle, location, saved turn]
v[1:1, 1:6, 1:41, 1:2] [particle, coordinate, location, saved turn]
q[1:1, 1:4, 1:41, 1:2] [particle, quaternion, location, saved turn]
bunch the Bunch at the end of tracking
The result holds the particle at the saved locations: for example its coordinates at the end of the beamline after the first (and only) turn:
res.v[end, turn=1, particle=1]
6-element Vector{Float64}:
-0.01591224148992837
0.011628139024362678
0.03867606428125545
0.10490576373334876
-0.006881038780460938
-0.2
Spin tracking tracks the rotation of the spin as a quaternion, so that the spin can be computed afterwards for any initial spin. With the initial spin along \(x\):
s = track_spin(res.q, [1, 0, 0])
s[end, turn=1, particle=1] # The spin (x, y, z) at the end
3-element Vector{Float64}:
0.9975250572284425
0.005731576238544188
0.07007787978538008
The orbit, with \(p_x\) = 0.06 at the start and changed to \(p_x\) = 0.1:
using CairoMakie
fig = Figure(size=(700, 350))
ax = Axis(fig[1, 1], xlabel="s [m]", ylabel="[mm]")
lines!(ax, res.s, 1e3 .* res.x[:, turn=1, particle=1], label="x")
lines!(ax, res.s, 1e3 .* res.y[:, turn=1, particle=1], label="y")
res2 = track(lat, v0=[0 0.1 0.01 0 0 -0.2], spin=true, at=:)
lines!(ax, res2.s, 1e3 .* res2.x[:, turn=1, particle=1], label="x (px = 0.1)", linestyle=:dash)
axislegend(ax, position=:lt)
fig
res.s is the \(s\) position of every saved location, and res.x[:, turn=1, particle=1] is \(x\) at
all of them. See Track for everything a TrackResult holds.
Exercises¶
Phase space: Construct a beamline with a single drift of 2 m length. Set the reference particle to be a proton with a reference energy of \(10^{12}\) eV (so that the approximation that the particle velocity is the speed of light can be made), and set the initial particle position to \(p_x\) = 0.2, \(p_z\) = 1 with all other coordinates zero. Calculate from first principles what the phase space coordinates will be at the end of the beamline, and check that your answer agrees with
track.Fringe fields: Quadrupoles have hard-edge fringe fields at both ends by default (
q.fringe_atisFringe.BothEnds). Track the particle of the example again withq.fringe_at = Fringe.NoEnd. How much do the fringe fields change the orbit at the end? Why are they so important here?