X

[a]ManuelSanchez del<EMAIL_ADDRESS>if different from Celestre Reyes-
Herrera Brumund Cammarata

[a]European Synchrotron Radiation Facility, 71 Avenue des Martyrs, 38000
Grenoble France

# Pairing transfocators under partially coherent x-ray beams

Rafael  Juan
Philipp  Marco

###### Abstract

We simulate the focusing of partial coherent beams produced by fourth-
generation storage rings. We used a new software tool to perform coherent mode
decomposition of the undulator radiation in 1D. The analysis of a focusing
system based on x-ray lenses, shows the shift and degradation of the focus
when the numerical aperture is reduced by a slit. The pairing of two
transfocators to assure a fixed focal position is studied in terms of beam
sizes and coherent fraction. The results show that the synchrotron source
imaged by two paired undulators is highly dependent on the aperture used to
control the coherence fraction, and simple concepts based on geometrical
optics cannot be applied.

We simulate the focusing of partial coherent beams produced by fourth-
generation storage rings using a new software tool, Wofry 1D, that implements
coherent mode decomposition of undulator radiation in 1D. We observe changes
in the focal spot of the focus when the numerical aperture is reduced by a
slit. The pairing of two transfocators to assure a fixed focal position is
studied and the resulting beam sizes analyzed.

##  1 Introduction

Recent fourth-generation storage-ring-based X-ray synchrotron sources deliver
photon beams with high brilliance and coherence. The transversal coherence of
these beams is highly improved, in particular in the horizontal direction,
with respect to previous 3${}^{\text{rd}}$ generation sources. This has a
beneficial impact for many applications requiring coherent beams, such as
X-ray photon correlation spectroscopy, coherent diffraction imaging,
propagation-based phase-contrast imaging, and ptychography (see, e.g.
[paganin_book]). On the other side, preserving wavefront quality requires
better quality materials and optical surfaces in the active beamline
components such as mirrors, gratings, crystals and lenses [Yabashi, Roth2017].
Moreover, the interaction of the coherent beam with the optical elements
produce diffraction that do affect their focusing power and resolving power of
these elements. Let us consider, for example, the case of an ideally focusing
system of focal length $f$ made by a mirror or lens that focuses the source
into the image plane. The position of the focus with respect to the focusing
element $q$ can be estimated by the lens equation $f^{-1}=p^{-1}+q^{-1}$, with
$p$ the source-element distance. If the beam numerical aperture (NA) is
reduced (for example by the finite dimension of the lens, mirror or by using a
slit) the position and also the dimensions of the focal point changes due to
diffraction. It has been shown [Tanaka:85] that the focal position created by
a Gaussian beam “moves” towards the lens position when NA reduces. This
shifting of the focal position is also relevant for synchrotron beamlines, as
demonstrated by westfahl. These authors noticed a shift of the horizontal
focal position upstream from the position given by geometrical optics (see
Fig. 7 in westfahl) when the horizontal acceptance is reduced by a slit. Their
numeric results from wavefront propagation using SRW [codeSRW] including
partial coherence agree with an analytical Gaussian Shell-model.

The diffraction effect at the slits and finite size of the optical elements
not only shifts the focal point, but also changes the focal dimensions, as we
will see later. These facts are critical when designing beamlines with several
coupled focusing elements. We study this phenomenon applied to the project for
the new ID18 beamline at the upgraded EBS-ESRF storage ring. This beamline
will produce highly coherent beams of variable cross section at the sample
position. Two refractive systems (transfocators) are paired to allow a varying
focal size, whereas a slit placed upstream from the transfocators is used to
control the coherent fraction. The optical matching of the transfocators is
studied in detail, and it is strongly correlated with the slit aperture (or
coherent fraction). To study the performances of such systems a new algorithm
for coherent mode decomposition (CMD) of the undulator beams has been
developed. This method is very fast allowing parametric simulations in a
common laptop.

The high efficiency of the CMD software developed is obtained by implementing
a 1D model, therefore studying separately the horizontal and vertical planes.
The results of this model are verified against 2D models using Monte-Carlo
multielectron propagation with SRW and also 2D coherent mode decomposition
with COMSYL [codeCOMSYL]. It is also found that ray-tracing simulations using
the “hybrid” method [codeHYBRID] give good approximations to the correct
results for these systems.

The paper is organized as follows. Section 2 summarizes the methodology used
for 1D coherent mode decomposition of undulator beams and their transport
along the beamline. Section 3 analyzes the focusing of partially coherent
beams with a single refractive system (lens). Section 4 discusses the pairing
of two refractive systems. Section 5 shows simulations for the full beamline
and compares different methodologies for a selected case. We finish with a
general discussion in Section 6 and concluding remarks in Section 7.

##  2 One dimensional coherent mode decomposition of an undulator source and
propagation along a beamline with lenses

For dealing with partially coherence beams produced by undulators in low-
emittance storage rings we developed a 1D model of the CMD method that we
previously developed in 2D [glass2017]. The motivation for developing these
new tools is to perform quick calculations (e.g., being able to perform
parametric calculations in a laptop) with high accuracy in the simulation of
the source and beam propagation. The separation of the real 2D wavefront in
two separated 1D wavefronts is well justified for most synchrotron beamlines,
where the cross-talk between these two directions is small. The tools
developed here are included in the OASYS toolbox [codeOASYS], available as an
WOFRY add-on. These tools can be used from the OASYS interface, which also
creates scripts that can be later modified for performing parametric
calculations and loops in batch runs.

###  2.1 Modeling the partial coherent emission of an undulator beam using
coherent mode decomposition

The electrons in a storage ring are statistically distributed, following in
good approximation a Gaussian distribution in a 6-dimensional space (three
spatial coordinates, two angles to define direction, and the electron energy).
The radiation of the individual electrons will add incoherently for
wavelengths smaller than the bunch lengths. This is the usual case for X-rays
produced by storage ring-based sources, but not for free electron lasers.
Therefore, each electron creates a wavefront (fully coherent) associated at a
given photon energy. As a consequence, the overall radiation cannot be
described deterministically. Statistical methods are then needed, like for
describing the electron beam. This is the origin of partial coherence of the
synchrotron emission. In an ideal storage ring of zero emittance, the
electrons follow a filament beam so the emission by an insertion device (ID)
would be fully coherent. When electron emittance is considered, the electrons
contributing to the radiation have different initial conditions (in the
6-dimensional space) and the overall emission cannot be describe by a single
wavefront, but by statistically distributed wavefronts, described by partial
coherent optics.

The radiation is “wide sense stationary” [mandel_wolf] if it verifies some
conditions, usually satisfied for light emitted by storage rings, but not for
XFELs [geloni2008]. These conditions can be summarized as i) the electron
bunch length being long enough (several times larger than the emitted
wavelength), ii) radiation is monochromatized ’not too much’ (like by standard
monochromators), and iii) the radiation frequency being large enough. It is in
this case all the coherent properties of the radiation can be described using
$W$, the “cross spectral density” (CSD), a complex function that measures the
correlation of the electric field $E$ in two different spatial points at a
given radiation frequency $\omega$. It can be mapped in a $(x,y)$ plane at a
third coordinate $z$. At that plane, the CSD depends on 5 variables:

$W_{2D}(x_{1},y_{1},x_{2},y_{2};\omega)=<E^{*}(x_{1},y_{1};\omega)E(x_{2},y_{2};\omega)>$
(1)

In the following, we suppose that the CSD is separable in its 1D horizontal
$x$ and vertical $y$ coordinates, therefore the $W_{2D}$ becomes a product of
two CSD functions $W$ of two variables for a given photon frequency $\omega$:

$W_{2D}(x_{1},y_{1},x_{2},y_{2};\omega)=W(x_{1},x_{2};\omega)W(y_{1},y_{2};\omega).$
(2)

Each $W$ function is treated separately in a similar way affecting the $x$
(horizontal) and $y$ (vertical) coordinate.

From the cross spectral density one can calculate the “spectral density”
(usually simply called “intensity”) $I(x;\omega)=W(x,x,\omega)$, and also the
complex degree of (transverse) coherence:

$\mu(x_{1},x_{2};\omega)=\frac{W(x_{1},x_{2};\omega)}{\sqrt{I(x_{1};\omega)}\sqrt{I(x_{2};\omega)}}$
(3)

The modulus of the complex degree of coherence is one for a completely
coherent beam and zero for an incoherent beam.

An important result in partial coherence optics permits to describe the CSD as
an infinite sum of independent coherent modes (in the sense of orthonormality)
:

$W(x_{1},x_{2};\omega)=\sum_{n=0}^{\infty}\lambda_{n}(\omega)\Phi_{n}^{*}(x_{1};\omega)\Phi_{n}(x_{2};\omega)$
(4)

where $\lambda_{n}$ (eigenvalues) are the intensity weights and the $\Phi_{n}$
are the complex coherent modes (eigenfunctions). Some important
characteristics of this coherent mode decomposition are [mandel_wolf]: i) the
modes are orthonormal (in the integral sense), ii) the modes maximize the
spectral density, the first mode is more intense than the second, and so on,
meaning that the truncated expansion is optimal, and iii) there is complete
coherence if and only if there is only a single mode. In case of beams with
good coherence, the infinite series can be truncated to a limited number of
modes $N$, which are functions of one (two) spatial variables in 1D (2D). The
numerical storage of the $N$ modes is more economic than the storage of the
cross spectral density $W$ that depends on two variables (4 variables for
$W_{2D}$). The eigenvalues $\lambda_{n}$ are a measure of the intensity.
Indeed, one can define the occupation $\eta$ of the i-th mode as the ratio of
its intensity to the total intensity:

$\eta_{i}(\omega)=\frac{\lambda_{i}(\omega)}{\sum_{n=0}^{\infty}\lambda_{n}(\omega)}.$
(5)

From these arguments, it is now natural to rigorously define Coherent Fraction
($CF$) as the occupation of the first coherent mode: $CF=\eta_{0}$.

