Optiland and RayCrafter (dev) vs Zemax

TWINKLE collection optics: Optiland and RayCrafter (dev) against Zemax

The fluorescence collection optics of the TWINKLE microscope, compared with our own Zemax run at its eight fields: a fold mirror, an achromat pair, a dichroic, a filter, an aspheric condenser and a 2.5 mm detector aperture. Optiland differs from Zemax by up to 0.01 mm at the detector, and 0.6% in focal length, from one cause: its data for the condenser's B270 glass differ from Zemax's by 1.1e-4. With Zemax's index, Optiland's rays agree to 3e-7 mm. RayCrafter now has Zemax's glass data (raycrafter #216): its focal length and its chief rays (to 2e-8 mm) agree. What differs is where rays are stopped, from 8 degrees out. There RayCrafter's spot is compared with Zemax's own traced rays that get through, launched at the same pupil points (raycrafter #231), and agrees to 1e-9 mm at 8, -8, 10 and -10 degrees; its own Spot Diagram, shown for reference, is cut by the image surface's opening by a rule we cannot reproduce (Zemax 822 um at 10 degrees against 990 um in RayCrafter's). The RMS spot against field is a Match because the scan is now cut at 5.4 degrees, not because RayCrafter changed: it agrees within 1.1e-6 % at 0 to 4.8 degrees, and from 5.4 degrees, where RayCrafter's vignetting analysis first shows stopped rays (99.8 % of the light gets through there), Zemax's operand counts the stopped rays too, so the scan is left out (evaluation #72). With the earlier cut, at 8 degrees (the first detailed field where Zemax's own rays are stopped), the row was Partial: 5.4 to 7.2 degrees still agreed within 1.1e-6 % (the rays stopped there are stopped only by the image surface's aperture, and both programs' RMS counts rays that reach the image), and only 7.8 degrees differed, by 0.88 %, where rays are stopped before the image (94.8 % of the light gets through in RayCrafter). RayCrafter's vignetting at these angles is the same with the earlier pin. At 12 degrees no ray gets through in Zemax. RayCrafter's share of the light through is inside the range Zemax's rings of rays allow at every field (12.3 % against 10.1 to 16.1 % at 10 degrees). RayCrafter now imports the image surface's own aperture as the image's clear opening, with a note (raycrafter #225), so its share of the light counts it as Zemax's does; its spots, like Zemax's RMS operand, are not cut by it. RayCrafter gives the RMS wavefront at every field since raycrafter #218 (a2f0adf) but no PSF or Strehl ratio (the wavefront changes too fast across the pupil), and Zemax made neither, so the RMS of RayCrafter's own wavefront map, fitted as Zemax's Wavefront Map is (piston and tilt over the pupil, raycrafter #243), is compared with the RMS of Zemax's: 308 against 303 waves at 0 degrees, 401 against 409 at 4, 576 against 569 at 6, 772 against 771 at 8, 583 against 528 at 10 (Fail: over 1 % of Zemax's value at 0, 4, 6 and 10 degrees, 1.8, 2.0, 1.3 and 10.4 %, with RayCrafter's map traced at 513 rays across the lit pupil since the review of round 9; RayCrafter's own reported RMS, shown beside, is 310, 380, 554, 763 and 576; per ray the phase agrees to 0.006 waves, but the wavefront has a step of about 1700 waves where rays stop meeting the reference sphere, so the RMS depends on where Zemax's 64 x 64 map grid meets it (raycrafter #235), and at 10 degrees Zemax's chief ray is blocked, so RayCrafter's reference is the mean of the rays through; raycrafter #218). Optiland stops the same rays as Zemax, to 4 in 10088.

optiland 0.6.3 RayCrafter dev 5ecb2efd λ 0.546074 µm Zemax OpticStudio 22.2.1 (file) EPD 18.4 mm fields -10, -8, 0, 4, 6, 8, 10, 12° Zemax run 2026-12-03 21:33 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
  • RayCrafter: the RMS wavefront of its own map differs from Zemax's Wavefront Map by 2.5 to 7.3 % at three of five fields (8 to 38 waves of 300 to 530). Both fitted the same way: 308 against 303 waves at 0 degrees, 401 against 409 at 4, 576 against 569 at 6, 772 against 771 at 8, 583 against 528 at 10. RayCrafter gives no PSF or Strehl ratio ('the image plane is far from any focus'), and Zemax made none either. Cause: Partly Zemax's 64 x 64 map grid meeting a phase step of about 1700 waves where rays stop meeting the reference sphere, not the per-ray phase (which agrees to 0.006 waves rms); at 10 degrees Zemax's chief ray is blocked, so the reference differs (raycrafter #218, raycrafter #235). The tilt is no longer part of it: since Rob's decision of 2026-12-04 both maps are fitted the same way (raycrafter #243).

System layout

Works

Drawn by this repository from Optiland's surface positions, sags and ray coordinates (Optiland's own draw fails on folds, issue 9). Glass is filled between surfaces, thick black lines are mirrors, the brown arrow-line is the ideal objective and the dashed line is the image plane. Everything is projected onto the plane of the folds.

Ray paths projected onto the plane of the system
Optiland geometry, rays for the extreme and central fields, projected onto the plane of the folds.
Zemax layout of the collection optics
Zemax's own layout (collection_vector.eps, rendered). Same element order as the drawing above: stop, 45° fold mirror, two achromat pairs, dichroic mirror, filter, condenser, detector. Checked by eye; we did not compare coordinates.

Interactive 3D

Static 3D render of the optical system from optiland's VTK viewer Loading 3D model…

The scene from Optiland's own VTK 3D viewer, rendered offscreen and exported as glTF. Drag to rotate, scroll to zoom, right-drag to pan.

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.

3matching
1partial
7failing

Not matching: partial and fail rows.

QuantityLargest difference from ZemaxMatch / partial withinResult
Refractive index of each glassN-BK7, B270. Optiland's data for B270 differ from Zemax's0.0001091e−06 / 0.0001Fail
Rays at the image, ray by rayThe rays Zemax traced, every galvo angle or field0.01148 mm1e−06 / 0.001 mmFail
Ray directions at the imageDirection cosines. Zemax's are reversed after an odd number of mirrors0.000311e−09 / 1e−06Fail
Largest ray radius on every surface0.004303 mm1e−06 / 0.001 mmFail
Rays stopped by apertures, ray by ray4 of 10088 rays stopped by one tool and not the other0.03965 %0 / 1 %Partial
Focal length, f-number, exit pupilSizes; Optiland's signs may differ after a mirror0.5805 %0.0001 / 0.1 %Fail
RMS spot against field, RmsSpotSizeVsField as it comesEqual weights on hexapolar rings count the pupil's edge too much, and only the rays that get through count56.99 %0.1 / 2 %Fail
Seidel coefficients, sizesZemax prints six decimals. Optiland's signs may be opposite2.01 mm1e−06 / 1e−05 mmFail
All 11 rows, matches included
QuantityLargest difference from ZemaxMatch / partial withinResult
Refractive index of each glassN-BK7, B270. Optiland's data for B270 differ from Zemax's0.0001091e−06 / 0.0001Fail
Position of every surface6.74e−14 mm1e−09 / 1e−06 mmMatch
Rays at the image, ray by rayThe rays Zemax traced, every galvo angle or field0.01148 mm1e−06 / 0.001 mmFail
Ray directions at the imageDirection cosines. Zemax's are reversed after an odd number of mirrors0.000311e−09 / 1e−06Fail
Largest ray radius on every surface0.004303 mm1e−06 / 0.001 mmFail
Rays stopped by apertures, ray by ray4 of 10088 rays stopped by one tool and not the other0.03965 %0 / 1 %Partial
RMS spot of the same raysThe rays that get through, every one counted alike0.05194 %0.1 / 2 %Match
Focal length, f-number, exit pupilSizes; Optiland's signs may differ after a mirror0.5805 %0.0001 / 0.1 %Fail
RMS spot against field, from Optiland's raysWith the pupil averaging Zemax uses (Gaussian quadrature)0.07484 %0.1 / 2 %Match
RMS spot against field, RmsSpotSizeVsField as it comesEqual weights on hexapolar rings count the pupil's edge too much, and only the rays that get through count56.99 %0.1 / 2 %Fail
Seidel coefficients, sizesZemax prints six decimals. Optiland's signs may be opposite2.01 mm1e−06 / 1e−05 mmFail

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.

6matching
0partial
1failing

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, 4, 6, 8, -8, -10, 10 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: 310 (fitted 308), 4 deg: 379.7 (fitted 401.1), 6 deg: 554 (fitted 576.3), 8 deg: 763.4 (fitted 771.7), -8 deg: 763.4 (fitted 771.7), -10 deg: 576.2 (fitted 582.5), 10 deg: 576.2 (fitted 582.5)54.65 waves0.001 / 0.01 waves, or 1 % of Zemax's if larger, to failFail
All 7 rows, matches included
QuantityLargest difference from ZemaxMatch / partial withinResult
Focal length and f-number9.9e−12 %0.0001 / 0.1 %Match
Chief ray at the image, every field±10°, 12°: both programs block the chief ray; left out2.04e−08 mm1e−06 / 0.001 mmMatch
Ray fan (tangential), every fieldFields where no ray gets through are left out2.54e−07 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 spot against fieldZemax's RMS operand counts the rays its apertures stop as well; RayCrafter's counts the light that gets through (evaluation #72). From the first angle where either program stops rays (5.4 deg, by RayCrafter's vignetting analysis) the scan is left out, and the fields are compared with Zemax's own traced rays that get through (rays_at_image.csv), RayCrafter's launched at the same pupil points (raycrafter #231); not its Spot Diagram, which is cut by the image surface's opening by a rule we cannot reproduce: 8, 12, -8, -10, 10 deg. No ray gets through in Zemax at 12 deg: not compared. The Spot Diagrams (um) for reference: 8 deg: Zemax 1374, RayCrafter 1387; -8 deg: Zemax 1374, RayCrafter 1387; -10 deg: Zemax 821.7, RayCrafter 989.6; 10 deg: Zemax 821.7, RayCrafter 989.60 %0.1 / 2 %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, 4, 6, 8, -8, -10, 10 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: 310 (fitted 308), 4 deg: 379.7 (fitted 401.1), 6 deg: 554 (fitted 576.3), 8 deg: 763.4 (fitted 771.7), -8 deg: 763.4 (fitted 771.7), -10 deg: 576.2 (fitted 582.5), 10 deg: 576.2 (fitted 582.5)54.65 waves0.001 / 0.01 waves, or 1 % of Zemax's if larger, to failFail
Share of the light that gets throughRayCrafter's vignetting analysis against the range that Zemax's rings of rays allow, its image surface's aperture counted. The file has an aperture on the image surface; RayCrafter's share counts it where its import took it as the image's clear opening (the import notes say whether it did; raycrafter #225). Where they differ, or the image surface's aperture stops light: at 6 deg RayCrafter 99.3 %, Zemax 98.4 to 100.0 % (100.0 to 100.0 % before the image surface's aperture); at 8 deg RayCrafter 92.8 %, Zemax 89.9 to 94.7 % (95.6 to 97.5 % before the image surface's aperture); at 10 deg RayCrafter 12.3 %, Zemax 10.1 to 16.1 % (17.7 to 22.7 % before the image surface's aperture)0 % points0.5 / 2 % pointsMatch
What RayCrafter said when it imported the file
  • 2 lens(es) are not in the catalogue and were named "Imported lens N".
  • Surface 17, the image surface, has a 5 mm round aperture. It was imported as the image's clear aperture: rays that reach the image outside it are stopped.
  • Surface 1 has a 20 mm round aperture in air at or in front of the source plane, where RayCrafter's beams start, so it was left out.
  • Surface 16 has a 5 mm round aperture in air; it was imported as an aperture 5 mm across, and none of the file's rays reach its edge.
  • The fold mirror at surface 10 ("DICHROIC MIRROR") has no aperture, only a semi-diameter of 22.8384 mm, at which Zemax does not block rays. It is round and was enlarged to 47.5 mm across so that none of the file's own rays is blocked.

Optiland: the file's own fields

Against field angle. Blue: from Optiland's rays and OPD with Zemax's meaning. Orange: Optiland's own analysis as it comes, where it differs.
Against field angle. Blue: from Optiland's rays and OPD with Zemax's meaning. Orange: Optiland's own analysis as it comes, where it differs.

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.

RMS spot radius against field angle.
RMS spot radius against field angle.
Light through, and relative illumination, against field angle.
Light through, and relative illumination, against field angle.

Semi-diameters stored in the file

An older check, from the authors' Zemax (22.2.1). Zemax stores, for every surface whose semi-diameter is automatic, the largest ray radius it computed. We re-trace the same file in Optiland (all fields and wavelengths, 40-ring hexapolar pupil) and take the largest local ray radius. Those values come from the file itself, so they are exact Zemax output, not read off a plot. Status is computed from the tolerances in comparison.json: match within 0.5%, partial within 5%. Relative illumination is compared with the Zemax plot (see below).

4matching
1partial
0failing

Not matching: partial and fail rows.

QuantityZemaxOptilandDifferenceResult
Mean |Zemax RI − Optiland pupil fraction|, 0 to 12° (21 points)Zemax: RelativeIllumination.svg, read from the plot vector data (digitised)0.000.030.0332Partial
All 5 rows, matches included
QuantityZemaxOptilandDifferenceResult
Semi-diameter, surface 10 (DICHROIC MIRROR) (mm)Zemax: DIAM stored in the .ZMX (computed by Zemax)22.838422.83840.00%Match
Semi-diameter, surface 17 (mm)Zemax: DIAM stored in the .ZMX (computed by Zemax)29.283529.27920.01%Match
Field angle where relative illumination falls to 50% (deg)Zemax: RelativeIllumination.svg, read from the plot vector data (digitised)9.068.960.1012Match
Field angle where relative illumination reaches 0 (deg)Zemax: RelativeIllumination.svg, read from the plot vector data (digitised)10.7110.650.0564Match
Mean |Zemax RI − Optiland pupil fraction|, 0 to 12° (21 points)Zemax: RelativeIllumination.svg, read from the plot vector data (digitised)0.000.030.0332Partial

Relative illumination: the authors' Zemax plot

Roll-off matchesMean offset partial

Zemax's relative-illumination plot for field 0° to 12° at 0.546 µm. Optiland has no relative-illumination analysis, so we count the fraction of pupil rays that survive the apertures it imports from the Zemax file (it clips by zeroing a ray's intensity). That ignores the cos-law terms Zemax includes, which are a few per cent here. The Zemax curve ripples by about ±3% from its own sampling, so we compare where the curve falls through 50% and where it reaches zero, plus the mean difference.

Zemax relative illumination against field
Zemax, as exported.
Zemax relative illumination (digitised) and the Optiland pupil fraction
Zemax points (read from the SVG vertices, digitised) and the Optiland pupil fraction.

Zemax falls through 50% at 9.06° and reaches zero at 10.71°. Optiland's pupil fraction does the same at 8.96° and 10.65°, within 0.1°. The mean absolute difference over the 21 Zemax points is 0.033, about the size of Zemax's own ripple. Note the beam is already clipped at 8°: the 2.5 mm detector aperture and the 12.7 mm condenser limit the field, not the 25 mm lenses.

Spots on the detector

Works

Spots at the eight Zemax fields on the last surface. The dashed circle is the 2.5 mm clear aperture Zemax puts on that surface; beyond about 8° the beam no longer fits inside it, which is the relative-illumination roll-off above.

RMS spot radius against field
Geometric RMS spot radius against the detector aperture radius.
Spot diagrams
Spot diagrams at each field, centred, one scale.

Optiland issues found

Full details are in upstream/optiland_issues_found.md (issues 5 to 10 are new with these designs).

  • 9. 2D layout mangles folded systems. This page draws its own projection. Worked around Upstream: not yet filed.
  • 25. B270 is a four-decimal table. 8.1e-5 to 1.1e-4 below Zemax's index. Open Upstream: not yet filed.
  • 26. Seidel sums ignore the asphere's r4 term. With it the sizes agree to 5e-4. Open Upstream: not yet filed.

Semi-diameters, every automatic surface

The same comparison as the verdict table, with the ratio, including any row that was not scored.

Zemax surfaceCommentZemax (mm)Optiland (mm)Ratio
10DICHROIC MIRROR22.838422.83841.0000
1729.283529.27920.9999

Lens data

Prescription as stored in the Zemax file (coordinate breaks left out; Optiland absorbs them into the neighbouring surfaces). The Optiland radius is read back from the loaded model, so a difference would show an import error. Thicknesses are signed Zemax values: negative after a mirror.

Zemax #CommentTypeRadius, Zemax (mm)Radius, Optiland (mm)Thickness (mm)GlassSemi-diameter (mm)Clear aperture (mm)
0STANDARD∞∞∞0
1STANDARD (stop)∞∞5010 (fixed)10
3STANDARD∞∞0MIRROR19 (fixed)19
5LA1384-ASTANDARD∞∞-8.2N-BK725 (fixed)25
6STANDARD64.464.4-525 (fixed)25
7LB1607-ASTANDARD-179.1-179.1-8.1N-BK725 (fixed)25
8STANDARD179.1179.1-57.71625 (fixed)25
10DICHROIC MIRRORSTANDARD∞∞-0MIRROR22.838
12filterSTANDARD∞∞6.284N-BK711 (fixed)11
13STANDARD∞∞1.511 (fixed)11
14EVENASPH8.8188.81814B27012.7 (fixed)12.7
15STANDARD-69.999-69.9995.812.7 (fixed)12.7
16STANDARD∞∞12.5 (fixed)2.5
17STANDARD∞∞029.2842.5

How Zemax was run

By make_zemax_reference.py, the same way for every design, on 2026-12-03 21:33. 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

Reproduce

export UV_PROJECT_ENVIRONMENT=~/uv_venvs/evaluation_mac
uv run python -m evaluation_tools.from_zemax.analyze_zmx designs/from_zemax/twinkle_collection   # about 1 to 3 minutes
uv run python -m evaluation_tools.build_summary                    # regenerates all HTML

zemax_text.py holds the workarounds for features Optiland ignores (tilted surfaces, pickups, configurations). analyze_zmx.py runs the analysis and pages/generic_page.py writes this page. The Zemax files come from the TWINKLE repository.