Open Tools · Lenstrain

Lenstrain user guide

The Lenstrain user guide: entering surfaces and glasses, sign conventions, first-order results, Seidel sums, spot diagrams and ray fans, Gaussian beam propagation, detector sampling, files, limits and verification. To use the tool itself, open Lenstrain.

Professional use. Results are for education and preliminary design. They must be checked by a qualified professional, and they are not a substitute for code-compliant design or licensed engineering judgement.

Lenstrain is a sequential ray-tracing bench for rotationally symmetric lens systems. You enter the prescription surface by surface, choose the glasses, the object, the field and the wavelengths, and Lenstrain reports the first-order properties, the Seidel third-order aberration sums, exact-ray spot diagrams, ray fans and through-focus behaviour. Two further workspaces reuse the same model: Gaussian beam propagation through thin lenses and an imaging and detector calculator. This Guide is the reference for every panel, the conventions, the limits and how the numbers are verified.

Start in two minutes

  1. Open Examples and pick a system, or keep the plano-convex fused-silica singlet.
  2. In the Prescription table edit radii, conic constants, thicknesses, glasses and semi-diameters; tick the surface that is the aperture stop. Below it set the object (infinity or a finite distance), the field (half angle or object height) and the wavelengths, and select the primary one.
  3. The Layout workspace redraws after every edit with three rays per field. First order lists focal lengths, principal planes, pupils and magnification at every wavelength. Aberrations shows the Seidel table, spot diagrams, ray fans and the through-focus curve.
  4. Gaussian beam propagates a laser beam through thin lenses; Imaging turns a focal length, f-number and pixel pitch into field of view, sampling, diffraction, depth of field and signal-to-noise.
  5. Save the project as a JSON file, export the prescription, the spot data or the Seidel table as CSV, and any chart as SVG or PNG. Your work is also kept in this browser between visits.

Conventions and units

Light travels from left to right along +z. Every length you type is in millimetres, wavelengths in nanometres and angles in degrees; the model behind the screen is stored in SI units and the display only converts.

  • Radius of curvature is positive when the centre of curvature lies to the right of the vertex (a surface convex toward the object has a positive radius). A radius of 0 means a flat surface.
  • Conic constant k: 0 sphere, −1 paraboloid, below −1 hyperboloid, between −1 and 0 a prolate ellipsoid, above 0 an oblate ellipsoid. The surface is z = c r² / (1 + √(1 − (1 + k) c² r²)) with c = 1/R.
  • Thickness is the axial distance from a surface vertex to the next vertex. The last thickness reaches the image plane; with "place the image plane at the paraxial focus" ticked it is solved from the primary-wavelength marginal ray and shown as solved.
  • Glass is the medium after the surface; air has index 1. Object space is always air.
  • Semi-diameter is the clear aperture radius. A ray that lands outside it is counted as vignetted and excluded from spot statistics. Consecutive surfaces must not intersect inside their common aperture; a prescription whose surfaces overlap (for example a curved pair with zero thickness) is refused with the off-axis height where they meet.
  • Stop: exactly one surface is the aperture stop; a prescription without one is refused, and deleting the stop surface moves the stop to a neighbouring surface with a message. The marginal ray fills its semi-diameter; the entrance pupil is its paraxial image in object space and exact rays are aimed at the stop itself (real pupil aiming), so edge rays cross the stop at its rim even when pupil aberration is large.
  • Field: for an object at infinity the half field angle in degrees (the chief ray slope is tan θ); for a finite object the object height. Spot diagrams and fans are computed at 0 %, 70 % and 100 % of the field.
  • Paraxial slopes are u = dy/dz, negative when a ray heads toward the axis. The sign conventions of the Seidel sums are stated in the Aberrations section.

The prescription and glasses

The Prescription table holds up to 50 surfaces. Use the arrows to reorder, + to insert after a row and × to delete; every edit is validated by the engine before it is applied, so an impossible entry (a semi-diameter larger than the surface can reach, a missing glass, a negative thickness) is refused with a message and the previous value stays.

