## 1.

## INTRODUCTION

Synchrotron Radiation Workshop (SRW) ^{1, 2} is a code that can model the trajectory of relativistic electrons through complex magnetic structures for example undulators, wigglers and bending magnets at storage ring sources. It can then calculate the emitted electric field in the frequency domain using the retarded potential.^{3} SRW is then able to propagate the electric field across optical elements such as mirrors and through drift spaces using the Fresnel-Kirchoff Eq.^{4} to simulate X-ray beamlines taking account of wave optical effects such as diffraction. The core of SRW is a library of routines written in C++. These core routines can be called from a high level interface written in the Python programming language which gives flexibility in developing new applications as wrapper code can be written in Python while retaining the speed and efficiency of the lower level SRW routines.

The Python interface gives the capability of running SRW in multi-electron mode using the MPI (message passing interface) commonly available on Linux workstations and clusters accessed through the mpi4py Python library. In our case we used the openMPI implementation of MPI. Multi-electron calculations simulate the finite size electron source of a synchrotron by using a Monte-Carlo procedure to generate random initial phase coordinates of electrons conforming to the phase space distribution of the source.^{5} This allows partially coherent beams to be simulated and is essential for wave modeling of 3rd generation synchrotron beamlines where the coherent properties of the beam are governed by a smaller vertical and larger horizontal source size so that the beam may be diffraction limited in the vertical direction but not in the horizontal direction.

In addition, the simulation requires accurate knowledge about the beamline optical elements, in particular about the exact surface profiles of mirrors used to condition and focus the X-ray beam. This is possible using metrology data obtained by nanometre optical metrology (NOM)^{6} and also from at wavelength measurements (i.e. made in-situ using the X-ray beam as a probe).

Our aim is to use the electron beam lattice functions as input to a multi-electron calculation using SRW. We also aim to use metrology data from X-ray optical elements such as X-ray mirrors to calculate the distortion that the optical elements causes to the X-ray wavefront. This will enable us to calculate the cross spectral density and the spectral degree of coherence on any propagation plane along the optical axis of the beamline.

## 2.

## MODELING THE ELECTRON BEAM SOURCE

The description of coherence in terms of cross-spectral density and spectral degree of coherence is shown in Appendix A. The Monte-Carlo method can be used to perform the summation over the electrons in Appendix A, Eq. 2 required to calculate the cross spectral density. In this method electrons are generated randomly with phase space coordinates conforming to the known electron distribution function. By generating sufficient numbers of electrons, the average will approach the required ensemble average in Eq. 1 as *N*^{-1/2} where *N* is the number of electrons generated. The multi-electron Monte-Carlo calculation is more demanding of computing power than single electron calculations as the computing time required scales as *N* which can be in excess of a hundred thousand. Fortunately, computer power has increased and the availability of parallel compute clusters containing hundreds of cores makes this approach possible. There are efficient routines available for generating a sequence of values of a set of uncorrelated random variables given their distribution function.

SRW is able to model the trajectories of relativistic electrons through an undulator given starting values for the phase space coordinates. To a good approximation, the horizontal motion (*x, x*′), vertical motion (*y, y*′) and energy (*E*) are uncorrelated in the undulator source so the distribution can be separated - *p*(*x, x*′, *y, y*′, *E*) = *p _{x}*(

*x, x*′)

*p*(

_{y}*y, y*′)

*p*(

_{E}*E*). At an electron beam waist,

*p*(

_{x}*x, x*′) and

*p*(

_{y}*y, y*′) can be further separated into the product of a distribution over position and over angle which allows efficient generation of phase space coordinates. In general, however, the position and angular phase space coordinates (both horizontally and horizontally) are correlated. In this case the phase space,(

*x, x*′) or (

*y, y*′), must be transformed to a new coordinate system which allows separation into independent distributions as shown in Appendix B.

## 3.

## MODELING MIRROR SURFACES

SRW is able to model mirrors using the thin optical element approximation where the effect of the mirror is reduced to a phase shift applied to the wavefront at the propagation plane - the plane transverse to the optical axis at the centre of the optical element. In addition, elliptical and ellipsoidal surfaces can be modeled in a thick approximation where ray tracing is used to propagate the field from the propagation plane to the mirror surface in order to account for the length of the mirror. This approach is needed in situations of strong focusing when the mirror length is comparable to the mirror focal length. Mirror surface errors - i.e. deviations from the perfect shape caused by manufacturing tolerances, heating effects or mounting stress can be measured using offline measurements such as NOM^{6} while for in-situ characterisation of the surface at wavelength methods with the X-ray beam may be used. Appendix C shows in the thin approximation how errors in the figure of the mirror are related to the ray path length and hence the distortion of the wavefront. Ignoring transverse dependence, the surface error is given by the height error as a function of position along the length of the mirror (*w*(*s*)). From Eq. 6 in Appendix C, to get the path length correction for the wavefront, this function is transformed to 2sin(α)w(s/sin(*α*)) where *α* is the incident glancing angle of the beam from the mirror. Since for X-ray mirrors, *α* is typically a few milliradians, the size of the wavefront distortion is reduced by a factor approaching 10^{3} while structures with scales of millimetres appear on the wavefront with scales of a few micrometres.

