RayCrafter (dev) vs Zemax

Object in water under a coverslip: RayCrafter (dev) against Zemax

An object point in water under a coverslip, exported by RayCrafter and traced by Zemax. Rays, spots and the RMS wavefront match (0.03445 against 0.03442 waves). The Strehl ratio is not compared: RayCrafter's is 0.954, which is what the RMS wavefront both programs agree on gives, exp(-(2π × 0.0344)²) = 0.954, and what Zemax's own wavefront map (0.954) and FFT PSF (0.9543) give; Zemax's Huygens PSF gives 0.961, from a reference sphere of the opposite sign (its exit pupil position is +1.4 mm; evaluation #84). RayCrafter reproduces that Huygens grid to 0.002 with the sphere reversed.

RayCrafter dev 5ecb2efd Zemax 24.1.3 λ 0.55 µm Zemax run 2026-12-03 22:25

The design

An object point in water (object-space NA 0.03 = n sin theta) under a 0.17 mm N-BK7 coverslip, imaged by a Thorlabs AC254-050-A at 550 nm.

RayCrafter's own ray diagram.
RayCrafter's own ray diagram.

What is tested

An object in a medium: Zemax's surface 0 glass, and what Zemax takes object-space NA to be there.

Issue: raycrafter #202.

RayCrafter against Zemax

This is RayCrafter's development branch

RayCrafter at commit 5ecb2efd of dev, not the release on PyPI. The .zmx was exported at d5d3377b.

RayCrafter opens the project itself; Zemax (OpticStudio 24.1.3) the .zmx RayCrafter exported from it. So a difference may be in the export, in a calculation, or in what a quantity means. Each row is the largest difference over every field (0 mm).

17matching
0partial
0failing

Every row matches Zemax.

All 17 rows, matches included
QuantityLargest difference from ZemaxMatch / partial withinResult
Zemax reads the aperture, fields, wavelength and afocal setting that were meant0 warnings0 / 0 warningsMatch
Surfaces: thicknesses, gaps and semi-diametersThe project file against the lens data Zemax holds0 mm1e−09 / 1e−06 mmMatch
Surfaces: curvatures and conicsCurvature in 1/mm01e−12 / 1e−09Match
Refractive index of each glassN-BAF10, N-BK7, SF1001e−06 / 0.0001Match
Rays at the image, ray by ray: positionThe rays that both programs trace and get through: 1261 at 06.5e−08 mm1e−06 / 0.001 mmMatch
Rays at the image, ray by ray: slopedx/dz and dy/dz1.19e−091e−08 / 1e−05Match
Share of the pupil's rays that get through the aperturesRayCrafter's vignetting analysis against the range that Zemax's rings of rays allow: at 0, RayCrafter 100.0 %, Zemax 100.0 to 100.0 % (1261 of 1261 rays through)0 % points0.5 / 2 % pointsMatch
Chief ray at the image, every field0 mm1e−06 / 0.001 mmMatch
Focal length2.22e−14 %0.0001 / 0.1 %Match
RMS spot radius, every fieldZemax by Gaussian quadrature, RayCrafter from its spot diagram0 %0.1 / 2 %Match
Ray fans, tangential and sagittal6.5e−08 mm1e−06 / 0.001 mmMatch
RMS spot against focus, every fieldWhere the two ranges overlap0.04584 % of the largest0.1 / 2 % of the largestMatch
RMS wavefront, every field2.72e−05 waves0.001 / 0.01 waves, or 1 % of Zemax's if larger, to failMatch
MTF (one wavelength), every fieldAt RayCrafter's own frequencies.0.0027740.005 / 0.02Match
MTF (one wavelength), cutoff frequency, every fieldOf the fields where Zemax's table reaches beyond the cutoff. Cycles/mm, RayCrafter then Zemax: 101 and 1000.7345 %2 / 5 %Match
MTF (all wavelengths), every fieldAt RayCrafter's own frequencies.0.0027740.005 / 0.02Match
MTF (all wavelengths), cutoff frequency, every fieldOf the fields where Zemax's table reaches beyond the cutoff. Cycles/mm, RayCrafter then Zemax: 101 and 1000.7345 %2 / 5 %Match
Not compared

Strehl ratio, fields where Zemax's Huygens PSF disagrees with its own wavefront map: Zemax reports a positive exit pupil position, and its Huygens PSF is reproduced by RayCrafter's summed over the reference sphere of the opposite sign to the one of Zemax's own wavefront map; the whole explanation, with the numbers, is in the section “Strehl ratio: Zemax's Huygens PSF disagrees with Zemax's own wavefront map” (https://github.com/raycrafter-optical-design/evaluation/issues/84). at 0 mm: Zemax 0.961, RayCrafter 0.954, Zemax's own wavefront map 0.954

Strehl ratio: Zemax's Huygens PSF disagrees with Zemax's own wavefront map

Not comparable at these fields