Glasses are yours to enter. Lenstrain ships no manufacturer catalogue. A glass can be:

ModelWhat you enterNotes
Constant indexnNo dispersion; colour sums are zero
n_d and V_dn_d at 587.56 nm and the Abbe number, optionally a validity rangeA two-term Cauchy fit through the d, F and C lines; good for generic "crown" or "flint" studies. Valid over 365–1014 nm by default (the i to t lines), refused outside
SellmeierB₁..B₃, C₁..C₃ (µm) and a validity rangen² − 1 = Σ Bᵢ λ²/(λ² − Cᵢ²). Outside the range the engine refuses the wavelength rather than extrapolating
CauchyA, B (µm²), C (µm⁴) and a validity rangen = A + B/λ² + C/λ⁴

Four example materials are available from Add example…: fused silica and calcium fluoride with the Sellmeier coefficients published by Malitson (1965 and 1963), and two generic glasses defined only by n_d and V_d. The source field records where your data came from and is written into saved projects. The First order workspace lists the index of every glass at every wavelength actually used.

Wavelengths: 1 to 8 values between 100 nm and 20 µm. The primary wavelength defines the image plane solve, the Seidel sums and the layout rays; the shortest and longest define the colour sums.

First-order results

All first-order quantities come from a paraxial y–u trace: refraction n′u′ = nu − yφ with φ = (n′ − n)c and transfer y₊ = y + t u′. Two base rays (y₁ = 1, u₁ = 0 and y₁ = 0, u₁ = 1) give the system matrix; the marginal ray is scaled to fill the stop and the chief ray is the full-field ray through the stop centre.

  • EFL is the image-space focal length n′/Φ (positive converging). BFL runs from the last vertex to the rear focal point and FFL from the front focal point to the first vertex. The principal planes H and H′ are given relative to the first and last vertices, positive to the right; nodal points coincide with them unless the image medium differs from air.
  • Paraxial image distance is where the marginal ray from the object entered crosses the axis, measured from the last vertex; it is negative for a virtual image. Magnification is n u₁/(n′ u′) for finite objects.
  • Entrance and exit pupils are the images of the stop in object and image space, found from the paraxial ray through the stop centre; they do not depend on the field or the object, so they are defined at zero field too. Their diameters are twice the marginal height there. f-number is EFL / entrance pupil diameter; the working f-number is 1/(2 n′|u′|) and applies at any conjugate.
  • The Lagrange invariant H = n(ū y − u ȳ) is the same at every surface; the paraxial ray table shows y, u, u′ for both rays and the refraction invariants A = n(yc + u) and Ā.
  • An afocal system (zero power) is reported with ∞ for the focal quantities and a warning; enter the last thickness by hand in that case.

The table repeats every quantity at every wavelength, so axial colour is visible directly as the change of back focal length.

Aberrations: Seidel sums, spots, fans, focus

Seidel sums

For each surface Lenstrain evaluates, from the paraxial marginal and chief rays at the primary wavelength:

SumFormulaMeaning
S_I−A² y Δ(u/n)spherical aberration
S_II−A Ā y Δ(u/n)coma
S_III−² y Δ(u/n)astigmatism
S_IV−H² c Δ(1/n)Petzval field curvature
aspheric term(n′ − n) k c³ y⁴ added to S_I, times ȳ/y, (ȳ/y)², (ȳ/y)³ for S_II, S_III, S_Vconic surfaces (k ≠ 0); S_IV has no aspheric term
S_V(Ā/A)(S_III + S_IV), evaluated in a division-free formdistortion
C_I, C_IIΣ A y Δ(δn/n), Σ Ā y Δ(δn/n)axial and lateral colour between the extreme wavelengths

with Δ(x) = x′ − x across the surface. The wavefront coefficients are W040 = S_I/8, W131 = S_II/2, W222 = S_III/2, W220 = (S_III + S_IV)/4 and W311 = S_V/2, also shown in waves at the primary wavelength; the Petzval radius is −H²/(n′ S_IV), negative when the field curves toward the lens.

