RayCrafter (dev) vs Zemax
A periscope whose second mirror clips the beam: RayCrafter (dev) against Zemax
Added to settle raycrafter #198: fold_clipping_mirror has one mirror, so Zemax reports its exit pupil at a positive position and its Huygens PSF sums over the reference sphere of the opposite sign, which cannot be compared. Here a second mirror, the round one of fold_periscope, makes the number of mirrors even, and the clipping mirror is the one of fold_clipping_mirror at the same distance from the first lens. Zemax's Huygens Strehl ratio of the 2 degree field is 0.240, with its exit pupil position at -39.06 mm, against RayCrafter's 0.237: a Match, and the prediction of raycrafter #198 held. Zemax's wavefront map (0.209) and FFT PSF (0.211), which take the pupil index as linear in the direction cosines, are as with one mirror, 0.03 below. So the 0.03 that fold_clipping_mirror leaves unscored is the difference between the Huygens integral (RayCrafter's sum, and Zemax's own Huygens PSF once its sphere has the right sign) and the linear-index model. Rays, spots and fans agree to 1e-13 mm; the MTF and the RMS wavefront of the clipped field are Partial, as for fold_clipping_mirror.
The design
Two Thorlabs AC254-100-A with a 4 mm beam at 555 nm, 0 and 2 degrees, and two mirrors forming a periscope: a round 50 mm one and then the elliptical mirror of fold_clipping_mirror, too small for the 2 degree beam, at the same distance from the first lens.