Where Zemax reports the exit pupil at a positive position, its Huygens PSF is the diffraction image of a different wavefront from the one in its own Wavefront Map, and the Strehl ratio it prints is not that of the wavefront it reports. RayCrafter's Strehl ratio is computed from the wavefront Zemax's map shows, summed over the reference sphere of the sign that map and Zemax's OPD use (it differs from Zemax's wavefront map by 0.000 at 0 mm, Zemax's FFT PSF by 0.000 at 0 mm). So the two Strehl ratios cannot be compared at these fields. This is an inconsistency inside Zemax's output; we do not claim to know that Zemax's code is wrong. Decision of the project's owner, evaluation #84: the page must say so in full, and it does here.

RayCrafter's Strehl ratio is read on the pixel grid of Zemax's Huygens PSF (its largest pixel, as Zemax reads it). The grid differences are the largest difference of relative intensity over the 128 x 128 pixels, RayCrafter's PSF against Zemax's: once with the reference sphere of the exit pupil as RayCrafter has it and as Zemax's own Wavefront Map and OPD have it, and once with the sphere's radius reversed (the one change; RayCrafter does the sum). Where the reversed sphere reproduces Zemax's grid and the right one does not, Zemax's Huygens PSF used the opposite sign.

Field (mm) Zemax exit pupil position (mm) Strehl, Zemax Huygens Strehl, RayCrafter (Zemax's grid) Strehl of Zemax's own wavefront map Peak of Zemax's FFT PSF Grid difference, sphere as it is Grid difference, sphere reversed
0 mm1.420.9610.9540.95400.95430.05870.0024

Zemax's FFT PSF. Its text prints no Strehl ratio and its values are "not normalized". Read as a Strehl ratio, the largest value of its grid is on the scale where a perfect wavefront peaks at 1, as the fields where nothing tells the two signs apart show (nearly diffraction limited, so that the wavefront map's own Strehl ratio is known): no field of this page is one, so the scale is not checked here (on the folded designs' pages it is checked on the axis). That scale is read off those fields, not computed: Zemax gives no unaberrated PSF of the same sampling. The peak is a pixel of the 256 x 256 grid, so it can sit a little below the true peak. Where a column shows a dash, Zemax was not asked for the FFT PSF there, or for a wavefront map.

What is and is not shown. Shown: Zemax's Huygens grid is reproduced by RayCrafter with the sphere reversed, and by nothing else we tried. Not shown: why Zemax's Huygens PSF uses the sign it does, and why the Strehl ratio of Zemax's wavefront map (or its FFT PSF) differs from RayCrafter's by what the table gives (the programs sum the light differently: Zemax's FFT takes plane waves, RayCrafter and Zemax's Huygens PSF sum the wavelets of the reference sphere).

Rays

Both programs trace a hexapolar pupil, with the first point of each ring at +x, so the rays that both trace can be paired one by one: RayCrafter's spot diagram (6 rings) with Zemax's ray trace (20 rings).

Spot diagrams about the chief ray: Zemax's rays (red dots) and RayCrafter's (blue dots).
Spot diagrams about the chief ray: Zemax's rays (red dots) and RayCrafter's (blue dots).
The rays both programs trace: worst difference at the image, against field.
The rays both programs trace: worst difference at the image, against field.

RayCrafter's own plots

What RayCrafter's window and report draw, with Zemax's points over them (open markers).

MTF (one wavelength) at 0 mm.
MTF (one wavelength) at 0 mm.
MTF (all wavelengths) at 0 mm.
MTF (all wavelengths) at 0 mm.

The numbers behind the rows

For the rows that have no plot of their own. Zemax's values are from our own run; RayCrafter's from its analysis of the project.

First orderZemaxRayCrafter
effective focal length mm50.1450.14
FieldChief ray, Zemax (mm) Chief ray, RayCrafter (mm)Share through, Zemax (%) Share through, RayCrafter (%)RMS spot, Zemax (mm) RMS spot, RayCrafter (mm) Strehl, ZemaxStrehl, RayCrafter Worst ray position difference (mm) Worst ray slope difference
0 mm001001000.0035220.0035220.9610.95436.505e-081.193e-09

Lens data

The radius and thickness in the project file beside the radius Zemax holds, with Zemax's catalogue and index for each glass.

Zemax #TypeRadius, RayCrafter (mm)Radius, Zemax (mm)Thickness (mm)GlassSemi-diameter (mm)
1Standard (stop)∞∞0.17N-BK7 SCHOTT, n = 1.51852211
2Standard∞∞9511
3Standard33.3433.349N-BAF10 SCHOTT, n = 1.67305712.7
4Standard-22.28-22.282.5SF10 SCHOTT, n = 1.73366112.7
5Standard-291.07-291.0797.71453812.7

How Zemax was run

By make_zemax_reference.py, the same way for every design, on 2026-12-03 22:25, on immersion_object_under_coverslip.zmx exactly as exported (0 failed steps). zmx_export.json ties that file to the project, and the run refuses a file that does not fit it. What is asked for, and why: zemax_analyses.md; every file: Zemax_reference_output.

Reproduce

export UV_PROJECT_ENVIRONMENT=~/uv_venvs/evaluation_mac
uv run python -m evaluation_tools.from_raycrafter.export_zmx --check immersion_object_under_coverslip
uv run python -m evaluation_tools.from_raycrafter.compare_zemax immersion_object_under_coverslip
uv run python -m evaluation_tools.build_summary

17 quantities compared.