The eigenvalues and the coherent modes are obtained by performing the coherent
mode decomposition (CMD). They are the solution of the homogeneous Fredholm
integral equation of second kind, an eigenvalue problem [glass2017]. The
numerical solution is obtained from the diagonalization of the CSD, which is a
multivariate tensor when sampled at the point coordinates. This
diagonalization problem is solved in 2D (i.e., $W_{2D}$ is a function of 4
variables) using complex numerical algorithms implemented in COMSYL.
Fortunately, in 1D the CSD is a function of two variables, represented in a
matrix that can be easily diagonalized using standard tools availables in
standard mathematical libraries, such as python-numpy. The construction of
$W(x_{1},x_{2})$ uses Kim’s convolution theorem [kim1986b] as described in
glass2017. It includes two ingredients: i) the statistical parameters of the
electron beam at the undulator center (sizes and divergences), and ii) the
intensity distribution of the undulator emission at the undulator center. The
undulator emission is calculated in a plane far enough from the undulator
using classical electrodynamics [jackson] (as implemented in the pySRU python
library [pySRU]), and then backpropagated (using a Fresnel propagator) to the
center of the undulator.

It is known that the emission of the undulator is not Gaussian. In spite of
that, Gaussian approximation has been proposed [coisson1997], and used
inadequately for undulator radiation. In this case, Kim’s convolution theorem
predicts a CSD that is identical to that of the Gaussian Shell-model (GSM),
whose CSD can be expanded analytically in coherent modes [Starikov82]. The
main arguments in favour of using numeric (non approximated) coherent modes
are: i) there are differences in the mode shape, that are different than the
Gaussian-Hermite modes in GSM, and ii) they produce different results after
propagation (divergence). Indeed, the GSM predicts for the first coherent mode
a phase space volume $\sigma\sigma^{\prime}=\lambda/(4\pi)$ whereas numeric
fits for the undulator emission come out to about twice this value [elleaume].
Moreover, the GSM modes have constant phase (they are real functions) whereas
the undulator modes have non-constant phase (complex functions).

The interest of the coherent mode decomposition method is twofold: the
possibility to propagate a partial coherent beam along the beamline by just
propagating a few modes (less modes for a more coherent beam) which behave
like coherent wavefronts, and the use of the coherent fraction (a scalar
parameter) as a well-defined measure of how coherent is the beam at any
position of the beamline.

###  2.2 Wavefront propagation in free-space

The wavefront evolves when transported in free space from two different
positions along the optical axis. We used integral propagators to calculate
the wavefront in a given point using the wavefront in another position. Two
main propagators are implemented in Wofry1D, one based on the direct
implementation of the Rayleigh-Sommerfeld integral, and a second one, the zoom
propagator, is a Fresnel propagator using FFT. Both propagators are described
in srioLBL. The effect of the different elements needed for the simulations in
this work are presented in the following sections.

###  2.3 Wavefront modification by apertures

A generic aperture is a mask that transmits a part of the wavefront complex
amplitude in a range $[x_{min},x_{max}]$ and absorbs the rest. It can be

