Xrt is a python-based software library for beamline simulation and analysis in x-ray regime. We provide classes for many beamline elements, propagation engine in ray and wave approximations with full account for shapes and material properties, and high quality visualization capabilities. Recently added support for the GPGPU calculations via OpenCL not only allowed us to speed up the existing ray tracing routines but to qualitatively extend the limits of the theoretical models involved at all stages. As an example for the sources: we managed to increase the integration precision at high magnetic fields and high energies, which allows to calculate wigglers as undulators, an important case for the next-generation low-emittance synchrotrons. For the optics: wave propagation is implemented in the most general Kirchhoff integral form, therefore diffraction efficiency can be derived for multiple diffraction orders in gratings and zone plates. For the materials: reflectivity curves are calculated for the deformed crystals by solving the Takagi-Taupin equations numerically for each photon in the beam.
We also introduce an XML-based file format to store the ray tracing project parameters and an interactive GUI tool, xrtQook, which we recommend for the project configuration editing and automatic ray tracing script generation.
We present an open source python based ray tracing tool that offers several useful features in graphical presentation,
material properties, advanced calculations of synchrotron sources, implementation of diffractive and refractive elements,
complex (also closed) surfaces and multiprocessing. The package has many usage examples which are supplied together
with the code and visualized on its web page.
We exemplify the present version by modeling (i) a curved crystal analyzer, (ii) a quarter wave plate, (iii) Bragg-Fresnel
optics and (iv) multiple reflective and non-sequential optics (polycapillary). The present version implements the use of
OpenCL framework that executes calculations on both CPUs and GPUs. Currently, the calculations of an undulator
source on a GPU show a gain of about two orders of magnitude in computing time.
The development version is successful in modelling the wavefront propagation. Two examples of diffraction on a plane
mirror and a plane blazed grating are given for a beam with a finite energy band.