Solutions Manual for
Hands-On Accelerator Physics Using MATLAB⃝
R
V. Ziemann
Contents
1 Introduction 4
2 For Chapter 2 4
2.1 FODO rings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.2 Racetrack . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.3 Dog-leg . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.4 Underpass . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.8 Equations of motion . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.9 Moments of distributions . . . . . . . . . . . . . . . . . . . . . . . . 8
2.10 Projections are also Gaussians . . . . . . . . . . . . . . . . . . . . . . 9
2.11 27183 random numbers . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.12 31416 random numbers . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.13 Fitting distributions . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.14 Adding Gaussian random variables . . . . . . . . . . . . . . . . . . . 11
2.15 Adding uniformly distributed random variables . . . . . . . . . . . . 11
2.16 Adding Lorentz-distributed random variables . . . . . . . . . . . . . 12
3 For Chapter 3 12
3.1 Phase-advance of FODO cell with thin quadrupoles . . . . . . . . . . 12
3.2 Phase-advance of FODO cell with thick quadrupoles . . . . . . . . . 13
3.3 Phase-space plots and trajectories . . . . . . . . . . . . . . . . . . . 13
3.4 Matching section between FODO cells, 2D . . . . . . . . . . . . . . . 14
3.5 Limit of stability of FODO cell . . . . . . . . . . . . . . . . . . . . . 15
3.6 Make small spots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
3.7 Dispersion in doublet lattice . . . . . . . . . . . . . . . . . . . . . . . 17
3.8 Matching section between FODO cells, 4D . . . . . . . . . . . . . . . 18
3.9 Necktie diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
3.10 Analyze FODO ring . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
3.11 Analyze doublet ring . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
3.12 Achromat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
3.13 Bunch compressor . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
3.14 Ring with rolled quadrupole . . . . . . . . . . . . . . . . . . . . . . . 23
4 For Chapter 4 26
4.1 Ampere-turns for dipole . . . . . . . . . . . . . . . . . . . . . . . . . 26
4.2 Ampere-turns for a quadrupole . . . . . . . . . . . . . . . . . . . . . 26
4.3 Dipole with bad iron near gap . . . . . . . . . . . . . . . . . . . . . . 26
4.4 Dipole with bad iron near top . . . . . . . . . . . . . . . . . . . . . . 28
4.5 Bumped dipole . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
1
, 4.6 The other bumped dipole . . . . . . . . . . . . . . . . . . . . . . . . 30
4.7 Narrower quadrupole . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
4.8 Sextupole . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
4.9 Magnets with super-conducting filaments . . . . . . . . . . . . . . . 34
4.10 Bad coils in super-conducting dipole . . . . . . . . . . . . . . . . . . 35
4.11 Try to fix the problem with the bad coils . . . . . . . . . . . . . . . 36
4.12 Halbach dipole . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
4.13 Field in undulator . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
4.14 Compensate poor permanent magnets in undulator . . . . . . . . . . 37
4.15 Rotating radial coil . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
4.16 Rotating tangential coil . . . . . . . . . . . . . . . . . . . . . . . . . 38
5 For Chapter 5 39
5.1 Why accelerate with TM-modes? . . . . . . . . . . . . . . . . . . . . 39
5.2 Why do TE-modes normally not work? . . . . . . . . . . . . . . . . . 39
5.3 Example of a TEM–mode . . . . . . . . . . . . . . . . . . . . . . . . 39
5.4 Plot fields for TM010 –mode . . . . . . . . . . . . . . . . . . . . . . . 39
5.5 Plot fields for a few other TMmnp –mode . . . . . . . . . . . . . . . . 40
5.6 100 MHz pill-box cavity . . . . . . . . . . . . . . . . . . . . . . . . . 41
5.7 Synchrotron frequency in CELSIUS . . . . . . . . . . . . . . . . . . . 41
5.8 Bucket half-height in electron ring . . . . . . . . . . . . . . . . . . . 42
5.9 Bunch-rotation simulation . . . . . . . . . . . . . . . . . . . . . . . . 42
5.10 De-bunching simulation . . . . . . . . . . . . . . . . . . . . . . . . . 43
5.11 Re-bunching simulation . . . . . . . . . . . . . . . . . . . . . . . . . 44
5.12 Re-bunching at higher harmonic . . . . . . . . . . . . . . . . . . . . 45
6 For Chapter 6 45
6.1 Cutoff frequency for rectangular wave guide . . . . . . . . . . . . . . 45
6.2 Why are square waveguides unsuitable . . . . . . . . . . . . . . . . . 45
6.3 Hz in several TE–modes . . . . . . . . . . . . . . . . . . . . . . . . . 46
6.4 Transverse fields of several TE–modes . . . . . . . . . . . . . . . . . 46
6.5 Dented WR-340 waveguide . . . . . . . . . . . . . . . . . . . . . . . 46
6.6 Triangular waveguide . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
6.7 Transmission line with transformers . . . . . . . . . . . . . . . . . . 48
6.8 Reflection coefficient Γ . . . . . . . . . . . . . . . . . . . . . . . . . . 48
6.9 Buckled pillbox cavity . . . . . . . . . . . . . . . . . . . . . . . . . . 49
6.10 Generator current and phase . . . . . . . . . . . . . . . . . . . . . . 50
6.11 P-controller in transient beam-loading simulation . . . . . . . . . . . 51
7 For Chapter 7 52
7.1 Quadrupole scan . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
7.2 Three wire scanners . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
7.3 Four wire scanners . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
7.4 Optimum phase advance . . . . . . . . . . . . . . . . . . . . . . . . . 55
7.5 Tunes from turn-by-turn data . . . . . . . . . . . . . . . . . . . . . . 55
8 For Chapter 8 56
8.1 IP-steering knob . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
8.2 Closed IP-knob . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
8.3 Orbit correction in doublet lattice . . . . . . . . . . . . . . . . . . . 57
8.4 Orbit correction in FODO ring . . . . . . . . . . . . . . . . . . . . . 60
8.5 Orbit correction with an additional steering magnet . . . . . . . . . 63
8.6 Displacement of long quadrupoles . . . . . . . . . . . . . . . . . . . . 64
8.7 Random quadrupole errors . . . . . . . . . . . . . . . . . . . . . . . . 65
2
, 8.8 Correct chromaticity . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
8.9 Tune diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
8.10 LOCO in a toy-ring . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
8.11 Dispersion term in response coefficient . . . . . . . . . . . . . . . . . 73
9 For Chapter 9 73
9.1 Target thickness to get data over a weekend . . . . . . . . . . . . . . 73
9.2 Energy loss in a lithium target . . . . . . . . . . . . . . . . . . . . . 73
9.3 Luminosity for elliptic beams . . . . . . . . . . . . . . . . . . . . . . 74
9.4 Beam-beam deflections in MATLAB . . . . . . . . . . . . . . . . . . 74
9.5 Weak-strong beam-beam simulation . . . . . . . . . . . . . . . . . . 75
9.6 Add displacement to disruption.m . . . . . . . . . . . . . . . . . . 76
10 For Chapter 10 78
10.1 Radiation loss in LEP . . . . . . . . . . . . . . . . . . . . . . . . . . 78
10.2 Numerically evaluate synchrotron radiation integrals in FODO ring . 78
10.3 Numerically evaluate synchrotron radiation integrals in doublet ring 80
10.4 Undulator parameters . . . . . . . . . . . . . . . . . . . . . . . . . . 80
10.5 Phase shifter tolerance . . . . . . . . . . . . . . . . . . . . . . . . . . 80
10.6 Effect of Momentum Spread in FEL oscillator . . . . . . . . . . . . . 81
11 For Chapter 11 83
11.1 Amplitude-dependent tune shift from tracking data . . . . . . . . . . 83
11.2 Tracking with octupole and decapole . . . . . . . . . . . . . . . . . . 84
11.3 1000-turn dynamic aperture . . . . . . . . . . . . . . . . . . . . . . . 85
11.4 Survival plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
11.5 Hamiltonian of thin corrector and other magnets . . . . . . . . . . . 87
11.6 Kicks from the Hamiltonians in the previous exercise . . . . . . . . . 87
11.7 Beam line with two steering magnets . . . . . . . . . . . . . . . . . . 87
11.8 Beam line with two other magnets . . . . . . . . . . . . . . . . . . . 88
11.9 Simulation with two sextupoles . . . . . . . . . . . . . . . . . . . . . 89
11.10Transverse displacements . . . . . . . . . . . . . . . . . . . . . . . . 90
11.11Beam line with three octupoles . . . . . . . . . . . . . . . . . . . . . 90
11.12Amplitude-dependent tune shift from normal forms . . . . . . . . . . 90
12 For Chapter 12 91
12.1 Space-charge tune shift in CELSIUS . . . . . . . . . . . . . . . . . . 91
12.2 Space-charge tune shift for general A and Z. . . . . . . . . . . . . . 91
12.3 Space-charge in doublet lattice . . . . . . . . . . . . . . . . . . . . . 92
12.4 Space-charge in a ring . . . . . . . . . . . . . . . . . . . . . . . . . . 95
12.5 Touschek effect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
12.6 Wakes from box distribution . . . . . . . . . . . . . . . . . . . . . . . 97
12.7 Wakes from parabolic distribution . . . . . . . . . . . . . . . . . . . 99
12.8 Stability diagram for parabolic distribution . . . . . . . . . . . . . . 100
12.9 Keil-Schnell criterion . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
12.10Phase-shift due to beam current . . . . . . . . . . . . . . . . . . . . 100
12.11Current dependence of the synchrotron tune . . . . . . . . . . . . . . 101
12.12Coupled-bunch instability . . . . . . . . . . . . . . . . . . . . . . . . 101
13 For Chapter 13 103
13.1 Parameters in electron gun . . . . . . . . . . . . . . . . . . . . . . . 103
13.2 Pump-down time scale . . . . . . . . . . . . . . . . . . . . . . . . . . 104
13.3 Differential pumping . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
13.4 Average dose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
3
, 1 Introduction
The material com-prises of all MATLAB code and the online appendices from the
book. Note that Appendix B.5 contains discussions of the code examples. Since
the solutions, dis-cussed in this manual, are based on the code examples from the
book, it is strongly recommended to download the additional material, which is
freely available from the web site mentioned above.
2 For Chapter 2
For the design of the beam lines in the first few exercises, it is convenient to encap-
sulate most of the script layout.m in a separate function, such that it can be used
repeatedly without excessive copying.
% layout_function.m
function vvpos=layout_function(beamline)
hold on
nlines=size(beamline,1); % number of lines
nele=sum(beamline(:,2))+1; % number of elements
vvpos=zeros(3,nele); % element positions
f=fopen(’layout.scad’,’w’); % open output file for 3D view
vv=[0;0;0]; % x,y,z or origin
ww=eye(3); % orientation of tripod
ic=1; % element counter
for line=1:nlines % loop over input elements
for seg=1:beamline(line,2) % loop over repeat-count
v0=vv; w0=ww; % remember previous point
ic=ic+1;
switch beamline(line,1)
case {1,2,5,7} % drift, quadrupole, solenoid
dv=[0;0;beamline(line,3)];
dw=eye(3);
case 4 % sector dipole
phi=beamline(line,4)*pi/180; % convert to radians
if abs(phi)>1e-7
rho=beamline(line,3)/phi; % bending radius
dv=[rho*(cos(phi)-1);0.0;rho*sin(phi)]; % sagitta
dw=wmake(0,-phi,0);
dw2=wmake(0,-phi/2,0); % for 3D renderer only
else
dv=[0;0;beamline(line,3)];
dw=eye(3);
end
4