$R(x;\omega)=\left\\{\begin{matrix}A,&\mbox{~{}~{}if~{}~{}}x_{min}\leq x\leq
x_{max}\\\ 1-A,&\mbox{~{}~{}elsewhere}\end{matrix}\right.$ (6)

When the element is a slit, then $A=1$. If it is a beamstop, then $A=0$. In
the following simulations we will use an aperture of finite length $a$
centered with the beam, therefore $x_{min}=-a/2$ and $x_{max}=a/2$.

A useful case is the “Gaussian slit” where $A=\exp(-x^{2}/(2\sigma_{a}))$. The
aperture acts as a Gaussian apodization window. Although artificial, it is
interesting to shape the beam with a Gaussian profile, which remains a
Gaussian after propagation. Therefore, a Gaussian slit acting on a plane
wavefront does not produce diffraction fringes. We define $\sigma_{a}=a/2.35$.

###  2.4 Wavefront modification by refractive systems

####  2.4.1 Ideal lens

We can define an ideal lens as a focusing device that converts a plane wave
into a spherical wave collapsing to the focus at a distance $f$ from the ideal
lens position. Therefore

$R(x;\omega)=e^{-ik~{}x^{2}/(2f)},$ (7)

with $k=2\pi/\lambda$, and $\lambda=2\pi c/\omega$ is the photon wavelength.
An ideal coupling (i.e. zero inter-lens spacing) of $N$ ideal lenses will
present a focal length $f=(f_{1}^{-1}+f_{2}^{-1}+...+f_{N}^{-1})^{-1}$.

####  2.4.2 Thin object

A refractor made by a material with refraction index
$n(\omega)=1-\delta(\omega)+i\beta(\omega)$ and thickness profile $z(x)$ adds
a phase to the wavefront $-\lambda\delta(\omega)z(x)$ and reduce its amplitude
by $\exp(-\mu z(x)/2)$, where $\mu=(4\pi/\lambda)\delta(\omega)$ is the
(intensity) attenuation coefficient. These expressions can be applied to any
transmission object of profile $x(z)$ assuming valid the thin object
approximation.

####  2.4.3 Real lens

The changes induced by a real lens in the wavefront can be calculated using
the thin object approximation discussed below, using the lens profile.
Usually, a single lens has a parabolic interface $z=x^{2}/(4R)$ with $R$ the
radius at the apex. A lens has two parabolic interfaces (front and back)
separated by a lens thickness $d$. The interfaces are flat outside the lens
aperture $L$. Therefore, the lens profile is:

$\displaystyle z(x)$ $\displaystyle=\frac{1}{2R}x^{2}+d;$
$\displaystyle|x|<L/2$ (8) $\displaystyle z(x)$
$\displaystyle=\frac{1}{2R}(L/2)^{2}+d;$ $\displaystyle|x|\geq L/2.$

####  2.4.4 CRLs and transfocators

A Compound Refractive Lens is a pile of $N$ identical lenses. If we neglect
the beam propagation in the inter-lens space, the effect of the $N$ lenses is
identical of a single lens with profile $x_{N}(z)=Nz(x)$. If one is interested
in assessing the effect of the inter-lens space (e.g. for studying the
adiabatic focusing [Schroer_adiabatic]) the CRL must be calculated as $N$
independent lenses, applying the free-space propagator in between two
consecutive lenses. For a transfocator (a transfocator is a pile of CRLs) the
same concept apply: it is possible to compute the accumulated lens profile and
use it as a single lens, or calculate lens by lens (or CRL by CRL) if the
effect of inter-lens or inter-CRL spaces are to be taken into account.

####  2.4.5 Lens errors

The profile of a real lens $z(x)$ can be decomposed in the ideal parabolic
profile (best fitted parabola) $z_{P}(x)$ plus a residual profile (errors)
$z_{error}(x)$. One can then apply the thin object approximation with this
profile [Celestre:mo5214].

####  2.4.6 Refractive corrector

One can imagine a “free form” refractive object to focus an arbitrary incoming
wavefront to a given point placed at a distance $D$. In other words, this
object would transform the incoming wavefront into a spherical (circular in
1D) wavefront collapsing to the focus, i.e. converging to a point image
[ChubarElleaumeSnigirev2001]. The profile of such refractive “corrector” can
be calculated using the phase difference $\Delta\phi(x)=\phi_{S}(x)-\phi(x)$
where $\phi_{S}=kx^{2}/(2D_{w})$ is the phase of the circular wave collapsing
at $D_{w}$, $k$ is the wavenumber ($k=2\pi/\lambda$) and $\phi$ is the phase
of the incoming wavefront. The corrective profile is
$z(x)=-\Delta\phi/(k\delta(\omega))$.

##  3 Effect of the numerical aperture in the focal position using a single
lens

This section analyzes an idealized case of focusing a synchrotron beam with a
transfocator. In many beamlines the beam coherence fraction is increased by
reducing the aperture of an entrance slit. Beam with high coherent fractions
are affected by diffraction effects originated at the slit aperture and at the
lens (finite dimension and surface errors). The focal position changes, as
well as the focal dimensions, thus modifying the focusing properties of the
transfocator.

###  3.1 Preliminary works.

When a coherent Gaussian beam is cropped by the slit aperture, the beam waist
moves towards the lens. Closing the slit affects the focus position, that
moves more and more to the lens position, which is reached at the limit of
zero aperture. The change of the waist position happens when the Fresnel
number111 The factor 4 in the denominator comes from the choice of $a$ as the
aperture size, thus $a/2$ is used for the radius. is smaller than one

$N_{F}=\frac{a^{2}}{4p\lambda}<1,$ (9)

where $p$ is the distance from the aperture to the lens. We use a fixed $p$
and modify $N_{F}$ by changing the aperture.

After Belland:82, there are three possible regimes

  1. 1.

when diffraction effects are negligible, the characteristics of the Gaussian
beam are unchanged behind the aperture ($N_{F}>1$),

  2. 2.

when the Gaussian beam is weakly diffracted, it looks in the far-field always
as a Gaussian beam, with slightly different characteristics; this is valid for
$N_{F}$ larger than a given $N_{0}$ and smaller than one,

  3. 3.

when the diffraction effects are large ($N_{F}<N_{0}$), the diffracted beam is
no longer Gaussian.

The transition (1) to (2) will move the focus towards the lens. The transition
(2) to (3) depends on $N_{0}$, a value difficult to estimate analytically. A
more general case happens when the numerical aperture is controlled by a slit
placed at at distance $p_{a}$ upstream from the lens. In this case, the
Fresnel number can be generalized as $N_{F}=a^{2}p/(4\lambda(p-p_{a})^{2})$.
The focus will shift to the position $q^{\prime}=fp_{a}/(p_{a}-f)$, a position
given by the geometrical optics when the source is placed at the slit
position.

An optical system that focuses a partially coherent synchrotron beam in the
horizontal plane is analyzed in detail by westfahl. The focal system is in
almost 1:1 magnification, and a shift of the focal position towards the mirror
is produced when closing a slit placed just before the mirror. Analytical
analyses using the Gaussian Shell-model and numerical partial coherent
(multielectron) calculations with SRW [codeSRW] agree in the obtained results.
The analyses revealed a different shift for the two photon energies analyzed
(3 and 9 keV). The good agreement between GSM and SRW is justified by a
relatively low horizontal coherent fraction at the source (about 21% at 3 keV
and 12% at 9 keV).

###  3.2 Changes in focal position and size as a function of the slit opening

Let us consider an aperture of dimension $a$ placed between the source and a
lens, at a distance $p_{a}$ from the lens ($p_{a}<p$). The lens is set to
focus the source into an image plane at $q$ downstream from the lens.
Following the geometrical optics, the position of the focal plane is not
changed if the aperture $a$ changes. The focal size is $Ms$ when the aperture
size $a$ is larger than the source size $s$ ($M=q/p$ is the optical
magnification). But if $a<s$ the aperture obscures part of the source like if
it was an “effective” smaller source. However, the position of the waist is
not modified. When the beam has a high coherence, these results predicted by
geometrical optics are insufficient. This section presents numerical
simulations of the focused beam (changes in focal position and focal size)
when considering the partial coherent undulator emission. We then compute the
beam evolution using wave optics. The insertion device source is a U18
undulator (period $\lambda_{u}=$ $18\text{\,}\mathrm{mm}$) with $N_{u}$ = 138
periods. The gap is tuned to have the first harmonic at $E$ =7 keV (deflecting
parameter $K$ = 1.851).

####  3.2.1 Full coherence

We first suppose an ideal storage ring with zero emittance, therefore
producing a fully coherent emission. A Be lens of radius $R=$
$0.2\text{\,}\mathrm{mm}$ ($f=$ $14.35\text{\,}\mathrm{m}$ at 7 keV) is placed
$p=$ $65\text{\,}\mathrm{m}$, and a slit of variable aperture $a$ is placed at
$p_{a}=$ $29\text{\,}\mathrm{m}$ upstream from the lens. The beam at the slit
plane has a full-width at half-maximum (FWHM) $a_{\text{FWHM}}=$
$565\text{\,}\mathrm{\SIUnitSymbolMicro m}$. The aperture is open at
$a=n\times a_{\text{FWHM}}$ with different values of $n$ covering from fully
opening to a very narrow aperture. The refracted beam is analyzed at different
positions from the lens by calculating the FWHM of the intensity distribution.
At the focal position the FWHM presents a minimum.

Figure 1: Evolution of the size of a coherent undulator beam cropped by a slit
and focused by a lens of $R$= $0.2\text{\,}\mathrm{mm}$ The plot shows the
FWHM of the beam as a function of the distance from the lens. The aperture is
open at $a=n\times a_{\text{FWHM}}$ with different values of $n$ (shown in the
legend) and $a_{\text{FWHM}}$ = $565\text{\,}\mathrm{\SIUnitSymbolMicro m}$
(the beam FWHM at the aperture plane). The focal positions given by
geometrical optics are represented for the source placed wither at the ID
position (yellow vertical line) or at the slit position (blue vertical line).
The Fresnel number $N_{F}$ calculated at the slit plane is also marked in the
legend.

Fig. 1 shows the evolution of the beam after being focused by the lens. With
the open slit the geometrical optics give a focal position $q=$
$18.4168\text{\,}\mathrm{m}$ (source at the ID position, distant $p$ from the
lens) and $q_{a}=$ $28.4089\text{\,}\mathrm{m}$ (source at slit position,
distant $p_{a}$ from lens). It can be noticed that for $n\geq$ 1 (Fresnel
number $N_{F}\geq$ 35) the situation does not change with respect the open
slit because the cropping by the slit is negligible. For $n=0.5$ ($N_{F}=8.7$,
brown line) the FWHM of the focal size increases and the depth of focus also
increases, manifested in a flat depression. For smaller values of $n$ and
$N_{F}$ the minimum shifts to higher distances (e.g., $n=0.1$ red line) and
becomes less pronounced. For $n$ = 0.05 (green line), a small beam size is
found again close to the $q_{a}$ position, but it presents a twin minimum due
to the interference fringes found in the intensity distributions. Both minima
converge to a the $q_{a}$ position for $n\leq$ 0.01 (orange line).

When the focal distance of the lens is reduced (using lenses with smaller
radius, or piling several lenses), the $q$ and $q_{a}$ positions shift to
shorter distances, and $|q-q_{a}|$ also reduces. They converge to a single
position: the lens focal length $q=q_{a}=f$. This happens when both source-
lens and slit-lens distances can be considered at infinite.

The dimension of the waist can be calculated using geometrical concepts only
for the limiting cases of waist at $q$ and $q_{a}$. For the waist at $q$, the
beam size is the source size times its magnification (ratio between lens-waist
distance and lens-source distance). Similarly, for the waist at $q_{a}$, the
beam size is the slit aperture times the magnification (now computed as the
ratio between lens-waist distance and slit-lens distance). This has been
verified numerically (not shown). However, for intermediate slit apertures,
where the waist position is in between $q$ and $q_{a}$, the waist size is
different to that predicted by geometric optics. Indeed, it can be observed in
Fig. 1 that for these intermediate slit apertures that crop the beam, the
waist size is larger than those found at limiting positions $p$ and $p_{a}$.
This is an important fact: A good focusing, i.e., a very small beam size is
only obtained in the limiting cases of open slit and almost-closed slit. This
means that for a fully coherent beam, the slit disturbs the focusing and
should be avoided. The diffraction at the slit creates an an spurious
divergence that affects the lens power.

The calculation shown in Figure 1 refers for the zero emittance case (complete
coherence, or $CF_{h}=CF_{v}=1$). Next section extends these results to the
more realistic case of finite emittance.

####  3.2.2 Partial coherence

The mission of the slit is to improve beam coherence (increase coherent
fraction). For usual photon energies (5-25 keV) the slit must be almost closed
to gain coherence in old storage rings like ESRF-1 ($CF<10^{-3}$), thus
forming a secondary source. For storage rings like EBS, with $CF>10^{-2}$, the
selection of the slit aperture $a$ is crucial: the slit must be closed until
the the desired $CF$ is obtained, but not more, because it not only reduces
intensity but also deteriorates the focusing.

Figure 2:  Coherent fraction in the horizontal and vertical directions for
different photon energies as a function of the slit aperture $a$. The slit is
placed at $36\text{\,}\mathrm{m}$ from the ID.

We used the EBS-ESRF emittance values222We used over this work the following
values of electron beam sizes at the center of the straight section:
$\sigma_{x}=~{}$29.7\text{\,}\mathrm{\SIUnitSymbolMicro m}$$,
$\sigma_{x^{\prime}}=~{}$4.37\text{\,}\mathrm{\SIUnitSymbolMicro rad}$$,
$\sigma_{y}=~{}$5.29\text{\,}\mathrm{\SIUnitSymbolMicro m}$$,
$\sigma_{y^{\prime}}=~{}$1.89\text{\,}\mathrm{\SIUnitSymbolMicro rad}$$,
corresponding to beam emittances:
$\epsilon_{x}=~{}$130\text{\,}\mathrm{pm}\text{\,}\mathrm{rad}$$,
$\epsilon_{y}=~{}$10\text{\,}\mathrm{pm}\text{\,}\mathrm{rad}$$, and beta
functions $\beta_{x}=~{}$6.8\text{\,}\mathrm{m}$$,
$\beta_{y}=~{}$2.8\text{\,}\mathrm{m}$$ to perform the coherent mode
decomposition of the undulator source. This is done for the horizontal and
vertical directions, resulting coherent fractions (at 7 keV) of $CF_{h}=$13%
and $CF_{v}=$58%, for the horizontal and vertical directions. These values are
much higher than for the old ESRF-1 source, but still low to justify
approximating the beam by a coherent beam. Therefore, we propagated a number
of modes large enough to contain more than 99% of the source intensity (36
modes in H and 8 in V). The illumination at the entrance slit plane is
$610\text{\,}\mathrm{\SIUnitSymbolMicro m}$ in H times
$566\text{\,}\mathrm{\SIUnitSymbolMicro m}$ in V. The slit aperture is used to
tune the coherence of the beam: closing the slit increases the $CF$. In the
limit (zero aperture) the beam after the slit is fully coherent ($CF=1$), but
obviously with zero intensity. The choice of the right slit aperture comes
from a compromise between coherence and flux. Figure 2 shows the $CF$ after of
the H and V 1D beams after the slit for different slit apertures. From this
figure we select the apertures to be used in the following simulations. We
selected a photon energy of $7\text{\,}\mathrm{k}\mathrm{e}\mathrm{V}$. A
first value of $CF_{h}=CF_{v}=$ 90% in both horizontal and vertical (thus with
a combined 2D $CF=CF_{h}CF_{v}=$ 81%) is obtained with slit apertures of
$a_{h}$ = $40.3\text{\,}\mathrm{\SIUnitSymbolMicro m}$, and $a_{v}$ =
$227\text{\,}\mathrm{\SIUnitSymbolMicro m}$ (horizontal and vertical,
respectively). A second value of $CF_{h}=CF_{v}=$ 70% (thus 2D $CF$ of about
50%), corresponds to $a_{h}$ = $85.1\text{\,}\mathrm{mm}$, and $a_{v}$ =
$506.7\text{\,}\mathrm{mm}$. The case of the “open” slit that does not crop
the beam is also included (this is obtained, for example, with $a_{h}$ =
$1\text{\,}\mathrm{mm}$ and $a_{v}$ = $1.5\text{\,}\mathrm{mm}$).

Figure 3 shows the focal size along the optical axis for these apertures in
the horizontal and vertical planes. We calculated the case of the partially
coherent beam (multi-mode, solid lines) and also the case of a fully coherent
beam (only the first coherent mode, dashed lines). We observe that the focal
positions (the minima of the plot lines) do not change significantly when
passing from full to partial coherence. However, the focal dimension changes
significantly in the horizontal direction for cases with $CF_{h}\leq$ 70%. In
the vertical, where the beam at the source was more coherent there is no
differences in sizes when going from full (dashed lines) to partial coherence
(solid lines).

Looking to the focal position shift versus slit aperture we find important
differences in the horizontal and vertical. The cropping of the beam by the
slit is important in horizontal as we need to increase the $CF_{h}$ from the
source (13%) to values required by the experiments, usually larger than 50%.
This produces a gradual shift of the focal position from the position of the
geometrical image of the ID source (black line in panel a)) to the geometrical
image of the slit (red line in panel a)). However, in the vertical plane, the
slit crops the beam only slightly, and closing the slit to go from the source
$CF_{v}$ = 58% to values up to 90% does not produce any focal shift from the
position of the geometrical image of the ID source. Only when the slit is very
closed (e.g., $a_{v}$ = $25\text{\,}\mathrm{\SIUnitSymbolMicro m}$, red curve)
the focal position shifts to the geometrical image of the slit. This case is
in principle not interesting experimentally as it reduces the intensity from
an already quite coherent beam ($CF_{v}$ = 90%).

