Diffraction Grating Models for Matlab

A collection of m-files useful for learning and teaching about the principles of diffraction gratings.
Click here to download the ZIP file "DiffractionGrating.zip" containing all the programs shown here.

GratingMono.m


Click to view enlarged figure
Diffraction grating geometry with a monochromatic incident light beam, diffracted orders +4 to -4 shown. The grating surface is at the bottom of the diagram, along the x axis. The line labeled "Incident beam" is the direction of the incoming light beam. The line labeled "0" is the direction of the zeroth-order diffraction. The upper left slider controls the angle of incidence, the lower left slider controls the grating ruling density (lines/mm), and the lower right slider controls the wavelength of the incident beam.

GratingOrder.m


Click to view enlarged figure
Diffraction grating with a monochromatic incident light beam, with a single selected order shown. The grating surface is at the bottom of the diagram, along the x axis. The line labeled "Incident beam" is the direction of the incoming light beam. The dotted line is the diffracted (outgoing) beam. The line labeled "Order 0" is the direction of the zeroth-order diffraction. The upper left slider controls the angle of incidence, the lower left slider controls the grating ruling density (lines/mm), the upper right slider controls the order shown, and the lower right slider controls the wavelength of the incident beam.
This can be used to illustrate the operation of echelle gratings, coarsely- ruled grating that acheive high dispersion by being operated at high diffraction orders and large angles of incidence and diffraction.

GratingWhite.m


Click to view enlarged figure
Diffraction grating geometry, with seven pre-selected diffracted wavelengths shown in orders +1 and +2 only. The grating surface is at the bottom of the diagram, along the x axis. The line labeled "Incident beam" is the direction of the incoming polychromatic light beam. The colored lines are diffracted beams of the 7 wavelengths defined in lines 30-36. Each is labeled with its wavelength and diffration order (m=1 or 2). The second-order diffractions are drawn as shorter lines to make them distinct from the first-order diffractions. The line labeled "Zero order" is the direction of the zeroth-order diffraction, at the angle of specular reflection from the grating surface. The slider on the left controls the angle of incidence and the slider on the right controls the grating ruling density (lines/mm).

Interference.m


Click to view enlarged figure
Interactive simulation of interference between reflections from adjacent grooves in a diffraction grating. A grating with N grooves is illuminated by monochromatic light. When viewed at an angle, the reflections from each groove travel over slightly different path lengths and therefore are slightly phase-shifted with respect to each other. In this simulation, the light beams from each reflection is represented by a sine wave, each of which is slightly phase-shifted compared to adjacent reflections by an amount that depends on the wavelength and the path length differences between adjacent reflections. When all the the sinewaves are added up, this phase shift results in a partial cancellation of some of the waves. As the path length differences are changed (by changing the wavelength or the angle at which the grating is viewed), a diffraction pattern emerges that shows intensity maxima whenever the path length difference (pld) is an integral number of wavelengths (called the "order"), thereby resulting in constructive interference. As the number of grooves (N) increases, these maxima become very sharp and the intensity between the maxima becomes lower and lower. Real gratings have thousands of grooves. Sliders on the graph allow you to adjust the number of grooves (N) and the path length difference (pld) between adjacent reflections.

DiffractionGratingSpectrum.m


Click to view enlarged figure
Self-running simulation of a diffraction grating spectrum illuminated by monochromatic light. Shows a plot of the total intensity at the detector vs the wavelength of the incident light (expressed at the path length difference between adjacent reflections, pld). It's instructive to run this simulation with the number of grooves N=2, then N=3, N=4, and so on. Maxima in the intensity occur whenever the path length difference (pld) is an integral number of wavelengths (called the "order"). As the number of grooves gets bigger and bigger, the maxima become very sharp and the intensity is nearly zero between the maxima. In this figure, the number of grooves N is 100.

DiffractionGratingFirstOrder.m


Click to view enlarged figure
Close-up of first-order diffraction pattern of grating illuminated by monochromatic light. Shows the "diffraction limit' caused by the finite number of grooves, N. The larger N, the narrower this pattern, and the higher the diffraction-limited resolution of the grating. The width of the maximum is inversly proportional to the number of grooves N. In this figure, the number of grooves N is 300. A real, practical spectrometer can not achieve this so-called diffraction limited resolution because it must utilize a finite slit width in order to allow sufficient light to enter the detector. As the slit with approaches zero, the effective resolution approaches the diffraction limit illustrated here, but the intensity of the light reaching the detector approaches zero.

ZIP file containing all of the above functions and demos.

Tom O'Haver
Professor Emeritus
Department of Chemistry and Biochemistry
The University of Maryland at College Park
toh@umd.edu
http://www.wam.umd.edu/~toh