One reflection, one column at a time: the images the textbooks show, computed for your crystal and your g.
Choose a crystal, a foil normal and an operating reflection, and the page integrates the two-beam Howie-Whelan equations with anomalous absorption down every column of the image, with the extinction and absorption distances from the structure factors and thermal-diffuse scattering. Straight and inclined dislocations, dipoles and loops with their inside-outside contrast, and stacking faults with their alpha fringes, in bright field, dark field and weak beam, with the profile across the defect and the g·b bookkeeping alongside.
b in fractional lattice coordinates (1/2 1/2 0 is a/2[110]); u the line direction in lattice indices. The line tilt rotates the line out of the foil plane about the image normal, so an inclined dislocation runs from the top surface to the bottom across the field of view.
The fault plane is inclined through the foil, crossing it from the top surface on the left to the bottom on the right; R in fractional coordinates (1/3 1/3 1/3 is the a/3[111] displacement of an intrinsic fault in fcc, α = 2πg·R).
Diffraction contrast from a lattice defect is computed here the way Howie and Whelan first did it in 1961 and Head, Humble, Clarebrough, Morton and Forwood turned into the standard programs a decade later: the crystal is treated as a set of narrow columns parallel to the beam, and within each column the two-beam coupled equations for the transmitted and diffracted amplitudes are integrated down through the foil with the local phase 2πg·R(z) of the displacement field added to the excitation error. The extinction distance ξg comes from the structure factor of the operating reflection, the absorption distances ξ′0 and ξ′g from the thermal-diffuse absorptive potential with room-temperature Debye-Waller factors, so the anomalous absorption that makes bright and dark field differ, and the fringes of a stacking fault asymmetric, comes out of the same calculation rather than being typed in. The integration is fourth-order Runge-Kutta with a few hundred steps per column, checked against the analytic two-beam intensities of a perfect crystal. A dislocation lying in the foil plane, or a fault, gives an image that is uniform along one direction, so one row of columns is integrated and resampled. A line inclined through the foil has no such shortcut: every column of the image is integrated, and on a browser with WebGPU those columns run as one compute shader on the graphics card, one thread per column, with the same equations, the same step and the same displacement fields, which turns a several-second calculation into a fraction of a second; the page checks the shader against the JavaScript integrator to a part in 105 and falls back to a worker when there is no WebGPU.
The displacement field of a straight dislocation is the isotropic elastic solution with the Burgers vector resolved into screw and edge parts, with a small core cut-off; a dipole or loop is two such dislocations of opposite Burgers vector; a stacking fault is a rigid displacement R across an inclined plane. The Burgers vector, the line direction and the fault plane are entered in the indices of the crystal and converted to the image frame through the lattice, so the g·b and g·R bookkeeping is done for you and reported in the readout: a dislocation with g·b = 0 comes out invisible or with the residual contrast of its edge component, a fault with g·R integer shows no fringes.
Bright field is the transmitted intensity at the exit surface, dark field the diffracted one; each image is scaled from black at zero to white at its own maximum, which the caption gives together with the level a perfect crystal would show at the same thickness and excitation error, and the profile carries the absolute values. The profile is taken through the centre of the image along g. For a dislocation the image lies to one side of the core, on the side fixed by the sign of (g·b)s, and it swaps sides when g or s is reversed; the weak-beam button sets s to the value at which 3g is at the Bragg condition, where the image narrows to a few nanometres and sits close to the core. For a dipole or loop the readout says whether the two images lie outside or inside the pair of cores, which is the inside-outside test for the nature of a loop when the sense of g and the loop normal are known. For a stacking fault the fringes run parallel to the intersection with the surfaces; with absorption the bright-field pattern is symmetric about the centre of the fault and the dark-field one is not, and the outer fringes at top and bottom surfaces differ in a way that gives the sense of R.
This is the two-beam column approximation of an elastically isotropic crystal. Systematic reflections (the row of 2g, 3g that matters for weak-beam images at large s) are not included: the weak-beam image is computed with the single reflection at the stated s, which reproduces the narrowing and the peak position of the (g, 3g) condition well but not the exact intensity. Anisotropic elasticity, surface relaxation, dislocation core structure and the image of a partial dislocation bounding a fault are outside the model, and so are dislocations that end inside the foil or curve. The crystal library supplies structure factors for the extinction distances; for a CIF the same is done from its atoms. Absorption uses the room-temperature Debye-Waller factors of the elements from the same table as the SAED simulator; the ratio ξg/ξ′g can be overridden when a measured value is at hand. Head et al. also simulated the images by the same equations; their book remains the reference for matching computed and observed images defect by defect.
@misc{tripathy2026twobeamdefectsimulator,
author = {Tripathy, Manisha},
title = {Two-Beam Defect Simulator},
year = {2026},
howpublished = {\url{https://untetheredatom.com/tem/two-beam-defect-simulator}},
note = {Interactive web tool}
}