RayCrafter (dev) vs Zemax
Gaussian beam overfilling its edge: RayCrafter (dev) against Zemax
A Thorlabs LA1509 singlet (f = 100 mm) at 550 nm under a 14 mm beam cut from a Gaussian twice as wide (fill factor 2, written `GFAC 0.25 1`: it shows which number Zemax takes as the factor).
Zemax's own two methods (FFT and Huygens) disagree with each other by more than our fail limit. The rows below keep their verdicts, each against one Zemax number. Where RayCrafter lies inside the band between Zemax's two numbers it is no further from either than they are from each other; where it lies outside, it is further from both than Zemax's own methods are from each other. Each row's note and Zemax against itself give both Zemax numbers, their difference and RayCrafter's value.
- Strehl ratio. Zemax's Huygens PSF and the Strehl ratio of its own Wavefront Map differ by up to 0.0313 (1.56 times the fail limit of 0.02). RayCrafter's Strehl ratio is inside the band at 0 deg. Plot of every Zemax number.
- RMS wavefront. Zemax gives one number per field, so there is no Zemax spread to show for it.
The design
A Thorlabs LA1509 singlet (f = 100 mm) at 550 nm under a 14 mm beam cut from a Gaussian twice as wide (fill factor 2, written `GFAC 0.25 1`: it shows which number Zemax takes as the factor).

What is tested
RayCrafter writes a Gaussian beam profile as Zemax's Gaussian pupil apodization, `GFAC G 1` with G = 1 / F^2 for a fill factor F; the syntax is inferred, not copied from a Zemax file. Does Zemax read it so, and then give RayCrafter's Strehl and MTF?
Issue: raycrafter #140.
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°).
Not matching: partial and fail rows.
| Quantity | Largest difference from Zemax | Match / partial within | Result |
|---|---|---|---|
| RMS wavefront, every fieldZemax 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 | 0.003966 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. RayCrafter's PSF weights each ray by sqrt(J), J being how far its part of the pupil spreads over direction cosine, so that energy is conserved (raycrafter #236); Zemax's Huygens PSF gives every ray the same amplitude. With every ray at the same amplitude RayCrafter's Strehl ratio is 0.4811 at 0 deg (0.0041 from Zemax's 0.477, against 0.0054 as it is). The row scores RayCrafter as it is. Zemax's own Strehl numbers differ by more than the fail limit (0.02) at 0 deg. 0 deg: Zemax Huygens PSF 0.477, Zemax Wavefront Map 0.508 (they differ by 0.0313, more than the fail limit of 0.02), RayCrafter 0.482: inside the band, 0.005 from the nearer Zemax value | 0.005415 | 0.005 / 0.02 | Partial |
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 | 0 | 1e−06 / 0.0001 | Match |
| Rays at the image, ray by ray: positionThe rays that both programs trace and get through: 1261 at 0 | 8.14e−15 mm | 1e−06 / 0.001 mm | Match |
| Rays at the image, ray by ray: slopedx/dz and dy/dz | 1.04e−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 % (1261 of 1261 rays through) | 0 % points | 0.5 / 2 % points | Match |
| Chief ray at the image, every field | 0 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) | 4.44e−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 | 7.99e−15 mm | 1e−06 / 0.001 mm | Match |
| RMS spot against focus, every fieldWhere the two ranges overlap | 0.006296 % of the largest | 0.1 / 2 % of the largest | Match |
| RMS wavefront, every fieldZemax 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 | 0.003966 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. RayCrafter's PSF weights each ray by sqrt(J), J being how far its part of the pupil spreads over direction cosine, so that energy is conserved (raycrafter #236); Zemax's Huygens PSF gives every ray the same amplitude. With every ray at the same amplitude RayCrafter's Strehl ratio is 0.4811 at 0 deg (0.0041 from Zemax's 0.477, against 0.0054 as it is). The row scores RayCrafter as it is. Zemax's own Strehl numbers differ by more than the fail limit (0.02) at 0 deg. 0 deg: Zemax Huygens PSF 0.477, Zemax Wavefront Map 0.508 (they differ by 0.0313, more than the fail limit of 0.02), RayCrafter 0.482: inside the band, 0.005 from the nearer Zemax value | 0.005415 | 0.005 / 0.02 | Partial |
| MTF (one wavelength), every fieldAt RayCrafter's own frequencies. | 0.00227 | 0.005 / 0.02 | Match |
| MTF (one wavelength), cutoff frequency, every fieldOf the fields where Zemax's table reaches beyond the cutoff. Cycles/mm, RayCrafter then Zemax: 258 and 256 | 0.858 % | 2 / 5 % | Match |
| MTF (all wavelengths), every fieldAt RayCrafter's own frequencies. | 0.00227 | 0.005 / 0.02 | Match |
| MTF (all wavelengths), cutoff frequency, every fieldOf the fields where Zemax's table reaches beyond the cutoff. Cycles/mm, RayCrafter then Zemax: 258 and 256 | 0.858 % | 2 / 5 % | Match |
Zemax against itself
Where Zemax's own two methods disagree by more than the fail limit, a single Zemax number is not what RayCrafter should match. Both Zemax numbers are shown here and in the plots, with RayCrafter's. No tolerance or verdict is changed by this section. RMS wavefront against field has one Zemax number only, so there is nothing to spread for it.
Strehl ratio: Huygens PSF against Wavefront Map
Zemax's Huygens PSF prints one Strehl ratio, the Strehl ratio of its Wavefront Map is the peak of the diffraction image of that wavefront, and where Zemax ran an FFT PSF its peak is a third (a dash where it did not).
| Field | Zemax Huygens PSF | Zemax Wavefront Map | Zemax FFT PSF peak | Zemax's own spread | RayCrafter (Zemax's pixel grid) | RayCrafter against the band |
|---|---|---|---|---|---|---|
| 0 deg | 0.477 | 0.508 | – | 0.0313 | 0.482 | inside the band, 0.0054 from the nearer Zemax value |

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 (20 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 | 99.34 | 99.34 |
| f number | 7.096 | 7.096 |
| 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.006259 | 0.006259 | 0.477 | 0.4824 | 8.143e-15 | 1.036e-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 | 51.51 | 51.51 | 3.59 | N-BK7 SCHOTT, n = 1.518522 | 12.7 |
| 3 | Standard | ∞ | ∞ | 96.633125 | 12.7 |
How Zemax was run
By make_zemax_reference.py, the same way for every design, on
2026-12-03, on apodization_gaussian_overfilled.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 apodization_gaussian_overfilled uv run python -m evaluation_tools.from_raycrafter.compare_zemax apodization_gaussian_overfilled uv run python -m evaluation_tools.build_summary
18 quantities compared.