computer programs\(\def\hfill{\hskip 5em}\def\hfil{\hskip 3em}\def\eqno#1{\hfil {#1}}\)

Journal logoJOURNAL OF
APPLIED
CRYSTALLOGRAPHY
ISSN: 1600-5767
Volume 49| Part 4| August 2016| Pages 1347-1355

WavePropaGator: interactive framework for X-ray free-electron laser optics design and simulations1

CROSSMARK_Color_square_no_text.svg

aEuropean XFEL GmbH, Albert-Einstein-Ring 19, Hamburg, 22761, Germany, bInstitute of Crystallography, Leninskii prospekt 59, Moscow, 119333, Russian Federation, and cNational Synchrotron Light Source II, Brookhaven National Laboratory, Upton, NY 11973, USA
*Correspondence e-mail: liubov.samoylova@xfel.eu, buzmakov@gmail.com

Edited by N. D. Loh, National University of Singapore (Received 9 February 2016; accepted 19 June 2016; online 6 July 2016)

This article describes the WavePropaGator (WPG) package, a new interactive software framework for coherent and partially coherent X-ray wavefront propagation simulations. The package has been developed at European XFEL for users at the existing and emerging free-electron laser (FEL) facilities, as well as at the third-generation synchrotron sources and future diffraction-limited storage rings. The WPG addresses the needs of beamline scientists and user groups to facilitate the design, optimization and improvement of X-ray optics to meet their experimental requirements. The package uses the Synchrotron Radiation Workshop (SRW) C/C++ library and its Python binding for numerical wavefront propagation simulations. The framework runs reliably under Linux, Microsoft Windows 7 and Apple Mac OS X and is distributed under an open-source license. The available tools allow for varying source parameters and optics layouts and visualizing the results interactively. The wavefront history structure can be used for tracking changes in every particular wavefront during propagation. The batch propagation mode enables processing of multiple wavefronts in workflow mode. The paper presents a general description of the package and gives some recent application examples, including modeling of full X-ray FEL beamlines and start-to-end simulation of experiments.

1. Glossary

FEL: free-electron laser.

FFT: fast Fourier transform.

Git: a distributed revision control and source code management system (https://git-scm.com).

GitHub: a web-based Git repository hosting service (https://github.com/).

HDF5: Hierarchical Data Format. To view HDF5 files one can use the official free HDFView tool (https://www.hdfgroup.org/products/java/hdfview).

IPython Notebook: an interactive computational environment for combining code execution, rich text, mathematics, plots and rich media (https://ipython.org/notebook.html).

MPI: Message Passing Interface. A standardized and portable message-passing system designed by a group of researchers from academia and industry to function on a wide variety of parallel computers (https://www.mpi-forum.org/).

SASE: self-amplified spontaneous emission. The process whereby an electron beam passes through a long undulator, such that the initial random field of spontaneous radiation becomes amplified in intensity and enhanced in coherence characteristics. SASE FEL pulses are characterized by spiky structure and fluctuations in wavelength and FEL pulse energy.

2. Introduction

The X-ray free-electron laser facilities (XFELs) that have emerged in recent years deliver radiation with a unique combination of properties, such as extreme peak field intensities, ultra-short X-ray pulse duration and a high degree of transverse coherence of the XFEL radiation, and thus establish a new specific combination of requirements for X-ray optics. Additional factors such as the varying beam size and divergence as a function of the electron bunch charge, the very large distances to the source, and, as a consequence, the large apertures required for the optics further complicate the environment.

Besides, the end stations at XFEL facilities have very versatile layouts, which can include multi-crystal monochromators, split-and-delay lines and units for pump–probe experiments (Roling et al., 2014[Roling, S., Zacharias, H., Samoylova, L., Sinn, H., Tschentscher, Th., Chubar, O., Buzmakov, A., Schneidmiller, E., Yurkov, M. V., Siewert, F., Braun, S. & Gawlitza, P. (2014). Phys. Rev. ST Accel. Beams, 17, 110705.]), monochromators for hard and soft X-ray self-seeding schemes (Amann et al., 2012[Amann, J. et al. (2012). Nat. Photon. 6, 693-698.]; Inagaki et al., 2014[Inagaki, T. et al. (2014). FEL2014, Proceedings of the 36th International Free Electron Laser Conference, TUC01, pp. 603-608. Geneva: JACoW.]), and various refocusing optics. For a correct optics design, one has to analyze and optimize all the factors that have an impact on the beam properties after propagation of the beam through the optics. Hard X-ray FEL wavefronts are subject to distortions caused by imperfections of the optics, in particular the effect of mirror surface errors, which have been measured experimentally at LCLS and SACLA (Rutishauser et al., 2012[Rutishauser, S., Samoylova, L., Krzywinski, J., Bunk, O., Grünert, J., Sinn, H., Cammarata, M., Fritz, D. M. & David, C. (2012). Nat. Commun. 3, 947.]; Kayser et al., 2014[Kayser, Y., Rutishauser, S., Katayama, T., Ohashi, H., Kameshima, T., Flechsig, U., Yabashi, M. & David, C. (2014). Opt. Express, 22, 9004-9015.]). Moreover, characterizing focused XFEL intense wavefields is crucial for their use in single-shot diffractive imaging experiments (Loh et al., 2013[Loh, N. D. et al. (2013). Opt. Express, 21, 12385.]; Park et al., 2013[Park, H. J. et al. (2013). Opt. Express, 21, 28729.]).

The wave optics formalism is a natural and reliable way to deal with interference effects that are unavoidable in coherent beam propagation (Bahrdt et al., 2014[Bahrdt, J., Flechsig, U., Grizolli, W. & Siewert, F. (2014). Proc. SPIE, 9209, 920908.]; Chubar et al., 2011[Chubar, O., Berman, L., Chu, Y. S., Fluerasu, A., Hulbert, S., Idir, M., Kaznatcheev, K., Shapiro, D., Shen, Q. & Baltser, J. (2011). Proc. SPIE, 8141, 814107.]). We present here the WavePropaGator (WPG) package, the goal of which is to provide a user-friendly software environment that any scientist involved in XFEL optics design can use, without having specific experience in numerical wave optics calculations. The package is built on top of the open-source Synchrotron Radiation Workshop (SRW) software (Chubar et al., 2011[Chubar, O., Berman, L., Chu, Y. S., Fluerasu, A., Hulbert, S., Idir, M., Kaznatcheev, K., Shapiro, D., Shen, Q. & Baltser, J. (2011). Proc. SPIE, 8141, 814107.]), which is actively used for development of X-ray and infrared beamlines at synchrotron light sources. The SRW code is based on the principle of physical optics using FFT and asymptotic expansion based propagators and is capable of accurate modeling of fully and partially coherent synchrotron radiation emission and propagation through different types of optics. The software is able to calculate the propagation of SASE XFEL pulses, which requires much larger computing resources than propagation of steady state beams or longitudinally coherent pulses.

For the WPG framework we use Python structures, which provide the possibility for coding in self-explaining meta-language, so that a complete beamline with tens of optical elements can be specified within one page of text. One can easily create and modify such scripts without going into implementation details. In addition, an experienced user can create propagators for new optics types in Python and include them in the beamlines. The WPG framework scripts can be run either within the IPython Notebook interactive environment, combining code execution, rich text, mathematics and plots in one file, or in batch file mode, as a Python script in Python or an IPython shell. The WPG also includes modules necessary for start-to-end simulations of XFEL experiments, which simulate propagation of the XFEL pulses (Manetti et al., 2016[Manetti, M., Samoylova, L., Schneidmiller, E., Sinn, H., Szuba, J., Wrona, K. & Yurkov, M. (2016). XPD: XFEL Photon Pulses Database, https://in.xfel.eu/xpd/.]) through beamline optics and provide an interface to codes modeling the interaction with the sample (SingFEL, PMI; Yoon et al., 2016[Yoon, C. H., Yurkov, M. V., Schneidmiller, E. A., Samoylova, L., Buzmakov, A., Jurek, Z., Ziaja, B., Santra, R., Loh, N. D., Tschentscher, T. & Mancuso, A. (2016). Sci. Rep. 6, 24791.]).

3. Coherent wavefront propagation

This section summarizes the basics of the calculation methods implemented in the SRW (Chubar & Elleaume, 1998[Chubar, O. & Elleaume, P. (1998). EPAC 98, 6th European Particle Accelerator Conference, pp. 1177-1179. Geneva: JACoW.]; Chubar et al., 2002[Chubar, O., Elleaume, P., Kuznetsov, S. & Snigirev, A. (2002). Proc. SPIE, 4769, 145-151.], 2008[Chubar, O., Couprie, M.-E., Labat, M., Lambert, G., Polack, F. & Tcherbakoff, O. (2008). Nucl. Instrum. Methods Phys. Res. Sect. A, 593, 30-34.], 2011[Chubar, O., Berman, L., Chu, Y. S., Fluerasu, A., Hulbert, S., Idir, M., Kaznatcheev, K., Shapiro, D., Shen, Q. & Baltser, J. (2011). Proc. SPIE, 8141, 814107.]) that are most relevant for FEL applications and are available through the WPG interface.

For small emission and observation angles, the propagation of the transverse components in free space from a point r1 to a point r2 can be described in terms of the Huygens−Fresnel principle in the frequency domain as a integral by integration over the plane Σ1 perpendicular to the z axis (beam axis):

[{E}_{\perp }({r}_{2}, \omega )\simeq -{{i\omega }\over{2\pi c}} \int\limits_{\,\,\,\,\,\,\,\Sigma_1}\!\!\!\!\!\!\int{E}_{\perp }\left({r}_{1}, \omega \right){{\exp({-{{i\omega \left|{r}_{2}-{r}_{1}\right|}/{c}})}}\over{\left|{r}_{2}-{r}_{1}\right|}}\,{\rm d}{\Sigma }_{1} ,\eqno (1)]

where ω is the angular frequency of the wave and c the speed of light. The wavefield at the observation plane can be written in a more general form as

[{E}_{\perp }({x}_{2},{y}_{2},\omega )\simeq \textstyle\int\!\int {\rm d}{x}_{1}\,{\rm d}{y}_{1}\,{\bi K}({x}_{2},{y}_{2},{x}_{1},{y}_{1},\omega )\,{E}_{\perp }({x}_{1},{y}_{1},\omega ), \eqno (2)]

where the kernel K(x2, y2, x1, y1, ω) is given as

[{\bi K}({x}_{2},{y}_{2},{x}_{1},{y}_{1},\omega)\simeq -{{ik}\over{2\pi z}}\exp\left\{{{{ik}\over{2z}}\left[{\left({x}_{2}-{x}_{1}\right)}^{2}+{\left({y}_{2}-{y}_{1}\right)}^{2}\right]}\right\}. \eqno (3)]

As shown in the following two sections, propagation through most X-ray optics elements can be presented in the form of the convolution integral (2)[link]. Using the Fourier optics modular approach, a complete beamline can be described as a set of propagators corresponding to individual optical components, which can be then numerically solved by means of a two-dimensional FFT algorithm.

The representation (3)[link] also enables the analytical treatment of the quadratic phase term, allowing for free-space propagation simulations with a reduced sampling rate (Chubar et al., 2008[Chubar, O., Couprie, M.-E., Labat, M., Lambert, G., Polack, F. & Tcherbakoff, O. (2008). Nucl. Instrum. Methods Phys. Res. Sect. A, 593, 30-34.]). This dramatically improves the technical feasibility and robustness of the Fourier optics method.

3.1. Thin optical elements

Many of the optical components of an X-ray beamline can be described as thin optical elements, i.e. as linear filters that change the wavefield amplitude and/or phase in the plane normal to the propagation direction. For thin optical elements the kernel (3)[link] can be represented as

[{\bi K}({{x_2},{y_2},{x_1},{y_1},\omega } ) = {\bi T}({x_1},{y_1},\omega)\,\delta ({{x_1} - {x_2}} )\,\delta ({{y_1} - {y_2}} ), \eqno(4)]

where T(x1, y1, ω) is a complex transmission function, and δ() is the δ function. For example, the transmission function for a thin lens is given by

[{\bi T}({x,y,\omega } ) = \exp\left\{{ - ik\left [{{{{{(x - {x_0})}^2}} \over {2{f_x}}} + {{{{(y - {y_0})}^2}} \over {2{f_y}}}} \right]}\right\}, \eqno(5)]

where (x0, y0) are coordinates of the lens center, and fx and fy are focal distances in the horizontal and vertical planes. The transmission for a two-dimensional parabolic compound refractive lens (CRL) (Kohn et al., 2003[Kohn, V., Snigireva, I. & Snigirev, A. (2003). Opt. Commun. 216, 247-260.]) is given by

[{\bi T}(x,y,\omega ) = \exp\left\{{-ik\left[\delta (\omega)-i\beta (\omega)\right]N\left({{r}/{R}}+d\right)}\right\}, \,\,\,\, r\,\lt\, a, \eqno(6)]

where the complex refractive index of the lens material is n = 1 − δ + iβ, the CRL thickness depending on the distance from the lens center r = ( x2 + y2)1/2 is t = N (r/R + d), R is the radius of the parabola tip, N is the total number of individual parabolic lenses, d is the minimum spacing between two parabolas and a is the lens aperture.

3.2. Extended optical elements

The wave optics method that we use for simulation of grazing-incidence mirrors is based on the local stationary-phase approximation (Canestrari et al., 2014[Canestrari, N., Bisogni, V., Walter, A., Zhu, Y., Dvorak, J., Vescovo, E. & Chubar, O. (2014). Proc. SPIE, 9209, 92090I.]). The kernel is presented as

[\eqalignno{{\bi K}({{x_2},{y_2},{x_1},{y_1},\omega } ) \cong &\,{\bi G}({x_1},{y_1},\omega)\cr & \times\exp\left[{({{i\omega } / c})\,{{\Lambda }}({{x_2},{y_2},{x_1},{y_1},\omega } )}\right]\cr & \times \delta [{{x_1} - {{\tilde x}_1}({x_2},{y_2})} ]\,\delta [{{y_1} - {{\tilde y}_1}({x_2},{y_2})} ], & (7)}]

where G is a matrix function defining local transformations of amplitudes of electric field components, i.e. the propagation between input (x1, y1) and output (x2, y2) planes including the reflection from a mirror surface; [{\tilde x_1}({{x_2},{y_2}} )] and [{\tilde y_1}({{x_2},{y_2}} )] are scalar functions defining the transformation of coordinates for points in transverse planes before and after the optical element; and Λ(x2, y2, x1, y1, ω) is a scalar function defining the optical path between the points in the input and output planes. These functions can be found by using the asymptotic expansion of the Fresnel−Kirchhoff integral over the mirror surface, namely, the stationary phase approximation, which is Fermat's principle for mirror reflection expressed in mathematical form. The stationary phase point can be found by defining a ray from the point (x1, y1) in the input plane in the direction provided by the local gradient of the input radiation field phase, finding its intersection with the mirror surface, generating the specular reflected ray, and finding its intersection with the output plane at the point (x2, y2) behind the mirror. As a final step, the electric field components are re-calculated on the required rectangular mesh, using a two-dimensional interpolation.

For gratings (Canestrari et al., 2014[Canestrari, N., Bisogni, V., Walter, A., Zhu, Y., Dvorak, J., Vescovo, E. & Chubar, O. (2014). Proc. SPIE, 9209, 92090I.]), an extra phase shift ΔΦ(x2, y2, ω) associated with the reflection should be taken into account:

[\eqalignno{ {\bi K}& ({x}_{2},{y}_{2},{x}_{1},{y}_{1},\omega ) \cong {\bi G}({x}_{1},{y}_{1},\omega)\cr & \times \exp\left[ {({{i\omega }/{c}})\Lambda ({x}_{2},{y}_{2},{x}_{1},{y}_{1},\omega )+\Delta \Phi ({x}_{2},{y}_{2},\omega )}\right]\cr & \times \delta[{x}_{1}-\tilde x_{1}({x}_{2},{y}_{2})]\,\delta [{y}_{1}-\tilde y_{1}({x}_{2},{y}_{2})] . & (8)}]

This function describes the phase shift introduced by grooves in the transverse direction, the shift being perpendicular to the grooves in the output plane:

[\Delta \Phi ({x}_{2},{y}_{2},\omega ) = -2\pi m {\tilde N}({x}_{2},{y}_{2},\omega ),\eqno(6)]

where m is the diffraction order, and [\tilde N({{x_2},{y_2},\omega } )] is the effective groove number for a given intersection point. For a variable line spacing (VLS) grating with a groove density that varies along the `longitudinal' direction of the grating surface according to the nth order polynomial [\rho ({\tilde x} ) = \textstyle \sum _{k = 0}^n {a_k}{\tilde x^k}], the effective number of grooves associated with the longitudinal position [\tilde x({x}_{2},{y}_{2},\omega )] on the grating surface is

[{\widetilde N} \left({x}_{2},{y}_{2},\omega \right) = \int\limits_{0}^{\tilde x} \rho ({\tilde x}) \,{\rm d}{\tilde x} = \sum _{k = 0}^{n} {{{a}_{k}}\over{k+1}} {\tilde x}^{(k+1)}\left({x}_{2},{y}_{2},\omega \right). \eqno(10)]

Propagation of the XFEL pulses through a perfect diffracting crystal can be described within the Fourier optics approach (Bushuev, 2008[Bushuev, V. A. (2008). J. Synchrotron Rad. 15, 495-505.]). For that, the crystal propagator known from dynamical diffraction theory is applied to wavefield Fourier amplitudes in reciprocal space. Afterwards the resulting wavefront in real space can be obtained with an inverse Fourier transformation. For implementation details see Sutter et al. (2014[Sutter, J., Chubar, O. & Suvorov, A. (2014). Proc. SPIE, 9209, 92090I.]); the first practical applications of these SRW modules were described by Suvorov et al. (2015[Suvorov, A., Cunsolo, A., Chubar, O. & Cai, Y. Q. (2015). Opt. Express, 23, 31607-31618.]) and Chubar et al. (2016[Chubar, O., Geloni, G., Kocharyan, V., Madsen, A., Saldin, E., Serkez, S., Shvyd'ko, Y. & Sutter, J. (2016). J. Synchrotron Rad. 23, 410-424.]).

The available optical elements are listed in Table 1[link].

Table 1
Optical elements (propagators) available in the WPG

The parameters are shown in bold italic and the names of the propagators in italic.

Optics Propagator Parameters Comments
Free space Drift Propagation distance In most cases the semi-analytical propagation is recommended, see §3.1[link].
Slits, apertures Aperture Slit or obstacle, shape (rectangular or circular), slit width, height, slit center coordinates For a circular aperture only slit width is used as aperture diameter.
Grazing-incidence plane elliptical mirror Mirror_elliptical Orientation, p and q, distances to source and focus, incidence angle in the mirror center, misalignment angle, mirror length See §3.3[link] for details.
Thin lens Lens Focal lengths in horizontal and vertical plane, and lens center coordinates Can be used to model sagittal bending in a plane elliptical mirror or to approximate focusing with a spherical mirror.
Mirror surface error WF_dist Mesh and dimensions Phase screen approach is used to introduce wavefront distortions caused by residual surface height errors (Samoylova et al., 2009[Samoylova, L., Sinn, H., Siewert, F., Mimura, H., Yamauchi, K. & Tschentscher, T. (2009). Proc. SPIE, 7360, 1-9.]).
Grazing-incidence VLS grating VLS_grating Substrate (a mirror propagator), diffraction order number m, grove density g0 in the grating center, gk, k = 1,…, 4, grove density polynomial coefficients: g = g0 + g1x + g2x2 + g3x3 + g4x4 See §3.3[link] for details.
Crystal monochromator Xtal Interplanar spacing of the selected Bragg reflection H, Fourier components of electric susceptibility, crystal thickness, asymmetry angle, deviation of the incidence angle from the rocking curve center  
CRLs CRLs Obligatory parameters: which focal plane (1 for horizontal, 2 for vertical, 3 for both), δ, attenuation length, shape (parabolic or spherical), horizontal and vertical aperture diameters, tip radius, number of CRLs (holes), lens thickness at apex; optional parameters: a flat array/list of void center coordinates and radii: [x1, y1, r1, x2, y2, r2,…], initial photon energy, final photon energy See also §3.3[link] on modeling voids in CRLs. Note: the energy range parameters are used only if the attenuation length and δ are arrays. Then the dispersion effect of CRLs is taken into account.
†The propagator should be used together with the calculateOPD() function, see Fig. 3[link].
‡For 0, H and −H reciprocal lattice nodes for reflection H.

3.3. Imperfections in optics

High-performing X-ray mirrors must be able to preserve the wavefront of the incident radiation inside the focused spot on the sample. Deviation of the mirror surface from an ideal one results in the appearance of scattered waves, which form speckles (irregularities of the radiation intensity caused by irregularities of the wavefront) in the beam spot downstream. In particular, the XFEL radiation divergence is only several microradians, and the source-to-mirror, r0, and the mirror-to-sample, r1, distances range up to several hundred metres. As a result, the mirror surface errors at the longest spatial wavelengths, comparable to the mirror length, have the greatest effect on the quality of the reflected beam. The spatial frequencies responsible for scattering radiation inside the spot (damaging frequencies) for a flat mirror, e.g. horizontal offset mirrors at the European XFEL, can be estimated as (Yashchuk et al., 2015[Yashchuk, V. V., Samoylova, L. V. & Kozhevnikov, I. V. (2015). Opt. Eng. 54, 025108.])

[{{{\theta _0}} \over {{r_0}\delta \theta }} \,\lt\, {\nu _x} \,\lt\, {{{\theta _0}\delta \theta } \over {2\lambda }}\left({1 + {{{r_0}} \over {{r_1}}}} \right), \eqno(11)]

where θ0 is the incidence angle, δθ is the radiation divergence and λ is the X-ray wavelength. With the parameters of the SASE1 beamline at the European XFEL, the range of spatial frequencies that can produce speckles is νx ≃ 0.033–0.3 cm−1. These frequencies correspond to the spatial lengths dx ≃ 3.3–30 cm. Lower spatial frequencies (spatial lengths longer than 30 cm) would lead to splitting of the beam. With the parameters of the SASE3 beamline, the range of spatial frequencies that will generate speckles is νx ≃ 0.02–1.5 cm−1. These frequencies correspond to the spatial lengths dx ≃ 0.67–50 cm.

If the coherent X-ray beam is reflected at grazing angle θ from a very smooth mirror surface with a height profile h(xm), the optical path differences introduced by the mirror's imperfections are much smaller than the X-ray wavelength λ:

[({{4\pi }/{\lambda }})\left|h\left({x}_{m}\right)\right|\sin\theta \ll 1 \quad \forall m,\eqno(12)]

where xm is the coordinate along the mirror surface and m is the point number. In this case one can use the complex transmission function

[{\bi T}(x,y) = \exp[{(-i4\pi /\lambda ) \,h(x,y)\sin\theta}]\eqno(13)]

to analyze wavefront distortions induced by mirror surface residual height errors. Owing to the very small incidence angle the beam footprint is much larger along the propagation direction than in the sagittal direction. If the full width at half-maximum of the XFEL beam is about 0.5 mm, for a typical incidence angle 2 mrad, the beam footprint is about 25 × 0.5 mm. Since the impact of sagittal errors will be small, one can use here only one-dimensional metrology data to model the surface imperfections along the beam propagation direction.

The propagator of an imperfect CRL is simulated in a two-step approach. First, it uses the propagator for an ideal CRL as given in §[link]3.2. Then, voids are simulated respecting a given void size distribution between a minimum and a maximum void diameter and are distributed in accordance with a given void density into a fictive cylinder of the same material, having the same aperture and thickness as the ideal CRL. In the next step, the paraboloids that are defining the CRL shape are removed, including the voids there. Finally, a plain void propagator is generated with the corresponding transmission. The passage of the wavefront through an imperfect CRL is thus calculated with two propagators, first for the ideal CRL, followed by the plane void propagator. To speed up the calculations the propagators for perfect and imperfect CRLs can be calculated only once, saved in a binary format supported by Python and later loaded from the hard drive. See also Roth et al. (2014[Roth, T., Helfen, L., Hallmann, J., Samoylova, L., Kwaśniewski, P., Lengeler, B. & Madsen, A. (2014). Proc. SPIE, 9207, 920702.]), example 7 (https://github.com/ochubar/SRW), and the WPG tutorial (https://wpg.readthedocs.org/en/latest/tutorials.html).

3.4. Wavefront propagation setup

In the WPG framework the model of wavefront propagation is implemented using two classes, Wavefront() and Beamline() as shown in Fig. 1[link]. To start the propagation one should define a wavefront, which can be a Gaussian steady state or time-dependent short pulse calculated using corresponding library functions, or an external XFEL pulse, e.g. from the X-ray FEL Photon Pulses Database (XPD; Manetti et al., 2016[Manetti, M., Samoylova, L., Schneidmiller, E., Sinn, H., Szuba, J., Wrona, K. & Yurkov, M. (2016). XPD: XFEL Photon Pulses Database, https://in.xfel.eu/xpd/.]), or any other external wavefield defined on a uniform Cartesian grid.

[Figure 1]
Figure 1
General structure of the WPG framework.

The beamline is defined as a container of propagators with suitable parameters. The basic workflow is shown in Fig. 2[link].

[Figure 2]
Figure 2
Workflow chart: a wavefront propagates through a beamline, which is set up as a container of propagators. Top: a simple `linear' workflow for a regular beamline; bottom: beamline with two branches, e.g. XFEL split-and-delay lines.
3.4.1. Wavefront data

The structure of the HDF5 wavefront file, which is described in glossary file wpg/glossary.py, is used for mapping the Python wavefront structure to HDF5.

The WPG wavefront HDF5 file contains the obligatory and optional sections described below.

The main groups include the following:

(a) data – contains two three-dimensional arrays of electromagnetic fields with horizontal and vertical polarizations, arrEhor and arrEver

(b) params – contains a Cartesian grid of wavefront data, geometrical parameters etc.

The following are optional groups, especially recommended for use in start-to-end simulations:

(a) history – contains a link to a parent wavefront, if it exists, and a hierarchy structure with parent wavefront parameters and a link to its data

(b) info – some information about the origin of the current wavefront

(c) misc – information for visual checking of wavefront parameters (intensity distribution etc.)

(d) version – version of the wavefront glossary

3.4.2. Beamline as a container of propagators

An example of the beamline definition is shown in Fig. 3[link].

[Figure 3]
Figure 3
Example of a beamline definition: the SASE3 beamline at the European XFEL will include two horizontal offset mirrors (M1 and M2), a vertical focusing mirror M3, and horizontal and vertical clean-up slits.
3.4.3. Adjustment of propagation parameters

Our framework provides special tools to facilitate propagation parameter adjustment and make the process transparent for the user. In particular, the method Use_PP() takes none or several propagation parameters defined by the user for a given optical element as arguments (see Fig. 3[link]) and provides the core library propagation function with a full propagation parameter set, using for the rest the default values. For instance, bl.append(Drift(50.),Use_PP(semi_analytical_treatement=1)) introduces a 50 m drift in free space and sets up calculations using the semi-analytical processing described in §3[link]. To tune the sampling, one can use the parameters zoom and sampling (Fig. 3[link]). As in all numerical methods involving discrete Fourier transforms, the correct sampling of the signal in real and reciprocal space is critical for correct numerical calculations (see e.g. Potter, 1973[Potter, D. E. (1973). Computational Physics. New York: Wiley.]; Goodman, 2004[Goodman, J. W. (2004). Introduction to Fourier Optics, 3rd ed. Green Village: Roberts and Company Publishers.]). To control the choice one can refer to the sampling in reciprocal Q space: the angular spectrum can be visualized using corresponding library utilities. See also the WPG documentation section with FEL beamline examples (https://wpg.readthedocs.org/en/latest/real_beamlines.html).

4. Examples

4.1. FEL pulse visualization

Fig. 4[link] shows the intensity and phase distribution of an XFEL pulse extracted from the XPD (Manetti et al., 2016[Manetti, M., Samoylova, L., Schneidmiller, E., Sinn, H., Szuba, J., Wrona, K. & Yurkov, M. (2016). XPD: XFEL Photon Pulses Database, https://in.xfel.eu/xpd/.]) and visualized by the WPG package at the exit of the SASE3 undulator with a maximum length of active segments of 130 m. The FEL data were simulated with the FAST code (Saldin et al., 1999[Saldin, E. L., Schneidmiller, E. A. & Yurkov, M. V. (1999). Nucl. Instrum. Methods Phys. Res. Sect. A, 429, 233-237.]) for photon energy 800 eV, electron bunch charge 250 pC and electron energy 14 GeV. Note that the shift is much smaller than the spot size. One can easily observe that the pulse after the tapered undulator is shorter and more collimated.

[Figure 4]
Figure 4
An example of three-dimensional wavefront visualization. For the SASE3 undulator with a defined maximum active segment length of 130 m, the simulated XFEL pulse data taken from the XPD (Manetti et al., 2016[Manetti, M., Samoylova, L., Schneidmiller, E., Sinn, H., Szuba, J., Wrona, K. & Yurkov, M. (2016). XPD: XFEL Photon Pulses Database, https://in.xfel.eu/xpd/.]) are used: photon energy 800 eV, electron bunch charge 250 pC and electron energy 14 GeV. The top row corresponds to an untapered undulator and pulse energy 8 mJ, and the bottom row to an undulator with optimized tapering (Schneidmiller & Yurkov, 2016[Schneidmiller, E. A. & Yurkov, M. V. (2016). J. Mod. Opt. 63, 288-292.]) and pulse energy 17 mJ. (a), (c) Vertical cuts of the pulse phase and intensity; (b), (d) slice-to-slice shift of the pulse center of mass. The slice times are color coded and the intensities are represented by the size of the circles.

4.2. Modeling the SCS SASE3 beamline

Fig. 5[link] shows the intensity distribution around the sample position of the SCS beamline at the European XFEL. The optical elements considered in this example are offset and distribution mirrors of the beam transport, vertical mirrors of the soft X-ray monochromator, clean-up slits in the vertical and horizontal intermediate foci, and Kirkpatrick–Baez micro-focusing mirrors close to the sample position.

[Figure 5]
Figure 5
Intensity distribution around the sample position of the SCS instrument. Left panel (a), (c): the clean-up slits in the vertical and horizontal focus are fully open. Right panel (b), (d): both clean-up slits are closed to a gap of 50 µm. The cuts perpendicular to the optical axis in (c) and (d) correspond to −6, 0 and 6 mm positions around the focus.

Cut-off effects of all optical elements were considered, assuming here an idealized Gaussian beam profile as a source with a divergence corresponding to XFEL SASE3 radiation from electron bunch charge 100 pC and electron energy 17.5 GeV. The simulations took into account a slightly deteriorated performance of the beamline mirrors with respect to their specifications. The left panel of Fig. 5[link] shows the beam intensity around the focus position with the clean-up slits fully open. The vertical cuts correspond to (left to right) −6, 0 and 6 mm positions around the focus. Asymmetric wings are visible in the horizontal plane, while the focus size is slightly enlarged in the vertical plane. By closing the clean-up slits (right panel), the focus becomes more homogeneous and smaller in the vertical plane. As demonstrated in this example, clean-up slits can in principle be used to reduce the effect of profile distortions from upstream mirrors without losing too much intensity. However, damage effects on these slits have to be carefully monitored and make this equipment usable only for moderate X-ray beam intensities.

4.3. Module for start-to-end simulation of XFEL experiments

The prop module numerically propagates the FEL wavefield data from the undulator exit, through the beamline optics, to the sample position using the Python module multiprocessing. Each file from the working directory is processed by one free CPU core. On modern PCs or servers this makes it possible to significantly speed up the calculations. However the memory load by every process can become a bottleneck: the required memory for processing of a short 30 fs XFEL pulse can exceed 8 Gb for a beamline including submicrometre focusing optics, such as the Kirkpatrick–Baez mirror system of the SPB-SFX instrument at the European XFEL (Bean et al., 2016[Bean, R., Aquila, A., Samoylova, L. & Mancuso, A. (2016). J. Opt. 18, 074011.]). The module was successfully used for modeling of a single biomolecule imaging experiment at the SPB instrument with the multiphysics simulation framework simS2E (Yoon et al., 2016[Yoon, C. H., Yurkov, M. V., Schneidmiller, E. A., Samoylova, L., Buzmakov, A., Jurek, Z., Ziaja, B., Santra, R., Loh, N. D., Tschentscher, T. & Mancuso, A. (2016). Sci. Rep. 6, 24791.]).

5. Software availability and documentation

The WPG framework runs reliably under Linux, Microsoft Windows 7 and Apple Mac OS X. Using IPython as a web front-end enables the users to run the code on a remote server as well as on their local personal computers. One can use popular Python libraries [such as SciPy (https://www.scipy.org/), NumPy (https://www.numpy.org/) and Matplotlib (https://matplotlib.org/)] for pre- and post-processing as well as for visualizing the simulation results.

The wavefronts are saved in HDF5 format for eventual further processing and start-to-end simulations of experiments. The HDF5 format allows for keeping the calculation history within a single file, thus facilitating communication between various scientific groups and cross-checking with other simulation results. The WPG source code (https://github.com/samoylv/WPG) together with guidelines for installation and application examples (https://wpg.readthedocs.org/en/latest/) are open source and available on the web. The installation includes building the C++ written SRW library from its sources.

The installation procedure for Linux, OS X and Windows 7 is described at https://wpg.readthedocs.org/en/latest/wpg.html#getting-started and includes installation of Python, Numpy, Scipy, Matplotlib, h5py (https://www.h5py.org/) and the IPython Notebook.

6. Future steps

In the near future, we plan to enhance the start-to-end simulation possibilities by employing the MPI technology through the mpi4py module and running the propagation of multiple pulses on a cluster. One should, though, keep in mind that transferring the input and resulting pulse data through the network can also become a bottleneck. Thus the efficiency strongly depends on the cluster configuration and the ratio of calculation time for one pulse and network data transfer rate. In addition, we plan for the WPG to support full inter-operation with a new framework, based on client–server architecture and using JavaScript and Python for a rich graphical user interface. This is currently under development in a project (Bruhwiler et al., 2014[Bruhwiler, D., Chubar, O., Nagler, R., Krzywinski, J. & Boehnlein, A. (2014). Proc. SPIE, 9209, 92090Z.]) sponsored by the US Department of Energy.

7. Conclusions

Knowledge of temporal, spatial, spectral and coherence properties of the radiation from X-ray FELs is of key importance for planning user experiments. We have developed the WPG software package as a new framework for wave optics simulations and have used it successfully for X-ray FEL optics beamline design and experimental data analysis. The software is also used as a part of the multiphysics simulation framework simS2E for source-to-experiment simulations of a single-particle imaging experiment, employing pulse data from the XPD as an input. For the upcoming commissioning of the European XFEL, the WPG will be available as a versatile tool capable of simulating all relevant optics at the facility.

Footnotes

1This article will form part of a virtual special issue of the journal on free-electron laser software.

Acknowledgements

We thank Mikhail Yurkov, Eugeny Schneidmiller, Igor Kozhevnikov and Frank Siewert for fruitful discussions, and Ann-Kristin Meyer for help with calculations. The work of AB was funded by the Russian Ministry of Education and Science via the program `Physics at Accelerators and Reactors of West Europe (excluding CERN)'. OC acknowledges funding from the US DOE Office of Science, Program of Basic Energy Sciences, under SBIR awards DE-SC0006284 and DE-SC0011237, for work on the development of the SRW code and its associated frameworks.

References

First citationAmann, J. et al. (2012). Nat. Photon. 6, 693–698.  Web of Science CrossRef CAS Google Scholar
First citationBahrdt, J., Flechsig, U., Grizolli, W. & Siewert, F. (2014). Proc. SPIE, 9209, 920908.  Google Scholar
First citationBean, R., Aquila, A., Samoylova, L. & Mancuso, A. (2016). J. Opt. 18, 074011.  CrossRef Google Scholar
First citationBruhwiler, D., Chubar, O., Nagler, R., Krzywinski, J. & Boehnlein, A. (2014). Proc. SPIE, 9209, 92090Z.  Google Scholar
First citationBushuev, V. A. (2008). J. Synchrotron Rad. 15, 495–505.  Web of Science CrossRef CAS IUCr Journals Google Scholar
First citationCanestrari, N., Bisogni, V., Walter, A., Zhu, Y., Dvorak, J., Vescovo, E. & Chubar, O. (2014). Proc. SPIE, 9209, 92090I.  Google Scholar
First citationChubar, O., Berman, L., Chu, Y. S., Fluerasu, A., Hulbert, S., Idir, M., Kaznatcheev, K., Shapiro, D., Shen, Q. & Baltser, J. (2011). Proc. SPIE, 8141, 814107.  CrossRef Google Scholar
First citationChubar, O., Couprie, M.-E., Labat, M., Lambert, G., Polack, F. & Tcherbakoff, O. (2008). Nucl. Instrum. Methods Phys. Res. Sect. A, 593, 30–34.  Web of Science CrossRef CAS Google Scholar
First citationChubar, O. & Elleaume, P. (1998). EPAC 98, 6th European Particle Accelerator Conference, pp. 1177–1179. Geneva: JACoW.  Google Scholar
First citationChubar, O., Elleaume, P., Kuznetsov, S. & Snigirev, A. (2002). Proc. SPIE, 4769, 145–151.  CrossRef Google Scholar
First citationChubar, O., Geloni, G., Kocharyan, V., Madsen, A., Saldin, E., Serkez, S., Shvyd'ko, Y. & Sutter, J. (2016). J. Synchrotron Rad. 23, 410–424.  Web of Science CrossRef CAS IUCr Journals Google Scholar
First citationGoodman, J. W. (2004). Introduction to Fourier Optics, 3rd ed. Green Village: Roberts and Company Publishers.  Google Scholar
First citationInagaki, T. et al. (2014). FEL2014, Proceedings of the 36th International Free Electron Laser Conference, TUC01, pp. 603–608. Geneva: JACoW.  Google Scholar
First citationKayser, Y., Rutishauser, S., Katayama, T., Ohashi, H., Kameshima, T., Flechsig, U., Yabashi, M. & David, C. (2014). Opt. Express, 22, 9004–9015.  Web of Science CrossRef PubMed Google Scholar
First citationKohn, V., Snigireva, I. & Snigirev, A. (2003). Opt. Commun. 216, 247–260.  Web of Science CrossRef CAS Google Scholar
First citationLoh, N. D. et al. (2013). Opt. Express, 21, 12385.  Web of Science CrossRef PubMed Google Scholar
First citationManetti, M., Samoylova, L., Schneidmiller, E., Sinn, H., Szuba, J., Wrona, K. & Yurkov, M. (2016). XPD: XFEL Photon Pulses Database, https://in.xfel.eu/xpd/Google Scholar
First citationPark, H. J. et al. (2013). Opt. Express, 21, 28729.  Web of Science CrossRef PubMed Google Scholar
First citationPotter, D. E. (1973). Computational Physics. New York: Wiley.  Google Scholar
First citationRoling, S., Zacharias, H., Samoylova, L., Sinn, H., Tschentscher, Th., Chubar, O., Buzmakov, A., Schneidmiller, E., Yurkov, M. V., Siewert, F., Braun, S. & Gawlitza, P. (2014). Phys. Rev. ST Accel. Beams, 17, 110705.  Web of Science CrossRef Google Scholar
First citationRoth, T., Helfen, L., Hallmann, J., Samoylova, L., Kwaśniewski, P., Lengeler, B. & Madsen, A. (2014). Proc. SPIE, 9207, 920702.  Google Scholar
First citationRutishauser, S., Samoylova, L., Krzywinski, J., Bunk, O., Grünert, J., Sinn, H., Cammarata, M., Fritz, D. M. & David, C. (2012). Nat. Commun. 3, 947.  Web of Science CrossRef PubMed Google Scholar
First citationSaldin, E. L., Schneidmiller, E. A. & Yurkov, M. V. (1999). Nucl. Instrum. Methods Phys. Res. Sect. A, 429, 233–237.  Web of Science CrossRef CAS Google Scholar
First citationSamoylova, L., Sinn, H., Siewert, F., Mimura, H., Yamauchi, K. & Tschentscher, T. (2009). Proc. SPIE, 7360, 1–9.  Google Scholar
First citationSchneidmiller, E. A. & Yurkov, M. V. (2016). J. Mod. Opt. 63, 288–292.  Web of Science CrossRef CAS Google Scholar
First citationSutter, J., Chubar, O. & Suvorov, A. (2014). Proc. SPIE, 9209, 92090I.  Google Scholar
First citationSuvorov, A., Cunsolo, A., Chubar, O. & Cai, Y. Q. (2015). Opt. Express, 23, 31607–31618.  Web of Science CrossRef PubMed Google Scholar
First citationYashchuk, V. V., Samoylova, L. V. & Kozhevnikov, I. V. (2015). Opt. Eng. 54, 025108.  Web of Science CrossRef Google Scholar
First citationYoon, C. H., Yurkov, M. V., Schneidmiller, E. A., Samoylova, L., Buzmakov, A., Jurek, Z., Ziaja, B., Santra, R., Loh, N. D., Tschentscher, T. & Mancuso, A. (2016). Sci. Rep. 6, 24791.  Web of Science CrossRef PubMed Google Scholar

This is an open-access article distributed under the terms of the Creative Commons Attribution (CC-BY) Licence, which permits unrestricted use, distribution, and reproduction in any medium, provided the original authors and source are cited.

Journal logoJOURNAL OF
APPLIED
CRYSTALLOGRAPHY
ISSN: 1600-5767
Volume 49| Part 4| August 2016| Pages 1347-1355
Follow J. Appl. Cryst.
Sign up for e-alerts
Follow J. Appl. Cryst. on Twitter
Follow us on facebook
Sign up for RSS feeds