## Saturday, November 12, 2011

### Codes for electrons and photons

The x-rays in a synchrotron are produced by high energy electrons traversing magnetic fields. The main devices that produce the magnetic fields are undulators or wigglers.

To model this process, therefore, first one needs to model the electrons in the ring, and to have a good model of the fields in the ring. This is the purpose of a tracking code. I focus on the code AT, since I have experience, and the elements representing the physics are easily accesible and available, so that one knows where to look if there are problems or questions.

To really know all the fields in the ring that act back on the electron beam, one must do measurements and modelling of the elements. For the insertion devices, there is the Mathematica based code Radia, which allows one to build an insertion device and compute the fields. One can also compute the kick map which will act on the electrons and can reduce the dynamic aperture and lifetime, particularly for narrow pole-width insertion devices.

Next, one needs to compute the radiation that will result from the electrons. For this, the code SRW is quite accurate and state-of the art. Next, one should model how this radiation can progress down the beam-line. For this purpose, the code Shadow is well developed.

In modeling both the electron beam dynamics and the radiation effects from undulators, one needs to have a model for the magnetic field of a given undulator. The field may be computed using a code such as Radia. But there are also representations of the field in terms of harmonics such as the Halbach representation. Here's a description of the symplectic integration routine for an analytical representation from Forest. One may also represent it via a kick map.  The latter two representations serve the purpose of the tracking of electrons for the purpose of tracking to determine dynamic aperture. Given the electron orbit, one can compute the radiation emitted. This can be done with e.g. SRW.

## Thursday, September 15, 2011

### Properties of electron and photon beams

Once one knows the electron beam properties, then one can calculate the radiation properties.
What are the basics? What photon beam is produced by a given electron beam as it goes through a bending magnet or undulator?
One computes the brightness via the Wigner function. Does this give the beam sizes also? The single electron brightness needs to be convolved with the beam distribution.

The basic result is that the photon beam sizes and divergences come from the electron beam sizes  and divergence and the single electron radiation size and divergence added in quadrature.

$\Sigma_x^2=\sigma_{x,b}^2 +\sigma_{x,e}^2$

The beam sizes thus depend on the frequency and also which harmonic for an undulator.
Here is the paper by Tanaka and Kitamura describing the impact of energy spread on the photon beam sizes.

The horizontal beam size and divergence are given by:
${\sigma }_{x}=\sqrt{{\epsilon }_{x}{\beta }_{x}+{\eta }_{x}^{2}{\sigma }_{\delta }^{2}}$
${\sigma }_{xʹ}=\sqrt{\frac{{\epsilon }_{x}}{{\beta }_{x}}+{\eta }_{xʹ}^{2}{\sigma }_{\delta }^{2}}$

To understand this, we need to understand the emittances and the Twiss parameters and the dispersion.

The same equations apply to the bunch length and energy spread. The longitudinal beta function is given to first order by
${\beta }_{z}=\frac{C{\alpha }_{c}}{{\mu }_{s}}$
with ${\alpha }_{c}$ the momentum compaction factor and ${\mu }_{s}$ equal to $2pi{\nu }_{s}$.

For ESRF these are available here.  A good reference is this article by M. Sands.

The x-rays produced in synchrotrons are used in a variety of experiments.  The production of the radiation depends on the properties of the electron beam.

One should calculate the power radiated. One should understand polarization. One should understand coherence.  Then there are the standard things people compute and use to compare sources:
brightness (or brilliance) and flux.

As emittance decreases for storage ring light sources, one claimed benefit is in the coherence of the resulting light. And indeed, the claimed benefit for FEL based light sources is also with respect to coherence (among other properties).

The paper by Geloni et. al. examines this issue.  The recent paper by Bazarov (on arxiv) also explores this issue and has computations of the Wigner function out of undulators.

The electron beam loses electrons over time.

The vacuum lifetime is result of the scattering process of electrons off of the gas molecules in the beam pipe. The Touschek lifetime is the result of the scattering of electrons off of each other.

The bunch length may be measured with a streak camera. Its value depends on the current and is given by solving the Haissinski equation, below the microwave instability.
The vertical emittance may be measured.
The energy acceptance is challenging. It may be given by the RF acceptance or by the dynamic acceptance. Computing this quantity is the work of a tracking code.

In AT, one uses the function atcalc_TouschekPM.

So, the basic mechanism of the synchrotron light source involve highly relativistic electrons moving through magnetic fields. What happens?
Well, we have dipole magnets that bend the electrons, and basically create the circular trajectory. Then we have quadrupole magnets for focusing, sextupole magnets for chromatic effects and other stability issues. To better understand, and control the electrons, we also need to model them.
Since there are lots of magnets, one needs a code to do this. Here, there's some nice aspects and some messes.

Basically, the equations of motion are given by the Lorentz force law. Newton's laws give a differential equation that needs to be integrated to get the orbit. So one needs a code that can integrate through the magnets. There are conserved quantities, and the motion is symplectic. So one needs a symplectic integrator in order to not lose precision over time.

A symplectic integrator comes in different orders. To get good results, one usually needs at least fourth order. One needs this together with flexible ways to define the magnetic fields. One code that can do this is the Matlab based code called AT- Accelerator Toolbox. An attempt at an open source collaboration is here. The underlying integrators are coded in C, which can be compiled as Mex files, and the definition of the fields to create the ring is done with Matlab.

Non-linear dynamics is mainly relevant for injection efficiency and Touschek lifetime.
One may also want to optimize parameters to improve the non-linear dynamics. One example is the tune shift with amplitude.
For the case of sextupoles distributed around a synchrotron, the general result is

In terms of an efficient algorithm, one may compute this as:
Thsi = sindex(s);
       ti = sindex(t);
b = b3vals(s)*b3vals(t);
c =  sqrt(bx(si)*bx(ti));

cx = cos(abs(mux(si) - mux(ti)) - muxT);
c3x= cos(3*(abs(mux(si) - mux(ti)) - muxT));
cxp2z = cos(abs(mux(si) - mux(ti)) + 2*abs((muz(si)-muz(ti))) - (muxT + 2* muzT));
cxm2z = cos(abs(mux(si) - mux(ti)) - 2*abs((muz(si)-muz(ti))) - (muxT - 2* muzT));

xdx = xdx + b * c ^ 3 * (3*cx/sx + c3x/s3x);
xdz = xdz + b * c * bz(si) * (-4 * bx(ti) * cx / sx + 2 * bz(ti) * cxp2z / sxp2z - 2 * bz(ti) * cxm2z / sxm2z);
zdz = zdz + b * c * bz(si) * bz(ti) * (4 * cx / sx + cxp2z / sxp2z + cxm2z / sxm2z);