14. Orbit Correction¶
While operating accelerators, the orbit of the beam is measured with beam position monitors (BPMs). The accelerator is designed with ideal BPM readings in mind, which are often 0. After extended operational experience, operators learn good readings for all BPMs, which are referred to as golden orbits. It then becomes important to change the trajectory of the beam to obtain the desired BPM readings, with corrector magnets.
Example: Adding Corrector Coils and BPMs¶
Fig. 20 FODO cell with corrector coils.¶
Start with the ring with sextupoles of chapter 12:
include("lattices/12-sextupoles.jl");
Corrector coils are placed in the
d1drifts, 6.4 cm away from the quadrupoles: downstream of the quadrupoles in the forward cells and upstream in the reverse cells. Horizontal correctors are put next to focusing quadrupoles, where the horizontal beta function is large, and vertical correctors next to defocusing quadrupoles. Define the drifts that fit the 0.2 m long correctors, and a marker for the BPMs:
@elements begin
d1c1 = Drift(L=0.064)
d1c2 = Drift(L=0.609 - 0.064 - 0.2)
bpm = Marker()
end;
Each corrector must be an element of its own, so that its kick can be set by itself. So instead of defining one corrector and placing it many times, a new corrector is made for each
d1. Becaused1is used throughout the ring, adding the correctors by editing the lines would be tedious. A beamline is built from a Julia vector of elements, so a loop over the elements of the ring can do it instead: it replaces eachd1with the two drifts and a new corrector, depending on the quadrupole next to it. The loop also puts a BPM after every bendbandbh, and after every straight section driftdb:
line = [sextant1; sextant3; sextant5; sextant7; sextant9; sextant11]
n = length(line)
elements = LatElement[]
hkickers = LatElement[]
vkickers = LatElement[]
for i in 1:n
ele = line[i]
if ele === d1
# The quadrupole next to d1: before it in forward cells, after it in reverse cells (the
# next element of the ring after the last one is the first one)
forward = line[i-1].kind == "Quadrupole"
j = forward ? i - 1 : mod1(i + 1, n)
while line[j].kind != "Quadrupole"
j = mod1(j + 1, n)
end
if line[j].Kn1 > 0
kicker = HKicker(name="ch_$(length(hkickers) + 1)", L=0.2)
push!(hkickers, kicker)
else
kicker = VKicker(name="cv_$(length(vkickers) + 1)", L=0.2)
push!(vkickers, kicker)
end
append!(elements, forward ? [d1c1, kicker, d1c2] : [d1c2, kicker, d1c1])
else
push!(elements, ele)
end
if ele === b || ele === bh || ele === db
push!(elements, bpm)
end
end
ring = Beamline(elements, species_ref=electron, pc_ref=pc_ref, context=ring.context)
length(hkickers), length(vkickers), length(ring[[bpm]])
(208, 208, 416)
The new ring keeps the context of the previous one, which holds the variables of the sextupoles and the phase trombones.
A phase trombone is a matrix applied around the closed orbit at its place, built from the closed orbit and the lattice functions at the time
phase_trombone!is called. The radiation and the correctors change the closed orbit, so the phase trombones are taken out now, and put back at the very end, after the orbit correction:
for tr in (tr_f, tr_r, tr_m)
ring[tr].MapParams = nothing
end
Example: Radiation-Induced Sawtooth Orbit Correction¶
Fig. 21 A) The sawtooth orbit due to synchrotron radiation (in Bmad). B) The orbit after correction using kickers and BPMs.¶
A sawtooth orbit is caused by the energy loss to synchrotron radiation around the ring. The energy of the particles changes along the ring (it decreases in the bends and is restored in the RF cavities), which makes the horizontal closed orbit a sawtooth through the dispersion. Turn on radiation damping in all elements:
for ele in ring.line
ele.rad_damping = true
end
tw = twiss(ring, cols=["x", "pz"])
using CairoMakie
fig = Figure(size=(800, 400))
ax = Axis(fig[1, 1], ylabel="x [mm]")
lines!(ax, tw.s, 1e3 .* tw.x)
ax2 = Axis(fig[2, 1], xlabel="s [m]", ylabel="pz")
lines!(ax2, tw.s, tw.pz)
fig
Correct the orbit with the horizontal correctors: make the orbit at the BPMs as small as possible (in the least-squares sense), with
minimize=sum(abs2, ...)(see Orbit Correction). There are more BPM readings than correctors, so the orbit cannot be zero at all of them. Each corrector is a knob, and its strength is its normal dipole fieldKn0L(a kick of-Kn0L).
tw_orbit = lazy_twiss(ring)
res = optimize!(vary=[Knob(kicker, :Kn0L) for kicker in hkickers],
minimize=sum(abs2, tw_orbit.x[[bpm]]))
res.converged, res.iterations
(true, 6)
tw2 = twiss(ring, cols=["x"])
lines!(ax, tw2.s, 1e3 .* tw2.x)
fig
The correctors kill the orbit at the BPMs, but between them, in the bends, the sawtooth remains, because the energy changes along each bend.
Example: Orbit Correction with Quadrupole Misalignments¶
Every placement of a quadrupole such as
qfis the same element, with the same parameters. To misalign each quadrupole by itself, first make a copy of the ring in which every element is an element of its own.deepcopycopies an element of a beamline into a new, independent element, with its parameters (including deferred expressions). The copy keeps the context of the ring:
ring_err = Beamline(deepcopy.(ring.line), species_ref=electron, pc_ref=pc_ref,
context=ring.context)
Beamline:
species_ref = electron
pc_ref = 1.7846262612447e10
Index Name Kind L [m] s [m] s_downstream [m]
1 tr_m Marker 0.0f0 0.0f0 0.0f0
2 qfss Quadrupole 0.5 0.0f0 0.5
3 d1c1 Drift 0.064 0.5 0.5640000000000001
4 ch_1 HKicker 0.2 0.5640000000000001 0.764
5 d1c2 Drift 0.3449999999999999 0.764 1.109
6 db Drift 5.855 1.109 6.964
7 bpm Marker 0.0f0 6.964 6.964
8 d2s1 Drift 0.501 6.964 7.465000000000001
9 sdss Sextupole 0.584 7.465000000000001 8.049000000000001
10 d2s2 Drift 0.156 8.049000000000001 8.205000000000002
11 qdss Quadrupole 0.5 8.205000000000002 8.705000000000002
12 d1c1 Drift 0.064 8.705000000000002 8.769000000000002
13 cv_1 VKicker 0.2 8.769000000000002 8.969000000000001
14 d1c2 Drift 0.3449999999999999 8.969000000000001 9.314000000000002
15 db Drift 5.855 9.314000000000002 15.169000000000002
16 bpm Marker 0.0f0 15.169000000000002 15.169000000000002
17 d2s1 Drift 0.501 15.169000000000002 15.670000000000002
18 sfss Sextupole 0.584 15.670000000000002 16.254
19 d2s2 Drift 0.156 16.254 16.41
⋮ ⋮ ⋮ ⋮ ⋮ ⋮
3556 rows omitted
Its elements are new, so they are found by their names, e.g. ring_err["bpm"] for all BPMs.
Add random horizontal offsets to all quadrupoles, from a Gaussian distribution with \(\sigma = 10\) µm, cut at \(3\sigma\):
using Random, Statistics
Random.seed!(1)
for q in ring_err["Quadrupole::*"]
dx = 1e-5*randn()
while abs(dx) > 3e-5
dx = 1e-5*randn()
end
q.x_offset = dx
end
tw_err = lazy_twiss(ring_err)
maximum(abs, value(tw_err.x["bpm"])) # The largest BPM reading [m]
0.001369541031636221
Correct the orbit with the same process:
res = optimize!(vary=[Knob(kicker, :Kn0L) for kicker in ring_err["HKicker::*"]],
minimize=sum(abs2, tw_err.x["bpm"]))
maximum(abs, value(tw_err.x["bpm"]))
7.59550853027617e-5
If the misalignments are large, the closed orbit can become unstable, and then there is no closed orbit to correct. Try larger misalignments, with \(\sigma = 100\) µm. One approach to avoid unstable orbits is to correct the orbit of an open line first: the trajectory of one turn through the ring, starting on the design orbit. A lazy twiss of the ring with
initial(the lattice functions at the start, e.g. a row of the periodictwisstable of the design) treats the ring as an open line. After the trajectory is corrected, the orbit excursions are much smaller, the periodic orbit is far away from the unstable region, and the closed orbit can be corrected.
Example: Putting the Phase Trombones Back¶
The orbit of ring is corrected, so its phase trombones can be put back, with the phase advances
of chapter 12. They are now built around the closed orbit with the radiation
and the correctors, so they do not change it:
reading = value(tw_orbit.x[[bpm]]) # The BPM readings without the phase trombones
phase_trombone!(ring[tr_f]; phi1=DefExpr(c -> c.x1), phi2=DefExpr(c -> c.y1))
phase_trombone!(ring[tr_r]; phi1=DefExpr(c -> c.x2), phi2=DefExpr(c -> c.y2))
phase_trombone!(ring[tr_m]; phi1=DefExpr(c -> -c.x1 - c.x2), phi2=DefExpr(c -> -c.y1 - c.y2))
maximum(abs, value(tw_orbit.x[[bpm]]) .- reading) # The change of the BPM readings [m]
8.860966668256583e-15
If the orbit is corrected again later, the phase trombones are taken out first, in the same way.
Exercises¶
Zero orbit at the IP: Use the 4 horizontal and 4 vertical correctors closest to the IP (on both sides) to make the orbit and its angle exactly 0 at the IP, without affecting the rest of the ring.
Vertical orbit: Misalign the quadrupoles vertically as well, and correct the vertical orbit with the vertical correctors.
Tapering: Instead of correcting the sawtooth with correctors, its effect on the optics can be removed by “tapering”: scaling the strength of every magnet with the energy of the closed orbit at it, so that particles on the closed orbit see the design fields. Taper the elements of
ring_err(without misalignments): multiply theKn0,Kn1andKn2of each element by \(1 + p_z\) of the closed orbit at it. What happens to the orbit?
The lattice file of this chapter is
lattices/14-orbit-correction.jl.