WavePropaGator: interactive framework for X-ray free-electron laser optics design and simulations1
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: email@example.com, firstname.lastname@example.org
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.
FEL: free-electron laser.
FFT: fast Fourier transform.
Git: a distributed revision control and source code management system (http://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 (http://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 (http://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.
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), monochromators for hard and soft X-ray self-seeding schemes (Amann et al., 2012; Inagaki et al., 2014), 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; Kayser et al., 2014). Moreover, characterizing focused XFEL intense wavefields is crucial for their use in single-shot diffractive imaging experiments (Loh et al., 2013; Park et al., 2013).
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; Chubar et al., 2011). 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), 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) through beamline optics and provide an interface to codes modeling the interaction with the sample (SingFEL, PMI; Yoon et al., 2016).
This section summarizes the basics of the calculation methods implemented in the SRW (Chubar & Elleaume, 1998; Chubar et al., 2002, 2008, 2011) 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):
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
where the kernel K(x2, y2, x1, y1, ω) is given as
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). 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) 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). This dramatically improves the technical feasibility and robustness of the Fourier optics method.
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) can be represented as
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
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) is given by
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.
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; and 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.
This function describes the phase shift introduced by grooves in the transverse direction, the shift being perpendicular to the grooves in the output plane:
where m is the diffraction order, and 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 , the effective number of grooves associated with the longitudinal position on the grating surface is
Propagation of the XFEL pulses through a perfect diffracting crystal can be described within the Fourier optics approach (Bushuev, 2008). 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); the first practical applications of these SRW modules were described by Suvorov et al. (2015) and Chubar et al. (2016).
‡For 0, H and −H reciprocal lattice nodes for reflection H.
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)
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 λ:
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
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 §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), example 7 (https://github.com/ochubar/SRW), and the WPG tutorial (http://wpg.readthedocs.org/en/latest/tutorials.html).
In the WPG framework the model of wavefront propagation is implemented using two classes, Wavefront() and Beamline() as shown in Fig. 1. 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), or any other external wavefield defined on a uniform Cartesian grid.
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
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) 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. To tune the sampling, one can use the parameters zoom and sampling (Fig. 3). 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; Goodman, 2004). 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 (http://wpg.readthedocs.org/en/latest/real_beamlines.html).
Fig. 4 shows the intensity and phase distribution of an XFEL pulse extracted from the XPD (Manetti et al., 2016) 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) 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.
Fig. 5 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.
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 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.
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). 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).
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 (http://www.numpy.org/) and Matplotlib (http://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 (http://www.h5py.org/) and the IPython Notebook.
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.
1This article will form part of a virtual special issue of the journal on free-electron laser software.
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.
Amann, J. et al. (2012). Nat. Photon. 6, 693–698. Web of Science CrossRef CAS
Bahrdt, J., Flechsig, U., Grizolli, W. & Siewert, F. (2014). Proc. SPIE, 9209, 920908.
Bean, R., Aquila, A., Samoylova, L. & Mancuso, A. (2016). J. Opt. 18, 074011. CrossRef
Bruhwiler, D., Chubar, O., Nagler, R., Krzywinski, J. & Boehnlein, A. (2014). Proc. SPIE, 9209, 92090Z.
Bushuev, V. A. (2008). J. Synchrotron Rad. 15, 495–505. Web of Science CrossRef CAS IUCr Journals
Canestrari, N., Bisogni, V., Walter, A., Zhu, Y., Dvorak, J., Vescovo, E. & Chubar, O. (2014). Proc. SPIE, 9209, 92090I.
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. CrossRef
Chubar, 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
Chubar, O. & Elleaume, P. (1998). EPAC 98, 6th European Particle Accelerator Conference, pp. 1177–1179. Geneva: JACoW.
Chubar, O., Elleaume, P., Kuznetsov, S. & Snigirev, A. (2002). Proc. SPIE, 4769, 145–151. CrossRef
Chubar, 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
Goodman, J. W. (2004). Introduction to Fourier Optics, 3rd ed. Green Village: Roberts and Company Publishers.
Inagaki, T. et al. (2014). FEL2014, Proceedings of the 36th International Free Electron Laser Conference, TUC01, pp. 603–608. Geneva: JACoW.
Kayser, 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
Kohn, V., Snigireva, I. & Snigirev, A. (2003). Opt. Commun. 216, 247–260. Web of Science CrossRef CAS
Loh, N. D. et al. (2013). Opt. Express, 21, 12385. Web of Science CrossRef PubMed
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/.
Park, H. J. et al. (2013). Opt. Express, 21, 28729. Web of Science CrossRef PubMed
Potter, D. E. (1973). Computational Physics. New York: Wiley.
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. Web of Science CrossRef
Roth, T., Helfen, L., Hallmann, J., Samoylova, L., Kwaśniewski, P., Lengeler, B. & Madsen, A. (2014). Proc. SPIE, 9207, 920702.
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. Web of Science CrossRef PubMed
Saldin, E. L., Schneidmiller, E. A. & Yurkov, M. V. (1999). Nucl. Instrum. Methods Phys. Res. Sect. A, 429, 233–237. Web of Science CrossRef CAS
Samoylova, L., Sinn, H., Siewert, F., Mimura, H., Yamauchi, K. & Tschentscher, T. (2009). Proc. SPIE, 7360, 1–9.
Schneidmiller, E. A. & Yurkov, M. V. (2016). J. Mod. Opt. 63, 288–292. Web of Science CrossRef CAS
Sutter, J., Chubar, O. & Suvorov, A. (2014). Proc. SPIE, 9209, 92090I.
Suvorov, A., Cunsolo, A., Chubar, O. & Cai, Y. Q. (2015). Opt. Express, 23, 31607–31618. Web of Science CrossRef PubMed
Yashchuk, V. V., Samoylova, L. V. & Kozhevnikov, I. V. (2015). Opt. Eng. 54, 025108. Web of Science CrossRef
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. Web of Science CrossRef PubMed
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.