What is tested
Whether Zemax's Huygens PSF of a cut beam agrees with RayCrafter's once the mirror count is even, so that Zemax reports a negative exit pupil position and its Huygens sphere has the right sign (raycrafter #198, evaluation #84). Prediction: Huygens Strehl near 0.24, wavefront map and FFT PSF near 0.21. Also the export of a folded design: Zemax must trace the same rays.
Issue: raycrafter #159, raycrafter #198.
RayCrafter against Zemax
RayCrafter at commit 5ecb2efd of
dev, not the release on PyPI. The .zmx was exported at
a2f0adf6.
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°, 2°).
Not matching: partial and fail rows.
| Quantity | Largest difference from Zemax | Match / partial within | Result |
|---|---|---|---|
| RMS wavefront, fields with rays stopped, against Zemax's Wavefront MapAt fields 2, where Zemax's apertures stop rays, Zemax's Wavefront Map (piston and tilt removed) of the rays that get through: its RMS operand counts the stopped rays too (evaluation #72). Both numbers are fitted the same way: the evaluation takes a least-squares plane (piston and tilt) out of Zemax's Wavefront Map and out of RayCrafter's own wavefront map over the pupil, every point that got through alike (raycrafter #243, Rob's decision of 2026-12-04). RayCrafter's reported RMS wavefront and Zemax's RMS operand, which take the tilt out in direction cosines on a focused image, are a different convention (on the focused designs of #243 a plane in pupil coordinates was 1.5 to 8 % from Zemax's operand), so they are not what is compared here. RayCrafter's map is traced with 513 rays across the part of the pupil that gets light, where its RMS has converged (its window's 65 were 1.6 % low on US005899585 at 15.12 mm). Zemax's map is 64 x 64, and on a field whose rays are stopped where the wavefront is steep its RMS depends on where its grid falls: on US005899585 at 15.12 and 21.6 mm a 64 x 64 grid moved by under a step changes the RMS by 0.9 % (one standard deviation), so differences of that size can be Zemax's sampling. RayCrafter's own reported RMS wavefront, for information (waves): 2: 0.2081 (fitted 0.206) | 0.001046 waves | 0.001 / 0.01 waves, or 1 % of Zemax's if larger, to fail | Partial |
| MTF (one wavelength), every fieldAt RayCrafter's own frequencies. | 0.01565 | 0.005 / 0.02 | Partial |
| MTF (all wavelengths), every fieldAt RayCrafter's own frequencies. | 0.01565 | 0.005 / 0.02 | Partial |
All 27 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, SF5 | 0 | 1e−06 / 0.0001 | Match |
| Fold mirrors (2): distance along the light | 0 mm | 1e−09 / 1e−06 mm | Match |
| Fold mirrors: half widths of the outlineAgainst the apertures Zemax holds (Zemax_layouts/layouts.json) | 0 mm | 1e−09 / 1e−06 mm | Match |
| Rays at the image, ray by ray: positionThe rays that both programs trace and get through: 27937 at 0, 13274 at 2 | 1.17e−13 mm | 1e−06 / 0.001 mm | Match |
| Rays at the image, ray by ray: slopedx/dz and dy/dz | 6.96e−16 | 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 % (27937 of 27937 rays through); at 2, RayCrafter 47.5 %, Zemax 47.2 to 47.9 % (13274 of 27937 rays through) | 0 % points | 0.5 / 2 % points | Match |
| Chief ray at the image, every field | 6.75e−14 mm | 1e−06 / 0.001 mm | Match |
| Rays stopped by apertures and mirrorsOf the pupil points both trace, Zemax / RayCrafter stop: 14663 / 14663 of 27937. Counted are points stopped by one program and not the other | 0 % | 0 / 1 % | 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) | 4.44e−14 % | 0.0001 / 0.1 % | Match |
| RMS spot radius, fields with no ray stoppedZemax by Gaussian quadrature, RayCrafter from its spot diagram | 0 % | 0.1 / 2 % | Match |
| RMS spot radius, fields with rays stopped, against Zemax's own raysZemax's RMS operand counts the stopped rays too, so its rays that get through are used, and RayCrafter's rays are launched at the same pupil points. field 2: Zemax's rays 33.57, RayCrafter 33.57 (launched at Zemax's pupil points; 0 points through in one program only), RayCrafter's spot diagram 33.96, Zemax's operand 85.58, RayCrafter's own rays summed finely 33.57 um | 1.29e−11 % | 1 / 2 % | Match |
| Ray fans, tangential and sagittal | 1.05e−13 mm | 1e−06 / 0.001 mm | Match |
| RMS spot against focus, fields with no ray stoppedWhere the two ranges overlap | 0.02802 % of the largest | 0.1 / 2 % of the largest | Match |
| RMS wavefront, fields with rays stopped, against Zemax's Wavefront MapAt fields 2, where Zemax's apertures stop rays, Zemax's Wavefront Map (piston and tilt removed) of the rays that get through: its RMS operand counts the stopped rays too (evaluation #72). Both numbers are fitted the same way: the evaluation takes a least-squares plane (piston and tilt) out of Zemax's Wavefront Map and out of RayCrafter's own wavefront map over the pupil, every point that got through alike (raycrafter #243, Rob's decision of 2026-12-04). RayCrafter's reported RMS wavefront and Zemax's RMS operand, which take the tilt out in direction cosines on a focused image, are a different convention (on the focused designs of #243 a plane in pupil coordinates was 1.5 to 8 % from Zemax's operand), so they are not what is compared here. RayCrafter's map is traced with 513 rays across the part of the pupil that gets light, where its RMS has converged (its window's 65 were 1.6 % low on US005899585 at 15.12 mm). Zemax's map is 64 x 64, and on a field whose rays are stopped where the wavefront is steep its RMS depends on where its grid falls: on US005899585 at 15.12 and 21.6 mm a 64 x 64 grid moved by under a step changes the RMS by 0.9 % (one standard deviation), so differences of that size can be Zemax's sampling. RayCrafter's own reported RMS wavefront, for information (waves): 2: 0.2081 (fitted 0.206) | 0.001046 waves | 0.001 / 0.01 waves, or 1 % of Zemax's if larger, to fail | Partial |
| 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.003217 | 0.005 / 0.02 | Match |
| MTF (one wavelength), every fieldAt RayCrafter's own frequencies. | 0.01565 | 0.005 / 0.02 | Partial |
| MTF (one wavelength), cutoff frequency, every fieldOf the fields where Zemax's table reaches beyond the cutoff. Cycles/mm, RayCrafter then Zemax: 85 and 84; 85 and 85 | 0.831 % | 2 / 5 % | Match |
| MTF (all wavelengths), every fieldAt RayCrafter's own frequencies. | 0.01565 | 0.005 / 0.02 | Partial |
| MTF (all wavelengths), cutoff frequency, every fieldOf the fields where Zemax's table reaches beyond the cutoff. Cycles/mm, RayCrafter then Zemax: 85 and 84; 85 and 85 | 0.831 % | 2 / 5 % | Match |
| Grid distortion, largestZemax 4.316 % | 3.12e−05 percentage points | 0.005 / 0.05 percentage points | Match |
| Distortion, f-tanAt the largest field: Zemax 4.316 %, RayCrafter 4.316 % | 5.57e−08 percentage points | 0.005 / 0.05 percentage points | Match |
| Distortion, f-thetaAt the largest field: Zemax 4.358 %, RayCrafter 4.358 % | 5.61e−08 percentage points | 0.005 / 0.05 percentage points | Match |
| Field curvature, change from the axisAt 0, 1, 2°, the angles RayCrafter plots | 0.002344 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. Where rays are stopped, RayCrafter's fan loses them; Zemax's rays near the chief ray do not see apertures | 0.002344 mm | 0.01 / 0.1 mm | Match |
RMS spot against field: Some rays are stopped, and Zemax's RMS operands count them all the same, so there is no number of Zemax's to compare with
RMS wavefront against field: Some rays are stopped, and Zemax's RMS operands count them all the same, so there is no number of Zemax's to compare with. 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's
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 (96 rings).


RayCrafter's own plots
What RayCrafter's window and report draw, with Zemax's points over them (open markers).
Some rays are stopped. Zemax's RMS spot and RMS wavefront against field count them all the same, so those two plots do not compare like with like where they are.









The folded layout




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 | -85.1 | -85.1 |
| f number | 21.28 | 21.28 |
| 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 | 8.515e-15 | 100 | 100 | 0.001932 | 0.001932 | 0.991 | 0.9912 | 7.122e-14 | 6.523e-16 |
| 2° | -3.074 | -3.074 | 47.54 | 47.5 | 0.08558 | 0.03396 | 0.24 | 0.2368 | 1.172e-13 | 6.964e-16 |
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) | 62.75 | 62.75 | 4 | N-BK7 SCHOTT, n = 1.518274 | 12.7 |
| 2 | Standard | -45.71 | -45.71 | 2.5 | SF5 SCHOTT, n = 1.676472 | 12.7 |
| 3 | Standard | -128.23 | -128.23 | 313.5 | 12.7 | |
| 10 | Standard | 62.75 | 62.75 | 4 | N-BK7 SCHOTT, n = 1.518274 | 12.7 |
| 11 | Standard | -45.71 | -45.71 | 2.5 | SF5 SCHOTT, n = 1.676472 | 12.7 |
| 12 | Standard | -128.23 | -128.23 | 181.908048 | 12.7 |
How Zemax was run
By make_zemax_reference.py, the same way for every design, on
2026-12-04 07:35, on fold_periscope_clipping_mirror.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 fold_periscope_clipping_mirror uv run python -m evaluation_tools.from_raycrafter.compare_zemax fold_periscope_clipping_mirror uv run python -m evaluation_tools.build_summary
27 quantities compared.