Synchrotron beamlinesin the soft x-ray regime (100–2000 eV) rely primarily on the use of mirrors at grazing incidence, since transmission optics (such as lensed) tend to absorb very strongly at the corresponding wavelengths (0.5–10 nm.) Common raytracing software such as Zemax or CodeIV do not handle grazing angles very well (navigating coordinate breaks is a hassle), and the synchrotron community has built open source software that allow to perform simulations of synchrotron radiation and for for the design of beamlines.
Broadly speaking, the tools belong to two categories: raytracing, generally for simulation with incoherent light (e.g. bend magnet, hard x-ray beamlines), and wavefront propagation, for coherent light simulations (insertion device, diffraction-limited storage rings)
Shadow is the community standard for x-ray raytracing, initially developed by Franco Cerrina, modernized and currently maintained by Manuel Sanchez del Rio (ESRF) and Luca Rebuffi (APS). The previous version of shadow (shadow3) allowed scripting in python, but calling routines in Fortran. The most recent version of Shadow (Shadow 4) has been entirely rebuilt and is in pure python. It can be installed using:
pip install shadow4
It is open source, but it can be difficult to master without prior experience. The (open source) OASYS2 software provides an intuitive graphical user interface to build beamlines, and can be downloaded here: https://www.aps.anl.gov/Science/Scientific-Software/OASYS (tab "Distribution and Impact", or here)
Example of the Oasys interface for raytracing simulation w/ Shadow
The Synchrotron Radiation Workshop (SRW) is a wavefront propagation initially developed by Pascal Elleaume, and primarily maintained and modernized (i.e. python scripting) by Oleg Chubar and Max Rakitin (NSLS-II.) This open source software allow for the computation of synchrotron radiation ab initio, and its propagation throughout the beamline. Because it is based on wavefront propagation, it requires careful sampling considerations and tends to be a slower than raytracing (~10 sec/simulation for monochromatic, single electron computation on a recent computer), but it is also more accurate and provides quantitative flux simulation. It can be installed using:
pip install srwpy
Coding a simulation from scratch is difficult, and the SRW tool in Sirepo (https://www.sirepo.com/srw) provides a good graphical user interface in a web browser, which can then easily be shared with colleagues. Sirepo is developed by Radiasoft, and used to be open to free users, but it now requires a license to use, to cover cloud computing cost. Sirepo is still open source can be installed locally on your computer our at your facility on a scientific virtual machine (https://github.com/radiasoft/sirepo.)
Oasys also provide a graphical user interface to generate SRW simulations, and export it as a python script if needed, for parameter sweeping or various optimizations.
Example of SRW code, and Sirepo web interface
XRayTracer (xrt) is more recent x-ray simulation software developed by Konstantin Klementiev (MAX IV Laboratory) and Roman Chernikov (NSLS-II), which used an hybrid approach between raytracing and wavefront propagation, by measuring the optical path of rays and taking into acount diffraction effects. https://xrt.readthedocs.io/. This open source software also leverages GPU acceleration for faster computation.
It can be installed using
pip install xrt
xrt has a companion graphical user interface (xrtQook) that can be used to build beamlines intuitively.
Spectra is an open-source software developped by Tanaka-san to calculate the radiation from undulators, wigglers or a bend magnets. It doesn't allow to simulate full beamline propagation, but provides a lot of useful tools to estimate the power on mirrors (for engineering) or the flux entering a beamline.
More recently, new features allows the computation of coherent mode decomposition, and interacting with the software in python. You can run spectra without installing using the web inteface: https://spectrax.org/spectra/app/12.2/
Example of the spectra interface, and angular power density calculation for a multi-pole wiggler at SLAC
Ray-UI is a raytracing software with a graphical user interface developed at HZ-B:
https://www.helmholtz-berlin.de/forschung/oe/wi/optik-strahlrohre/arbeitsgebiete/ray_en.html
The user interface is very intuitive, and conveniently offers parameter looping (on right-lcik) for systematic studies.
The core engine Ray is not open-source, but RayUI has a python interface RayPyNg, and a new development RayX is open-source
example of raytracing with Ray using RayUI
CXRO database, for the calculation of reflectivity and other optical effects