sim icon

Diffraction Grating

The simulation below shows the pattern generated by a set of slits. The user has control over:

Some things to investigate:

Always be aware of possible aliasing effects in regions where the maxima become very fine. If odd things are happening then zoom in as much as possible to ensure that the maxima are being truly represented.

Separation a (μm):
Width b (μm):
Wavelength λ (nm):
Δλ (nm):
x (mm):
y (mm):
I (a.u.):

Open this simulation in a separate window.

Code Samples

Matlab
% Parameters (SI units)
L = 1;                  % Distance to observation plane       
a = 400e-6;             % Slit separation
b = 40e-6;              % Slit width
N = 4;                  % Number of slits
wavelength = 540e-9;    % Wavelength

% Observation plane lateral distances
points = 1000;
xmin = -5E-3;
xmax = 5e-3;
x = linspace(xmin,xmax,points);

% Calculate intensity
theta = atan(x/L);
beta = pi*b*sin(theta)/wavelength;
alfa = pi*a*sin(theta)/wavelength;
I = (sin(beta)./beta).^2.*(sin(N*alfa)./sin(alfa)).^2/N^2;

% Plot result
plot(x*1E3,I);
axis([xmin*1E3 xmax*1E3 0 1]);
xlabel('Distance (mm)');
ylabel('Intensity (a.u.)');
Python
from pylab import *

# Parameters (SI units)
L = 1                       # Distance to observation plane       
a = 400e-6                  # Slit separation
b = 40e-6                   # Slit width
N = 4                       # Number of slits
wavelength = 540e-9         # Wavelength

# Observation plane lateral distances
points = 1000
xmin = -5e-3
xmax = 5e-3
x = linspace(xmin,xmax,points)

# Calculate intensity
theta = arctan(x/L)
beta = pi*b*sin(theta)/wavelength
alfa = pi*a*sin(theta)/wavelength
I = (sin(beta)/beta)**2*(sin(N*alfa)/sin(alfa))**2/N**2

# Plot result
plot(x*1e3,I)
xlim(xmin*1e3,xmax*1e3)
xlabel('Distance (mm)')
ylabel('Intensity (a.u.)')
show()