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: Wavefront with the galvo tilted, gives no number (22 of 22 configurations: UnsupportedParaxialGeometryError (issue 8))
Every failing row of the tables below, against our own Zemax run.
- 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
WorksDrawn 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.

Show Optiland's own 3D viewer (incomplete for this system)

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.
Not matching: partial and fail rows.
| Quantity | Largest difference from Zemax | Match / partial within | Result |
|---|---|---|---|
| Wavefront with the galvo tilted22 of 22 configurations: UnsupportedParaxialGeometryError (issue 8) | refused | Fail |
All 10 rows, matches included
| Quantity | Largest difference from Zemax | Match / partial within | Result |
|---|---|---|---|
| Refractive index of each glassBK7, N-BK7, N-LAK22, N-SF6HT, SF2 | 2.22e−16 | 1e−06 / 0.0001 | Match |
| Position of every surface | 4.48e−13 mm | 1e−09 / 1e−06 mm | Match |
| Rays at the image, ray by rayThe rays Zemax traced, every galvo angle or field | 7.46e−14 mm | 1e−06 / 0.001 mm | Match |
| Ray directions at the imageDirection cosines. Zemax's are reversed after an odd number of mirrors | 7.44e−14 | 1e−09 / 1e−06 | Match |
| Largest ray radius on every surface | 6.15e−13 mm | 1e−06 / 0.001 mm | Match |
| Rays stopped by apertures, ray by ray0 of 7282 rays stopped by one tool and not the other | 0 % | 0 / 1 % | Match |
| RMS spot of the same raysThe rays that get through, every one counted alike | 0 % | 0.1 / 2 % | Match |
| Wavefront with the galvo tilted22 of 22 configurations: UnsupportedParaxialGeometryError (issue 8) | refused | Fail | |
| RMS spot through focus, every galvo angleEvery ray counted, as in Zemax's RMS analyses | 9.7e−09 % | 0.1 / 2 % | Match |
| Best focus, every galvo angle | 0 mm | 0.0001 / 0.001 mm | Match |
RayCrafter against Zemax
Tested at commit 5ecb2efd of dev, not the release on PyPI.
The file as authored
Not matching: partial and fail rows.
| Quantity | Largest difference from Zemax | Match / partial within | Result |
|---|---|---|---|
| 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 out | 0.000804 mm | 1e−06 / 0.001 mm | Partial |
| 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 out | 0.000809 mm | 1e−06 / 0.001 mm | Partial |
| 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 waves | 0.001 / 0.01 waves, or 1 % of Zemax's if larger, to fail | Partial |
All 4 rows, matches included
| Quantity | Largest difference from Zemax | Match / partial within | Result |
|---|---|---|---|
| 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 out | 0.000804 mm | 1e−06 / 0.001 mm | Partial |
| 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 out | 0.000809 mm | 1e−06 / 0.001 mm | Partial |
| 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 ones | 0 % | 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 waves | 0.001 / 0.01 waves, or 1 % of Zemax's if larger, to fail | Partial |
±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.


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%.
Every row matches Zemax.
All 10 rows, matches included
| Quantity | Zemax | Optiland | Difference | Result |
|---|---|---|---|---|
| Semi-diameter, surface 1 (MEASURED: ~2.0mm beam) (mm)Zemax: DIAM stored in the .ZMX (computed by Zemax) | 2.1950 | 2.1950 | 0.00% | Match |
| Semi-diameter, surface 4 (mm)Zemax: DIAM stored in the .ZMX (computed by Zemax) | 3.1042 | 3.1084 | 0.14% | Match |
| Semi-diameter, surface 26 (mm)Zemax: DIAM stored in the .ZMX (computed by Zemax) | 16.9749 | 16.9776 | 0.02% | Match |
| Semi-diameter, surface 30 (mm)Zemax: DIAM stored in the .ZMX (computed by Zemax) | 16.8994 | 16.9020 | 0.02% | Match |
| Semi-diameter, surface 34 (dichroic) (mm)Zemax: DIAM stored in the .ZMX (computed by Zemax) | 15.9890 | 16.0048 | 0.10% | Match |
| Semi-diameter, surface 35 (READ SEMI-DIAMETER HERE) (mm)Zemax: DIAM stored in the .ZMX (computed by Zemax) | 16.5586 | 16.5750 | 0.10% | Match |
| Semi-diameter, surface 36 (Target is 2*2.5mm) (mm)Zemax: DIAM stored in the .ZMX (computed by Zemax) | 11.0323 | 11.0346 | 0.02% | Match |
| Semi-diameter, surface 37 (mm)Zemax: DIAM stored in the .ZMX (computed by Zemax) | 10.9031 | 10.9054 | 0.02% | Match |
| Semi-diameter, surface 38 (mm)Zemax: DIAM stored in the .ZMX (computed by Zemax) | 0.1461 | 0.1461 | 0.00% | Match |
| Semi-diameter, surface 39 (mm)Zemax: DIAM stored in the .ZMX (computed by Zemax) | 0.1404 | 0.1404 | 0.00% | Match |
Zemax angle scan: PSF width and focus shift
Blocked in OptilandThe 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).


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



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 surface | Comment | Zemax (mm) | Optiland (mm) | Ratio | |
|---|---|---|---|---|---|
| 1 | MEASURED: ~2.0mm beam | 2.1950 | 2.1950 | 1.0000 | |
| 4 | 3.1042 | 3.1084 | 1.0014 | ||
| 26 | 16.9749 | 16.9776 | 1.0002 | ||
| 30 | 16.8994 | 16.9020 | 1.0002 | ||
| 34 | dichroic | 15.9890 | 16.0048 | 1.0010 | |
| 35 | READ SEMI-DIAMETER HERE | 16.5586 | 16.5750 | 1.0010 | |
| 36 | Target is 2*2.5mm | 11.0323 | 11.0346 | 1.0002 | |
| 37 | 10.9031 | 10.9054 | 1.0002 | ||
| 38 | 0.1461 | 0.1461 | 1.0000 | ||
| 39 | 0.1404 | 0.1404 | 1.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 # | Comment | Type | Radius, Zemax (mm) | Radius, Optiland (mm) | Thickness (mm) | Glass | Semi-diameter (mm) | Clear aperture (mm) |
|---|---|---|---|---|---|---|---|---|
| 0 | 1mm diameter laser X2 magn. | STANDARD | ∞ | ∞ | ∞ | 0 | ||
| 1 | MEASURED: ~2.0mm beam | STANDARD | ∞ | ∞ | 20 | 2.195 | 1 | |
| 4 | STANDARD | ∞ | ∞ | 0 | MIRROR | 3.104 | ||
| 7 | STANDARD | ∞ | ∞ | -2.5 | BK7 | 25.4 (fixed) | 25.4 | |
| 8 | KPC070AR.16 | STANDARD | -103.36 | -103.36 | -4.599 | 25.4 (fixed) | 25.4 | |
| 9 | LB1199-B | STANDARD | -204.98 | -204.98 | -6.16 | N-BK7 | 25.4 (fixed) | 25.4 |
| 10 | STANDARD | 204.98 | 204.98 | -5 | 25.4 (fixed) | 25.4 | ||
| 11 | AC508-200-B | STANDARD | -134 | -134 | -8.2 | N-LAK22 | 25.4 (fixed) | 25.4 |
| 12 | STANDARD | 109.2 | 109.2 | -5 | N-SF6HT | 25.4 (fixed) | 25.4 | |
| 13 | The SL-TL telescope | STANDARD | 515.2 | 515.2 | -2 | 25.4 (fixed) | 25.4 | |
| 14 | is exactly 2X | STANDARD | -515.2 | -515.2 | -5 | N-SF6HT | 25.4 (fixed) | 25.4 |
| 15 | see Disatnce2 file | STANDARD | -109.2 | -109.2 | -8.2 | N-LAK22 | 25.4 (fixed) | 25.4 |
| 16 | AC508-200-B | STANDARD | 134 | 134 | -72.3 | 25.4 (fixed) | 25.4 | |
| 18 | STANDARD | ∞ | ∞ | 0 | MIRROR | 38.1 (fixed) | 38.1 | |
| 21 | STANDARD (stop) | ∞ | ∞ | 0 | MIRROR | 38.1 (fixed) | 38.1 | |
| 23 | STANDARD | -1330.5 | -1330.5 | -2 | SF2 | 25.4 (fixed) | 25.4 | |
| 24 | STANDARD | -336 | -336 | -4.5 | N-BK7 | 25.4 (fixed) | 25.4 | |
| 25 | AC508-750-A | STANDARD | 417.8 | 417.8 | -4 | 25.4 (fixed) | 25.4 | |
| 26 | STANDARD | ∞ | ∞ | -0 | 16.975 | |||
| 27 | STANDARD | -1330.5 | -1330.5 | -2 | SF2 | 25.4 (fixed) | 25.4 | |
| 28 | STANDARD | -336 | -336 | -4.5 | N-BK7 | 25.4 (fixed) | 25.4 | |
| 29 | STANDARD | 417.8 | 417.8 | -4 | 25.4 (fixed) | 25.4 | ||
| 30 | STANDARD | ∞ | ∞ | -215.3 | 16.899 | |||
| 32 | STANDARD | ∞ | ∞ | -0 | MIRROR | 38.1 (fixed) | 38.1 | |
| 34 | dichroic | STANDARD | ∞ | ∞ | 1.1 | N-BK7 | 15.989 | |
| 35 | READ SEMI-DIAMETER HERE | STANDARD | ∞ | ∞ | 50 | 16.559 | ||
| 36 | Target is 2*2.5mm | STANDARD | ∞ | ∞ | 7.2 | 11.032 | 10 | |
| 37 | PARAXIAL | ∞ | ∞ | 7.2 | 10.903 | |||
| 38 | STANDARD | ∞ | ∞ | 0.0071 | 0.146 | |||
| 39 | STANDARD | ∞ | ∞ | 0 | 0.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.
| System | What it is | Tests |
|---|---|---|
| As authored | The file untouched, at every galvo angle | Optiland, 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.