Bragg's law, discovered a century ago, is a fundamental principle widely used to investigate the microscopic structure of crystals. However, there is a large gap between the classroom X-ray diffraction (XRD) concept and a practical XRD experiment in real-life. This software is written to simulate a modern XRD experiment, with multiple degrees of motion and a 2-dimensional detector. This program is designed to give students a head start on their first experiment, and also to help to plan more complex experiments often conducted at synchrotron facilities.
A schematic drawing of the six-circle diffractometer.
From H. You, J. Appl. Cryst. 32, 614-623 (1999).
X-ray diffraction experiments are conducted on so called "diffractometer", which equipped with multiple degrees of rotational freedom. This allows for the precise control of the sample's and detector's orientation relative to the incident X-ray beam.Typically, diffractometers use up to six circles of rotation: four for the sample (ϕ, χ, η, μ, from inner to outer motor) and two for the detector (δ, ν, from inner to outer). By combining rotations from these different axes, specific Bragg peaks or regions in reciprocal space can be accessed. While the lab diffractometer often use point or line detector due to lower X-ray intensity and limited budget, two-dimensional detector are more common (with exceptions!) at synchrotron light sources because they can survey the reciprocal space more efficiently.
This program simulates a real XRD experiment on a given crystal by visualizing the portion of reciprocal space that can be reached with a certain combination of motor values. Interactive sliders allow for a quick and intuitive understanding of how effective a particular motor scan is at covering reciprocal space and what volume is explored by the scan. This visualization helps users understand how changes in these angles affect the position and orientation of the detector in reciprocal space, which is crucial for targeted measurements of Bragg reflections and diffuse scattering.
Example geometry 1: Forward scattering geometry
In the forward scattering geometry, the detector is positioned near the direct beam (at δ, ν ~ 0°) to capture X-rays scattered at very small angles. This setup is primarily used for two types of experiments:
1. Small Angle X-ray (Neutron) Scattering (SAXS/SANS), which probe structural correlation at large length scales about 1~100 nm;
2. Crystallography, typically combined with high-energy photons (>tens and hundreds of keV) that can penetrate the sample and have large reciprocal space coverage. By a 360° rotation scan (e.g. ϕ in the animation), it collects a large number of Bragg peaks (e.g. with indices -5 < h,k,l < 5 or even more). The measured intensity of these 1000+ Bragg peaks are used to refine the crystal structure. Pre-orient the sample is not required for this type of measurements. I conducted experiment at QM2 at CHESS with this geometry.
Example 2: Backward scattering geometry
At large scattering angles, the detector covers only small section of the reciprocal space. Therefore, it is critical to orient the sample before the experiment and plan where to go in the reciprocal space. The main advantages of this geometry are the high sensitivity to weak signals when away from low |Q| diffuse scattering, the ability to probe higher |Q| values, and improved Q resolution offered by high angular resolution with slightly lower photon energy. A single motor scan does not make a straight trajectory in the reciprocal space along high symmetry direction, the signal can easily walk off the detector. This is also the main reason why I develop this program.
This is a more common geometry used in my experiment, including (hard X-ray, soft X-ray):
6ID, 7ID, 29ID at APS
17-2 and 13-3 at SSRL
23ID-CSX, 4ID-ISR at NSLS-II
REIXS at CLS
BM28 at ESRF
The code for this simulation is available on Google Colab. I have also developed a similar package for analyzing beamtime data, which is available on Github. You are welcome to use it but please triple check your result for accuracy.
Polarization and azimuthal angle dependence of the magnetic Bragg peak intensity in NdNiO3 thin film.
The lines represent the model calculation based on a chiral magnetic spiral. From J. Li, Nat. Comm. 15, 7427 (2024).
For Bragg peaks with a large out of plane component, i.e. (002), a full 360° rotation of azimuthal angle is often possible. However, for peaks with large in-plane component, like (0.5, 0.5, 0.5) in the animation, some azimuthal angles cannot be measured (red shaded area on the cone).This is due to either the incident or scattered X-ray beam is blocked by the sample's horizon (the grey z=0 plane), meaning X-ray need to come/exit through the back side of the sample. Moreover, as the X-ray approaches this boundary, it becomes so grazing to the surface that self-absorption significantly distorts the Bragg peak intensity. Therefore, the goal of this simulation program is to determine the range of azimuthal angles that will produce meaningful data for a given Bragg peak and photon energy.