Free software

About OpticalSetup

Copyright © 2026 Luca Genchi and contributors.

OpticalSetup is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

It is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose. See the GNU General Public License for more details.

The numbers OpticalSetup reports come from models with stated limits; read each component's page in the wiki before relying on one.

If you use OpticalSetup in your research, teaching or publications, please cite the software:

Bertoncini, A., & Genchi, L. (2026). OpticalSetup - the optical workbench software [Computer software]. Zenodo. https://doi.org/10.5281/zenodo.23191537

Wiki / Dispersive elements / Diffraction grating

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 →

A live trace, not a picture of one — but this preview is not interactive. Open it in the canvas to move things, change parameters, and save or export your own version.

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:

d (sin⁡θi+sin⁡θm)=mλd\,(\sin\theta_i + \sin\theta_m) = m\lambda
The grating equation: incidence angle θᵢ, diffraction angle θₘ, integer order m, line spacing d.

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.

GDD=−m2λ3G2πc2d2cos⁡3β\mathrm{GDD} = -\frac{m^2\lambda^3 G}{2\pi c^2 d^2\cos^3\beta}
A parallel grating pair at perpendicular separation G and diffraction angle β (Treacy 1969); the tracer reproduces it from the traced paths.
Simplified vs. reality

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.

Related components

Further reading