## 4.

## BEAM LINE MODELING EXAMPLE

At 3rd generation synchrotron sources, many experiments are designed to exploit the high coherence of the undulator radiation. Such experiments range from coherent imaging experiments to applications requiring nano-focusing. The X-ray beam coherence is a consequence of the low emittance of the electron beam source in the storage ring and the current trend is for the design of new storage rings and upgrade of existing facilities to produce sources with lower still emittance. In this low emittance regime, beamline modeling requires wave propagation techniques to account for effects such as diffraction. Typical of the undulator source at storage ring facilities is an electron source size which is more than an order of magnitude larger in the horizontal compared to the vertical direction. Consequently, the X-ray beam may approach complete coherence in the vertical direction while at the same time having low coherence in the horizontal direction. To achieve defocusing of the source to sub micrometre levels in both horizontal and vertical directions is therefore difficult to achieve and it is often necessary to use optics to generate a virtual horizontal source with an aperture used to select a small horizontal beam which can then be successfully demagnified by nanofocusing optics. We have used SRW to perform wavefront propagation on an example beamline for nanofocusing at the Diamond Light Source. The beamline layout is shown schematically in Fig. 1.

The virtual source is created at the variable width secondary source aperture (SSA) by a horizontally focusing mirror (HFM) set to collimate the beam. The nanofocusing is achieved by a Kirckpatrick-Baez (KB) mirror system. As the beam at the SSA is partially coherent, the horizontal focal spot size depends on the horizontal size of the aperture. This is illustrated in Fig. 2 which shows the horizontal focal spot size (FWHM) plotted against the horizontal size of the SSA at 5, 10, 15 and 20keV.

As expected, the single electron calculation gives completely coherent radiation (horizontally and vertically) and therefore shows little dependence on the SSA width. The multi-electron calculation however produces partially coherent radiation at the SSA and hence the focus size depends on the aperture width.

This can be further elucidated by calculation of the mutual coherence function before the KB mirrors. For diffraction limited focusing achieving the smallest focal spot size, the beam at this point should be completely coherent. If the SSA horizontal aperture is small enough, any degree of coherence can be obtained (at the expense of intensity). Fig. 3 shows the simulated mutual coherence function at 5keV for points separated horizontally (*x*_{1} and *x*_{2}) as the SSA aperture is varied from 10*µ*m to 100*µ*m. As the horizontal KB mirror accepts about 300*µ*m the calculation indicates that the focusing will be at the diffraction limit for SSA apertures below about 30*µ*m. The effect of the slope error on the HFM is shown in Figs. 4, 5, 6 and 7.

## 5.

## CONCLUSIONS

With the trend for new storage rings and upgrades of existing facilities achieving ever lower emittance and therefore producing more coherent X-ray beams, the requirement for wave optical simulation is growing. In addition, challenging experiments such as coherent imaging and nanoprobe experiments are putting higher demands of delivery of the higher quality beans to the sample are making modeling of optical elements more important. SRW provides an excellent framework for modelling the X-ray beam from the source to the sample with the capability of propagating partially coherent beams using multi-electron calculations. We are combining simulations with offline and in-situ metrology to improve the accuracy of the modeling to help with the design and optimisation of beamlines.

## APPENDIX A.

## DESCRIPTION OF PARTIAL COHERENCE

Complete coherence between two points on a wavefront implies a fixed phase relationship between the fields. Transverse coherence is therefore measured by the correlation between the electric field at two spatially separated points **r**_{1}, **r**_{2} for waves with the same frequency ω. The definition of the cross-spectral density is^{7}

Where 〈…〉 denotes an ensemble average and *V*(**r**, *ω*) is a component of the photon field with angular frequency ω at position r. By definition, the spectral density at position **r** is given by *I*(**r**, *ω*) = *W*(**r, r**, *ω*). We then express the field in Eq. 1 as a summation over the field from each electron - . When the resulting double summation is separated into a single summation of terms from the same electron and a double summation of terms from different electrons, this leads to

If electron bunch length is much longer than the X-ray wavelength, the phase of the field from different electrons are uncorrelated and the double summation term averages to zero giving

