RayCrafter (dev) vs Zemax
Ideal lens at F/0.6 behind an aberrated singlet: RayCrafter (dev) against Zemax
An ideal (paraxial) lens behind an aberrated singlet, to see which of Zemax's two Paraxial OPD modes RayCrafter's path across the lens matches (raycrafter #217). It matches mode 1, the one the export writes, and not mode 0: Zemax's own two modes differ by 30.0, 29.3 and 27.6 waves rms at 0, 5 and 10 deg, and RayCrafter differs from mode 0 by 30.0, 29.4 and 27.8. Since the fit of the arriving slopes was converged (raycrafter #233), the per-ray phase differs from mode 1 by 0.00007, 0.029 and 0.243 waves rms (of Zemax's 57.6, 52.1 and 41.7; it was 0.56, 0.57 and 0.68), the tangential fan to 0.0001 to 0.0003 waves (Match). The sagittal fan (0.020, 0.173 at 5 and 10 deg) and all rays still fail off axis: an x^2 y term in the pupil, growing as the field cubed, that is not the fit (degrees 12 and 16 agree) but the path along which the phase of the lens is integrated; none of about ten simple paths reproduces Zemax's. The RMS wavefront against field is Partial (0.0125 waves at 10 deg).
- Per-ray OPD against Zemax's mode 1 (as exported), sagittal fan (py = 0), every field: differs by 0.1729 waves
- Per-ray OPD against Zemax's mode 1 (as exported), all rays, every field: differs by 0.2426 waves
Mode: RayCrafter's per-ray phase is that of Zemax's mode 1 (it integrates the actual phase the surface adds), not mode 0 (the parabasal ray's sphere); reported on raycrafter #217.
Fit: RayCrafter now fits the slopes with the lowest polynomial degree that follows them (up to 16, raycrafter #233). Limiting it to degree 4 (a diagnostic, the old fixed degree) leaves 0.56 waves on the axis; degree 10 leaves 0.0007, 12 leaves 0.0001, the 16 allowed 0.00007. On the tangential fan, which is path-independent, the difference is the fit alone and falls with the degree: 0.0006, 0.0001 and 0.00006 on the axis, 0.0026, 0.0005 and 0.0003 at 10 deg (limits 10, 12, 16), so the tangential-fan limit is lambda/1000 (it was 1e-4, set before the converged fit; the row was Partial at 0.0003).
What is left off axis is the path, not the fit: 0.029 and 0.243 waves rms over all rays at 5 and 10 deg whatever the degree of the fit. The Zemax run that records the rays at the Paraxial surface (intercepts, directions, optical path to and through it) has been made: rays_at_paraxial_surface_3.csv, 4921 rays at each of the 3 fields, in both as_exported and as_exported_paraxial_opd_mode_0, no error codes. It is data for raycrafter #233, where RayCrafter's integrated phase is to be compared with the phase Zemax adds ray by ray; nothing is scored from it on this page, and the verdicts of this design are unchanged by the new run.
RayCrafter's phase at a ray no longer depends on the other rays traced with it beyond the fit's tolerance (1e-7 mm of phase); a sagittal fan on its own is still not defined (a single line of rays does not fix a two-dimensional fit), so the fan's rays are traced with the full set here.
The design
An ideal (paraxial) lens of f = 12.5 mm, 25 mm wide, 3.2 mm behind a Thorlabs LB1811-B bi-convex singlet (f = 35 mm, N-BK7), with a 20 mm collimated beam at 555 nm and fields 0, 5 and 10 degrees. The singlet's spherical aberration reaches the ideal lens as a wavefront of 18 waves rms; the system is F/0.52.

What is tested
The path RayCrafter adds across an ideal lens when the light arriving at it is aberrated, against Zemax's Paraxial surface in OPD mode 1 (what the export writes) and mode 0, on the per-ray OPD, a sagittal-only fan, the wavefront map and the RMS wavefront against field (raycrafter #217).
Issue: raycrafter #217.
RayCrafter against Zemax
RayCrafter at commit 5ecb2efd of
dev, not the release on PyPI. The .zmx was exported at
891febba.
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°, 5°, 10°).
Not matching: partial and fail rows.
| Quantity | Largest difference from Zemax | Match / partial within | Result |
|---|---|---|---|
| RMS wavefront against fieldPiston and tilt removed; at the largest field, Zemax 15.99 and RayCrafter 15.98 waves. The design has an ideal (paraxial) lens, whose optical path each program works out in its own way. The difference is over 0.01 waves but within 1 % of Zemax's value, so it is not a fail | 0.01253 waves | 0.001 / 0.01 waves, or 1 % of Zemax's if larger, to fail | Partial |
| Per-ray OPD against Zemax's mode 1 (as exported), sagittal fan (py = 0), every fieldRayCrafter's phase at Zemax's own pupil points (its phase is minus Zemax's opd, both about the chief ray), the root-mean-square difference over the rays that get through in waves, at each field in turn. Zemax's OPD over all rays is 57.6, 52.1, 41.7 waves rms. Here, with the slope polynomial RayCrafter chooses (the lowest degree that follows the slopes, up to 16): 4.855e-05, 0.01984, 0.1729. The fit's share: with the polynomial limited to degree 4 instead of 16 (a diagnostic, not what RayCrafter does), all rays 0.5558, 0.569, 0.6587 and the tangential fan 0.5041, 0.5144, 0.5894; with the polynomial limited to degree 10 instead of 16 (a diagnostic, not what RayCrafter does), all rays 0.0007404, 0.02859, 0.2421 and the tangential fan 0.0006356, 0.0009461, 0.002604; with the polynomial limited to degree 12 instead of 16 (a diagnostic, not what RayCrafter does), all rays 0.0001223, 0.02858, 0.2427 and the tangential fan 0.0001037, 0.0001721, 0.0005411 | 0.1729 waves | 0.005 / 0.02 waves | Fail |
| Per-ray OPD against Zemax's mode 1 (as exported), all rays, every fieldRayCrafter's phase at Zemax's own pupil points (its phase is minus Zemax's opd, both about the chief ray), the root-mean-square difference over the rays that get through in waves, at each field in turn. Zemax's OPD over all rays is 57.6, 52.1, 41.7 waves rms. Here, with the slope polynomial RayCrafter chooses (the lowest degree that follows the slopes, up to 16): 7.054e-05, 0.02858, 0.2426. The fit's share: with the polynomial limited to degree 4 instead of 16 (a diagnostic, not what RayCrafter does), all rays 0.5558, 0.569, 0.6587 and the tangential fan 0.5041, 0.5144, 0.5894; with the polynomial limited to degree 10 instead of 16 (a diagnostic, not what RayCrafter does), all rays 0.0007404, 0.02859, 0.2421 and the tangential fan 0.0006356, 0.0009461, 0.002604; with the polynomial limited to degree 12 instead of 16 (a diagnostic, not what RayCrafter does), all rays 0.0001223, 0.02858, 0.2427 and the tangential fan 0.0001037, 0.0001721, 0.0005411 | 0.2426 waves | 0.005 / 0.02 waves | Fail |
All 22 rows, matches included
| Quantity | Largest difference from Zemax | Match / partial within | Result |
|---|---|---|---|
| Zemax reads the aperture, fields, wavelength and afocal setting that were meant | 0 warnings | 0 / 0 warnings | Match |
| Surfaces: thicknesses, gaps and semi-diametersThe project file against the lens data Zemax holds | 0 mm | 1e−09 / 1e−06 mm | Match |
| Surfaces: curvatures and conicsCurvature in 1/mm | 0 | 1e−12 / 1e−09 | Match |
| Refractive index of each glassN-BK7 | 0 | 1e−06 / 0.0001 | Match |
| Rays at the image, ray by ray: positionThe rays that both programs trace and get through: 4921 at 0, 4921 at 5, 4921 at 10 | 8.58e−15 mm | 1e−06 / 0.001 mm | Match |
| Rays at the image, ray by ray: slopedx/dz and dy/dz. The design has ideal (paraxial) lenses, which each program bends rays through in its own way | 1.6e−15 | 1e−08 / 1e−05 | Match |
| 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 % (4921 of 4921 rays through); at 5, RayCrafter 100.0 %, Zemax 100.0 to 100.0 % (4921 of 4921 rays through); at 10, RayCrafter 100.0 %, Zemax 100.0 to 100.0 % (4921 of 4921 rays through) | 0 % points | 0.5 / 2 % points | Match |
| Chief ray at the image, every field | 4.44e−16 mm | 1e−06 / 0.001 mm | Match |
| 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 diagram | 0 % | 0.1 / 2 % | Match |
| Ray fans, tangential and sagittal | 4.88e−15 mm | 1e−06 / 0.001 mm | Match |
| RMS spot against focus, every fieldWhere the two ranges overlap | 0.0068 % of the largest | 0.1 / 2 % of the largest | Match |
| RMS spot against fieldFrom the axis to the largest field, 21 angles | 0 % | 0.1 / 2 % | Match |
| RMS wavefront against fieldPiston and tilt removed; at the largest field, Zemax 15.99 and RayCrafter 15.98 waves. The design has an ideal (paraxial) lens, whose optical path each program works out in its own way. The difference is over 0.01 waves but within 1 % of Zemax's value, so it is not a fail | 0.01253 waves | 0.001 / 0.01 waves, or 1 % of Zemax's if larger, to fail | Partial |
| Per-ray OPD against Zemax's mode 1 (as exported), tangential fan (px = 0), every fieldRayCrafter's phase at Zemax's own pupil points (its phase is minus Zemax's opd, both about the chief ray), the root-mean-square difference over the rays that get through in waves, at each field in turn. Zemax's OPD over all rays is 57.6, 52.1, 41.7 waves rms. Here, with the slope polynomial RayCrafter chooses (the lowest degree that follows the slopes, up to 16): 5.985e-05, 0.0001022, 0.0002791. The fit's share: with the polynomial limited to degree 4 instead of 16 (a diagnostic, not what RayCrafter does), all rays 0.5558, 0.569, 0.6587 and the tangential fan 0.5041, 0.5144, 0.5894; with the polynomial limited to degree 10 instead of 16 (a diagnostic, not what RayCrafter does), all rays 0.0007404, 0.02859, 0.2421 and the tangential fan 0.0006356, 0.0009461, 0.002604; with the polynomial limited to degree 12 instead of 16 (a diagnostic, not what RayCrafter does), all rays 0.0001223, 0.02858, 0.2427 and the tangential fan 0.0001037, 0.0001721, 0.0005411 | 0.000279 waves | 0.001 / 0.02 waves | Match |
| Per-ray OPD against Zemax's mode 1 (as exported), sagittal fan (py = 0), every fieldRayCrafter's phase at Zemax's own pupil points (its phase is minus Zemax's opd, both about the chief ray), the root-mean-square difference over the rays that get through in waves, at each field in turn. Zemax's OPD over all rays is 57.6, 52.1, 41.7 waves rms. Here, with the slope polynomial RayCrafter chooses (the lowest degree that follows the slopes, up to 16): 4.855e-05, 0.01984, 0.1729. The fit's share: with the polynomial limited to degree 4 instead of 16 (a diagnostic, not what RayCrafter does), all rays 0.5558, 0.569, 0.6587 and the tangential fan 0.5041, 0.5144, 0.5894; with the polynomial limited to degree 10 instead of 16 (a diagnostic, not what RayCrafter does), all rays 0.0007404, 0.02859, 0.2421 and the tangential fan 0.0006356, 0.0009461, 0.002604; with the polynomial limited to degree 12 instead of 16 (a diagnostic, not what RayCrafter does), all rays 0.0001223, 0.02858, 0.2427 and the tangential fan 0.0001037, 0.0001721, 0.0005411 | 0.1729 waves | 0.005 / 0.02 waves | Fail |
| Per-ray OPD against Zemax's mode 1 (as exported), all rays, every fieldRayCrafter's phase at Zemax's own pupil points (its phase is minus Zemax's opd, both about the chief ray), the root-mean-square difference over the rays that get through in waves, at each field in turn. Zemax's OPD over all rays is 57.6, 52.1, 41.7 waves rms. Here, with the slope polynomial RayCrafter chooses (the lowest degree that follows the slopes, up to 16): 7.054e-05, 0.02858, 0.2426. The fit's share: with the polynomial limited to degree 4 instead of 16 (a diagnostic, not what RayCrafter does), all rays 0.5558, 0.569, 0.6587 and the tangential fan 0.5041, 0.5144, 0.5894; with the polynomial limited to degree 10 instead of 16 (a diagnostic, not what RayCrafter does), all rays 0.0007404, 0.02859, 0.2421 and the tangential fan 0.0006356, 0.0009461, 0.002604; with the polynomial limited to degree 12 instead of 16 (a diagnostic, not what RayCrafter does), all rays 0.0001223, 0.02858, 0.2427 and the tangential fan 0.0001037, 0.0001721, 0.0005411 | 0.2426 waves | 0.005 / 0.02 waves | Fail |
| Grid distortion, largestZemax 0.3599 % | 1.39e−06 percentage points | 0.005 / 0.05 percentage points | Match |
| Distortion, f-tanAt the largest field: Zemax -0.3599 %, RayCrafter -0.3599 % | 3.61e−09 percentage points | 0.005 / 0.05 percentage points | Match |
| Distortion, f-thetaAt the largest field: Zemax 0.6643 %, RayCrafter 0.6643 % | 6.59e−09 percentage points | 0.005 / 0.05 percentage points | Match |
| Field curvature, change from the axisAt 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10°, the angles RayCrafter plots | 0.000221 mm | 0.01 / 0.1 mm | Match |
| Field curvatureRayCrafter takes the best focus of a whole fan, Zemax that of rays near the chief ray, so they differ with spherical aberration | 0.000221 mm | 0.01 / 0.1 mm | Match |
Strehl ratio: RayCrafter gives none for 3 of 3: “The aberrations are too large for a diffraction calculation: far below the diffraction limit. The spot diagram is the better guide”
MTF (one wavelength): RayCrafter gives none for 2 of 3: “The aberrations at 555 nm are too large for a diffraction MTF: see the spot diagram” Zemax says its sampling is too low at this field
MTF (all wavelengths): RayCrafter gives none for 2 of 3: “The aberrations at 555 nm are too large for a diffraction MTF: see the spot diagram” Zemax says its sampling is too low at this field
Per-ray OPD against Zemax's mode 0 (reported, no verdict): All rays, rms difference in waves at each field: 30, 29.4, 27.8. Zemax's own two modes differ from each other by 30, 29.3, 27.6 waves rms, so RayCrafter's path is that of mode 1 and not of mode 0, to the number the mode 1 rows give. Reported on raycrafter #217 (https://github.com/raycrafter-optical-design/raycrafter/issues/217).
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 (40 rings).


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




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 order | Zemax | RayCrafter |
|---|---|---|
| effective focal length mm | 10.41 | 10.41 |
| f number | 0.5206 | 0.5206 |
| Field | Chief ray, Zemax (mm) | Chief ray, RayCrafter (mm) | Share through, Zemax (%) | Share through, RayCrafter (%) | RMS spot, Zemax (mm) | RMS spot, RayCrafter (mm) | Strehl, Zemax | Strehl, RayCrafter | Worst ray position difference (mm) | Worst ray slope difference |
|---|---|---|---|---|---|---|---|---|---|---|
| 0° | 0 | 0 | 100 | 100 | 0.08113 | 0.08113 | 0.002 | none | 5.403e-15 | 1.341e-15 |
| 5° | 0.9013 | 0.9013 | 100 | 100 | 0.09456 | 0.09456 | 0 | none | 7.109e-15 | 1.596e-15 |
| 10° | 1.812 | 1.812 | 100 | 100 | 0.152 | 0.152 | 0 | none | 8.577e-15 | 1.51e-15 |
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 # | Type | Radius, RayCrafter (mm) | Radius, Zemax (mm) | Thickness (mm) | Glass | Semi-diameter (mm) |
|---|---|---|---|---|---|---|
| 1 | Standard (stop) | 34.86 | 34.86 | 6.79 | N-BK7 SCHOTT, n = 1.518274 | 12.7 |
| 2 | Standard | -34.86 | -34.86 | 3.21 | 12.7 | |
| 3 | Paraxial | ∞ | ∞ | 8.457756 | 12.5 |
How Zemax was run
By make_zemax_reference.py, the same way for every design, on
2026-12-04 07:36, on ideal_lens_behind_aberrated_singlet.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 ideal_lens_behind_aberrated_singlet uv run python -m evaluation_tools.from_raycrafter.compare_zemax ideal_lens_behind_aberrated_singlet uv run python -m evaluation_tools.build_summary
22 quantities compared.