Diffraction grating
Separates light into selected diffraction orders using the grating equation, with adjustable groove density, order efficiency, and a choice of spectral illumination.
Open in the canvas →In the real world
A diffraction grating is a surface ruled with closely, evenly spaced lines (period d). Light diffracting from it interferes constructively only at angles satisfying the grating equation:
Because the equation depends on λ, each nonzero order spreads white light into a spectrum — the same effect a prism produces through dispersion, but from interference rather than refractive-index variation.
In OpticalSetup
This is one of the few components where OpticalSetup implements the textbook formula directly and exactly, solving the grating equation per sampled wavelength for every configured diffraction order, in either reflective or transmissive mode. Orders where the equation has no real solution (|sinθₘ| > 1) are simply dropped, matching a real grating's behavior of only lighting up the orders that geometrically exist. Their light is not dropped with them: it goes to the orders that do exist, as it does on a real grating when an order passes off. A 2400 lines/mm grating at 532 nm has nowhere to send the beam but the zeroth order, and sends all of it there.
For a pulse, each diffracted colour also carries the phase the grating adds, 2πm x/d at the point x where it is diffracted, the term that turns it by the grating equation. With the phase of its path, that gives a detector the GDD of a grating pair (Treacy's compressor) or of a stretcher built with lenses, and a single grating's fan reads as the central ray's GDD with no duration, since its colours diverge enough to change it within a metre.
Diffraction efficiency per order sets the share each diffracted order keeps per bounce (100 % by default, so older sketches are unchanged); a compressor's four bounces at 90 % pass 66 %. Power is split evenly across the configured orders that propagate, rather than computed from the groove profile (a real blazed grating concentrates most of the light into one order by design) — order existence and angle are exact, relative brightness between orders is not. Since which orders propagate depends on wavelength, a broadband beam whose orders pass off inside its band divides its power differently at each end of the band.