Bragg Diffraction Simulator Back
Solid State Physics Simulator

Bragg Diffraction Simulator — X-Ray Crystallography

Use Bragg's law 2d sin theta = n lambda to compute, in real time, the Bragg angle, diffraction angle 2 theta, effective d-spacing and maximum diffraction order from plane spacing d, X-ray wavelength lambda, order n and lattice strain epsilon. The tool visualises reflection from adjacent lattice planes and the positions of multi-order diffraction peaks.

Parameters
Plane spacing d
A
X-ray wavelength lambda
A
Diffraction order n
Lattice strain epsilon

Defaults are d = 2.500 A, lambda = 1.540 A (Cu K-alpha), n = 1, epsilon = 0. Cu K-alpha is the most common XRD source for metals and ceramics; Mo K-alpha (0.71 A) reaches higher angles; Co K-alpha (1.79 A) suppresses iron fluorescence and suits steel analysis.

Results
Bragg angle theta
Diffraction angle 2 theta
Effective d-spacing d_eff
Maximum order
Crystal planes and reflection path

Horizontal lines = lattice planes spaced by d / yellow = incident X-ray at angle theta / red = reflected X-ray at angle theta / white dashed = normal to the planes / green = path difference 2d sin theta between adjacent planes

Multi-order diffraction peaks

Horizontal axis = diffraction angle 2 theta (0 deg to 180 deg) / vertical axis = relative intensity / blue lines = positions of orders n = 1, 2, 3 ... / yellow marker = current order n / grey strip = physically allowed range

Theory & Key Formulas

Bragg's law is derived from the requirement that the path-length difference $2d\sin\theta$ between waves reflected by adjacent crystal planes equals an integer multiple of the wavelength $\lambda$:

$$2d\sin\theta = n\lambda$$

$\theta$ is the Bragg angle and $2\theta$ is the diffraction angle. With lattice strain $\varepsilon$ the effective plane spacing changes:

$$d_{\text{eff}} = d(1+\varepsilon),\quad \sin\theta = \frac{n\lambda}{2 d_{\text{eff}}}$$

The physical constraint $\sin\theta \le 1$ yields the maximum observable order:

$$n_{\max} = \left\lfloor \frac{2 d_{\text{eff}}}{\lambda} \right\rfloor$$

$d$ is the plane spacing (A), $\lambda$ is the X-ray wavelength (A), $n$ is an integer order and $\varepsilon$ is the dimensionless lattice strain. 1 A equals 1e-10 m.

What is the Bragg Diffraction Simulator?

🙋
I've heard X-rays can "see through" crystals to reveal their structure. How does that actually work? Is it like taking a photograph?
🎓
Good question. It isn't a photograph but diffraction. A crystal is a stack of regularly spaced atomic planes, and when X-rays strike it, every plane reflects a fraction of the wave. When the waves from adjacent planes are offset by exactly one wavelength, they reinforce each other and a strong reflection is observed — that is Bragg's law, 2d sin theta = n lambda. With the defaults in this tool (Cu K-alpha at lambda = 1.540 A and d = 2.5 A planes) the Results panel shows Bragg angle theta about 17.94 deg, diffraction angle 2 theta about 35.88 deg, and up to order 3 observable.
🙋
The diagram shows "path diff 2d sin theta". Where does that come from, and why the factor of 2 in front of d?
🎓
Pure geometry. Compare a wave that reflects from the upper plane with one that goes down to the next plane at depth d, reflects, and comes back. The second wave travels extra distance "down then back up", and because both rays make the angle theta with the planes, the extra path works out to 2d sin theta. When this matches an integer number of wavelengths n lambda the waves arrive in phase. Slide d from 2.5 to 5.0 A in this tool and the path-difference label in the bottom of the diagram doubles in real time.
🙋
The "Maximum order 3" value is intriguing. What does it mean?
🎓
It is a physical limit. Because sin theta = n lambda / (2 d) and sin theta cannot exceed 1, the order n can be at most 2 d / lambda. Taking the floor gives the integer maximum. For the defaults (d = 2.5, lambda = 1.540) that is 2 * 2.5 / 1.540 = 3.247, whose integer part is 3. Try switching lambda to 0.71 A (Mo K-alpha) and the maximum order jumps to 7. That is one reason Mo K-alpha is preferred for single-crystal structure analysis where many high-order reflections are needed.
🙋
One more question: what is "lattice strain epsilon" and how does it relate to residual stress measurement?
🎓
Epsilon is the fractional change in plane spacing when the crystal is stretched or compressed. We treat the effective spacing as d_eff = d (1 + epsilon); epsilon = +0.01 means a 1 percent tensile stretch. Move epsilon from 0 to +0.01 in this tool and 2 theta shifts from 35.88 deg down to about 35.52 deg (a "low-angle shift"); a compressive strain shifts the peak the other way. The sin squared psi method measures this tiny peak shift in multiple directions to recover the residual stress tensor with MPa accuracy. It is the same principle behind residual stress measurements on jet-engine turbine blades, welded bridges and semiconductor thin films.

Frequently Asked Questions

