RayCrafter (dev) vs Zemax
4f scan system (RayCrafter's example): RayCrafter (dev) against Zemax
RayCrafter's own 4f scan system example, exported by RayCrafter and traced by Zemax. Distortion, the question of raycrafter #124, agrees: -0.2416 % (f-tan and grid) at 5 degrees in both, measured on the leaving angles. So do f-theta distortion (0.0124 % in both, since raycrafter #211), the rays, the angular magnification and the wavefront. Every row matches.
The design
RayCrafter's Help > Examples > 4f scan system: a scanner, a Plossl scan lens of two AC254-100-A and an ACT508-250-A tube lens turned round, with a 4 mm beam at 555 nm and fields 0, 2.5 and 5 degrees. The light leaves collimated.

What is tested
Grid distortion of a system whose output is collimated (raycrafter #124): RayCrafter measures it on the leaving angles and ticks Afocal Image Space, so Zemax should give the same, not the 558 % RayCrafter once gave on the image plane.
Issue: raycrafter #124, raycrafter #211.
RayCrafter against Zemax
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°, 2.5°, 5°).
Every row matches Zemax.
All 18 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, N-SF2, SF5 | 0 | 1e−06 / 0.0001 | Match |
| Rays at the image, ray by ray: positionThe rays that both programs trace and get through: 331 at 0, 331 at 2.5, 331 at 5 | 7.14e−14 mm | 1e−06 / 0.001 mm | Match |
| Rays at the image, ray by ray: slopedx/dz and dy/dz | 2.62e−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 % (331 of 331 rays through); at 2.5, RayCrafter 100.0 %, Zemax 100.0 to 100.0 % (331 of 331 rays through); at 5, RayCrafter 100.0 %, Zemax 100.0 to 100.0 % (331 of 331 rays through) | 0 % points | 0.5 / 2 % points | Match |
| Chief ray at the image, every field | 1.6e−14 mm | 1e−06 / 0.001 mm | Match |
| Angular magnification (size)Zemax's from its paraxial pupils, RayCrafter's from real rays; RayCrafter's sign says whether the image is inverted | 1.03e−06 % | 0.0001 / 0.1 % | Match |
| Divergence of the leaving light, every fieldRayCrafter: RMS angle to the mean direction. Zemax: its RMS spot radius, which is an angle when the image space is afocal | 0.009008 % | 0.1 / 2 % | Match |
| RMS wavefront against fieldPiston and tilt removed; at the largest field, Zemax 0.05198 and RayCrafter 0.05133 waves | 0.000646 waves | 0.001 / 0.01 waves, or 1 % of Zemax's if larger, to fail | Match |
| 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.003293 | 0.005 / 0.02 | Match |
| Footprint at surface 8 (tube lens, front): ray X and Y limitsZemax's numbers are the Footprint Diagram's printed numbers. RayCrafter against Zemax, mm: x min -9.4877 against -9.4877, x max 9.4877 against 9.4877, y min -9.4877 against -9.4877, y max 13.8322 against 13.8322 | 3.15e−05 % of the largest radius | 0.01 / 0.15 % of the largest radius | Match |
| Footprint at surface 8 (tube lens, front): largest radiusRayCrafter 13.8322 mm, Zemax 13.8322 mm (the Footprint Diagram's printed numbers) | 3.15e−05 % of the largest radius | 0.01 / 0.15 % of the largest radius | Match |
| Footprint at surface 8 (tube lens, front): rim rays, one by oneThe same pupil points round the rim of each field's pupil in both programs; 363 rays paired | 7.77e−14 mm | 1e−06 / 0.001 mm | Match |
| Grid distortion, largestZemax 0.2416 %, on the leaving angles | 2.31e−07 percentage points | 0.005 / 0.05 percentage points | Match |
| Distortion, f-tanAt the largest field: Zemax -0.2416 %, RayCrafter -0.2416 % | 2.42e−09 percentage points | 0.005 / 0.05 percentage points | Match |
| Distortion, f-thetaAt the largest field: Zemax 0.01238 %, RayCrafter 0.01238 %. For collimated output the two define f-theta differently: Zemax as tan(leaving angle) / (m x entering angle) - 1, RayCrafter as leaving angle / (m x entering angle) - 1. Zemax's own rays give both numbers (raycrafter #211) | 1.17e−10 percentage points | 0.005 / 0.05 percentage points | Match |
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 (10 rings). With Afocal Image Space ticked Zemax's trace ends on the exit pupil, so its rays are carried on to the image plane.


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


Footprint diagram
Where each field's beam crosses a surface of the design (Zemax's Footprint Diagram, RayCrafter's Bench.footprint_diagram): the rays round the rim of each field's pupil, open red circles for Zemax and filled blue diamonds for RayCrafter, with the surface's clear aperture in black.

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 |
|---|---|---|
| angular magnification | 0.2037 | -0.2037 |
| 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 | none | none | 0.998 | 0.9984 | 1.685e-14 | 9.062e-17 |
| 2.5° | -0.02135 | -0.02135 | 100 | 100 | none | none | 0.989 | 0.9923 | 3.026e-14 | 2.255e-16 |
| 5° | -0.1172 | -0.1172 | 100 | 100 | none | none | 0.898 | 0.9007 | 7.142e-14 | 2.623e-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) |
|---|---|---|---|---|---|---|
| 2 | Standard | 128.23 | 128.23 | 2.5 | SF5 SCHOTT, n = 1.676472 | 12.7 |
| 3 | Standard | 45.71 | 45.71 | 4 | N-BK7 SCHOTT, n = 1.518274 | 12.7 |
| 4 | Standard | -62.75 | -62.75 | 1 | 12.7 | |
| 5 | Standard | 62.75 | 62.75 | 4 | N-BK7 SCHOTT, n = 1.518274 | 12.7 |
| 6 | Standard | -45.71 | -45.71 | 2.5 | SF5 SCHOTT, n = 1.676472 | 12.7 |
| 7 | Standard | -128.23 | -128.23 | 287.49298 | 12.7 | |
| 8 | Standard | 538.0773 | 538.0773 | 6 | N-SF2 SCHOTT, n = 1.651147 | 25.4 |
| 9 | Standard | 115.980066 | 115.980066 | 9.3 | N-BK7 SCHOTT, n = 1.518274 | 25.4 |
| 10 | Standard | -131.197968 | -131.197968 | 249.74527 | 25.4 |
How Zemax was run
By make_zemax_reference.py, the same way for every design, on
2026-12-04 12:46, on 4f_scan_system.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 4f_scan_system uv run python -m evaluation_tools.from_raycrafter.compare_zemax 4f_scan_system uv run python -m evaluation_tools.build_summary
18 quantities compared.