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.

RayCrafter dev 5ecb2efd Zemax 24.1.3 λ 0.555 µm Zemax run 2026-12-04 12:46

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.

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

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

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

18matching
0partial
0failing

Every row matches Zemax.

All 18 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-BK7, N-SF2, SF501e−06 / 0.0001Match
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 57.14e−14 mm1e−06 / 0.001 mmMatch
Rays at the image, ray by ray: slopedx/dz and dy/dz2.62e−161e−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 % (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 % points0.5 / 2 % pointsMatch
Chief ray at the image, every field1.6e−14 mm1e−06 / 0.001 mmMatch
Angular magnification (size)Zemax's from its paraxial pupils, RayCrafter's from real rays; RayCrafter's sign says whether the image is inverted1.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 afocal0.009008 %0.1 / 2 %Match
RMS wavefront against fieldPiston and tilt removed; at the largest field, Zemax 0.05198 and RayCrafter 0.05133 waves0.000646 waves0.001 / 0.01 waves, or 1 % of Zemax's if larger, to failMatch
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.0032930.005 / 0.02Match
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.83223.15e−05 % of the largest radius0.01 / 0.15 % of the largest radiusMatch
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 radius0.01 / 0.15 % of the largest radiusMatch
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 paired7.77e−14 mm1e−06 / 0.001 mmMatch
Grid distortion, largestZemax 0.2416 %, on the leaving angles2.31e−07 percentage points0.005 / 0.05 percentage pointsMatch
Distortion, f-tanAt the largest field: Zemax -0.2416 %, RayCrafter -0.2416 %2.42e−09 percentage points0.005 / 0.05 percentage pointsMatch
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 points0.005 / 0.05 percentage pointsMatch

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.

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

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.

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.

Footprint on surface 8 (tube lens, front): the rays round the rim of each field's pupil.
Footprint on surface 8 (tube lens, front): the rays round the rim of each field's pupil.

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
angular magnification0.2037-0.2037
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°00100100nonenone0.9980.99841.685e-149.062e-17
2.5°-0.02135-0.02135100100nonenone0.9890.99233.026e-142.255e-16
5°-0.1172-0.1172100100nonenone0.8980.90077.142e-142.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 #TypeRadius, RayCrafter (mm)Radius, Zemax (mm)Thickness (mm)GlassSemi-diameter (mm)
2Standard128.23128.232.5SF5 SCHOTT, n = 1.67647212.7
3Standard45.7145.714N-BK7 SCHOTT, n = 1.51827412.7
4Standard-62.75-62.75112.7
5Standard62.7562.754N-BK7 SCHOTT, n = 1.51827412.7
6Standard-45.71-45.712.5SF5 SCHOTT, n = 1.67647212.7
7Standard-128.23-128.23287.4929812.7
8Standard538.0773538.07736N-SF2 SCHOTT, n = 1.65114725.4
9Standard115.980066115.9800669.3N-BK7 SCHOTT, n = 1.51827425.4
10Standard-131.197968-131.197968249.7452725.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.