RayCrafter (dev) vs Zemax

Asphere Edmund67248: RayCrafter (dev) against Zemax

The asphere Edmund 67248, exported by RayCrafter and traced by Zemax. The surfaces are read as written. Rays, RMS spot radius and field curvature match. Not all matches: the MTF at 1 deg is Partial: it differs from Zemax's Huygens MTF by 0.019 (limit 0.02; from its FFT MTF by 0.022), and Zemax's FFT MTF, which assumes the pupil index is linear in the direction cosine, is not the reference there because its own rays depart from that by 0.011 (evaluation #86). The RMS wavefront differs by 0.0021 waves (Partial).

Zemax disagrees with itself here, so "matching Zemax" is not well defined

Zemax's own two methods (FFT and Huygens) disagree with each other by more than our fail limit. The rows below keep their verdicts, each against one Zemax number. Where RayCrafter lies inside the band between Zemax's two numbers it is no further from either than they are from each other; where it lies outside, it is further from both than Zemax's own methods are from each other. Each row's note and Zemax against itself give both Zemax numbers, their difference and RayCrafter's value.

  • MTF. Zemax's FFT MTF and its Huygens MTF differ by up to 0.038 (at 1 deg), 1.9 times our fail limit of 0.02. Taking every frequency, RayCrafter's MTF is beside the band (outside it by up to the fail limit of 0.02) at 1 deg, the band being the range between Zemax's two curves. Plots with both Zemax curves, the band and RayCrafter's: 1 deg.
  • RMS wavefront. Zemax gives one number per field, so there is no Zemax spread to show for it.
RayCrafter dev 5ecb2efd Zemax 24.1.3 λ 0.5876 µm Zemax run 2026-12-04 07:31

The design

Edmund 67248 (f/0.75), the right way round, under a collimated 36 mm beam at 587.6 nm, 0 and 1 degree, image at RayCrafter's autofocus.

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

What is tested

RayCrafter's ZMX export of an asphere (it writes the PARM lines itself), and the rays through it traced by both programs.

Issue: raycrafter #160.

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°, 1°).

20matching
4partial
0failing

Not matching: partial and fail rows.

