How to build a spectrometer - theory

This article is part of the How to Build a Spectrometer free tutorial.

Spectroscopy is a non-invasive technique and one of the most powerful tools available to study tissues, plasmas and materials. This article describes how to model a lens-grating-lens (LGL) spectrometer using paraxial elements, addressing the design process from the required parameters to the performance evaluation with Advanced OpticStudio features such as Multiple Configurations, Merit Functions and ZPL macros.

Authored By Lorenz Martin


Article Attachments


How to build a spectrometer -theory - YouTube


Optical spectrometers are instruments to measure the intensity of light as a function of wavelength. There is a variety of generic setups for spectrometers. This article features the line-grating-line (LGL) spectrometer. After setting up the spectrometer in OpticStudio, its critical design parameters are identified and discussed.

Basic setup of an LGL spectrometer

The basic setup of an LGL spectrometer is as follows:

The polychromatic light enters the spectrometer through the entrance pinhole resulting in a divergent beam. The collimator lens is then used to generate parallel rays. The following transmission diffraction grating is the core element of the spectrometer. It changes the direction of the light beam as a function of its wavelength (i.e. its colour). The focusing lens, finally, focuses the light beams on the detector. Every wavelength has a different position on the detector, and by measuring the intensity as a function of position on the detector the spectrum of the light is obtained.

As a first approach, this setup is modelled in OpticStudio using paraxial elements. Doing so allows to ignore aberration and optimization issues, which are discussed in the Knowledgebase article "How to build a spectrometer – implementation". On the other hand, our LGL spectrometer is suitable for understanding the basic physical concepts of a spectrometer and its resolution.

Modelling a paraxial LGL spectrometer in OpticStudio

System setup

Let’s start with setting the basic parameters of our design in the System Explorer. Set the Entrance Pupil Diameter as follows (we will see later how the aperture affects the performance of the spectrometer):

With our spectrometer, we want to analyse visible light in the range from λmin = 400 nm to λmax = 700 nm wavelength, resulting in a bandwidth of Δλ = 300 nm. Hence, we set three wavelengths, two at the edge of the spectrum and the central wavelength λ0 at 550 nm. The latter will also be the primary wavelength:

Collimator lens

This done, we can proceed with the first element in the spectrometer and add the first lines in the lens file. We are assuming that the light originates from a point source (corresponding to a pinhole). Using a paraxial lens with a focal length of 30 mm positioned 30 mm behind the pinhole will produce a collimated beam. A second surface of 30 mm thickness is inserted to account for the distance between collimating lens and diffraction grating:

The 3D Layout of our design will look like this:

Diffraction grating

The next element in the spectrometer is the transmission diffraction grating. Let’s have a closer look at the grating before implementing it in OpticStudio, since this is the crucial element of the spectrometer.

The grating is essentially a stop with several slits arranged in parallel and with equal distances between them. For the sake of simplicity, we first have a look at a grating with only two slits (top view):

The incident beam is collimated, so all the rays in the beam are parallel to each other. If we consider the two rays passing through the two slits (red arrows), we can calculate the path difference, Δs, between these two rays (blue section) as a function of the distance between the two slits, d, the angle of incidence, α, and the diffraction angle, β:

We want this path difference to be one wavelength in order to have constructive interference between the two rays:

The two previous equations enable us to calculate the diffraction angle:

This formula describes how polychromatic light is split into its wavelengths in a spectrometer. As we can see, the diffraction angle only depends on the wavelength (for given α and d).

The concept of the double slit can then be extended to a grid with many slits, which will concentrate more rays of a specific wavelength in the direction of the diffraction angle and thus enhance the diffraction efficiency.

There is much more to say about diffraction gratings and their features such as efficiency, blazing angle, etc. This information can be found in the Knowledgebase article "Simulating diffraction efficiency of surface-relief grating using the RCWA method". We just keep in mind that a diffraction grating is characterized by its distance between two adjacent slits and that it diverts the collimated light beam as a function of its wavelength.