Sign convention. With u′ the image-space marginal slope (negative for a real image), the third-order transverse ray aberration is S/(2 n′ u′) times the pupil and field powers: S_I ρ³ for spherical, 3 S_II ρ² (tangential) and S_II ρ² (sagittal) for coma, (3 S_III + S_IV) ρ and (S_III + S_IV) ρ for the astigmatic slopes, and S_V for distortion. The Verify view checks each of these relations against exact rays in the small-aperture and small-field limit. Because u′ < 0, a positive S_I means undercorrected spherical aberration (marginal rays focus short) and a negative S_V means pincushion distortion; compare signs with other software only after checking its convention. The distortion printed next to each spot diagram is measured from exact chief rays and is positive for pincushion.

Spot diagrams and statistics

Rays are launched on a hexapolar grid (a centre ray plus 6i rays on ring i of N; 6 rings = 127 rays) for every field and wavelength and intersected with the image plane. The diagram is centred on the chief ray of the first wavelength; the RMS radius is about the centroid of each wavelength's spot and the geometric radius is the largest distance from it. The dashed circle is the Airy radius 1.22 λ N_w at the working f-number, so you can see when the geometric blur falls below diffraction. Rays that miss a surface, are totally internally reflected or fall outside a semi-diameter are counted and excluded.

Ray fans

The tangential fan plots Δy against the normalised pupil coordinate p_y for rays in the meridional plane; the sagittal fan plots Δx against p_x. Both are relative to the chief ray of the same wavelength. A pure cubic is spherical aberration, an even parabola is coma, a tilted line is defocus or astigmatism and a vertical offset between wavelengths is lateral colour.

Through focus and best focus

The on-axis RMS radius at the primary wavelength is recomputed on image planes shifted around the paraxial focus, over a span set by the geometric blur and the diffraction depth of focus, and a golden-section search finds the shift of minimum RMS. The paraxial colour values are the differences of image distance and image height between the shortest and longest wavelength.

Gaussian beam workspace

The beam is a TEM₀₀ Gaussian with an optional beam quality factor M². From the waist radius w₀ (1/e² intensity), the wavelength and the medium index: Rayleigh range z_R = π w₀² n/(M² λ), beam radius w(z) = w₀ √(1 + (z/z_R)²), wavefront radius R(z) = z[1 + (z_R/z)²], Gouy phase atan(z/z_R) and far-field half-angle divergence M² λ/(π n w₀).

Thin lenses are listed by focal length and position along z (positions must increase). Propagation uses the complex beam parameter q = (z − z₀) + i z_R: free space adds the distance, a thin lens applies 1/q′ = 1/q − 1/f. Each segment between lenses reports its waist, waist position, Rayleigh range and divergence, and the chart draws the ±w(z) envelope from two Rayleigh ranges before the first waist to two after the last. The beam parameter product w₀ θ = M² λ/(π n) is conserved by every lens, which the tests check.

Limits: waist 10 nm to 1 m, M² from 1 to 1000, up to 20 lenses, positions and focal lengths within ±10 km. The paraxial beam model is accurate while the divergence is small (roughly below 0.3 rad); Lenstrain does not apply aperture clipping, aberrations or thick-lens effects to the beam, and the Gaussian workspace does not read the lens prescription.

Imaging and detector workspace