In this section, we have supposed that the 2D beam can be separated in two 1D
beams, for H and V directions. No other approximations were made: we used the
full undulator source, performed coherent mode decomposition, used an aperture
with a rectangular function, and used a Be lens with the real parabolic
profile (with thickness $t=$ $50\text{\,}\mathrm{\SIUnitSymbolMicro m}$ and
aperture $1\text{\,}\mathrm{mm}$).

We remarked that hybrid ray-tracing [codeHYBRID] correctly reproduces the
effect of shift and degradation of the focal spot when the NA is reduced. The
results are shown in Fig. 4. Compared to Fig. 1, they show a good qualitative
agreement (the focal position do agree). This result pushed us to compare our
wavefront propagation results with those of hybrid ray-tracing (sections 5 and
6).

Figure 4: Evolution of the size of a coherent undulator beam cropped by a slit
and focused by a lens of $R$ = $0.2\text{\,}\mathrm{mm}$ using hybrid ray-
tracing.

##  4 Pairing two transfocators

We study here an optical system composed by two lenses (lens-1 with focal
length $f_{1}$ and lens-2 with $f_{2}$) separated by a distance $D$. Following
Goodman85, the relationship between object-to-lens-1 distance $p_{1}$ and the
lens-2-to-image distance $q_{2}$ is

$D-(f_{1}+f_{2})=\frac{f_{1}^{2}}{p_{1}-f_{1}}+\frac{f_{2}^{2}}{q_{2}-f_{2}}.$
(10)

The global magnification is the product of the magnification of the individual
lenses. It can be written as

$M=M_{1}M_{2}=\frac{1-q_{2}/f_{2}}{1-p_{1}/f_{1}}.$ (11)

The magnification is not dependent on $D$, however the length of the optical
system $L=p_{1}+D+q_{2}$ will change if one changes the focal distances of the
lenses. For a constant $L$ one can change magnification by changing the inter-
lenses distance $D$ (zoom effect). In a synchrotron beamline using
transfocators, the magnification can be changed by varying the focal lengths
of the transfocators (by adding or removing individual or group of lenses in
the transfocator) [Vaughan:kv5084].

We analyze the optical design of a focusing system that uses two
transfocators, and how to configure it for the desired focal size or
magnification. We start using the oversimplified assumptions of geometrical
optics, for then using wave optics simulations with the focusing system
illuminated by a partial coherent beam.

Table 1: Position of the two transfocators, slit and sample (focal point) corresponding to the ID18 beamline configuration under study.  element | position [m] | comment
---|---|---
ID (undulator) source | 0 | U18 $N_{u}$ = 138 $K$ = 1.851 (7 keV)
Slit | 36 | variable aperture $a_{h}\times a_{v}$
Transfocator 2D | 65 |
Transfocator 2D | 170 |  $D$ = $105\text{\,}\mathrm{m}$
sample | 200 | focal plane

Figure 5: Trajectories $(f_{1},f_{2})$ for $D$ = $105\text{\,}\mathrm{m}$
calculated numerically for different values of apertures. Panel a) is for the
horizontal direction and panel b) for the vertical. Analytical values
displayed are obtained using equation (10) with $p_{1}$ =
$65\text{\,}\mathrm{m}$ (object at source position) (solid lines) or $p_{1}$ =
$29\text{\,}\mathrm{m}$ (object at slit position) (dashed lines).

The two transfocators in use are idealized as two real beryllium lenses of
variable curvature radius $R_{1}$ and $R_{2}$ that correspond to focal
distances $f_{1}$ and $f_{2}$ ($f=R/(2\delta)$, with $\delta=$ 6.96 10-6 for
Be at $7\text{\,}\mathrm{k}\mathrm{e}\mathrm{V}$). A slit of aperture $a_{h}$
in horizontal and $a_{v}$ in vertical is placed upstream the lens-1. The
positions of the elements is determined by room constraints and are considered
fixed (although different values could be studied). We set the distances
matching the requirements of the EBS-ESRF ID18 beamline (see Table 1), and we
analyzed the system at a photon energy of
$7\text{\,}\mathrm{k}\mathrm{e}\mathrm{V}$. We study the variation of the spot
size as a function of the focal distances. The final goal is to get the
desired focal size by selecting the configuration of the transfocators (the
focal length and the particular combination of lenses to approach it).

For fixed distances $p_{1}$, $D$ and $q_{2}$, and also a given value of
$f_{1}$, one can calculate analytically $f_{2}$ using equation (10) and the
corresponding magnification $M$ in the framework of geometrical optics. Taking
$f_{1}$ as variable parameter, Fig. 5 shows the trajectories of $f_{2}$ as a
function of a variable $f_{1}$. The choice of one pair $(f_{1},f_{2})$ from
these curves guarantees that the focus is at the sample position
($L=p_{1}+D+q_{2}$ = $200\text{\,}\mathrm{m}$ from source).

Figure 5 also shows the value of $f_{2}$ optimized numerically333Calculations
in this section use a Gaussian slit aperture to minimize diffraction fringes.
They are calculated from the analysis of the wavefront phase impinging on lens
2. A correction profile to focus on the sample is calculated using the method
described in section 2.4.6. This profile is fitted with a circle over the
central part of the lens, thus giving the radius of curvature or the most
adequate lens, and also the its focal length. The $(f_{1},f_{2})$ curves
depend strongly on the slit aperture in the horizontal, because of the low
$CF_{h}$ of the source (12%) is highly increased by the slit. In the vertical
the source is more coherent ($CF_{v}$ = 58%) therefore the slit improves the
$CF_{v}$ and there is not much change in the trajectories up to values of 90%.
However, in the case of a slit with $a_{v}$ =
$25\text{\,}\mathrm{\SIUnitSymbolMicro m}$ that is acting as a pinhole the
trajectories (red line) approach the results of the geometrical optics
considering the source at the slit position.

Figure 6 shows the calculated focal sizes. Analytical values (dashed and
dotted lines), based on geometrical optics, use equation (11). They do not
reproduce correctly values of beam sizes calculated numerically with wave
optics. It can be concluded that the analytical values have very limited
applicability, at least in the configurations studied. In the horizontal
direction, for slit apertures $a_{h}>$ $40\text{\,}\mathrm{\SIUnitSymbolMicro
m}$ the sizes change considerably for small changes in $a_{h}$. The focusing
characteristics of the system depends highly on the diffraction effects
produced at the slit. For the slit $a_{h}$ =
$40.3\text{\,}\mathrm{\SIUnitSymbolMicro m}$ ($CF_{h}=$ 90%) the focal size
can vary from roughly 10 to 50 microns. In vertical the focal size can be
changed from 5 to 100 $\text{\,}\mathrm{\SIUnitSymbolMicro m}$ at at $CF_{v}=$
90%.

Figure 6: Focal sizes obtained by a two transfocator system as a function of
focal length of lens-1 $f_{1}$. The focal length $f_{2}$ of the second lens is
obtained from the trajectories in Fig. 5. Analytical values are obtained using
equation (11) with $p_{1}$ = $65\text{\,}\mathrm{m}$ (object at source
position) (solid lines) or $p_{1}$ = $29\text{\,}\mathrm{m}$ (object at slit
position) (dashed lines).

##  5 Multiple simulations of the focusing system in the beamline

In this section we analyse particular beamline focusing configurations using
several methodologies in detail. We calculate the intensity distribution at
the focal plane for four cases. They have been selected from the results in
Fig. 6. The first case is selected to obtain a small spot (about
$5\text{\,}\mathrm{\SIUnitSymbolMicro m}$) and the second one a large spot
(more than $30\text{\,}\mathrm{\SIUnitSymbolMicro m}$). For these cases the
slits are selected to match a $CF_{h}=CF_{v}=$ 90% for a photon energy of
$7\text{\,}\mathrm{k}\mathrm{e}\mathrm{V}$. The values are shown in Table 2.
The cases 3 and 4 follow the same logic but the slits are opened to obtain a
less coherent beam ($CF_{h}=CF_{v}=$ 70%). The analysis is made with different
methodologies, using different software codes, following an hierarchical
approach, as discussed in hierarchical, with the idea of balancing accuracy
and computational effort, to subsequently select and use the most advantageous
method for the analyzed problem. This multi-method analysis will also help to
validate the new 1D CMD method introduced in this work. The results of the
Wofry1D results are compared with other well-known simulation packages.

