An Analytic Approach for Symplectic Particle Tracking
in Complex 3-Dimensional Magnetic Structures Johannes Bahrdt, HZB / BESSY II, APS-ASD, October, 2011
Outline
• Need for accurate tracking in APPLE II devices
• Symplectic tracking based on generating functions
• Analytic description of arbitrary undulator fields
• Potential applications to other magnet structures
• Analytic equations for dynamic field integrals
• Benefits and limitations of shimming techniques
device design operational λ0 / mm periods Gap / mm By / Bz / T
U49-1 Hybrid 1998 - 49,4 83 15 0,799
U49-2 Hybrid 2000 - 49,4 83 15 0,788
U125-1 Hybrid 1998 – 2005 125 31 20 1,162
U125-2 Hybrid QPU 2000 - 125 31 15 1,360
U41 Hybrid 1999 - 41,2 79 15 0,659
U139 Hybrid 2004 - 139 10 15 1,471
UE56-1 APPLE II 1999 - 2003 56 2 x 30 16 0,771 / 0,529
UE56k APPLE II 2003 - 56 1 x 30 16 0,772 / 0,529
UE56-2 APPLE II 1999 - 56 2 x 30 16 0,772 / 0,529
UE46 APPLE II 2001 - 46,3 70 16 0,680 / 0,435
UE52 APPLE II 2002 - 52 77 16 0,742 / 0,505
UE49 APPLE II 2003 - 49 63 16 0,709 / 0,477
UE112 APPLE II 2006 - 112 32 20 0,994 / 0,765
Permanent Magnet Undulators of BESSY II
UE112 APPLE II Undulator at BESSY II
PETRA III APPLE II Undulator as built at HZB
J. Bahrdt et al., Proc. EPAC 2008, Genua, Italy; J. Bahrdt et al., SRI 2009, Melbourne Australia;
J. Bahrdt et al., IPAC 2010 Kyoto, Jap; J. Bahrdt et al., IPAC 2011 San Sebastian, Spain
L=5m
gap=11mm
The BESSY Soft X-ray polarimeter
Agreement between theory and measurement 0 undulator phase π
elliptical
mode
inclined
mode
Polarization Characterization
Universal Mode of APPLE Undulator
Modification of undulator radiation polarization by beamline components
J. Bahrdt et al, SRI 2009,
Melbourne, Australia
Müller-Matrix describes beamline effects
Parameters of beamline Müller matrix
and of analyzer vs. photon energy.
Gap and shift settings for normalized
Stokes parameters at the sample.
transmissions of field amplitudes
phase difference of electric field components
8
Need for symplectic tracking code in APPLE II structures
• symplectic and fast particle tracker dynamic kicks:
• extended undulator structure instead of thin lens approach
• simple interface (30 Fourier coefficients per undulator)
• full parametrization of undulator field in all operation modes
(linear superposition of magnet fields)
• simple implementation of shims
Numeric approach
• fast and symplectic, full turn FFAG orbit tracking
H. Lustfeld, Ph. F. Meads, G. Wüstefeld et al., LINAC 1984
• tracking of superconducting wave length shifter (strong field devices)
M. Scheer, G. Wüstefeld, EPAC 1992
Analytic approach
• tracking of undulators (nonlinear, weak fields)
J. Bahrdt, G. Wüstefeld, PAC 1991…
J. Bahrdt, G. Wüstefeld, Phys. Rev. Special Topics,
A & B 14, 040703 (2011)
History
𝜃𝑥/𝑦~𝜆02 ∙ 𝐵0
2/𝛾2
9
Hamilton‟s Principle of Stationary Action
A
B
𝛿𝑆 = 0 = 𝐿 𝑞 + 휀, 𝑞 + 휀 − 𝐿(𝑞, 𝑞 ) 𝑑𝑡𝐵
𝐴
= 휀𝜕𝐿
𝜕𝑞+ 휀
𝜕𝐿
𝜕𝑞
𝐵
𝐴
𝑑𝑡
휀 𝑡𝐴 = 휀 𝑡𝐵 = 0
𝛿𝑆 = 휀(𝑡)𝜕𝐿
𝜕𝑞−
𝑑
𝑑𝑡
𝜕𝐿
𝜕𝑞 𝑑𝑡
𝐵
𝐴
integration by parts using
theorem about the
calculus of variation
𝜕𝐿
𝜕𝑞−
𝑑
𝑑𝑡
𝜕𝐿
𝜕𝑞 = 0
Hamilton’s principle:
independent variation
of coordinates qi
Modified Hamilton’s principle:
independent variation of
coordinates qi and momenta pi
𝛿 𝐿 𝑞, 𝑞 𝑑𝑡 = 0 𝐵
𝐴
𝛿 (𝑝𝑞 − 𝐻)𝑑𝑡 = 0 𝐵
𝐴
≡
Newton‟s Laws
Lagrange Euler equation
2nd order DEs in N variables:
Hamilton‟s equations of motion
1st order DEs in 2N variables:
Differential equations: complete description of system but:
- small step sizes required (pretty nasty for undulators)
- symplectic integrator needed
Alternative method: Integration of Hamilton Jacobi Equation
- permits step sizes as long as undulator length
- symplectic even for long step sizes
10
Equivalent Descriptions for System Evolution
𝜕𝐿
𝜕𝑞−
𝑑
𝑑𝑡
𝜕𝐿
𝜕𝑞 = 0
𝜕𝐻
𝜕𝑥= −𝑝 𝑥
𝜕𝐻
𝜕𝑦= −𝑝 𝑦
𝜕𝐻
𝜕𝑝𝑥= 𝑥
𝜕𝐻
𝜕𝑝𝑦= 𝑦
Hamiltonian of relativistic particle in magnetic field:
𝐻 = (𝑝 − 𝑒𝐴 )2𝑐2 +𝑚02𝑐4
Canonical variables: 𝑥, 𝑦, 𝑝𝑥, 𝑝𝑦, and independent variable t
Hamiltonian is independent upon t.
Change independent variable from time t to z to enable
further transformation to cyclic coordinates; new Hamiltonian:
𝐻 = −𝑝 𝑧 = −𝐻 2
𝑐2−𝑚0
2𝑐2 − 𝑝 𝑥 − 𝑒𝐴 𝑥2− 𝑝 𝑦 − 𝑒𝐴 𝑦
2− 𝑒𝐴 𝑧
Normalization and 2nd order expansion in 𝑝𝑥, 𝑝𝑦, 𝑥3
𝑥3~1/𝑘𝐵𝜚 small quantity in undulators; well suited as expansion variable
11
Analytic Approach for Symplectic Mapping I
3
2
3
2
3 2/)(2/)(1 xAxApxAppH zyyxxz
Goal:
Change of canonical variables to cyclic variables using generating functions
Usual procedure of canonical transformation (keeps stationarity of action):
𝑝𝑖𝑞 𝑖 − 𝐻 = 𝑃𝑖𝑄 𝑖 − 𝐾 +𝑑𝐹
𝑑𝑧
with various options for 𝐹
We choose 𝐹 = 𝐹3 𝑄, 𝑝, 𝑧 + 𝑞𝑖𝑝𝑖 getting the new Hamiltonian:
𝐾 𝑄𝑥𝑖 , 𝑄𝑦𝑖 , 𝑃𝑥𝑖 , 𝑃𝑦𝑖 = 0 = 𝐻 𝑥𝑓 , 𝑦𝑓 , 𝑝𝑥𝑓, 𝑝𝑦𝑓 +𝜕𝐹3(𝑄𝑥𝑖 , 𝑄𝑦𝑖 , 𝑝𝑥𝑓, 𝑝𝑦𝑓, 𝑧)
𝜕𝑧
I
and the differential equations:
𝑃 = −𝜕𝐹3𝜕𝑄
𝑞 = −𝜕𝐹3𝜕𝑝
Note:
final coordinates and momenta 𝑥𝑓 , 𝑦𝑓 , 𝑝𝑥𝑓, 𝑝𝑦𝑓 depend upon z
initial coordinates and momenta 𝑄𝑥𝑖 , 𝑄𝑦𝑖 , 𝑃𝑥𝑖 , 𝑃𝑦𝑖 are constants of motion 12
Analytic Approach for Symplectic Mapping II
With substitutions
get HJE
Insert Taylor series expansion of generating function in HJE
expansion variables: 𝑝𝑥𝑓, 𝑝𝑦𝑓, 𝑥3
Each individual expansion term must be zero.
Iterative solution and determination of z-derivatives of 𝑓𝑖𝑗𝑘
Integration of 𝜕𝑓𝑖𝑗𝑘/𝜕𝑧 along z yields generating function.
implicit formulation
of transformation:
02/)(2/)(1 33
2
33
2
33 zzyyxx FxAxAFxAF
𝑝𝑥𝑓 = −𝜕𝐹3𝜕𝑥𝑓
= −𝐹3𝑥 𝑝𝑦𝑓 = −𝜕𝐹3𝜕𝑦𝑓
= −𝐹3𝑦
ijk
kj
yf
i
xijk xppfF 33
yFp
xFp
pFy
pFx
y
x
yff
xff
/
/
/
/
3
3
3
3
Analytic Approach for Symplectic Mapping III
Generating Function in 2nd Order
A 2nd order expansion of GF includes the following terms
Note: the term 𝑥3 always appears (last index ≥ 1)
thus, GF is linear in momenta in 2nd order expansion
Integration of expansion coefficients with respect to z:
From the generating function the transformation map is evaluated
.2/)(2/)( 2
001
2
001002
001101
001011
001
yyxxz
xxz
yyz
zz
AfAff
Aff
Aff
Af
.)')/(()')/(()2/1(
)')/((
)')/((
22
002
011
101
001
dzdzyAAdzxAAf
dzdzyAAf
dzdzxAAf
dzAf
zyzx
zy
zx
z
Transformation Map
2nd order means 1st order in momenta:
In this case the implicit form can be converted into an explicit form:
With pn = (1−f011y)(1−f101x)−f011xf101y
Note: Transformation is not limited to 2nd order, however, the
Newton Raphson Method has to be used for higher order
expansions to solve the implicit equations
.001002011101
011
001002011101
101
yyyfyxfyyfy
yff
xxyfxxfxxfx
xff
ffpfpfpp
fzpyy
ffpfpfpp
fzpxx
.
/))())(1((
/))())(1((
011
001002101001002101
101
001002011001002011
fyff
nxxxyyyyxyf
fxff
nyyyxxxxyxf
zpfyy
pffpfffpfp
zpfxx
pffpfffpfp
Example I: Simple Planar Undulator Structure
Scalar potential of a Halbach type undulator:
Derivation of vector potential from scalar potential
which is
From this expressions the particle dynamics in undulators can be derived
Note:
Analytic expressions of the vector potential are required since GF is
derived from analytic integration over z
).cos()sinh()cos()/( 0 kzykxkkBV yxy
.0
)/(
)/(
2
1
z
y
x
A
CdzxVA
CdzyVA
.0
)sin()sinh()sin())/()((
)sin()cosh()cos()/(
0
0
z
yxzyxy
yxzx
A
kzykxkkkkBA
kzykxkkBA
Example II: Arbitrary Periodic Structure in x and z
The following functions cos(kxnx)cos(kzmz), sin(kxnx)cos(kzmz)
cos(kxnx)sin(kzmz), sin(kxnx)sin(kzmz)
form a basis on the interval S=[-λx0/2, λx0/2]x[-λz0/2, λz0/2]
for all periodic functions in x and z direction with periodicity λx0 and λz0
Complete description of arbitrary periodic magnet fields in a plane:
Fourier coefficients:
Ansatz for 3D field:
with 𝛻𝐵 = 𝛻 × 𝐵 = 0:
solving the differential equation:
with midplane symmetry:
))sin()sin()sin()cos(
)cos()sin()cos()cos((),(
,,
,
0 0
,
zkxksszkxkcs
zkxksczkxkcczxB
zjxijizjxiji
zjxiji
n
i
m
j
zjxijiy
01
01
/2
/2
xxxi
zzzj
iikk
jjkk
jijijiji sssccscc ,,,, ,,,
)(),(),,( ,, yHzxBzyxB ijijyijy
222~
2 /)( yHHkk ijjxi
)exp()exp( ~,2~
,1 ykcykcHjyijyiij
)cosh( ~,
ykcHjyiij
Skip sin-terms for planar undulator (symmetric in x)
and get usual Halbach fields:
Derivation of Fourier coeffifficients
- undulator:
single trans. field distribution
- wiggler:
seveveral trans. field distributions
)cos(
...
...
~
1
~,,
1
~,1,
1
~,01,0
mj
m
jjnmn
m
jjnn
m
jj
zkcC
cC
cC
)cos()cosh()cos(),,( ~~,
0 1
~,
zkykxkczyxBjjyi
n
i
m
j
xijiy
...5,3,1~
22~~
,
j
kkk xijjyi
BESSY U125 Wiggler I
solve system of
linear equations
(1,5,9… for ppm structure)
Field reconstruction using different
numbers of harmonics J. Bahrdt et al., IPAC 2011
The 3rd field harmonic has to be
included for a a field reconstruction
on the percent level
For undulators usually 1st field harmonic
is sufficient
Shimmed device
U125-2 Magic fingers
BESSY U125 Wiggler II
Theoretic dynamic
field integrals
22
0
0
0
04
03
02
01
1
4321
)2/cos(
))(sin(
))(cos(
)/)()/((
)/)()/((
)/)()/((
)/)()/((
)(
zxiyi
xxi
zz
xixi
xixi
zz
yk
xisyixicyiyi
yk
i
zz
yk
xisyixicyiyi
yk
i
zz
yk
xisyixicyiyi
yk
i
zz
yk
xisyixicyiyi
yk
i
n
i
iiii
kkk
kik
zkc
xxks
xxkc
cnkeBsBcBkeV
cnkeBsBcBkeV
cnkeBsBcBkeV
cnkeBsBcBkeV
VVVVV
zyi
zyi
zyi
zyi
)(VB
Scalar potential of APPLE II field
Example III: APPLE II Undulator
.0
)/(
)/(
2
1
z
y
x
A
CdzxVA
CdzyVA
Accuracy of APPLE II Field Description
analytic representation (black)
simulation with RADIA (red)
Parametrization of magnet field distribution with high accuracy
By at phase = 0 Bx at phase = pi
in midplane
4mm vertical off-axis
8mm vertical off-axis
22
Comparison with ELEGANT
Aimin Xiao
Planar undulator
Period length 28mm
Analytic approach and
symplectic tracker
cwigg of ELEGANT
Acceleration of undulator tracking
By more than an order of magnitude
23
First Results for APPLE II
Aimin„s implementation of
analytic method into ELEGANT
Comparison of thick lens
and thin lens approach
phase = 0
phase = pi
phase = pi/2
Aimin Xiao
• Other complicated undulator structures such as
Figure 8 undulator for lin. pol. SPRING 8 helical ID
and reduced on axis power density
• Dipole magnet:
Curved coordinate system along the reference orbit is used
particle displacements and momenta with resect to this reference orbit
starting from a modified Hamiltonian 𝑝𝑠 the same method is applicable
• Fringe fields in quadrupoles and sextupoles
• …
Other Interesting Applications
Courtesy of H. Kitamura Courtesy of B. Diviacco
𝑞𝑖
𝑞 𝑖
25
Analytic Kick Maps (Thin Lens Approximation)
Kick
phase space volume is preserved with kick maps
𝑞𝑖
𝑞 𝑖
𝑞 𝑖𝑛𝑒𝑤=𝑞 𝑖
𝑜𝑙𝑑 +𝑊(𝑞𝑖)
Dynamic Kicks in a Planar Undulator
))cosh()cosh()sinh()sinh(1
(
)cos()sin()(2
~,2
~,1
~,2
~,1
~,2
2
2
~,1
01 02 1
212~
1~
,2~
,12
ykykykykk
k
k
xkxkk
kcc
B
z
jijijiji
jyi
xi
jyi
n
i
n
i
m
j
xixi
j
xi
jiji
f
x
The integrated dynamic kicks due to the wiggling motion in undulators
follow directly from generating function:
These expressions can be used in a thin lens approximation (kick map)
which assumes a localized kick of the strength of the integrated quantity
))sin()sin()cos()cos((
)sinh()cosh(1
)(2
21~
,2
2121~
,2
01 02 1
~,2
~,12
~
~,2
~,12
xkxkk
kkxkxkk
ykykk
ccB
z
xixi
jyi
xixixixijyi
n
i
n
i
m
jjyijyi
j
jiji
f
y
x/f002x y/f002y
Elliptical mode (φ2=0)
𝑐𝑝𝑝, 𝑠𝑝𝑝 analytic functions of φ1
𝑒𝑖 , 𝑒𝑗 include gap dependence
For general expressions in universal mode and for off-midplane expressions see
J. Bahrdt, G. Wüstefeld, Phys. Rev. Special Topics, A & B 14, 040703 (2011)
Dynamic Kicks of APPLE II Undulators
.)(
8
)(
8
0
0 0
00
2
22
0 0
00220
22
0
n
i
n
j
xjxjxixi
yj
xj
yi
xijiji
n
i
n
j
xjxjxixixjjiji
y
ppppx
sscsk
k
k
keecc
Bk
Lf
sccckeeccBk
Lf
sfcf
)).(
)(()(
8
)()(
8
0000
0000
0 0222/
0000
2
0 0222/
22
2/
22
2/
44
0
xjxjxixixjxjxixiyj
xjxjxixixjxjxixixj
yi
xin
i
n
j
jiji
xjxjxixixjxjxjxixi
yj
xj
yi
xin
i
n
j
jiji
papay
papapapax
ccsssscck
csscsccskk
keecc
Bk
Lg
cssskccsck
k
k
keecc
Bk
Lf
scg
scfsfcf
Inclined mode (φ1=0):
𝑐𝑝𝑝 , 𝑠𝑝𝑝 analytic functions of φ2
f0
fπ
fπ/2
4 generic
functions
22
2/ papa scg
L-Shims for Dynamic Kick Reduction
Field integrals of L-Shim
analytic representation (black)
simulation with RADIA (red)
Parametrization of shim field integral with high accuracy
J. Chavanne et al., Proceedings of
the EPAC 2000, Vienna, Austria
.
]2/exp[
)cosh()sin()sinh()cos(
]2/exp[
)sinh()cos()cosh()sin(
0
0
yixi
yi
n
i
yixiiyixiiy
yi
n
i
yixiiyixii
yi
xix
kk
gk
ykxksykxkcB
gk
ykxksykxkck
kB
Implementation in our tracking scheme:
Active Compensation of Dynamic Kicks
with Flat Wires: BESSY II UE112 APPLE II
current settings for gaps of 20mm
24mm, 30mm and 40mm
J. Bahrdt et. al., EPAC 2008, Genoa, Italy
water cooled
undulator
vacuum chamber
30
,1
))(
(
1)2,mod()12/(2
02
0
0
0
)2),1mod(()2/)1((2
0
)2,mod(2
0
11)2,mod()12/(2
02
00
1
m
istarti
mmim
iij
m
m
x
mmimm
mistartii
ij
m
istarti
mmim
i
ij
m
m
y
xr
cydxB
xr
cmh
xr
cdxB
.1)(
2)1(1
1
2)(2)2,mod(
1)(2)2,mod(
12/
0,
12
)1(
1
2
0
2
0
2
0
)1()1(
)1(
m
jji
ij
mh
j
ic
istartimj
istartimj
yxr
mistart
Multipole Decomposition of Flat Wire Field Integrals
Accuracy of Multipole Expansion
Accuracy of field integral description (y=0)
with z0=0,, 10, 20, 30mm and y0=10mm.
Thick lines: exact fields integrals, dotted lines:
approximation with m=20.
y
z y0
z0 position of wire
multipole expansions is senseless
outside radius of convergence
(defined by magnet field sources)
use instead: multipole specs at various hor. trans. positions
UE112 shimming effect
x-kick per ID passage (vertical linear mode) particles distributed on horizontal phase
space ellipse, semi axes: 30mm / 1.87mrad
red: no shims
blue: wire shims powered
BESSY II: 1000-turns tracking (x-x‟-plane)
frequency
map
EPAC 2006 Bahrdt, Scheer& Wüstefeld
Particle Tracking for BESSY UE112 APPLE II
30mm
400ura
d
UE112: Tune Shift and Beam Size Variation
dynamic multipoles with and
without active compensation
horizontal and vertical tunes
vs horizontal displacement:
black: tune correction off, wires off
blue: tune correction on, wires off
red: no tune correction, wires on
source size variation with row phase of the
UE112 at gap = 24mm in the elliptical mode
(top) and the inclined mode (bottom). Black,
blue: currents switched off; red, magenta:
currents switched on.
UE112: Recovery of Injection Efficiency
Active shimming of the UE112 is essential for a top-up mode.
- inclined mode: no alternative to active compensation
- elliptical mode: improvement of passive shimming results
The next step: Compensation for universal mode
Static multipoles:
Complete description of two dimensional straight line field integral distributions
on a source free circular disc
is an analytic function; the bar indicates a straight line integration
Cauchy Riemann relations: are equivalent to the
2D-Maxwell equations
“Dynamic multipoles” (DM):
is not an analytic function; the tilde indicates an integration
along a wiggling trajectory
Cauchy Riemann relations
are not fullfilled:
Note: By principle “dynamic multipoles” can not be compensated
with shims which are usually described by static field integrals
Static Multipoles and so-called „Dynamic Multipoles“
0/~
/~
)~
,~
( 002002 xyyxyxyx ffyBxBBB
0/~
/~
)~
,~
( 002002 yyxxxyzyx ffyBxBBB
yx BiBF
y
B
x
B
y
B
x
B
xy
yx
)(
)(
yx BiBF~~~
36
„Dynamic Multipoles“ of Planar Undulator
,)1(
)1(
1)1(22/
1
21)(
)1(22/
1
211)(
in
i
in
xni
in
x
in
i
in
yni
in
y
yxaB
yxaBStatic regular multipoles
are usually described by:
In contrast the
“Dynamic multipoles” of a
planar undulator with only one
transverse and one long.
Fourier component:
),)2()2()!2(
1
)!12(
1)1()(
)2()!1(
1)1)(((
8
~
22/
1
122121
2
3
1112/
2
3
2)2,mod(,0
)(
inn
i
iin
y
i
x
i
x
y
x
nn
x
n
x
y
xn
n
y
yxkkini
kk
k
xkn
kk
k
kB
LB
).)2()!1(
1)(
)2()!21(
1)2(
)!22(
1)1(
)2()!12(
1)2(
)!22(
1)1(
(8
~
11
2
2
21212/
1
22221
12122/
1
22221
2
2
2)2,mod(,0
)(
nn
yyy
y
x
inin
y
n
i
ii
x
i
y
inin
y
n
i
ii
x
i
y
y
x
n
n
x
ykn
kkk
k
ykin
xki
k
ykin
xki
kk
k
kB
LB
37
„Dynamic Multipoles“ of Planar Undulator
Special Cases
.~~
~~
1)1(22/
1
2)(
)1(22/
1
21)(
in
i
in
xni
n
x
in
i
in
yni
n
y
yxaB
yxaBCase 1:
The undulator focusses horizontally
with the same strength as vertically
Case 2:
The undulator defocusses horizontally
And the period length is long:
Case 3:
The undulator has infinitely wide poles
Note: In all cases the “dynamic
multipoles (DM)” are principally
different from static multipoles
22
yx kk .~~
)1(~~
1)(
112/)(
n
xn
n
x
nn
yn
n
y
ybB
xbB
.~~
0~
1)(
)(
n
xn
n
x
n
y
ycB
B
,)1(
)1(
1)1(22/
1
21)(
)1(22/
1
211)(
in
i
in
xni
in
x
in
i
in
yni
in
y
yxaB
yxaB
38
Shimming of „Dynamic Multipoles“
Why does shimming of DM work at all?
Shimming of DM in the midplane has no principle limitations, but
vertical off-axis effects are enhanced; this is acceptable because:
• usually, vertical beta-function smaller than horizontal beta functions
• usually vertical emittance smaller than horizontal emittance
• large particle amplitudes occur during horizontal injection
What about gap dependency?
DM are expected to drop off much faster
than shim field integrals due 𝐵2 dependency, but:
• detailed considerations show similar gap dependence of
dynamic multipoles and static multipoles for long period lengths
• DM scale with square of period length; Murphy‟s Law does not apply
39
Summary and Outlook
Fast analytic, symplectic GF-based tracking scheme
one step per undulator is possible
Analytic description of undulator fields and shim field integrals
simplifies interface
Analytic expressions for analytic kicks
Extension of method to other undulator structures
and accelerator magnets