Abstract
Modeling of large-scale research facilities is extremely challenging due to complex physical processes and engineering problems. Here, we adopt a data-driven approach to model the photoinjector of European XFEL with a deep learning-based autoencoder. A deep convolutional neural network (decoder) is used to build images measured on the screen from a small feature map generated by another neural network (encoder). We demonstrate that the autoencoder trained only with experimental data can make high-fidelity predictions of megapixel images for the longitudinal phase-space measurement. The prediction significantly outperforms existing methods. We also show the scalability and explicability of the autoencoder by sharing the same decoder with more than one encoder used for different setups of the photoinjector, and propose a pragmatic way to model a photoinjector with various diagnostics and working points. This opens the door to a new way of accurately modeling a photoinjector using neural networks. The approach can possibly be extended to the whole accelerator and even other types of scientific facilities.
Introduction
Operating large-scale particle accelerators like the European XFEL requires precise control over the electron beam's longitudinal phase-space (LPS). LPS provides a critical "snapshot" of the energy distribution of electrons over time, which is essential for optimizing beam quality. Traditionally, physicists have relied on numerical simulations or low-resolution machine learning (ML) models. Numerical simulations are computationally expensive and often fail to account for time-varying factors like component aging. Previous ML attempts typically utilized Multi-Layer Perceptrons (MLPs) that produced blurry, low-resolution (e.g., 100x100) images, lacking the detail necessary for high-precision diagnostics.
Methods
To overcome these limitations, we developed an encoder-decoder neural network architecture designed to generate high-resolution (megapixel) LPS images in real-time.
The architecture consists of an MLP encoder that compresses machine parameters (such as RF phases) into a low-dimensional "latent feature map." This map is then processed by a deep convolutional neural network (CNN) decoder utilizing transposed convolutional layers. These layers up-sample the latent features into a full 768 x 1024 pixel image.
A critical component of our method is the loss function. We utilized the Multi-Scale Structural Similarity Index Measure (MS-SSIM) instead of the standard Mean Squared Error (MSE). MS-SSIM prioritizes structural features, luminance, and contrast, which prevents the "over-smoothing" effect common in MSE-trained models and preserves sharp edges in the electron distribution.
Key Results
The autoencoder demonstrates exceptional performance in both speed and accuracy. Predictions are generated in approximately 20 ms on an NVIDIA Tesla P100 GPU, enabling real-time virtual diagnostics.
As shown in the figure above, the model's predictions align closely with experimental measurements. The SSIM score on the test dataset reached 0.9955 ± 0.0020. Crucially, the model maintains physical consistency; extracted properties such as current profiles, energy spectra, and RMS slice energy spread show excellent agreement with the "ground truth" measured data. The use of MS-SSIM loss specifically allowed for the accurate capture of high-frequency features and sharp current peaks that MSE-based models missed.
Discussion and Scalability
A key finding of this work is the scalability of the decoder. We observed that different encoders, trained for different machine states (Working Points), can successfully share the same decoder. This suggests that the decoder learns a generalized representation of the diagnostic screen's response, while the encoders specialize in mapping specific machine parameters to that representation. Furthermore, the model proved robust to irregular beam shapes, accurately reconstructing complex phase-space distributions that it had not explicitly memorized.
Conclusion
This data-driven approach provides a high-fidelity, real-time alternative to traditional beam dynamics simulations. By bypassing the need for complex physical assumptions and training directly on experimental data, the autoencoder captures the actual behavior of the facility with unprecedented clarity. Future work will focus on expanding this model to the entire accelerator complex and integrating additional diagnostic dimensions, moving toward a comprehensive "digital twin" of the European XFEL.
Summary updated