Table 2: Configurations selected for 2D simulations. Slit aperture ($a_{h}$ or $a_{v}$) is selected for obtaining $CF_{h}=CF_{v}=$ 90% in cases 1 and 2, and $CF_{h}=CF_{v}=$ 70% in cases 3 and 4. Data are obtained from Fig. 6.  case h/v |  $a_{h}/a_{v}$ [$\text{\,}\mathrm{\SIUnitSymbolMicro m}$] |  $f_{1}$ [m] |  $f_{2}$ [m] |  $R_{1}$ [$\text{\,}\mathrm{\SIUnitSymbolMicro m}$] |  $R_{2}$ [$\text{\,}\mathrm{\SIUnitSymbolMicro m}$] | size [$\text{\,}\mathrm{\SIUnitSymbolMicro m}$]
---|---|---|---|---|---|---
1 h | 40.3 | 46.1 | 26.5 | 641.9 | 369.5 | 8.6
1 v | 227.0 | 15.0 | 22.2 | 209.4 | 309.6 | 5.3
2 h | 40.3 | 25.1 | 21.3 | 349.1 | 296.3 | 42.0
2 v | 227.0 | 42.2 | 55.6 | 588.6 | 775.3 | 32.3
3 h | 85.1 | 46.1 | 31.8 | 641.9 | 443.7 | 35.5
3 v | 506.7 | 85.2 | 27.8 | 1187.4 | 387.6 | 5.3
4 h | 85.1 | 25.1 | 20.7 | 349.1 | 288.7 | 24.0
4 v | 506.7 | 42.2 | 55.7 | 588.6 | 776.0 | 134.3
Table 3: Comparison of sizes (FWHM, in $\text{\,}\mathrm{\SIUnitSymbolMicro m}$) calculated with different methods for the cases defined in Table 2. In brackets, the values for the fully coherent beam (single electron with SRW, first coherent mode with COMSYL/WOFRY), and zero emittance with Hybrid).  case h/v | Wofry1D | COMSYL | SRW | Hybrid
---|---|---|---|---
1 h | 8.5(8.1) | 10.0 (9.9) | 8.6 (7.5) | 17.3 (17.5)
1 v | 4.8(4.8) | 4.7 (5.1) | 4.6 (4.6) | 3.3 (3.1)
2 h | 39.9(38.2) | 39.5 (39.5) | 40.0 (36.1) | 39.9 (37.5)
2 v | 32.4(29.6) | 30.6 (29.3) | 34.4 (29.6) | 74.0 (75.3)
3 h | 37.5(29.0) | 36.6 (28.1) | 40.3 (28.4) | 43.3 (33.0)
3 v | 6.1 (4.9) | 6.4 (5.7) | 6.3 (4.6) | 6.5 (5.8)
4 h | 24.6(19.1) | 26.1 (18.6) | 27.4 (18.0) | 27.1 (18.8)
4 v | 133.7(110.3) | 111.7 (90.4) | 137.4 (132.0) | 150.2 (159.8)

###  5.1 Model WOFRY 1D

We have recalculated the cases shown in Table 2 using Wofry. We optimized
manually some parameters, including the zoom factor for propagation in drift
spaces. We then combined the 1D horizontal and vertical profiles (using the
outer product) to form the 2D intensity profile at the focal plane. Results
are shown in Fig. 7. We can observe in the intensity distributions a variety
of features that are due to the diffraction effects. Case 1 shows an
horizontal profile mostly triangular with shoulders that evidence small
diffraction fringes. The fringes are more resolved in the vertical direction.
Case 2 presents in horizontal a soft Gaussian-like profile, but in vertical
important symmetric shoulders are remarked. Case 3 shows a smooth Gaussian
profile in horizontal and a small shoulder with fringes in vertical. Case 4
shows a conventional smooth profile in horizontal but an original three-lobe
plateau in vertical. This variety of profile distribution demonstrates how
relevant the diffraction effects are, which modulate the beam shape in a non-
trivial way.

###  5.2 2D Model COMSYL

COMSYL performs full CMD of undulator beam [glass2017]. It requires high
performance computing (HPC) to solve the Friedholm problem and obtain the full
2D eigenfunctions (coherent modes) and eigenvalues. Simulation of the source
with COMSYL took 55 min using 28 x 3.30 GHz CPUs of 251.82 GB RAM, for getting
174 modes of 1691 $\times$ 563 pixels. Once COMSYL calculates the source,
OASYS is used to propagate the modes along the beamline. The propagation uses
2D propagators and optical elements available in Wofry. Results are shown in
Fig. 8. This figure shows results very similar to Fig. 7, which is reasonable
because the physical models used for the CMD and propagation are similar. The
beam profiles calculated with COMSYL have more noise because the 2D wavefront
sampling cannot be as high as in Wofry within a reasonable CPU usage. The full
calculation with COMSYL helped to validate for the studied beamline the
underlying approximation in the one-dimensional CMD introduced in this work.

###  5.3 2D Model SRW

SRW [codeSRW] is a well-established code in the synchrotron community for
simulating the emission of synchrotron sources and propagating it along a full
beamline. It can be used in single-electron (SRW-SE) mode, where the source is
the fully coherent undulator radiation in an ideal storage ring with zero
emittance. To include finite-emittance, and therefore the production and
propagation of partial coherent beams, SRW uses the multi-electron (SRW-ME)
algorithm, that propagates many wavefronts each one created by an electron
that enters in the ID with different initial conditions (position and
direction) that are sampled from the parameters of the electron beam (moments
or Twiss parameters) using a Monte Carlo method [codeSRW_ME]. This method
allows to produce accurate intensity maps (by adding the intensity of
individual electrons) and is possible to calculate other parameters of the
partially coherent-beam, such as coherence lengths. However, it is not able to
store the 4D CSD nor to calculate the CF. The SRW-ME requires the use of HPC.

We have simulated the cases shown in Table 2 using SRW-ME, and results are
shown in Fig. 9. We performed a convergence analysis as described in Appendix
A to determine the minimum number of electrons needed to get accurate results.
The SRW-ME simulations for the cases analyzed converge with only a few
thousands electrons, that can be run in less than one hour in a node with 28
CPUs totalizing 256 GB. The reason is that the beam after the slit has a
relatively high CF.

The agreement between the results of SRW (Fig. 9) with Wofry1D (Fig. 7) is
striking. All intensity distributions reproduce exactly the same features, and
the FWHM values are different in less than 12%, a value that is compatible
with the errors of the simulations (discussed in section 6). This results
validates, once more, the 1D CMD method proposed here, whose requirements in
computer power are extremely low (it runs very fast in an averaged laptop).

###  5.4 2D Model hybrid ray-tracing

The use of pure ray tracing methods (based in geometrical optics) is not
adequate when analyzing optical systems dealing with coherent beams
(originating diffraction effects). Conventional ray tracing does not reproduce
the effects of focal position shift and focus degradation when the NA is
reduced. However, ray tracing-based methods much simple and fast than wave-
optics-based methods, and in many occasions they are very useful to evaluate
the impact of the beam coherence when studying a synchrotron beamline. Because
of that, a hybrid [codeHYBRID] algorithm has been developed, incorporating
concepts of coherent diffraction in the ray tracing code SHADOW [codeSHADOW].
It is fully integrated in the ShadowOUI [codeSHADOWOUI] add-on in OASYS. It
has been demonstrated to be an efficient and fast tool to design beamlines
also including coherence effects. The hybrid ray-tracing can reproduce the
effect of degradation of the focus shift and focal shift when changing the NA,
as shown in Fig. 4.

We analysed the four cases defined in Table 2 with hybrid ray tracing. Figure
10 displays the results. One can observe that the intensity distributions are
no so rich, in the sense that features obtained with full wave-optics methods
(like the three-lobe plateau in case 4v are not reproduced. However, values of
FWHM are close to full wave-optics calculations for most cases, with the
exception of two particular cases: 1h (hybrid
$16.5\text{\,}\mathrm{\SIUnitSymbolMicro m}$ Wofry1D
$8.5\text{\,}\mathrm{\SIUnitSymbolMicro m}$), 2v
($71.2\text{\,}\mathrm{\SIUnitSymbolMicro m}$ Wofry1D
$32.4\text{\,}\mathrm{\SIUnitSymbolMicro m}$). They will be discussed in the
next section.

Figure 7: 2D intensity distribution at the focal plane. It has been
constructed from the Wofry1D calculations.  Figure 8: COMSYL calculations of
the intensity distribution at the focal plane for the cases listed in Table 2.
Figure 9: Multi-electron SRW calculations of the intensity distribution at the
focal plane for the cases listed in Table 2. Figure 10: Hybrid ray tracing
calculations of the intensity distribution at the focal plane for the cases
listed in Table 2.

##  6 Discussion

###  6.1 $f_{1}$ $f_{2}$ trajectories and focal sizes

The focusing of the partial coherence x-ray beams produced by low emittance
storage rings is a complex phenomenon, because diffraction effects induced by
coherence modify significantly the beam characteristics. The concepts of
geometrical optics often used to calculate the focal position (lens equation)
and the focal size (using magnification) fail when the x-ray beam is cropped
significantly (reduced NA) (see Figs. 5, 6). The system studied here, based on
the project for the new ID18 beamline at EBS-ESRF, will image directly the
source to the focal plane (sample), using two focusing elements (paired
transfocators). This is an innovative concept only possible thanks to the high
coherence that the new storage rings provide. Beamlines in old synchrotrons
always imaged the source into a secondary source at least in horizontal. The
use of a secondary source is advantageous in terms of controlling the size
with a slit and therefore the coherence, but the drastic reduction in distance
source-sample reduces the benefits of the long beamlines. Also, bringing the
source closer to the sample imply a larger beam divergence that affects
negatively to the transmittivity. Transmittivity depends on the optical
element acceptance, usually limited by the extremely good surface finish
required. Indeed, in most nonofocusing beamlines (e.g. the ID16A beamline at
ESRF [ID16A, hierarchical]) the focal size is mainly defined by the aperture
which also limits the transmittivity to values close to the coherent fraction.
At the ID18 beamline at the EBS-ESRF source, the goal is obtain a variable
beam size, but keeping flux as high as possible. It is therefore driven by the
requirements on coherence controlled by the slit. Imaging the source directly
on the sample is much affected by the NA and beam coherence, as our results
show. Note also that the ID18 will be able to work in other configurations not
analyzed here, giving higher demagnification (with the transfocator 2 closer
to the sample). It will also be possible to use a secondary source, the image
of transfocator 1, placed close before transfocator 2.

For the EBS-ESRF, the horizontal coherent fraction is lower than the vertical
one (Fig. 2). This implies the necessity of cropping the beam more
horizontally than vertically to get $CF_{h}=CF_{v}$, thus the smaller NA
induces more distortions in the beam. In the vertical direction, the beam must
be less cropped, causing smaller beam distortion than in horizontal direction.
The horizontal apertures used to obtain typical values of CF suitable for
experiments (50-95 %) do strongly affect the evolution of the beam, but are
not small enough to consider the slit as a secondary source. This is
manifested in the shift and degradation of the focus that the first
transfocator creates (Fig. 1): whereas in vertical most of the typical
apertures (down to $227\text{\,}\mathrm{\SIUnitSymbolMicro m}$) induce the
optical system to image the source (at the ID center), in horizontal the slit
aperture required to obtain $CF_{h}=$ 90% provokes a ”shifting” of the source
from its real position (ID center) to the slit position. Although this shift
of the focal position has been predicted and calculated before (see Tanaka:85
for Gaussian beams, or westfahl for synchrotron beams) our calculations in
Fig. 3 reveal two new facts: i) the shift exists but it is directed upstream
to the position defined by the geometrical optics for the slit image (and not
downstream to the lens position, as found for the systems analyzed in the
references mentioned), and ii) the focal size is highly degraded (its size
increases) when the beam focus is found in between the two positions defined
by the geometrical optics.

