Optiland and RayCrafter (dev) vs Zemax

TWINKLE excitation path: Optiland and RayCrafter (dev) against Zemax

The full excitation path of the TWINKLE two-photon microscope, compared with our own Zemax run at all 22 galvo configurations (20 distinct angles): galvo, relay, scan lens, tube lens, three fold mirrors, a tilted dichroic plate and an ideal objective. With our preparation of the file, Optiland traces every ray as Zemax does (to 1e-13 mm), stops the same rays at the 2 mm aperture (1 mm radius), and gives Zemax's RMS spot through focus. It refuses the wavefront, so the PSF, Strehl ratio and widths the authors judged the design by cannot be compared. RayCrafter (dev) now loads the file as authored, one beam per galvo angle, with the scan line's bow in x (raycrafter #210). Its chief rays land within 1 µm of Zemax's, in x and y (a constant 0.8 µm in y, put down to the offset of the tilted dichroic plate, which the import does not model). At either end of the scan (-10 and +10 degrees) both programs stop the chief ray at the rim of the first 2-inch tube lens (AC508-750, 25.4 mm: Zemax stops 47 of its 331 rays there, the chief ray among them), so those two angles are left out of the chief-ray rows. Against Zemax's own spot diagram and wavefront map at each of the 11 detailed angles, which count only the light through the 2 mm aperture, its RMS spot agrees within 1.9 % (Match) and its RMS wavefront within 0.0024 waves (Partial: 0.0099 against 0.0075 at -8 degrees). Zemax's RMS operands, which count the stopped rays too, are not used; the other 9 angles have no such listings and are left out of those two rows.

optiland 0.6.3 RayCrafter dev 5ecb2efd λ 0.92 µm Zemax OpticStudio 22.2.1 (file) EPD 4.39 mm fields 0° Zemax run 2026-12-01 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: chief rays and wavefront in the galvo scan, a little. The chief ray lands within 1 µm of Zemax's in x and y (the scan line's bow now agrees), the distance from the axis to 1 µm (Partial). At -10 and +10 degrees both programs stop the chief ray, and those angles are left out of the chief-ray rows. The RMS wavefront is up to 0.0024 waves from Zemax's (0.0099 against 0.0075 at -8 degrees, Zemax's wavefront map with piston and tilt removed); the RMS spot is within 1.9 % (2.4 nm), a Match under the 15 nm floor. Both are compared at the 11 detailed angles only. Cause: Put down, not confirmed, to the tilted dichroic plate: the chief ray differs from Zemax's by a constant 0.8 µm in y at every galvo angle, which equals Zemax's own y at 0 degrees, the axis offset of the plate that the import's untilted plate does not reproduce (raycrafter #206, closed; raycrafter #151, open: what cannot be unfolded). For the wavefront, not located. At the ends of the scan both programs stop the chief ray at the rim of the AC508-750 tube lens: Zemax too stops rays at the 25.4 mm semi-diameter the file gives it (47 of 331 at its front surface, surface 23, the chief ray among them), where an earlier page said it let them through (raycrafter #214, evaluation #70).
  • Wavefront, PSF, Strehl and FWHM. Optiland refuses to compute them on tilted or multi-fold systems, so Zemax's PSF plots cannot be compared. Cause: Optiland's paraxial engine (issue 8; upstream roadmap #865). Upstream: #865 (roadmap, with our comment), #1210.
  • Optiland's 3D viewer. Shows only the first leg of the path and misplaces elements. Cause: not located (issue 10). Upstream: not yet filed.
  • Galvo angles and tilted surfaces on import. Only configuration 1 loads and the tilted dichroic is ignored unless our workaround rewrites the file first. Anything loading these files without the workaround is silently wrong. Cause: Optiland's Zemax reader silently drops them (issues 5 to 7). Upstream: #1247.

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
Source and galvo at top left, relay and scan lens (two doublet groups) down to the first fold, the long leg to the second fold, then the tube-lens pair, the last fold and the dichroic, and the ideal objective (brown) at top right. Galvo angles −10°, 0° and +10°. The authors supplied no Zemax layout of the whole path (only a close-up of the focus), so this is checked against the element order and spacings in the ZMX, not against a Zemax drawing.
Show Optiland's own 3D viewer (incomplete for this system)
Optiland 3D viewer render showing only the first leg of the ray path
Optiland's VTK viewer. The rays stop at the galvo mirror and some elements are misplaced (issue 8 in upstream/optiland_issues_found.md). The projected layout above, drawn from the same ray coordinates, shows the whole path.

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.

9matching
0partial
1failing

Not matching: partial and fail rows.

QuantityLargest difference from ZemaxMatch / partial withinResult
Wavefront with the galvo tilted22 of 22 configurations: UnsupportedParaxialGeometryError (issue 8)refusedFail
All 10 rows, matches included
QuantityLargest difference from ZemaxMatch / partial withinResult
Refractive index of each glassBK7, N-BK7, N-LAK22, N-SF6HT, SF22.22e−161e−06 / 0.0001Match
Position of every surface4.48e−13 mm1e−09 / 1e−06 mmMatch
Rays at the image, ray by rayThe rays Zemax traced, every galvo angle or field7.46e−14 mm1e−06 / 0.001 mmMatch
Ray directions at the imageDirection cosines. Zemax's are reversed after an odd number of mirrors7.44e−141e−09 / 1e−06Match
Largest ray radius on every surface6.15e−13 mm1e−06 / 0.001 mmMatch
Rays stopped by apertures, ray by ray0 of 7282 rays stopped by one tool and not the other0 %0 / 1 %Match
RMS spot of the same raysThe rays that get through, every one counted alike0 %0.1 / 2 %Match
Wavefront with the galvo tilted22 of 22 configurations: UnsupportedParaxialGeometryError (issue 8)refusedFail
RMS spot through focus, every galvo angleEvery ray counted, as in Zemax's RMS analyses9.7e−09 %0.1 / 2 %Match
Best focus, every galvo angle0 mm0.0001 / 0.001 mmMatch

RayCrafter against Zemax

This is RayCrafter's development branch

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

The file as authored

1matching
3partial
0failing

Not matching: partial and fail rows.

QuantityLargest difference from ZemaxMatch / partial withinResult
As authored: galvo scan: distance of the chief ray from the axisThe file as authored: each galvo angle imported as a beam. ±10°: both programs block the chief ray (Zemax vignettes it, RayCrafter gives none); left out0.000804 mm1e−06 / 0.001 mmPartial
As authored: galvo scan: where the chief ray lands (x and y)Distance between the two programs' chief rays on the image. ±10°: both programs block the chief ray (Zemax vignettes it, RayCrafter gives none); left out0.000809 mm1e−06 / 0.001 mmPartial
As authored: galvo scan: RMS wavefrontZemax's Wavefront Map (piston and tilt removed) at each angle, as its apertures stop rays there: it counts only the light that gets through, as RayCrafter does, where its RMS operand counts the stopped rays too (evaluation #70). Compared at 11 of 20 angles: Zemax makes it only at the detailed ones. 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): -10 deg: 0.0129 (fitted 0.01281), -8 deg: 0.009466 (fitted 0.009438), -6 deg: 0.004372 (fitted 0.004398), -4 deg: 0.002493 (fitted 0.002565), -2 deg: 0.003773 (fitted 0.003811), 0 deg: 0.004492 (fitted 0.0045), 2 deg: 0.003773 (fitted 0.003811), 4 deg: 0.002493 (fitted 0.002565), 6 deg: 0.004372 (fitted 0.004398), 8 deg: 0.009466 (fitted 0.009438), 10 deg: 0.0129 (fitted 0.01281)0.001979 waves0.001 / 0.01 waves, or 1 % of Zemax's if larger, to failPartial
All 4 rows, matches included
QuantityLargest difference from ZemaxMatch / partial withinResult
As authored: galvo scan: distance of the chief ray from the axisThe file as authored: each galvo angle imported as a beam. ±10°: both programs block the chief ray (Zemax vignettes it, RayCrafter gives none); left out0.000804 mm1e−06 / 0.001 mmPartial
As authored: galvo scan: where the chief ray lands (x and y)Distance between the two programs' chief rays on the image. ±10°: both programs block the chief ray (Zemax vignettes it, RayCrafter gives none); left out0.000809 mm1e−06 / 0.001 mmPartial
As authored: galvo scan: RMS spot11 of 11 values differ by under 15 nm, which counts as a match; as a percentage the largest difference would be 1.885 %. Zemax's Spot Diagram at each angle, as its apertures stop rays there: it counts only the light that gets through, as RayCrafter does, where its RMS operand counts the stopped rays too (evaluation #70). Compared at 11 of 20 angles: Zemax makes it only at the detailed ones0 %0.1 / 2 %Match
As authored: galvo scan: RMS wavefrontZemax's Wavefront Map (piston and tilt removed) at each angle, as its apertures stop rays there: it counts only the light that gets through, as RayCrafter does, where its RMS operand counts the stopped rays too (evaluation #70). Compared at 11 of 20 angles: Zemax makes it only at the detailed ones. 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): -10 deg: 0.0129 (fitted 0.01281), -8 deg: 0.009466 (fitted 0.009438), -6 deg: 0.004372 (fitted 0.004398), -4 deg: 0.002493 (fitted 0.002565), -2 deg: 0.003773 (fitted 0.003811), 0 deg: 0.004492 (fitted 0.0045), 2 deg: 0.003773 (fitted 0.003811), 4 deg: 0.002493 (fitted 0.002565), 6 deg: 0.004372 (fitted 0.004398), 8 deg: 0.009466 (fitted 0.009438), 10 deg: 0.0129 (fitted 0.01281)0.001979 waves0.001 / 0.01 waves, or 1 % of Zemax's if larger, to failPartial

±10°: both programs block the chief ray (Zemax vignettes it, RayCrafter gives none), so those angles are left out of the chief-ray rows above.

What RayCrafter said when it imported the file
  • 5 lens(es) are not in the catalogue and were named "Imported lens N".
  • Surface 1 ("MEASURED: ~2.0mm beam") has a 2 mm round aperture in air at or in front of the source plane, narrower than the 4.39 mm beam. It clips the beam as it enters, so the beams were made 2 mm wide, as in Zemax.
  • The file's 22 configurations turn the scanning mirror (surface 3) from -10 to 10 degrees; each angle became a field.
  • The scanning mirror's beams keep their true directions (in x as well as y), but the outline of another fold mirror after the mirror is not round about the axis: the MTF, wavefront and Strehl ratio of a beam that leaves sideways are worked out for one of the same angle to the axis in y, so they are approximate.
  • The scanning mirror is drawn and clips the beams at rest, not turned to each angle.
  • Surface 36 ("Target is 2*2.5mm") has a 20 mm round aperture in air; it was imported as an aperture 20 mm across, and none of the file's rays reach its edge.
  • The fold mirror at surface 4 has no aperture, only a semi-diameter of 3.1042 mm, at which Zemax does not block rays. It is round, 6.2084 mm across, which the file's rays fit in.
  • The file's stop is on this fold mirror (surface 21). Its beam is set by an entrance pupil diameter, with every field on axis at infinity and ray aiming off, so the stop's place changes no ray; the stop is now on the first surface after the object.
  • Surfaces 34 and 35 ("dichroic"): a flat plate 1.1 mm thick, tilted 45 degrees about x and decentred -0.37 mm by SCBD and tilted back. It was imported untilted: the light on it is collimated (marginal rays within 0.031 degrees of the chief ray), so a flat plate adds no aberration (a tilted one would add at most 1.1e-05 waves of astigmatism, at most 49 degrees incidence) and only shifts each beam sideways by 0.365 mm, which RayCrafter does not model; the file's own axis leaves its beams 0.78 mm off the axis behind the plate, which is not modelled either.

Optiland: galvo scan

The file exactly as authored. Open circles and black dots are Zemax, blue is Optiland.

Chief-ray position, its departure from a straight line, RMS spot, and the worst distance of any ray from Zemax's, against galvo angle.
Chief-ray position, its departure from a straight line, RMS spot, and the worst distance of any ray from Zemax's, against galvo angle.
Spot diagrams about their centroids: Zemax (red dots) above, Optiland (amber dots) below. Same rays, so the RMS here counts every ray alike.
Spot diagrams about their centroids: Zemax (red dots) above, Optiland (amber dots) below. Same rays, so the RMS here counts every ray alike.

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

10matching
0partial
0failing

Every row matches Zemax.

All 10 rows, matches included
QuantityZemaxOptilandDifferenceResult
Semi-diameter, surface 1 (MEASURED: ~2.0mm beam) (mm)Zemax: DIAM stored in the .ZMX (computed by Zemax)2.19502.19500.00%Match
Semi-diameter, surface 4 (mm)Zemax: DIAM stored in the .ZMX (computed by Zemax)3.10423.10840.14%Match
Semi-diameter, surface 26 (mm)Zemax: DIAM stored in the .ZMX (computed by Zemax)16.974916.97760.02%Match
Semi-diameter, surface 30 (mm)Zemax: DIAM stored in the .ZMX (computed by Zemax)16.899416.90200.02%Match
Semi-diameter, surface 34 (dichroic) (mm)Zemax: DIAM stored in the .ZMX (computed by Zemax)15.989016.00480.10%Match
Semi-diameter, surface 35 (READ SEMI-DIAMETER HERE) (mm)Zemax: DIAM stored in the .ZMX (computed by Zemax)16.558616.57500.10%Match
Semi-diameter, surface 36 (Target is 2*2.5mm) (mm)Zemax: DIAM stored in the .ZMX (computed by Zemax)11.032311.03460.02%Match
Semi-diameter, surface 37 (mm)Zemax: DIAM stored in the .ZMX (computed by Zemax)10.903110.90540.02%Match
Semi-diameter, surface 38 (mm)Zemax: DIAM stored in the .ZMX (computed by Zemax)0.14610.14610.00%Match
Semi-diameter, surface 39 (mm)Zemax: DIAM stored in the .ZMX (computed by Zemax)0.14040.14040.00%Match

Zemax angle scan: PSF width and focus shift

Blocked in Optiland

The TWINKLE authors scanned the galvo from −10° to +10° in 0.5° steps and, at each angle, a Huygens PSF through focus in 0.1 µm steps (MATLAB driving the Zemax API; script in Authors_reference_output/). They squared the PSF for two-photon excitation and measured radial FWHM, axial FWHM and the focus position. Values below are read from the vector markers of the MATLAB plot (digitised, not Zemax numeric output).

Zemax: field curvature, radial FWHM and axial FWHM against galvo angle
Zemax plot as supplied by the authors.
The same three curves redrawn from the digitised markers
The same markers redrawn from the SVG vertices.

On axis the two-photon radial FWHM is 0.77 µm and the axial FWHM 5.1 µm; both grow to 1.35 and 7.8 µm at ±10°. Focus moves by about ±0.4 µm.

Optiland cannot reproduce this

FFT PSF, wavefront and Strehl all raise UnsupportedParaxialGeometryError on this file (issue 8). There is no number to compare. Real rays do give a geometric picture below: the RMS spot radius is 0.05 to 0.33 µm, inside the 0.90 µm Airy radius at every angle, so the design is diffraction-limited on this evidence. That is a prediction to check against the Zemax widths once a PSF can be computed, not a match.

Spots and scan linearity

Works

At each of the 20 distinct galvo angles we traced a 24-ring hexapolar pupil to the image plane (Zemax surface 39, after the ideal objective). The chief ray moves -45.7 µm per degree of galvo angle, in a straight line to within a few µm, and the RMS spot radius stays below 0.35 µm. Dashed: the Airy radius from the real marginal-ray NA of 0.63.

RMS spot radius against galvo angle
Geometric RMS spot radius against the Airy radius. It is smallest near ±4° to ±5° and rises towards ±10°, the same trend as the Zemax FWHM above.
Chief-ray position against galvo angle
Chief-ray position on the image plane against galvo angle.
Spot diagrams
Spot diagrams at five galvo angles, each centred on its own centroid, same scale.

Optiland issues found

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

  • 5. Surface tilts (SCBD) ignored. The tilted dichroic loads untilted, with no warning. Patched locally Upstream: #1247.
  • 6. Parameter pickups (PPAR) ignored. Only matters when a value is edited. Patched locally Upstream: #1247.
  • 7. Multi-configuration data dropped. Only configuration 1 loads; the galvo angles are configurations. Worked around Upstream: #1247.
  • 8. Paraxial engine refuses tilted systems. Blocks wavefront, PSF and Strehl on the tilted galvo systems. Open Upstream: #865 (roadmap, with our comment), #1210.
  • 9. 2D layout mangles folded systems. This page draws its own projection. Worked around Upstream: not yet filed.
  • 10. 3D viewer shows one leg of the excitation path. Cause not located. 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
1MEASURED: ~2.0mm beam2.19502.19501.0000
43.10423.10841.0014
2616.974916.97761.0002
3016.899416.90201.0002
34dichroic15.989016.00481.0010
35READ SEMI-DIAMETER HERE16.558616.57501.0010
36Target is 2*2.5mm11.032311.03461.0002
3710.903110.90541.0002
380.14610.14611.0000
390.14040.14041.0000

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)
01mm diameter laser X2 magn.STANDARD∞∞∞0
1MEASURED: ~2.0mm beamSTANDARD∞∞202.1951
4STANDARD∞∞0MIRROR3.104
7STANDARD∞∞-2.5BK725.4 (fixed)25.4
8KPC070AR.16STANDARD-103.36-103.36-4.59925.4 (fixed)25.4
9LB1199-BSTANDARD-204.98-204.98-6.16N-BK725.4 (fixed)25.4
10STANDARD204.98204.98-525.4 (fixed)25.4
11AC508-200-BSTANDARD-134-134-8.2N-LAK2225.4 (fixed)25.4
12STANDARD109.2109.2-5N-SF6HT25.4 (fixed)25.4
13The SL-TL telescopeSTANDARD515.2515.2-225.4 (fixed)25.4
14is exactly 2XSTANDARD-515.2-515.2-5N-SF6HT25.4 (fixed)25.4
15see Disatnce2 fileSTANDARD-109.2-109.2-8.2N-LAK2225.4 (fixed)25.4
16AC508-200-BSTANDARD134134-72.325.4 (fixed)25.4
18STANDARD∞∞0MIRROR38.1 (fixed)38.1
21STANDARD (stop)∞∞0MIRROR38.1 (fixed)38.1
23STANDARD-1330.5-1330.5-2SF225.4 (fixed)25.4
24STANDARD-336-336-4.5N-BK725.4 (fixed)25.4
25AC508-750-ASTANDARD417.8417.8-425.4 (fixed)25.4
26STANDARD∞∞-016.975
27STANDARD-1330.5-1330.5-2SF225.4 (fixed)25.4
28STANDARD-336-336-4.5N-BK725.4 (fixed)25.4
29STANDARD417.8417.8-425.4 (fixed)25.4
30STANDARD∞∞-215.316.899
32STANDARD∞∞-0MIRROR38.1 (fixed)38.1
34dichroicSTANDARD∞∞1.1N-BK715.989
35READ SEMI-DIAMETER HERESTANDARD∞∞5016.559
36Target is 2*2.5mmSTANDARD∞∞7.211.03210
37PARAXIAL∞∞7.210.903
38STANDARD∞∞0.00710.146
39STANDARD∞∞00.14

How Zemax was run

By make_zemax_reference.py, the same way for every design, on 2026-12-01. 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
As authoredThe file untouched, at every galvo angleOptiland, RayCrafter

Reproduce

export UV_PROJECT_ENVIRONMENT=~/uv_venvs/evaluation_mac
uv run python -m evaluation_tools.from_zemax.analyze_zmx designs/from_zemax/twinkle_excitation   # 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.