QuantityLargest difference from ZemaxMatch / partial withinResult
RMS spot against focus, every fieldWhere the two ranges overlap0.4418 % of the largest0.1 / 2 % of the largestPartial
RMS wavefront against fieldPiston and tilt removed; at the largest field, Zemax 1.155 and RayCrafter 1.154 waves. Zemax gives one RMS wavefront number per field (its RMS Wavefront operand), so there is no Zemax spread to show for this row: it compares that one number with RayCrafter's0.002052 waves0.001 / 0.01 waves, or 1 % of Zemax's if larger, to failPartial
MTF (one wavelength), every fieldAt RayCrafter's own frequencies. Against Zemax's Huygens MTF, not its FFT MTF, at 1 deg: the FFT MTF takes the pupil index as linear in the direction cosine, and Zemax's own rays at the image depart from that by 0.011 (more than 0.005; a plane fit of L and M on px, py, over half their range), while the Huygens MTF follows the rays' own directions. It is not exact either: it gives every ray of its pupil grid the same amplitude, so where the density of rays in direction cosine varies across the pupil it weights the pupil by that density, where conservation of energy gives its square root (evaluation #86, https://github.com/raycrafter-optical-design/evaluation/issues/86). The difference from the Huygens MTF there is 0.019; from the FFT MTF, which is not scored there, 0.022. Zemax's own FFT and Huygens MTFs differ from each other by 0.003, 0.038 at 0 deg, 1 deg (largest of the two azimuths). Zemax's own FFT and Huygens MTFs differ by more than the fail limit (0.02) at 1 deg, so matching Zemax is a band, not a line (zemax-spread). 1 deg: at 41 cycles/mm, where Zemax's two MTFs differ most (tangential), Zemax FFT 0.439, Zemax Huygens 0.477 (they differ by 0.038, 1.9 times the fail limit), RayCrafter 0.460: inside the band, 0.017 from the nearer Zemax value; over all frequencies RayCrafter is at most 0.009 outside the band0.018770.005 / 0.02Partial
MTF (all wavelengths), every fieldAt RayCrafter's own frequencies. Against Zemax's Huygens MTF, not its FFT MTF, at 1 deg: the FFT MTF takes the pupil index as linear in the direction cosine, and Zemax's own rays at the image depart from that by 0.011 (more than 0.005; a plane fit of L and M on px, py, over half their range), while the Huygens MTF follows the rays' own directions. It is not exact either: it gives every ray of its pupil grid the same amplitude, so where the density of rays in direction cosine varies across the pupil it weights the pupil by that density, where conservation of energy gives its square root (evaluation #86, https://github.com/raycrafter-optical-design/evaluation/issues/86). The difference from the Huygens MTF there is 0.019; from the FFT MTF, which is not scored there, 0.022. Zemax's own FFT and Huygens MTFs differ from each other by 0.003, 0.038 at 0 deg, 1 deg (largest of the two azimuths). Zemax's FFT and Huygens MTFs are of one wavelength: the numbers against the band are in the note of the one-wavelength row and in the section on Zemax against itself0.018770.005 / 0.02Partial
All 24 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-SF501e−06 / 0.0001Match
Rays at the image, ray by ray: positionThe rays that both programs trace and get through: 469 at 0, 469 at 11.52e−07 mm1e−06 / 0.001 mmMatch
Rays at the image, ray by ray: slopedx/dz and dy/dz4.65e−101e−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 % (469 of 469 rays through); at 1, RayCrafter 100.0 %, Zemax 100.0 to 100.0 % (469 of 469 rays through)0 % points0.5 / 2 % pointsMatch
Chief ray at the image, every field1.11e−16 mm1e−06 / 0.001 mmMatch
Focal length and f-numberCompares Zemax's image-space F/# with RayCrafter's f-number, which is the focal length over the diameter of the beam that gets through; for an unclipped beam that is the same quantity, so the two agree to rounding (they differ only where a rim clips the beam, as on clipped_negative_lens, where it is recorded, not scored)2.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 sagittal2.91e−07 mm1e−06 / 0.001 mmMatch
RMS spot against focus, every fieldWhere the two ranges overlap0.4418 % of the largest0.1 / 2 % of the largestPartial
RMS spot against fieldFrom the axis to the largest field, 21 angles0 %0.1 / 2 %Match
RMS wavefront against fieldPiston and tilt removed; at the largest field, Zemax 1.155 and RayCrafter 1.154 waves. Zemax gives one RMS wavefront number per field (its RMS Wavefront operand), so there is no Zemax spread to show for this row: it compares that one number with RayCrafter's0.002052 waves0.001 / 0.01 waves, or 1 % of Zemax's if larger, to failPartial
Strehl ratio, every fieldRayCrafter's Strehl ratio on the pixel grid of Zemax's Huygens PSF, as Zemax reads its own (its largest pixel); Zemax's prints three decimals.0.0013770.005 / 0.02Match
MTF (one wavelength), every fieldAt RayCrafter's own frequencies. Against Zemax's Huygens MTF, not its FFT MTF, at 1 deg: the FFT MTF takes the pupil index as linear in the direction cosine, and Zemax's own rays at the image depart from that by 0.011 (more than 0.005; a plane fit of L and M on px, py, over half their range), while the Huygens MTF follows the rays' own directions. It is not exact either: it gives every ray of its pupil grid the same amplitude, so where the density of rays in direction cosine varies across the pupil it weights the pupil by that density, where conservation of energy gives its square root (evaluation #86, https://github.com/raycrafter-optical-design/evaluation/issues/86). The difference from the Huygens MTF there is 0.019; from the FFT MTF, which is not scored there, 0.022. Zemax's own FFT and Huygens MTFs differ from each other by 0.003, 0.038 at 0 deg, 1 deg (largest of the two azimuths). Zemax's own FFT and Huygens MTFs differ by more than the fail limit (0.02) at 1 deg, so matching Zemax is a band, not a line (zemax-spread). 1 deg: at 41 cycles/mm, where Zemax's two MTFs differ most (tangential), Zemax FFT 0.439, Zemax Huygens 0.477 (they differ by 0.038, 1.9 times the fail limit), RayCrafter 0.460: inside the band, 0.017 from the nearer Zemax value; over all frequencies RayCrafter is at most 0.009 outside the band0.018770.005 / 0.02Partial
MTF (one wavelength), cutoff frequency, every fieldOf the fields where Zemax's table reaches beyond the cutoff. Cycles/mm, RayCrafter then Zemax: 2056 and 2040; 2056 and 20410.7555 %2 / 5 %Match
MTF (all wavelengths), every fieldAt RayCrafter's own frequencies. Against Zemax's Huygens MTF, not its FFT MTF, at 1 deg: the FFT MTF takes the pupil index as linear in the direction cosine, and Zemax's own rays at the image depart from that by 0.011 (more than 0.005; a plane fit of L and M on px, py, over half their range), while the Huygens MTF follows the rays' own directions. It is not exact either: it gives every ray of its pupil grid the same amplitude, so where the density of rays in direction cosine varies across the pupil it weights the pupil by that density, where conservation of energy gives its square root (evaluation #86, https://github.com/raycrafter-optical-design/evaluation/issues/86). The difference from the Huygens MTF there is 0.019; from the FFT MTF, which is not scored there, 0.022. Zemax's own FFT and Huygens MTFs differ from each other by 0.003, 0.038 at 0 deg, 1 deg (largest of the two azimuths). Zemax's FFT and Huygens MTFs are of one wavelength: the numbers against the band are in the note of the one-wavelength row and in the section on Zemax against itself0.018770.005 / 0.02Partial
MTF (all wavelengths), cutoff frequency, every fieldOf the fields where Zemax's table reaches beyond the cutoff. Cycles/mm, RayCrafter then Zemax: 2056 and 2040; 2056 and 20410.7555 %2 / 5 %Match
Grid distortion, largestZemax 0.0039 %2.75e−07 percentage points0.005 / 0.05 percentage pointsMatch
Distortion, f-tanAt the largest field: Zemax -0.0039 %, RayCrafter -0.0039 %3.97e−11 percentage points0.005 / 0.05 percentage pointsMatch
Distortion, f-thetaAt the largest field: Zemax 0.006255 %, RayCrafter 0.006255 %6.2e−11 percentage points0.005 / 0.05 percentage pointsMatch
Field curvature, change from the axisAt 0, 1°, the angles RayCrafter plots6.81e−05 mm0.01 / 0.1 mmMatch
Field curvatureRayCrafter takes the best focus of a whole fan, Zemax that of rays near the chief ray, so they differ with spherical aberration6.81e−05 mm0.01 / 0.1 mmMatch

Zemax against itself

Where Zemax's own two methods disagree by more than the fail limit, a single Zemax number is not what RayCrafter should match. Both Zemax numbers are shown here and in the plots, with RayCrafter's. No tolerance or verdict is changed by this section. RMS wavefront against field has one Zemax number only, so there is nothing to spread for it.

MTF: FFT against Huygens

Zemax computes the MTF two ways. The values are at the spatial frequency where its two curves differ most (the worse azimuth). RayCrafter is inside the band when it lies between the two Zemax values, beside it when it is outside by up to the fail limit (0.02), and outside it beyond that; the last column is the largest such distance over all frequencies. The band is shaded in the plots.

FieldAt (cycles/mm)Zemax FFT MTFZemax Huygens MTFZemax's own differenceRayCrafter MTFRayCrafter against the band thereLargest distance outside the band, all frequencies
0 deg140.9910.9940.0030.991beside the band: 0.000 outside it, which is within the fail limit of 0.020.001
1 deg410.4390.4770.0380.460inside the band, 0.017 from the nearer Zemax value0.009
MTF at 1 deg: Zemax FFT, Zemax Huygens, the band between them, and RayCrafter.
MTF at 1 deg: Zemax FFT, Zemax Huygens, the band between them, and RayCrafter.

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 (12 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).

RMS spot radius against field angle.
RMS spot radius against field angle.
Strehl ratio and RMS wavefront against field angle.
Strehl ratio and RMS wavefront against field angle.
Distortion, f-tan and f-theta.
Distortion, f-tan and f-theta.
Field curvature, tangential and sagittal.
Field curvature, tangential and sagittal.
MTF (one wavelength) at 0°.
MTF (one wavelength) at 0°.
MTF (one wavelength) at 1°.
MTF (one wavelength) at 1°.
MTF (all wavelengths) at 0°.
MTF (all wavelengths) at 0°.
MTF (all wavelengths) at 1°.
MTF (all wavelengths) at 1°.

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 mm3030
f number0.83330.8333
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°001001000.00044280.00044280.8950.89632.623e-141.196e-15
1°0.52380.52381001000.0070340.0070340.0330.031621.518e-074.649e-10

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)
1Even Asphere (stop)20.18099920.18099920N-SF5 SCHOTT, n = 1.67270322.5
2Standard∞∞18.05308322.5

How Zemax was run

By make_zemax_reference.py, the same way for every design, on 2026-12-04 07:31, on asphere_Edmund67248.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 asphere_Edmund67248
uv run python -m evaluation_tools.from_raycrafter.compare_zemax asphere_Edmund67248
uv run python -m evaluation_tools.build_summary

24 quantities compared.