Pairing two transfocators consists in matching their focal distances to
guarantee the focus at the desired focal plane (the sample position). By
matching the lens equations of the two lenses, it is possible the analytical
expression in Eq. 10 permits to calculate $f_{2}$ as a function of $f_{1}$.
This can be done for the two cases: with the source at the ID center (limit of
high NA, no cropping) of with the source at the slit (pinhole limit when NA
$\rightarrow$ 0). The analytical equations diverge at the position where
lens-1 focuses onto lens-2. Figure 5 shows an asymptotic approach (for
$f_{1}<$ $25\text{\,}\mathrm{m}$ or $f_{1}>$ $70\text{\,}\mathrm{m}$) of the
numerical results to geometrical optics results, mostly with source at the ID,
but sometimes (with closed slit) to the case of the source at the slit
position. However, this case is obtained in the horizontal direction with a
reasonable aperture $a=$ $40.4\text{\,}\mathrm{\SIUnitSymbolMicro m}$ (to
reach good coherence $CF_{h}=$ 90%) but with a very small aperture in the
vertical direction $a=$ $25\text{\,}\mathrm{\SIUnitSymbolMicro m}$, a less
interesting setup because high coherence can be obtained with more opened
slits without compromising transmission.

Equation 4 predicts analytical singularities in $f_{2}$ when lens-1 focuses on
lens-2. The numerical results (Fig. 5) show smooth transition from one branch
to another, softer for smaller NAs in the horizontal (Fig. 5a) but not
relevant in the vertical (Fig. 5b). As NA is reduced, the inflexion point
shifts from the position calculated with the source at the center of the ID to
the source at the slit position. However, as discussed in the last paragraph,
this shifting is evident in the horizontal for the usual slit openings, but is
not yet relevant in vertical for common apertures.

It is remarkable that the focal sizes calculated in Fig. 6 differs
considerably from the results of the geometrical optics, making it not
adequate to estimate focal sizes using geometrical concepts driven by source
demagnification. Only in some particular areas geometrical optics give good
results: in horizontal around $f_{1}\approx$ $30\text{\,}\mathrm{m}$, and at
$f_{1}<$ $30\text{\,}\mathrm{m}$ in vertical.

In summary, the numerical simulation of the $(f_{1},f_{2})$ trajectory maps
present two characteristics: i) they asymptotically match the analytical
positions for sufficiently high or small $f_{1}$, either the position obtained
when the source is at ID (high NA) or when the source is at the slit (low NA),
and ii) the analytical singularities found when lens-1 focuses on lens-2 are
smoothed originating an inflexion point that shifts, when reducing the NA,
from the analytical position considering the source at the center of the ID to
the position with the source sitting at the slit.

###  6.2 Methods of calculation

The results presented here in Fig. 5 contain more than one thousand individual
simulation (2 directions $\times$ 4 slits $\times$ 200 points in $f_{1}$).
Each point in the graph represents a calculation including full partial
coherence simulations that involves the transport of many modes. This has only
be possible with the development of a new fast Wofry1D code for coherent mode
decomposition method outlined in Section 2. The results from the some selected
configurations in Section 5 (Figs. 5 and 6) validate the accuracy of the
Wofry1D method by comparing its results with full 2D methods (COMSYL and SRW).
The wave optics simulations using the three methods (Wofry1D, COMSYL and SRW)
give very similar results. There is good agreement in focal size FWHM values,
but also in the shape of intensity distributions (compare Figs. 7, 8 and 9).
The Wofry1D code can be run in a few seconds in a laptop, whereas the
simulation of the full CMD with COMSYL required about 1h (for 1691 x 563
pixels, 174 modes) using 1 node of 28 cores. This source is then reused for
propagating the different configurations. Each configuration required a full
SRW-ME with 5000 electrons run in also about 1h in a similar configuration.

The specific numeric value for sizes calculated with the different methods
(Table 3) depends not only on the code itself, but also on the particular
specific parameters in each method (number of pixels for sampling wavefronts,
propagation parameters, etc.). To estimate the calculation error in the final
size numbers, we vary randomly these specific parameters in a reasonable range
(e.g., 10%). The evaluation of the mean size and the dispersion (standard
deviation) of the sizes obtained give an good estimation of the error in this
parameter. This exercise would take a considerable computational effort using
2D methods, but it can be easily done with Wofry1D. We run 200 cases with 10%
random variation in the values in number of pixels and magnification factor in
drift spaces. The obtained sizes (horizontal $\times$ vertical) are 8.49 $\pm$
0.60 $\times$ 4.97 $\pm$ 0.37 $\text{\,}\mathrm{\SIUnitSymbolMicro m}$2 (case
1), 39.94 $\pm$ 2.98 $\times$ 32.77 $\pm$ 2.69
$\text{\,}\mathrm{\SIUnitSymbolMicro m}$2 (case 2), 36.39 $\pm$ 2.89 $\times$
6.12 $\pm$ 0.51 $\text{\,}\mathrm{\SIUnitSymbolMicro m}$2 (case 3), and 24.18
$\pm$ 1.80 $\times$ 133.44 $\pm$ 10.06 $\text{\,}\mathrm{\SIUnitSymbolMicro
m}$2 (case 4). We confirmed that the values given in Fig. 7 are within these
error intervals.

###  6.3 Hybrid ray tracing

The simulation results for the four cases studied using the hybrid method
indicate that, although this method does not reproduce exactly the intensity
distibution given by full partial coherent optics, the numerical values are
approaching the good ones, but with two exceptions: the case 1h (hybrid
$16.5\text{\,}\mathrm{\SIUnitSymbolMicro m}$ Wofry1D
$8.5\text{\,}\mathrm{\SIUnitSymbolMicro m}$) and the case 2v
($71.2\text{\,}\mathrm{\SIUnitSymbolMicro m}$ Wofry1D
$32.4\text{\,}\mathrm{\SIUnitSymbolMicro m}$). We remark that these thee cases
have in common that the $f_{1}$ value in use is close to $f_{1}$ =
$40\text{\,}\mathrm{m}$ that corresponds to the singularity in the analytical
(geometrical optics) calculations, when the lens-1 focuses on lens-2. A
detailed study with hybrid was performed to calculate the FWHM for all
possible values of $f_{1}$ (as done in Fig. 6. The result (Fig. 11) confirms
that there is good agreement everywhere except in the region close to $f_{1}$
= $40\text{\,}\mathrm{\SIUnitSymbolMicro m}$. We thus conclude that the hybrid
ray tracing is a valid method to obtain good values of focal sizes in most
cases, excepts for the case that lens-1 focus is close to the position of
lens-2 ($f_{1}\approx$ $40\text{\,}\mathrm{m}$).

Figure 11: Focal sizes obtained by hybrid ray tracing method, for two slit
aperture cases, compared with values from Wofry1D (from Fig. 6).

###  6.4 Transmitted flux

We have limited our study to the focal sizes, but it can be complemented with
focal flux. At $7\text{\,}\mathrm{k}\mathrm{e}\mathrm{V}$, the undulator in
the configuration selected emits a flux of 1.5 1015 photons/s/0.1%bw. Each of
the three elements studied (slit, lens -1 and lens-2) absorb part of the flux.
The estimation of the absorption by the slit can be done using simple
geometrical arguments, and the absorption by the slits depend on the average
Be thickness presented to the beam. The linear attenuation coefficient of Be
at 7 keV is $\mu=$ $3\text{\,}\mathrm{cm}$-1, giving 1.45% attenuation for a
$50\text{\,}\mathrm{\SIUnitSymbolMicro m}$ thick layer (like lens thickness
used in simulations444In the simulations the horizontal and vertical focusing
are separated in two lenses, with accumulated thickness
$100\text{\,}\mathrm{\SIUnitSymbolMicro m}$ thus absorption 3%). For the case
1 simulations we extracted the absorption for the different absorbing elements
(slit, lens-1 and lens-2) in the case of partial coherence and also for full
coherence (see Table 4).

There is excellent agreement for partial coherence. For full coherence, the
Wofry1D results are different than the SRW+Hybrid, because the geometry of the
1st coherent mode used to represent the full coherent beam is not the same as
the geometry of the filament beam (used in SRW and Hybrid). We note a high
absorption in lens-2, due to the fact that in this case the lens-2 is
overilluminated, therefore the $1\text{\,}\mathrm{mm}$ physical aperture
absorbs considerably the beam.

Table 4: Comparison of beam intensity attenuation in percent by the slit, lens-1 and lens-2 for the partial coherent beam, for the four cases studied. The Wofry1D data shown here comes after combining the horizontal and vertical wavefronts using the outer product.  case | slit | lens-1 | lens-2
---|---|---|---
|  Wofry1D |  SRW |  Hybrid |  Wofry1D |  SRW |  Hybrid |  Wofry1D |  SRW |  Hybrid
1 | 97.6 | 97.6 | 97.2 | 7.9 | 7.6 | 5.2 | 50.7 | 51.1 | 52.6
2 | 97.6 | 97.6 | 97.2 | 7.0 | 6.6 | 4.3 | 3.9 | 3.7 | 3.3
3 | 89.5 | 90.2 | 88.6 | 6.3 | 6.1 | 4.6 | 23.4 | 21.8 | 25.2
4 | 89.5 | 90.2 | 88.6 | 8.0 | 7.7 | 6.2 | 3.8 | 3.6 | 3.6

###  6.5 Accuracy of the focal position and depth of focus

We have calculated the beam evolution in the neighbourhood of the sample
position for the four cases studied (see Fig. 12). From these plots one can
obtain the position of the best focus and the depth of focus. In some cases
there is a mismatch between the position of the best focus and its expected
position (the sample position, at the zero abscissas). This effect, certainly
due to an error in setting $f_{2}$, may have several origins.

For pairing two transfocators, the algorithm chosen to calculate the $f_{2}$
value consist in analyzing the wavefront at the lens-2 position, find a
corrector refractive object that would transform the incoming wavefront in a
converging wavefront (see section 2.4.6), and fit the radius at the center. We
then get the $R_{2}$ and therefore the $f_{2}$ value. In addition, to obtain
smooth $(f_{1},f_{2})$ curves in Fig. 5 we have used a Gaussian slit (see
section 2.3). It smears out the diffraction fringes, because in an ideallized
system where a point source is focused at the sample position, the recorded
intensity would correspond to the diffraction pattern of the slit, that can be
considered as an ”object” placed in the beam (see e.g. [paganin_book]). The
use of a Gaussian object implies that its diffraction pattern is a Gaussian
with no diffraction fringes.

For cases 1h, 1v, 3v (see Fig. 12), there is a good agreement between the
focal position obtained from the maximum of intensity on-axis (plotted at the
top of the image) and our expected position (the zero in the plots). In some
other cases (2v, 3h, 4h) the agreement is acceptable, taking into account that
the observed depth of focus is of the order of meters. A small correction in
$f_{2}$ would bring the best focus to its ideal position. This correction is
necessary because we used a Gaussian slit for calculating $f_{2}$, thus
neglecting some oscillations around the $(f_{1},f_{2})$ curves. There are two
pathological cases where the algorithm used to calculate $f_{2}$ did not
succeed: the cases 2h and 4v. The error in $f_{2}$ for case 2h is also due to
the oscillations in the $(f_{1},f_{2})$ and can be corrected, as shown in Fig.
13a. However, case 4v cannot be corrected because we would need a divergent
lens to bring the focus of $f_{1}$ to the sample position. Setting
$R_{2}=f_{2}=\infty$ would reduce the beam size at the sample position (Fig.
13b), but cannot get the best focus there. However, an ad-hoc defined
refractive corrector in the place of lens-2 would do the job (Fig. 13d).

The depth of focus (measured as the distance where the peak value is reduced
by 15%) is larger than two meters (except for the cases 1v, 3v).

Figure 12: Evolution of the beam size in the around the sample position for
the cases listed in Table 2. The top and side graphs correspond to the
profiles passing by (0,0).  Figure 13: Evolution of the beam size in the
around the sample position for the “pathological” case 2h and 4v shown in Fig.
12. Top row: using corrected lens-2 with
$R_{2}$=$410\text{\,}\mathrm{\SIUnitSymbolMicro m}$
($f_{2}=$$29.4\text{\,}\mathrm{m}$) for case 2h and $R_{2}=f_{2}=\infty$ for
case 4v. Bottom: using a free-form refractive corrector instead of lens-2.

###  6.6 Errors in optical surfaces

The performance of X-ray optics in the new generation synchrotron beamlines is
limited by the quality of the optical surfaces [lengeler1999, Yabashi]. Finish
errors can be divided in three families: i) height errors, associated with
surface finishing (high spatial frequency), ii) figure errors, associated with
deviations from ideal profile (e.g. bending, gravity sag, thermal
deformations), and iii) slope errors or waviness, associated to medium spatial
frequencies [srio1992, signorato1997]. Finish errors in x-ray lenses can be
measured by different techniques (eg. grating interferometry, x-ray speckle
tracking or ptychography) and readily included in the simulations
[Celestre:mo5214]. Some profiles measured at ESRF using x-ray speckle tracking
[berujon2020] with height error RMS of the order of
$1\text{\,}\mathrm{\SIUnitSymbolMicro m}$ are used to verify that the focal
spot produced by lenses with realistic errors is not degraded with respect to
the ideal lens surface.