When implementing the refraction grating in the spectrometer, the angle of incidence is typically chosen so that it is equal to the diffraction angle for the central wavelength, i.e.

and using equation 1

In our example we assume d = 0.5 µm and get α = 33.367°. With that in mind, we set up the diffraction grating in OpticStudio. First, we introduce a coordinate break in our lens file and set the Tilt About X to 33.367° in order to tilt the rays by the angle of incidence. The next line to add is the Diffraction Grating. Set the Lines/µm (which is the inverse of d) to 2, and the diffraction order to –1. Another Coordinate Break is needed to account for the diffraction angle. Here, we set a Chief Ray solve for Tilt About X to have the coordinates automatically follow the primary wavelength:

Focusing lens and detector

The last group of elements in the spectrometer is the focusing lens and detector. We add four lines to our lens file being space between grating and focusing lens (30 mm), the paraxial focusing lens (focal length ff = 30 mm), space accounting for the focal length and the detector plane, respectively:

Our 3D Layout will now look like this, once you have adjusted the settings as shown here:

One last setting concerns the rays in the 3D Layout marked with the red circle in the previous image where OpticStudio draws too many lines. They can be eliminated by setting the properties of surface 6 in the lens file:

Now we are done with the design of our paraxial LGL spectrometer and we can open a Standard Spot Diagram to view the spot size in the image plane (i.e. on the detector) at the three wavelengths we chose initially:

It is seen that the spot size is infinitesimally small which is only possible because we chose paraxial lenses and used geometric ray tracing. In reality, the spots are larger due to diffractive effects. That’s what we will address in the last part of this article. But first we have a closer look at the focusing lens and at the detector to understand how they must be dimensioned.

Spectrometer resolution

Detector width

The width of the detector is defined through three parameters: The bandwidth of the spectrometer, Δλ = λmax – λmin, the slit distance of the grating, d, and the focal length ff of the focusing lens. Whereas Δλ and d are typically prerequisites, the focusing lens can be chosen to match the geometry of the detector.

Taking the minimum and maximum wavelength of the spectrometer (in our example 400 nm and 700 nm, respectively), we can calculate the minimum and maximum angle of diffraction using equation 1. The result is βmin = 14.48° and βmax = 58.21°, which can be verified in OpticStudio in the Single Ray Trace data, tracing the marginal ray at the minimum and maximum wavelength:

When the rays pass through the focusing lens under minimum and maximum angle, we have the following situation:


Where ff is the focal length of the focusing lens and L the detector width. Consequently, we can calculate the detector width using

In our example we get L = 24.16 mm. This result can again be verified in OpticStudio. A simple and approximative way is to measure it directly with the Measure tool in the 3D Layout:

A more sophisticated and precise way is to use operands. For this purpose, we open the Merit Function Editor, key in the following lines and update the window (red arrow):

With the REAY operand we get the real ray’s y-coordinate, in our example on surface 9 (the detector). We select the values for wave 1 and 3, which correspond to 400 nm and 700 nm wavelength, respectively. The DIFF operand is used to calculate the difference between the two y-coordinates. The resulting value is now exactly what we calculated analytically before.

Let’s recall the essential outcome of the previous considerations: Once the bandwidth of a spectrometer is defined, the diffraction grating yields the minimum and maximum refraction angle (equation 1). The minimum and maximum diffraction angle, in turn, with the focal length of the focusing lens ff defines the detector width (equation 2). Large detectors call for a large ff and vice versa.

Remapping of the wavelengths on the detector

When we have a look at the Spot Diagram, we notice that the spots of the three wavelengths are not uniformly distributed on the detector surface, even though being uniformly distributed in the wavelength range. This effect comes from the sinus in equation 1 and must be accounted for in spectrometers by remapping the position on the detector to the corresponding wavelength.

We can calculate the mapping function (being the inverse of the remapping function) in OpticStudio by sweeping through the wavelengths of the spectrometer bandwidth and record the position of the ray on the detector. An efficient way to do so is to use a Zemax Programming Language (ZPL) Macro. Download the attached macro Mapping_Function_Resolution.ZPL and save it in the folder Zemax\Macros. Open it and have a look at the structure. The macro first gets the system wavelengths (operand WAVL) and then computes the y-coordinate of the ray on the detector (operand RAYY) while looping through the wavelengths using multiple configurations. The resulting plot after execution shows the mapping function:


Spectral resolution

The macro Mapping_Function_Resolution.ZPL produces a second plot showing the spectral resolution of the spectrometer R, i.e. the fraction of bandwidth, δλ, per unit width of the detector, ΔL:

The spectral resolution as it is defined here is the inverse of the derivative of the mapping function. For this reason, it is computed in the same macro:

The lower the spectral resolution, the less bandwidth we have per unit width of the detector. Multiplying the spectral resolution with the pixel width of the detector finally yields a measure for the spectrometer resolution, being an important characteristic value of every spectrometer.

We could enhance the spectral resolution of the spectrometer by selecting a larger focal length for the focusing lens and thus spreading the spectrum over a larger detector width, according to equation 2. However, this strategy wouldn’t work out. We must also consider that the spot size on the detector is limited by diffraction, introducing new constraints for spectrometer design.

Diffraction limit

A spectrometer can be considered as an optical system mapping an object (the entrance pinhole, i.e. a point source) to the image plane (the detector). Using rays to calculate the propagation of light through the optical system as OpticStudio does is very efficient. But the result we get with ray tracing does not fully correspond to reality. Instead of an infinitesimally small point (corresponding to a sharp image) the image of the point source will be blurred. This effect is due to diffraction and limits the resolution of all optical systems. The way an optical system like the spectrometer maps a point source into the blurred image is referred to as point spread function.

OpticStudio has a variety of tools to take diffraction into account. Here we consider the Airy disk (being the diffraction limited spot size) in the Spot Diagram where it is plotted along with its numerical value in the plot comments:

The Airy disk is also used for the Rayleigh criterion. The Rayleigh criterion states that the images of two-point sources can be discriminated as soon as the distance between them is larger than the radius of their Airy disk. In a spectrometer, the distance between two point sources corresponds to the fraction of bandwidth, δλ, as introduced in the previous section.

The Rayleigh criterion has a direct impact on the choice of the pixel size of the detector. It is useless to have pixels smaller than half the Airy disk radius since they would oversample the diffraction-limited resolution of the spectrometer.

The formula to calculate the radius of the Airy disk is

where F# is the working f-number, which corresponds to the focal length of the focusing lens, ff, divided by the system aperture. The consequences of this relation are the following:

  1. The diffraction-limited resolution of the spectrometer varies with wavelength. This effect cannot be eliminated with the optical design.
  2. Choosing a large focal length for the focusing lens, ff, will increase the f-number which, in turn, increases the size of the Airy disk. This effect goes hand in hand with the detector width L as discussed in the previous section (equation 2): The detector width will increase as well. In the end, we only get larger Airy disks on a larger detector and do not enhance the spectrometer resolution.
  3. Choosing a large system aperture will decrease the f-number which reduces the size of the Airy disk.

Choice of system parameters

Assuming that the bandwidth and the grating of our spectrometer are pre-set, we have two parameters we can tune to get the most out of our spectrometer:

System aperture

The system aperture has a direct impact on the size of the Airy disc, i.e. the diffraction-limited resolution of our spectrometer (equation 3). It is a good strategy to choose the aperture as large as possible since this yields small Airy disks.

Focusing lens

The choice of the focal length of the focusing lens, ff, is more delicate. The most important is to illuminate the detector entirely (equation 2). If the detector is small, also ff is small and we get a more compact spectrometer. On the other hand, small focal lengths entail more aberrations. Consequently, the detector should be chosen as large as possible. The diffraction-limited resolution of the spectrometer is not affected by the focusing lens, since the size of the airy disk scales with the detector width.


This article is the first component of the How to Build a Spectrometer free tutorial.

Next article: How to build a spectrometer – implementation


Was this article helpful?
68 out of 71 found this helpful



Article is closed for comments.