Bragg's law 2d sin theta = n lambda describes the condition under which X-rays reflected from adjacent crystal planes interfere constructively. William Henry Bragg and his son William Lawrence Bragg derived it in 1913 and were jointly awarded the Nobel Prize in Physics. Here d is the spacing between neighbouring planes, theta is the Bragg angle (the angle of incidence measured from the plane), n is an integer order and lambda is the X-ray wavelength. With the defaults (d = 2.500 A, lambda = 1.540 A of Cu K-alpha, n = 1, epsilon = 0) this tool shows theta about 17.94 deg, 2 theta about 35.88 deg, effective d-spacing 2.500 A and maximum order 3.
When the path-length difference 2d sin theta between waves reflected from adjacent planes equals an integer multiple of the wavelength (n lambda), the waves stay in phase and interfere constructively, producing strong diffraction. For non-integer multiples the phases cancel and nothing is observed. Sweeping n from 1 to 3 in this tool shifts 2 theta to 35.88 deg, 71.96 deg and 152.99 deg (for Cu K-alpha and d = 2.5 A) so each order sits at a distinct peak position. The constraint sin theta = n lambda / (2 d) <= 1 limits the number of accessible orders for any given d and lambda.
Lattice strain epsilon is the fractional change in plane spacing under tension or compression and rescales the effective spacing as d_eff = d (1 + epsilon). Tensile strain (epsilon > 0) makes d_eff larger, so for a given order n the value sin theta = n lambda / (2 d_eff) decreases and 2 theta shifts to lower angle; compressive strain shifts the peak to higher angle. X-ray residual stress measurement (sin squared psi method) exploits this effect to detect MPa-level stresses from peak shifts. Sweep epsilon from -0.05 to +0.05 in this tool and the 2 theta peaks slide continuously.
Cu K-alpha (characteristic line, lambda = 1.5406 A) is produced efficiently from a copper anode tube and offers a good balance of intensity, coherence and ease of handling, so it is by far the most common XRD source worldwide. Its wavelength matches typical crystal-plane spacings of 1 to 5 A, giving many observable peaks from low to high angle for most samples. Switching lambda to 0.71 A (Mo K-alpha) in this tool for the same d = 2.5 A pushes 2 theta to lower values and allows up to order 7 to be observed, which is why Mo K-alpha is preferred for single-crystal structure analysis. Co K-alpha at 1.79 A is used to suppress iron fluorescence in steel analysis.

Real-World Applications

Phase identification of crystalline materials: An unknown sample is irradiated with X-rays, the 2 theta positions of its diffraction peaks are measured, and Bragg's law converts those angles into d-spacings. Comparing the list of d values with the ICDD Powder Diffraction File identifies the substance. Geologists use this to fingerprint minerals in rocks; pharmaceutical companies use it to distinguish polymorphs (alpha vs. beta) of a drug substance. The d slider in this tool gives a hands-on feel for how peak positions track plane spacing; real instruments record the entire 2 theta intensity profile and match it against databases.

Residual stress and strain measurement: Tiny shifts in peak position reveal internal stress in metals and semiconductors. Typical applications are the compressive stress introduced by shot peening of jet-engine turbine blades, the residual stress around welds in automotive parts, and the stress in thin films deposited on silicon wafers. The sin squared psi method tilts the sample and measures 2 theta at many angles to reconstruct the full stress tensor. Sweeping epsilon by plus or minus 5 percent in this tool produces several-degree shifts; real instruments routinely resolve microstrain (1e-6 fractional changes).

Crystallite size and texture analysis: The Scherrer equation B = K lambda / (L cos theta) extracts the average crystallite size L from the full width at half maximum B of a Bragg peak, combined with the Bragg angle from this tool. The technique is indispensable in catalyst-particle design, lithium-ion battery cathode characterisation and magnetic nanoparticle development. Texture analysis of rolled or extruded metals uses the relative intensities of multiple hkl peaks to recover the orientation distribution function and predict plastic anisotropy.

Protein crystallography for drug discovery: Protein-ligand complexes are crystallised, irradiated with synchrotron X-rays (typically 0.7 to 1.0 A), and tens of thousands of Bragg reflections are recorded. Inverse Fourier synthesis turns them into electron-density maps that reveal atomic positions. The DNA double helix (1953) and myoglobin (1958) were landmark results; today the COVID-19 spike-protein structure was solved within a week and used directly in vaccine design. This tool addresses a single plane spacing, but real experiments apply the same Bragg condition to thousands of spacings simultaneously.

Common Misconceptions

The most common confusion is the idea that "the Bragg angle is the angle between the X-ray and the sample surface". In fact the Bragg angle is measured from the crystal plane, not the macroscopic surface. Textbook diagrams happen to draw the plane parallel to the surface, but in a real powder sample only the grains whose planes happen to satisfy the Bragg condition contribute to a given peak. The diffraction angle 2 theta, the angle by which the beam is deflected from its original direction, is exactly twice the Bragg angle. This tool deliberately reports theta and 2 theta as separate stats because beginners often mix the two up.

Next, many people assume that Bragg's law alone determines the full crystal structure. In practice Bragg's law only tells you where peaks will appear; the intensity of each peak depends on the arrangement of atoms inside the unit cell through the structure factor F_hkl. For example BCC crystals only show reflections with h + k + l even, while FCC crystals require h, k, l to share the same parity. Structure-factor calculations and full-pattern fitting (Rietveld refinement) are needed to convert a powder diffractogram into a complete crystal structure. This tool focuses on the angular geometry only.

Finally, "X-ray diffraction works on every kind of crystal" is not quite right. Light elements such as hydrogen and lithium have very small X-ray scattering cross-sections, so neutron diffraction or electron diffraction is used to locate them; this is why neutron diffraction is essential for finding lithium positions in battery cathodes. Amorphous materials such as glasses and polymers have no regular plane spacing and show broad halos rather than sharp Bragg peaks; their structure is analysed by the pair distribution function (PDF) method instead. This tool is restricted to the ideal Bragg condition in a well-ordered crystalline sample.