Where the ensemble averaging has been incorporated into the summation. The spectral degree of coherence at frequency ω is given in terms of the cross-spectral density

The normalisation in Eq. 3 ensures that *µ*(**r, r**, ω) = 1 independent of **r**. The spectral coherence also satisfies with 0 corresponding to complete lack of coherence and 1 to complete coherence (e.g. the field from a single electron). For emission from a realistic electron bunch, we must take account of the fact that the radiation field is generated by a large number of electrons which have some known distribution in phase space. The coordinates of the electron phase space are horizontal transverse position and angle (*x, x*’), vertical transverse position and angle (*y, y*’) and energy *E*.

## APPENDIX B.

## ELECTRON BEAM TWISS PARAMETERS

The distribution function of electrons in phase space (*x, x*′)^{8} is given by

where *α*, *β* and *γ* are the Twiss parameters and ∊ is the beam emittance. If we can transform the phase space coordinates (*x, x*′) using a transform matrix **M** so that is transformed to a diagonal matrix of the form , then the distribution (Eq. 4) is transformed to the product of two independent Gaussian distributions in the transformed coordinates.

where the transformed coordinates are given by

The matrix **M** can be found by standard methods. First, the eigenvalues of , are found. Using the relationship *γβ* = *α*^{2} the two eigenvalues are

and defining two vectors

The matrix **M** is then given by **M** = (**u**_{+}, **u**_). This allows the phase coordinates (ζ, ζ′) to be each separately selected using the two independent Gaussian distributions in Eq. 5 and then transformed to the physical coordinates (*x, x*′) using the matrix **M.**

## APPENDIX C.

## PATH LENGTH CHANGE AT THE SURFACE OF A MIRROR

The incident rays are defined as travelling along the *z* direction with the *x* direction being horizontal. Coordinates on the mirror surface are (*u, v, w*). A unit vector in the *u* direction is û = (cos υ, sin υ, 0) - υ = 0 corresponds to vertical scattering geometry and υ = π/2 to horizontal scattering geometry and *α* is the glancing angle of the incident ray to the surface. A unit vector in the *v* direction is = (sin *α* sin *υ*, – sin *α* cos *υ*, cos *α*). The *w* direction defines the mirror surface height relative to a flat surface. The path length difference on reflection for a point on the surface with height *w*(*u, v*) is Δ*l* = 2*w*(*u, v*) sin *α* as shown in Fig. 8.

A ray passing through (*x, y*) and travelling along (0, 0, 1) intersects the mirror surface at position *r*û + *s*. Hence

Therefore

and the path length correction is

Alternatively, if the height profile of the mirrors is known on a grid of points (*r, s*), this can be converted to a grid of points in the (*x, y*) plane

Hence the path length is equal to the mirror height error scaled by a factor 2 sin(*α*) and the spatial frequencies are increased by a factor sin(*α*).

## REFERENCES

O. Chubar, “Accurate and efficient computation of synchrotron radiation in the near field region,” proc. of the EPAC98 Conference, pp. 1177–1179, 1998.Google Scholar

O. Chubar, “Precise computation of electron-beam radiation in nonuniform magnetic fields as a tool for beam diagnostics,” Review of Scientific Instruments 66(2), p. 1872, 1995. 10.1063/1.1145810Google Scholar

L. D. Landau and E. M. Lifshitz, The classical theory of fields, vol. 2 of Course of theoretical physics, Butterworth-Heinemann, 1980.Google Scholar

M. Born and E. Wolf, Principles of Optics, vol. 10, Cambridge University Press, 1999. 10.1017/CBO9781139644181Google Scholar

D. Laundy, J. P. Sutter, U. H. Wagner, C. Rau, C. a. Thomas, K. J. S. Sawhney, and O. Chubar, “Parallel simulations of partially coherent wavefront propagation from a finite emittance electron beam,” Journal of Physics: Conference Series 425, p. 162002, Mar. 2013.Google Scholar

S. Alcock, K. Sawhney, S. Scott, U. Pedersen, R. Walton, F. Siewert, T. Zeschke, F. Senf, T. Noll, and H. Lammert, “The Diamond-NOM: A non-contact profiler capable of characterizing optical figure error with sub-nanometre repeatability,” Nuclear Instruments and Methods in Physics Research Section A: Accelerators, Spectrometers, Detectors and Associated Equipment 616, pp. 224–228, May 2010. 10.1016/j.nima.2009.10.137Google Scholar

L. Mandel and E. Wolf, Optical Coherence and Quantum Optics, Cambridge University Press, 1995. 10.1017/CBO9781139644105Google Scholar

R. Talman, Accelerator X-Ray Sources, Wiley-VCH, 2006. 10.1002/9783527610303Google Scholar