The effect of finish errors in the white double-mirror system is also analyzed
using a measured mirror meridional profile of $2.5\text{\,}\mathrm{nm}$ height
error RMS and $140\text{\,}\mathrm{nrad}$ RMS slope error.

The heat load affect several elements of the beamline. For the beamline under
consideration, the affected elements (white beam mirrors, and double-crystal
monochromators) are not presented in our simulations. Finite element analysis
of mirrors and crystals done for other EBS beamlines [Brumund] show that the
deformation height profile can be decomposed it two parts: an average bending
that is possible to correct by a small readjustment of the focal length of the
optical elements downstream the heated element, and a “residual error” which
remain after removing the averaged bending radius, and could only be corrected
using adaptive optics. Wofry1D simulations using FEA-generated deformations at
the first crystal of a monochromator placed just after the coherent slit
showed no significant degradation of the focal spot, both in size and shape.
This is mainly due to the low power transmitted by the coherent slit. We
checked that the focused beam is almost unchanged when using a profile from
FEA analysis with curvature of about $1\text{\,}\mathrm{km}$ and residual
slope errors of $30\text{\,}\mathrm{nrad}$.

###  6.7 Selection of the transfocator configuration.

The results presented in this paper idealizes the transfocator with two
orthogonal single lenses, each one focusing one direction (horizontal of
vertical), with parabolic profiles and apex radii adjusted for the wanted
focal length (via the usual $f=R/(2N\delta$). The real transfocator will use a
combination of one or several lenses to give a similar radius of curvature
($R^{-1}=R_{1}^{-1}+R_{2}^{-1}+...$). Two independent transfocators can be
used for focusing independently the horizontal and vertical planes. Also,
combination of 2D lenses matching the higher radius could be combined with 1D
lenses to correct the radius of the direction that requires a shorter focal
distance. The combinations of the lenses in the transfocator will not match
perfectly the exact focal distances, thus producing a focal position close to
the exact focal position at sample location. Depending on the used lenses, a
different absorption is due to the accumulated thickness of the individual
lenses. For example, the lens radii for case 4 can be obtained in using 2D
lenses adjusted to focus in vertical (three lenses with $R_{1}=$
$5\text{\,}\mathrm{mm}$, $R_{2}=$ $2\text{\,}\mathrm{mm}$ and $R_{3}=$
$1\text{\,}\mathrm{mm}$ to get $R=$ $0.588\text{\,}\mathrm{mm}$) then adding
two more 1D lenses to adjust the horizontal ($R_{1}=$ $5\text{\,}\mathrm{mm}$
and $R_{1}=$ $1\text{\,}\mathrm{mm}$ to get $R=$ $0.345\text{\,}\mathrm{mm}$,
values very close to the exact values from Table 2. We simulated this
configuration and got similar profiles than the case studied previously, with
small differences in FWHM (10% or less) and obviously more absorption. The
empty space in between the lenses is neglected, which is a good approximation
unless effects of “adiabatic” focusing are expected, which may be the case for
sub-micron focii.

###  6.8 The measurement of coherence

We measured the beam coherence using the coherent fraction $CF$, an idea
introduced by glass2017. This parameter has a strict definition in the context
of the CMD: $CF$ is the occupation of the first coherent mode ($\eta_{0}$ in
Eq. 5). We verified that this strict definition give values close to the
approximated $CF$ calculated as the phase space dimension ratio between the
coherent undulator emission (zero emittance) over the convolution of the
electron beam phase space and the undulator emission. The CMD gives also the
possibility of propagating the modes and also recalculate the $CF$ after the
slits and optical elements. The coherence slit selects the wanted coherence
(90% for cases 1 and 2; or 70% for cases 3 and 4 in our study) but the
absorption of the lenses can also increase a bit more the coherence at the
sample: $CF_{h}=$ 94, 94, 77, 77 $CF_{v}=$ 97, 90, 77, 71 for cases 1, 2, 3
and 4, respectively.

Other common parameters to define the coherence are the degree of coherence
and coherence length. The degree of (transversal) coherence is not a scalar
but a function (see equation 3. The coherence length has not a strict
definition and it is usually given as the “width” of some cut of the coherence
degree. We found more intuitive and practical to use the $CF$ as a measure of
the coherence. However, a good idea of the coherence length at a given
position along the beamline is also given by the FWHM of the first coherence
mode (given in brackets in Table 3 for the four cases studied).

###  6.9 Practical considerations

Simulations like those presented here could be very beneficial for beamline
operation, for its optimization and quick setting. Complicated relationships
exist between the beam parameters requested by users (beam size and coherent
fraction) and the beamline configuration (undulator, slit and transfocator
setting). Quick simulations as done by Wofry1D could be a helpful instrument
for the beamline staff to get the desired configurations. The plots shown here
(e.g., $CF$ vs slit size in Fig. 2, trajectories in Fig. 5, or final size in
Fig. 6 could be simulated on-line and compared with results presented as look-
up tables with similar aspect. We are also considering the design of a digital
twin that mimics the real transfocator systems to assist beamline setting. For
that, the fast simulation using the CMD method developed in Wofry1D will be an
integrated component.

Some practical consequences can be directly deduced from the results shown
here. For example, looking at Fig. 6 one can observe that the same focal size
can be obtained with different configurations. To get a similar size, it is
better to prefer a large $f_{1}$ to avoid over-illuminating the lens-2 and
increase transmission of lens-1. The transfocator design is simplified if we
restrict the horizontal focal distance t to be smaller than the vertical
$f_{h}>f_{v}$. Here, $f_{v}$ can be obtained with lenses focusing in 2D and
$f_{h}$ by adding 1D lenses focusing in the horizontal plane.

In this work we configured the transfocator to have the resulting focal
position on the sample plane, an ”in-focus” setup. It could also be possible
to work off-focus to vary the beam size at the sample plane. The in-focus
setup will generally produce the sharpest image of very small details in the
image. Moreover, it will reduce the artifacts produced by the surface finish
errors. Also, a larger depth of focus is obtained at this position (see e.g.
Fig. 13).

##  7 Summary and conclusions

We have studied in detail the focusing of a partial coherent beam (as produced
by the low emittance storage ring EBS-ESRF) by a system of one and two
transfocators (or lenses). In agreement with existing works, we observe a
displacement of a focal position originated by the reduction of NA. The
reduction of NA is the result of closing a slit to gain coherence, a usual
procedure in beamlines for X-ray coherence applications. We observed that good
focusing (small focus) is obtained when its position coincide with the
positions predicted by the geometrical optics (considering the source either
at the ID position or at the slit position) but not in intermediate positions
(Fig. 3).

We calculated numerically the map or trajectory of focal distances
$(f_{1},f_{2})$ needed to maintain the focus at the image plane. The beam size
values obtained for different cases are very different than those predicted by
geometrical optics.

Numerical calculations for this work have been done using a newly developed
method of coherent mode decomposition in 1D. This method is very fast, and
many simulations can be run in a laptop, therefore it is ideal for parametric
calculations as presented here. This method is available in the Wofry add-on
of the OASYS suite [codeOASYS]. Four cases are calculated and compared using
the other methods available in OASYS, like the full 2D coherent mode
decomposition using COMSYL [codeCOMSYL], the OASYS interface for the SRW
[codeSRW] code, and hybrid ray tracing [codeHYBRID]. OASYS workspaces for the
simulations performed in this paper are available555
https://github.com/srio/paper-transfocators-resources/tree/main/workspaces.

##  Appendix A Some considerations on partially-coherent calculations using
SRW’s macro-electrons & simulation convergence

In the frequency domain, the synchrotron radiation (SR) intensity from
$N_{\text{e}}$ electrons is given by:

$\begin{split}|E&{}_{\omega\text{~{}bunch}}(\textbf{r})|^{2}\approx\\\
&N_{\text{e}}\int\big{|}E_{\omega}(\textbf{r};\textbf{s}_{\text{e}},\textbf{s}^{\prime}_{\text{e}},\gamma_{\text{e}})\big{|}^{2}\cdot
f(\textbf{s}_{\text{e}},\textbf{s}^{\prime}_{\text{e}},\gamma_{\text{e}})~{}\text{d}\textbf{s}_{\text{e}}\text{d}\textbf{s}^{\prime}_{\text{e}}\text{d}\gamma_{\text{e}}~{}+\\\
&+~{}N_{\text{e}}(N_{\text{e}}-1)\bigg{|}\int
E_{\omega}(\textbf{r};\textbf{s}_{\text{e}},\textbf{s}^{\prime}_{\text{e}},\gamma_{\text{e}})\cdot
f(\textbf{s}_{\text{e}},\textbf{s}^{\prime}_{\text{e}},\gamma_{\text{e}})~{}\text{d}\textbf{s}_{\text{e}}\text{d}\textbf{s}^{\prime}_{\text{e}}\text{d}\gamma_{\text{e}}\bigg{|}^{2},\end{split}$
(12)

where $E_{\omega\text{~{}bunch}}(\textbf{r})\equiv
E_{\text{~{}bunch}}(x,y;\omega)$ and $E_{\omega}(\textbf{r})\equiv
E(x,y;\omega)$;
$\textbf{s}_{\text{e}}=(x_{\text{e}},y_{\text{e}},z_{\text{e}})$ represents
the electron initial positions,
$\textbf{s}^{\prime}_{\text{e}}=(x^{\prime}_{\text{e}},y^{\prime}_{\text{e}})$
gives the electron initial directions and $\gamma_{\text{e}}$ is the electron
energy. All sampled from the 6D electron-beam phase-space such that $\int
f(\textbf{s}_{\text{e}},\textbf{s}^{\prime}_{\text{e}},\gamma_{\text{e}})~{}\text{d}\textbf{s}_{\text{e}}\text{d}\textbf{s}^{\prime}_{\text{e}}\text{d}\gamma_{\text{e}}=1$
[codeSRW_CSR]. The methods for computing the spontaneous emission by a
relativistic electron submitted to an arbitrary magnetic field, that is
$E_{\omega}(\textbf{r};\textbf{s}_{\text{e}},\textbf{s}^{\prime}_{\text{e}},\gamma_{\text{e}})$,
are described in [Chubar1995, codeSRW]. The first term in the sum from Eq. 12
describes temporally incoherent SR, while the second term, temporally coherent
SR:
$\text{I}_{\text{~{}bunch}}=\text{I}_{\text{~{}iSR}}+\text{I}_{\text{~{}cSR}}$.
For emitted wavelengths shorter than the electron bunch length, the power
associated with the term $\text{I}_{\text{~{}cSR}}$ vanishes quickly
[Wiedemann2015]. At typical X-ray energy ranges in the ESRF-EBS, i.e. from a
few hundred electron-volts to a few hundred keV, and typical bunch lengths
(over 30 ps), $\text{I}_{\text{~{}cSR}}$ can be completely neglected even when
considering standard monochromatisation schemes in beamlines. A further
simplification to Eq. 12 is done when considering that the intensity of the
single-electron emission is not dependent on the initial electron position
$z_{\text{e}}$. The integration of Eq. 12 can then be done in 5 dimensions.

The SRW-ME algorithm used to account for partial (transverse) coherence
implements Eq. 12 by individually calculating the SR emission of several
electrons subjected to the initial conditions sampled from
$f(\textbf{s}_{\text{e}},\textbf{s}^{\prime}_{\text{e}},\gamma_{\text{e}})$
passing through an arbitrary magnetic field describing the X-ray source. Each
resulting electric field is then propagated through the beamline until the
observation point, where the contributions from different electrons are added
in intensity [codeSRW_ME]. It is impractical (and unnecessary) to account for
the emission of every single electron in a beam that very often has a current
of few hundreds mA. Electrons are then divided in so-called macro-electrons
(me’s), which is an abstraction that allows to group the emission of several
individual electrons into one particle behaving (in electro-dynamics theory
terms) as a single electron emission, but with resulting intensity given by
the total intensity $\text{I}_{\text{~{}bunch}}$ divided by the number of
macro-electrons. An advantage of the SRW-ME approach is that the electric
fields of the me’s propagate independently from each other, which allows a
convenient parallelisation of the wavefront propagations among many
processors.

The convergence of this method is based on the finesse with which the
distribution
$f(\textbf{s}_{\text{e}},\textbf{s}^{\prime}_{\text{e}},\gamma_{\text{e}})$ is
sampled. While an exquisitely large number of me’s will lead to a more
accurate simulation, the resulting calculation would be very long and
impossible to be performed on personal computers within reasonable time even
if performed in parallel. The number of me’s depends on overall beamline
degree of coherence at the observation plane, which is impacted by the source
coherent fraction and beamline overall transmission (eg. slits, creation of
secondary sources or any other spatial filtering scheme). Special attention to
the number of macro-electrons should be given if the simulation accounts for
vibrations in the beamline elements or broad-band radiation (eg. pink beam or
radiation filtered by multi-layer monochromators).

To illustrate the effect of the number of macro-electrons on the beam profile
we choose the previously studied cases 1 and 3 from section 5 \- due to their
$CF$, cases 2 and 4 are expected to have the same convergence as 1 and 3,
respectively. Both systems 1 & 3 (and 2 & 4) have the same X-ray source and
are illuminated up until the slits (36 m downstream U18) by the same beam,
differing mainly by the coherent fraction selected for the rest of the
beamline with case 1 having a higher $CF$ than case 3 - refer to Tables 1 and
2 for the complete simulation parameters. The results for a selected number of
me’s are shown in Figs. 14 and 15. The 1 me simulation represents the
filament-beam source, where the electron beam emittance is negligible and the
fully spatial coherence is assumed - this is often called a “single electron
simulation”. On the other extreme, an exaggerated value of 100k $me^{\prime}s$
is chosen as a way of guaranteeing convergence by brutal-force. Two criteria
are used to evaluate the convergence of the simulations: the beam shape and
peak intensity stabilisation. The profile cuts in Fig. 14(a)-(b) and Fig.
15(a)-(b) show that the profile shape starts to converge to that of a 100k
$me^{\prime}s$ after $\sim$500 macroelectrons for case 1 and $\sim$1k
macroelectrons for case 3. Beyond that, it is necessary to resort to the
relative error standard deviation and the peak intensity stabilisation. Fig.
14(c)-(d) and Fig. 15(c)-(d) show that for both cases, the convergence happens
between 2k and 5k $me^{\prime}s$. Further increase in the number of macro
electrons does not translate in improvements in the simulations (see
simulations for 10k $me^{\prime}s$ onward), but increase greatly the cost of
the calculation as shown in Fig. 16. For the work presented here a good
compromise between accuracy and efficiency of the calculations is reached at
5k $me^{\prime}s$. Other factors contributing to the total elapsed simulation
time and overall parallel performance of SRW-ME method are presented in §3.3
from [codeSRW_MEscan], but these do not impact the SRW-ME convergence.

It is important to note that this large scan procedure is merely illustrative.
Usually an experienced optical designer starts with a good guess of the
necessary number of $me^{\prime}s$ based on the characteristics of the source
(degree of coherence) and optical system (transmission and expected degree of
coherence at the observation plane). This choice usually includes
considerations of time and resources consumption. If there are signs that the
choice may be too low, further attempts with higher $me^{\prime}s$ should be
done. If the simulation looks fine from the first guess, reducing the number
of $me^{\prime}s$ is also interesting as very often it is necessary to repeat
the simulations (eg. testing different configurations, different energies,
tolerancing or even different observation planes). At the time of writing, the
authors are unaware of any widespread metric within the SRW’s community
capable of giving the exact number of me’s necessary for the convergence of
the SRW-ME method other than the $me^{\prime}s$ scan. We welcome the
discussion on SRW-ME convergence and we encourage the reader to reach out if
they employ any interesting and reproducible convergence metric that is less
time (and resource) consuming.

Figure 14: Partially-coherent simulations convergence study: case 1. (a)
horizontal and (b) vertical intensity cuts at E=7 keV for $me^{\prime}s$
ranging from 1 to 100k. (c) errors relative to the $me^{\prime}s=$100k plots
and (d) peak intensity. Figure 15: Partially-coherent simulations convergence
study: case 3. (a) horizontal and (b) vertical intensity cuts at E=7 keV for
$me^{\prime}s$ ranging from 1 to 100k. (c) errors relative to the
$me^{\prime}s=$100k plots and (d) peak intensity. Figure 16: Total elapsed
time for partially-coherent simulations using a computer cluster with 28
processors for parallel calculations as a function of number of
$me^{\prime}s$.

Acknowledgements

The authors thank Jean-Pierre Guigay for the helpful discussions. This project
has received funding from the European Union’s Horizon 2020 Research and
Innovation programme under Grant Agreement No 823852 (PaNOSC).

iucr