Enter the focal length and f-number (or copy them from the current lens with Use lens EFL and f/#), the pixel pitch and pixel counts, the wavelength, the object distance and the circle of confusion. Thin-lens geometry is used with distances measured from the front principal plane and a pupil magnification of 1.

  • Field of view 2 atan(W/2v) horizontally, vertically and diagonally and IFOV p/v per pixel, both measured at the image distance v = f (1 + |m|) of the conjugate entered (v = f for an object at infinity); magnification f/(s − f); GSD p/|m| and the sensor footprint in object space, so that GSD = IFOV·s and footprint = 2 s tan(FOV/2) exactly.
  • Working f-number N_w = N(1 + |m|). Airy radius 1.22 λ N_w, angular resolution 1.22 λ/D, diffraction cut-off 1/(λ N_w), Nyquist 1/(2p) and the sampling ratio Q = λ N_w/p (Q = 2 means the optics cut off exactly at Nyquist).
  • Hyperfocal distance H = f²/(N c) + f; near and far limits s(H − f)/(H + s − 2f) and s(H − f)/(H − s), derived from the exact blur circle of a thin lens (the tests find the same limits by root search). The far limit is ∞ at or beyond the hyperfocal distance.
  • Photon budget: image irradiance π τ L/(4 N_w²) from the scene radiance L (W·m⁻²·sr⁻¹) and transmission τ, photon rate E p² λ/(h c) at the single wavelength entered, signal QE × rate × exposure in electrons, shot noise √S, dark noise √(D t), read noise added in quadrature, SNR and well fill. A well fill above 100 % is flagged as saturation.

These are design-sizing relations: a real sensor's spectral response, a lens's transmission spectrum and the scene spectrum all vary with wavelength, so treat the SNR as a monochromatic estimate at the wavelength you entered.

Files, exports and autosave

Save writes a JSON project (format lenstrain, version 1) with the prescription, glasses, object, field, wavelengths, the Gaussian beam and the imaging inputs, plus the attribution and the professional-use notice. Open reads the same format back and validates it with the engine's admission rules before anything replaces your current work; other formats, newer versions and files above 2 million characters are refused with a message. No proprietary lens-design file format is read or written.

CSV exports (prescription, spot data, Seidel table) quote every text cell and neutralise cells that a spreadsheet could read as a formula. Lengths in CSV files are in millimetres and wavelengths in nanometres. Charts export as SVG or 2× PNG with a title line and the attribution footer.

Your current project is autosaved in this browser (versioned, with a migration step for older records) and restored on the next visit; an autosave written by a newer version of Lenstrain is ignored rather than guessed at. Undo and redo cover every edit; switching workspaces is not an edit.

Keyboard shortcuts

KeysAction
Ctrl/Cmd + ZUndo
Ctrl + Y or Cmd + Shift + ZRedo
Ctrl/Cmd + SSave project as JSON
Ctrl/Cmd + OOpen a project file
Ctrl/Cmd + EnterRecalculate now
Alt + 1 … Alt + 6Switch workspace
?Open or close this Guide
EscClose the Guide
F (inside a chart)Fit the whole visual

Limitations and what Lenstrain does not do

  • Rotationally symmetric, sequential systems of refracting spherical and conic surfaces only: no mirrors, tilts, decentres, gratings, aspheric polynomials, gradient-index media or non-sequential paths. Object space is air.
  • Exact rays are aimed at the stop surface from the paraxial entrance pupil with real pupil aiming; the paraxial pupil is used for the f-number and the Airy circle. Vignetting is a hard clip at each semi-diameter; no partial obscuration or apodisation.
  • Third-order (Seidel) sums are reported, not fifth-order terms; conic surfaces contribute their fourth-order aspheric term, higher aspheric polynomials are not supported. The transverse aberration relations hold in the limit of small aperture and field, which is exactly what the Verify view checks.
  • Geometric spot and RMS values only: no wavefront maps, OPD fans, MTF, PSF or encircled energy. The Airy circle is drawn for scale.
  • The Gaussian beam workspace is paraxial, aberration-free and independent of the lens prescription. The imaging workspace is a thin-lens, monochromatic sizing tool.
  • No optimisation, tolerancing or glass substitution. Glass data is user-entered; the two Sellmeier examples are the only published material data shipped.
  • Budgets: 50 surfaces, 20 glasses, 8 wavelengths, 12 spot rings, 101 fan points, 41 through-focus samples and 60,000 rays per analysis; radii at least 1 µm in magnitude or exactly 0; thickness up to 100 m; semi-diameter 0.1 µm to 10 m; refractive index 1 to 10; field up to 80° or an object height up to 10 m; object distance 1 µm to 1 km. Real pupil aiming may trace up to 12 partial rays per launched ray; the budget counts launched rays.

Lenstrain is a geometrical-optics design aid. Results depend on the prescription and glass data you enter, use paraxial pupil aiming and third-order theory where stated, and are not a substitute for review by a qualified optical engineer before manufacture or use.

How we verify this tool

Every output Lenstrain shows has at least one declared ledger comparison that does not share its formula with the engine (a test derives the list of displayed outputs from the engine and fails if one is missing), and the same case file runs in our automated tests and in the Verify workspace on your device. Each case declares exactly which outputs it compares, with an absolute and a relative tolerance; a case passes only when every declared comparison is finite and within tolerance, and a shortened or substituted result set fails.

  • Published worked examples: the thin-lens and lens-maker examples of OpenStax University Physics Volume 3 §2.4 (real, virtual and unit-magnification images; a projection lens).
  • Closed forms from cited open formulas and own derivations: the thick-lens focal length and principal-plane positions, two separated thin lenses, the ball lens with its nodal points, the Sellmeier fits for fused silica and calcium fluoride evaluated at the d line (transcription checks), the Airy radius, the image-plane illuminance law and the hyperfocal distance, entrance and exit pupil location and size for a rear stop (at zero field and for a finite object), the Lagrange invariant, the Petzval sum and radius of a thin lens, the perfect focus of an ellipsoidal surface of eccentricity 1/n (spot RMS and optical-path spread below 10⁻¹³ m), the aplanatic points of a sphere (paraxial and exact rays agree on one virtual image point), the Cartesian ellipsoid's vanishing Seidel S_I, a symmetric system at unit magnification with zero coma, distortion and lateral colour, the exact-ray distortion of a chief ray through a single surface, the paraxial colour of the plano-convex singlet, the best-focus search on a perfect focus, plane refraction, total internal reflection, the Gaussian free-space profile, the thin-lens focusing of a Gaussian beam and the M² scaling, the depth-of-field limits and the shot-noise-limited SNR.
  • Third-order limits: exact rays reproduce the Seidel predictions for spherical aberration, tangential and sagittal coma, astigmatism and field curvature, distortion for a front and a rear stop, and the two colour sums, by Richardson extrapolation toward zero aperture and field, on spherical systems and on a conic (hyperbolic/oblate) meniscus.
  • Invariants: Snell's law and the continuity of the tangential component of n·D at every surface of a skew ray, reversibility of a skew ray through a doublet, the equality of the two forms of S_V, the stop-shift identities, etendue conservation and the finite-conjugate identities GSD = IFOV·s and footprint = 2 s tan(FOV/2).
  • Independent code in the tests: a second ray tracer written with a different intersection method (Newton on the sag) and a different refraction method (normal and tangential components), paraxial optics by matrix products, depth of field by bisection on the blur circle and the Gaussian width from a numerical Fresnel integral, all compared on hundreds of seeded random inputs.

One validation case is pending source: comparison with a complete published multi-element design needs that design's glass data from a lawful source, so no number is claimed and the case is listed, skipped and never counted as a pass. Lenstrain is a draft: an independent review of the first build found and we fixed a missing aspheric term in the Seidel sums, field-dependent pupils, a silently defaulted stop and infinity-focus FOV formulas, each now pinned by a reference case; Firefox and WebKit visual checks are deferred to a cross-browser host.

Compared with other tools

Commercial optical design programs trace more surface types, optimise and tolerance; Lenstrain is a free browser bench for the analysis part of that workflow, with every result traceable to a formula register and a reference case you can run yourself, your data never leaving your device, and plain JSON and CSV files. Use it to learn, to check, to prototype and to communicate; use a qualified optical engineer and dedicated software for final designs.

Lenstrain user guide: prescriptions, ray tracing, aberrations, Gaussian beams and imaging | Simulations4All