I am working on building a very simple optical simulator for my workflow.

I am stuck at a point where I am trying to simulate the impact of diffraction on a lens system that has geometric aberrations.

Textbooks such as Goodman and others specify the wavefront aberrations at the exit pupil essentially add a phase-shift to the perfect spherical wave. This phase-shift term $e^{jW(x, y)}$ where $W(x, y)$ are the Seidel or Zernike polynomials that represents the optical path difference (OPD) between the actual and ideal wavefronts.

I have implemented a detailed ray tracing code that helps me generate spot diagrams. I am even able to calculate optical path length for every ray that traverses through the system. However, I am unclear on how I can (a) compute the actual wavefront OR (b) Determine the function $W(x, y)$ that represents the OPD at the exit pupil.

I came across this post on Zemax communities where they mention something about "subtracting a chief-ray centered reference sphere phase from the optical path lengths computed via ray tracing".

Any help on explaining this or pointing to resources that can help with this will be really appreciated.

  • $\begingroup$ Good-quality raytrace code is very complicated & difficult, which is why you pay so much for CODEV or Zemax. If you want to keep it simple, calculate pure geometric behavior and simple Airy-disc size based on aperture, and use whichever one is larger as a simple estimate. $\endgroup$ Commented Jun 3, 2022 at 12:47
  • $\begingroup$ I agree that Zemax and CodeV have been industry standards for a long time. However, even these tools must use a technique to determine the OPD that is based on some theoretical foundation. I am just looking for an algorithm or paper or technique to understand how ray trace is converted into OPD. $\endgroup$ Commented Jun 3, 2022 at 19:31

1 Answer 1


I would recommend a book by Warren Smith, Modern Optical Engineering, McGraw Hill. The older editions, at least, mention the calculation of OPD (for which you have to construct a reference sphere). OPD is calculated for rays traced to this reference sphere. Example D is used for the OPD calculations. You can use Smith's calculations as a check on your own. I've never found errors in his books. Another very good reference is WT Welford, Aberrations of Optical Systems. I've used both of these for similar problems.

Basic ray-tracing is one thing - what CodeV does well is figure out what rays to trace such that they go through the stop properly. (In particular, the chief ray which goes from the tip of the object, through the center of the stop). This can be tricky for off-axis points, especially when field angles get large. Zemax historically doesn't do this as well, so beware if you compare. Or try OSLO, which has a free version. OSLO is an high quality lens design package, at low cost if you buy it. (I have no association with them other than past use). You could use OSLO at least to compare your calculations.

  • $\begingroup$ Thanks - I'd forgotten OSLO $\endgroup$ Commented Jun 6, 2022 at 10:52
  • $\begingroup$ Thanks JB2. I was able to access copy of Modern Optical Engg and Chapt 10 and 11 seem to be relevant for what I am trying to do. $\endgroup$ Commented Jun 6, 2022 at 15:04
  • $\begingroup$ I am little confused on why tracing the chief ray it would be tricky. I have calculated the exit and entrance pupil positions (both are virtual) for my lens system using paraxial analysis. I am circularly sampling entrance pupil and tracing rays from my object point to them. One of the points is the center of the pupil. Isnt this sufficient? Due to aberrations, rays might not pass through this, but isnt that ok? $\endgroup$ Commented Jun 6, 2022 at 15:10
  • $\begingroup$ For the highest accuracy, you have to find the real chief ray which goes through the center of the stop. A paraxial approximation may not work as well due to aberrations: the entrance pupil is the image of the stop, but the imaging between the stop and the entrance pupil (or the stop and the exit pupil) may have aberrations. When I said chief ray, I should have said the chief ray and the upper and lower marginal rays that go to the edge of the pupil. Finding those upper and lower rays are important because they define the numerical aperture for the off- axis field points. $\endgroup$
    – JB2
    Commented Jun 7, 2022 at 12:20
  • 1
    $\begingroup$ Dinesh - To answer your earlier question, the exit pupil is a theoretical spherical surface that is located with its center at the image point. You trace rays to this surface and compare them. I haven't done this, and I think there are some subtleties about keeping track of OPD. The books by Michael Kidger might have details, as he developed a ray trace program. Regarding your comment about Seidel aberrations, Zemax certainly calculates them. However, most people rely on the real ray aberrations, computed by tracing real rays for optimizing lenses. . $\endgroup$
    – JB2
    Commented Jun 11, 2022 at 20:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.