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

RayCrafter dev 5ecb2efd Zemax 24.1.3 λ 0.555 µm Zemax run 2026-12-04 07:36
Not working on this page

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.

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

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

This is RayCrafter's development branch

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

19matching
1partial
2failing

Not matching: partial and fail rows.

QuantityLargest difference from ZemaxMatch / partial withinResult
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 fail0.01253 waves0.001 / 0.01 waves, or 1 % of Zemax's if larger, to failPartial
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.00054110.1729 waves0.005 / 0.02 wavesFail
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.00054110.2426 waves0.005 / 0.02 wavesFail
All 22 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-BK701e−06 / 0.0001Match
Rays at the image, ray by ray: positionThe rays that both programs trace and get through: 4921 at 0, 4921 at 5, 4921 at 108.58e−15 mm1e−06 / 0.001 mmMatch
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 way1.6e−151e−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 % (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 % points0.5 / 2 % pointsMatch
Chief ray at the image, every field4.44e−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 sagittal4.88e−15 mm1e−06 / 0.001 mmMatch
RMS spot against focus, every fieldWhere the two ranges overlap0.0068 % of the largest0.1 / 2 % of the largestMatch
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 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 fail0.01253 waves0.001 / 0.01 waves, or 1 % of Zemax's if larger, to failPartial
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.00054110.000279 waves0.001 / 0.02 wavesMatch
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.00054110.1729 waves0.005 / 0.02 wavesFail
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.00054110.2426 waves0.005 / 0.02 wavesFail
Grid distortion, largestZemax 0.3599 %1.39e−06 percentage points0.005 / 0.05 percentage pointsMatch
Distortion, f-tanAt the largest field: Zemax -0.3599 %, RayCrafter -0.3599 %3.61e−09 percentage points0.005 / 0.05 percentage pointsMatch
Distortion, f-thetaAt the largest field: Zemax 0.6643 %, RayCrafter 0.6643 %6.59e−09 percentage points0.005 / 0.05 percentage pointsMatch
Field curvature, change from the axisAt 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10°, the angles RayCrafter plots0.000221 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 aberration0.000221 mm0.01 / 0.1 mmMatch
Not compared

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

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.

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 mm10.4110.41
f number0.52060.5206
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.081130.081130.002none5.403e-151.341e-15
5°0.90130.90131001000.094560.094560none7.109e-151.596e-15
10°1.8121.8121001000.1520.1520none8.577e-151.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 #TypeRadius, RayCrafter (mm)Radius, Zemax (mm)Thickness (mm)GlassSemi-diameter (mm)
1Standard (stop)34.8634.866.79N-BK7 SCHOTT, n = 1.51827412.7
2Standard-34.86-34.863.2112.7
3Paraxial∞∞8.45775612.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.