It is often required to represent an optical system in a design even though you do not have detailed prescription data like radii of curvature, glasses etc. This article shows how to use Zernike coefficients to describe the wavefront aberrations of a system and produce a simple but accurate representation of an optical system if a Zemax Black Box Surface file cannot be used. This is typically the case if you are relying on experimental data measured using the optical system, but its prescription data is not available to you.
This article is also available in Japanese.
Authored By: Mark Nicholson
Introduction
This article is also available in Japanese.
It is sometimes required to represent an optical sub-system without having detailed knowledge of its prescription. For first-order calculations a paraxial lens is adequate, but when wavefront aberrations are needed as well, Zernike phase coefficients can be used to give an accurate model of the wavefront produced by the optical system.
Zemax supports a comprehensive black-box capability which is recommended for this purpose. However the following procedure can be used if a Zemax Black Box file cannot be provided.
These Zernike phase coefficients can be produced by Zemax, if you want to distribute aberration data to your customers without revealing prescription data, or by an interferometer if you are measuring a lens on which you have no prescription data. Depending on your interferometer software, you may have data in Zemax Zernike format already, grid phase data, or .INT files. Zemax can work with all of these, but for the purposes of this article we will use only Zernike data.
Zernike phase data represents a measurement of the performance of an optical system at a specific field and at a specific wavelength. Because information about the glasses, radii of curvature, aspheric coefficients etc are not part of the Zernike data, there is no way to scale Zernike data to a different field or wavelength. For this reason, you will need a set of Zernike phase data for each (field, wavelength) pair you want to model performance at. These can be entered into Zemax by either having a separate file for each (field, wavelength) combination or (more likely) a separate configuration for each (field, wavelength) pair.
There is one important exception: when the system being modeled is an all-reflective system, then the Zernike Standard SAG surface can be used to model performance at all wavelengths for a given field point. This article gives full details of this special case.
The Starting Design
All the sample files used in this article are included in a zip file that can be downloaded from a link on the last page of this article. The first file we will look at is 'Cooke one field, one wavelength.zmx', which is based on the Cooke triplet sample file distributed with Zemax. As the name implies, this file is based on a single (field, wavelength) pair.

and its wavefront looks like so:

and its spot size is like so:

Now Zernike coefficients are a compact way of describing the wavefront error produced by an optical system. In order to produce a 'black box' model, we must first produce a paraxial optical system with the same first-order properties, and then aberrate the wavefront produced by this paraxial system with the Zernike data.
The key paraxial data we need is the exit pupil position, and exit pupil diameter. All wavefront data is measured in the exit pupil, and so our black box system must have the same pupil data. For this file, the pupil data is as follows:
Exit Pupil Diameter = 10.2337 mm
Exit Pupil Position = -50.9613 mm
The Paraxial Equivalent
Open the file 'Paraxial Equivalent.zmx'. It models the same sytem with just a paraxial lens surface:

Note the following:
- It uses the same field and wavelength as the original design.
- Its entrance pupil diamater is set to the same value as the exit pupil diameter of the original system. In this file the entrance pupil, stop surface and exit pupil are all co-located.
- The focal length of the paraxial lens, and the thickness to the image surface, are both set equal to -1*exit pupil position of the original file. The -1 factor is because the EXPP is measured from the image to the pupil, but the surface thickness is the distance from the pupil to the image, and so need to change sign.
- The system has the same first-order properties as the original system.
The exit pupil of this system is exactly the same size and in the same location as the exit pupil of the original system. In order to add aberrations onto the paraxial lens output, we use a Zernike Standard Phase surface immediately after the paraxial lens. Our goal is to take the Zernike coefficients of the original lens, and add them onto the Zernike surface of the paraxial equivalent lens.

Copying Zernike Data Between Lenses
Return to the 'Cooke One Field One Wavelength.zmx' file, and click on Analysis...Aberration Coefficients...Zernike Standard Coefficients. Zemax computes the wavefront of the system, and then fits a series of Zernike polynomials.

Both the sampling of the wavefront, and the number of Zernike terms, can be defined by the user via the Settings dialog. The key parameters in determining whether the wavefront is adequately sampled or the number of Zernike terms are the RMS fit error and the maximum fit error. Using the default parameters for both sampling and number of terms, this design delivers

Which means that when we subtract the real wavefront from one reconstructed from the Zernike coefficients, the errors are of the order of a millionth of a wave. That's close enough! However, in general you may need to adjust the wavefront sampling and maximum Zernike term in order to achieve an acceptable fit.
We now need to transfer the Zernike coefficient data out of this design and into the paraxial equivalent design. This could be done by printing the Zernike data out and re-typing it, but this is tedious. This is a good job for a macro.
The following macro (also included in the zip file at the end of the article), called Zernike Readout.zpl, gets the Zernike data from this lens and saves it to a file in the format that Tools...Import Data on the Extra Data Editor can read. The steps it goes through are as follows:
First it defines all the variables it will need.

(Note the editor used to write this macro was ConText. Note also that the sampling amd maximum Zernike terms should be set to the values you used for the Zernike Analysis above.) Then the macro gets the Exit Pupil Diameter and Zernike data:

Note that the normalization radius of the Zernike surafce is half the Exit Pupil Diameter. The macro then prints the data out to a .DAT file in the correct format for the Zernike Standard Phase surface to read it:

The Zernike data is entered into the Extra Data Parameter columns of the Zernike Standard Phase surface as follows:

Put this macro into the {Zemaxroot}/macros folder, click on Macros...Refresh Macro List so that the macro appears in the menu listing, and then run it. It will create a file called 'zernike.dat' in the same folder as the original Zemax file. If you open this file in Notepad, you will see:

This file contains all the data the Zernike Standard Phase surface needs. The first number is the number of Zernike terms, then the normalization radius, then each Zernike term. The Extra Data Editor's Import tool can read this file directly.
Return to the paraxial equivalent lens file, and open the Extra Data Editor. On its Tools menu, select Import Data:

Press the 'Browse' button and navigate to the folder where zernike.dat is stored:

and import this to surface 2. The Extra Data Editor now shows:

and the Zernike data has been imported. The wavefront error shows:

and the spot diagram shows

This file produces identical ray-tracing results to the original file! In the attached zip, the file 'Zernike Equivalent.zmx' shows the finished system. Also, the file 'Direct Comparison.zmx' shows both the original and Zernike versions of the same file as two different configurations. This allows easy comparisons between the two versions of the file.

Summary
The combination of a paraxial lens surface and a Zernike Standard Phase surface allows a very accurate 'black box' model of an optical system to be built. The paraxial lens has the first order properties of the original system (namely exit pupil size and location), and the Zernike surface adds the wavefront aberration.
A simple macro allows easy transfer of the Zernike data from the original file to the Zernike surface in the black box file.
All files used in this article are contained in the zip file you can download from the link below.