Optiland and RayCrafter (dev) vs Zemax

Relay with custom spherical aberration: Optiland and RayCrafter (dev) against Zemax

Two groups of plano-convex lenses relaying a collimated 15 mm beam, to see how much spherical aberration they add. With the ignored surfaces taken out, Optiland traces every ray where Zemax does, to rounding error. Its default wavefront is 2.4 waves out here; its plane reference (afocal=True) matches Zemax but for the sign. RayCrafter (dev) agrees on the focal length and, since the pupil coordinates of an inverted stop are taken at the entrance pupil (raycrafter #212), on the ray fan (1e-8 mm; it was 14.98 mm apart, reversed), and its image is now where Zemax's is. With raycrafter #218 (a2f0adf) it gives the RMS wavefront of this nearly collimated output; its own wavefront map, fitted as Zemax's Wavefront Map is (piston and tilt over the pupil, raycrafter #243), gives 7.659 waves against 7.613 in Zemax's (0.6 %, Partial; within what Zemax's 64 x 64 grid itself moves an RMS by; the number RayCrafter reports, with the tilt taken out its own way, is 7.651), once the exit pupil of the pivoted beam is taken where Zemax has it (on the image plane); it gives no PSF or Strehl ratio, which Zemax did not make either (raycrafter #218).

optiland 0.6.3 RayCrafter dev 5ecb2efd λ 0.587562 µm Zemax OpticStudio 24.1.3 (file) EPD 15 mm fields 0° Zemax run 2026-12-02 Zemax 24.1.3 (our run)
Not working on this page

Every failing row of the tables below, against our own Zemax run.

What we know about them
  • Optiland: surfaces set to be ignored are traced. The file's two doublets are ignored in Zemax. Without our workaround Optiland traces them, with no warning, and the rays are wrong. Cause: Optiland's Zemax reader does not read the flag (issue 28). Upstream: not yet filed.
  • Optiland: the default wavefront with the exit pupil at the image. OPD and Zernike coefficients differ from Zemax's by up to 2.4 and 0.8 waves. Cause: not located; the reference sphere's radius is all but zero here (issue 30). Upstream: not yet filed.
  • Optiland: the sign of the afocal wavefront. With afocal=True the OPD and Zernikes are Zemax's with the opposite sign. Cause: not located (issue 29). Upstream: not yet filed.

System layout

Works

Drawn from Optiland's surface positions and rays, with the four surfaces Zemax ignores taken out.

Ray paths through the system
Light travels from left to right. The position of every surface is compared with Zemax in the first table.
Optiland spot diagrams
Optiland's spot diagrams at the file's own fields.

Optiland against Zemax

Optiland 0.6.3, as released, with the file preparation and patches listed under "Optiland issues found". Nothing here uses RayCrafter. Each row is the largest difference from our own Zemax run (OpticStudio 24.1.3) over every galvo angle or field of every system below.

12matching
0partial
5failing

Not matching: partial and fail rows.

QuantityLargest difference from ZemaxMatch / partial withinResult
OPD of every rayDefault reference sphere, exit pupil at the image (issue 30); see the afocal rows2.396 waves0.001 / 0.01 wavesFail
Zernike coefficients (37 standard)0.7958 waves0.001 / 0.01 wavesFail
RMS wavefront of every field, from Optiland's OPDPiston and tilt removed, as Zemax does. 8.35 against 7.66 waves (issue 30)0.6944 waves0.001 / 0.01 waves, or 1 % of Zemax's if larger, to failFail
Afocal: OPD of every ray, afocal=True as it comesThe sign is opposite to Zemax's (issue 29)53.07 waves0.001 / 0.01 wavesFail
Afocal: Zernike coefficients, afocal=True as it comesThe sign is opposite to Zemax's (issue 29)26.15 waves0.001 / 0.01 wavesFail
All 17 rows, matches included
QuantityLargest difference from ZemaxMatch / partial withinResult
Refractive index of each glassN-BK72.22e−161e−06 / 0.0001Match
Position of every surface5.68e−14 mm1e−09 / 1e−06 mmMatch
Rays at the image, ray by rayThe rays Zemax traced, every galvo angle or field7.16e−15 mm1e−06 / 0.001 mmMatch
Ray directions at the imageDirection cosines. Zemax's are reversed after an odd number of mirrors1.22e−151e−09 / 1e−06Match
Largest ray radius on every surface1.78e−14 mm1e−06 / 0.001 mmMatch
RMS spot of the same raysThe rays that get through, every one counted alike0 %0.1 / 2 %Match
Focal length, f-number, exit pupilSizes; Optiland's signs may differ after a mirror. Both put the exit pupil within 1 µm of the image5.95e−07 %0.0001 / 0.1 %Match
OPD of every rayDefault reference sphere, exit pupil at the image (issue 30); see the afocal rows2.396 waves0.001 / 0.01 wavesFail
Zernike coefficients (37 standard)0.7958 waves0.001 / 0.01 wavesFail
RMS spot of every field, from Optiland's raysWith the pupil averaging Zemax uses (Gaussian quadrature)0 %0.1 / 2 %Match
RMS wavefront of every field, from Optiland's OPDPiston and tilt removed, as Zemax does. 8.35 against 7.66 waves (issue 30)0.6944 waves0.001 / 0.01 waves, or 1 % of Zemax's if larger, to failFail
Seidel coefficients, sizesZemax prints six decimals. Optiland's signs may be opposite4.99e−07 mm1e−06 / 1e−05 mmMatch
Afocal: OPD of every ray, afocal=True as it comesThe sign is opposite to Zemax's (issue 29)53.07 waves0.001 / 0.01 wavesFail
Afocal: OPD of every ray, sign turned1.97e−07 waves0.001 / 0.01 wavesMatch
Afocal: Zernike coefficients, afocal=True as it comesThe sign is opposite to Zemax's (issue 29)26.15 waves0.001 / 0.01 wavesFail
Afocal: Zernike coefficients, sign turned9.78e−08 waves0.001 / 0.01 wavesMatch
Afocal: RMS wavefront, from Optiland's OPDPiston and tilt removed5.68e−08 waves0.001 / 0.01 waves, or 1 % of Zemax's if larger, to failMatch

RayCrafter against Zemax

This is RayCrafter's development branch

Tested at commit 5ecb2efd of dev, not the release on PyPI.

The rows below are on a system with a flat image.

4matching
1partial
0failing

Not matching: partial and fail rows.

QuantityLargest difference from ZemaxMatch / partial withinResult
RMS wavefront against Zemax's Wavefront Map, every fieldRayCrafter gives the RMS wavefront but no PSF or Strehl ratio (No diffraction image: the image plane is far from any focus, so the wavefront changes too fast across the pupil for a diffraction calculation. The RMS wavefront error is given; the spot diagram is the better guide) and Zemax made neither, so the RMS is compared with Zemax's Wavefront Map (piston and tilt removed) at 0 deg. 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): 0 deg: 7.651 (fitted 7.659). The difference is over 0.01 waves but within 1 % of Zemax's value, so it is not a fail0.04662 waves0.001 / 0.01 waves, or 1 % of Zemax's if larger, to failPartial
All 5 rows, matches included
QuantityLargest difference from ZemaxMatch / partial withinResult
Focal length and f-number6.34e−05 %0.0001 / 0.1 %Match
Chief ray at the image, every fieldFields where both programs block the chief ray are left out0 mm1e−06 / 0.001 mmMatch
Ray fan (tangential), every fieldFields where no ray gets through are left out1.16e−08 mm1e−06 / 0.001 mmMatch
Ray fan: pupil points with a ray in one program only, every fieldLight that one program lets through and the other stops: vignetting that differs. Zemax draws a tangential fan point only if the ray one step lower in the pupil also gets through, so its window really starts one to two steps below its first point and ends up to one step above its last; a point where the edge may be is undecided and not counted (raycrafter #258); the sagittal fan is not compared (no vignetted sagittal reference to show Zemax does the same)0 %0 / 1 %Match
RMS wavefront against Zemax's Wavefront Map, every fieldRayCrafter gives the RMS wavefront but no PSF or Strehl ratio (No diffraction image: the image plane is far from any focus, so the wavefront changes too fast across the pupil for a diffraction calculation. The RMS wavefront error is given; the spot diagram is the better guide) and Zemax made neither, so the RMS is compared with Zemax's Wavefront Map (piston and tilt removed) at 0 deg. 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): 0 deg: 7.651 (fitted 7.659). The difference is over 0.01 waves but within 1 % of Zemax's value, so it is not a fail0.04662 waves0.001 / 0.01 waves, or 1 % of Zemax's if larger, to failPartial
What RayCrafter said when it imported the file
  • Left out the surfaces Zemax is set to ignore: 5, 6, 12, 13.
  • Surface 7 is curved but has air on both sides; ignored.
  • Surface 14 is curved but has air on both sides; ignored.
  • The stop (surface 15) is in air, and the file gives it no aperture, so it blocks no light with aiming off; it was not imported as an element.
  • Surface 7 has a 25.4 mm round aperture in air; it was imported as an aperture 25.4 mm across, and none of the file's rays reach its edge.
  • Surface 14 ("AC254-100-A") has a 25.4 mm round aperture in air; it was imported as an aperture 25.4 mm across, and none of the file's rays reach its edge.
  • The file has no ray aiming and its stop is behind the front of the first lens, so, as in Zemax, each beam has the file's entrance pupil diameter and is aimed at the centre of the paraxial entrance pupil; it is not aimed to fill the stop, so off-axis beams may be vignetted or miss the stop's centre (#204).

Optiland: afocal image space

OPD of Zemax's rays against their distance from the pupil's centre: Optiland's default reference sphere, and its plane reference with the sign turned.
OPD of Zemax's rays against their distance from the pupil's centre: Optiland's default reference sphere, and its plane reference with the sign turned.

RayCrafter: its own plots

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

Ray fan, last field.
Ray fan, last field.

Optiland issues found

Full details are in upstream/optiland_issues_found.md.

  • 28. Ignored surfaces are traced. The file's two doublets are set to be ignored. Patched locally Upstream: not yet filed.
  • 29. The afocal wavefront has the opposite sign. OPD and Zernikes are otherwise Zemax's. Open Upstream: not yet filed.
  • 30. The default wavefront is wrong with the exit pupil at the image. Up to 2.4 waves of OPD. Open Upstream: not yet filed.

Semi-diameters stored in the file

Zemax stores, for every surface whose semi-diameter is automatic, the largest ray radius it computed. We re-trace the file in Optiland and take the largest local ray radius. Status is computed from the tolerances in comparison.json: match within 0.5%, partial within 5%.

2matching
0partial
0failing

Every row matches Zemax.

All 2 rows, matches included
QuantityZemaxOptilandDifferenceResult
Semi-diameter, surface 15 (mm)Zemax: DIAM stored in the .ZMX (computed by Zemax)7.49247.49240.00%Match
Semi-diameter, surface 16 (mm)Zemax: DIAM stored in the .ZMX (computed by Zemax)7.49247.49240.00%Match

Lens data

Prescription as stored in the Zemax file. The Optiland radius is read back from the loaded model, so a difference would show an import error. The four surfaces Zemax ignores (5, 6, 12 and 13) are left out.

Zemax #CommentTypeRadius, Zemax (mm)Radius, Optiland (mm)Thickness (mm)GlassSemi-diameter (mm)Clear aperture (mm)
0STANDARD∞∞∞0
1LA1253STANDARD1031032.8N-BK712.5 (fixed)12.5
2STANDARD∞∞012.5 (fixed)12.5
3LA1253STANDARD1031032.8N-BK712.5 (fixed)12.5
4STANDARD∞∞012.5 (fixed)12.5
7STANDARD-128.23-128.2320012.7 (fixed)12.7
8STANDARD∞∞2.8N-BK712.5 (fixed)12.5
9LA1253STANDARD-103-103012.5 (fixed)12.5
10STANDARD∞∞2.8N-BK712.5 (fixed)12.5
11LA1253STANDARD-103-103012.5 (fixed)12.5
14AC254-100-ASTANDARD-62.75-62.7510012.7 (fixed)12.7
15STANDARD (stop)∞∞07.492
16STANDARD∞∞07.492

How Zemax was run

By make_zemax_reference.py, the same way for every design, on 2026-12-02. What is asked for, and which tool each result tests, is in zemax_analyses.md; every file is in Zemax_reference_output.

SystemWhat it isTests
The file's own fieldsThe file untouched, at its own fieldsOptiland, RayCrafter
Afocal image spaceThe same file with "Afocal Image Space" ticked: a plane reference for the wavefrontOptiland

Reproduce

export UV_PROJECT_ENVIRONMENT=~/uv_venvs/evaluation_mac
uv run python -m evaluation_tools.from_zemax.analyze_zmx designs/from_zemax/relay_custom_spha
uv run python -m evaluation_tools.from_zemax.compare_optiland designs/from_zemax/relay_custom_spha
uv run python -m evaluation_tools.from_zemax.compare_raycrafter designs/from_zemax/relay_custom_spha
uv run python -m evaluation_tools.build_summary                    # regenerates all HTML

The spherical aberration of the pair is in the afocal system's wavefront: 7.66 waves RMS, mostly defocus (Zernike 4, 7.66 waves), with 0.087 waves of primary spherical (Zernike 11).