Docs / Lens design

Lens design

Design, optimise, and tolerance optical systems with real glass catalogs and automatic damped least-squares optimisation.

What is lens design?

Lens design is the process of choosing the right sequence of surfaces, glasses, and spacings to form a sharp, clear image of an object. In a perfect world, a single thin piece of glass would do this flawlessly. In reality, light of different wavelengths bends differently (dispersion), and spherical surfaces don't bring all rays to the same focus (spherical aberration).

In Photonica, you don't just simulate what an existing lens does—you can actively design new ones by defining variables and letting the optimiser find the best parameters to meet your targets.

The thick-lens equation

While thin-lens approximations are useful for sketches, Photonica calculates precise ray traces using exact trigonometric ray tracing. However, for initial paraxial setup, the thick lens equation is used to compute focal length and principal planes:

P = P₁ + P₂ − P₁ P₂ d / n

Where P is the total optical power, P₁ and P₂ are the powers of the front and back surfaces, d is the center thickness, and n is the refractive index of the glass.

Aberrations

Aberrations are departures from perfect imaging. Photonica calculates and displays these in real-time.

  • Spherical Aberration: Marginal rays focus closer to the lens than paraxial rays.
  • Chromatic Aberration: Different wavelengths (colors) focus at different distances due to dispersion.
  • Coma: Off-axis light rays form a comet-like tail rather than a sharp spot.

The quickest way to evaluate aberrations in Photonica is by looking at the Spot Diagram, which traces a grid of rays from a single point source and plots where they intersect the image plane.

The Optimiser

Photonica features a built-in damped least-squares (DLS) optimiser. You define a merit function—a single number that represents how "bad" the lens is—and the optimiser adjusts variables to minimize it.

MF = Σ Wᵢ (Tᵢ − Vᵢ)²Wᵢ = weight, Tᵢ = target, Vᵢ = current value

Variables and Operands

VariablesOperands (Targets)
Radius of curvature / CurvatureRMS Spot Size (Radial or X/Y)
Thickness / Air spacingEffective Focal Length (EFL)
Conic constant (Aspheres)Collimation / Beam divergence
Tilt (X, Y)Chromatic focus shift
Decenter (X, Y)Magnification

Designing an Achromat

A classic exercise is designing an achromatic doublet—a lens made of two different glasses that brings two wavelengths (usually red and blue) to the same focus, significantly reducing chromatic aberration.

  1. Start with a singlet: Place a single biconvex lens using N-BK7 glass. Aim for a 100 mm focal length. Look at the spot diagram for white light; you'll see a large chromatic blur.
  2. Add a second element: Append a diverging element made of a high-dispersion flint glass, like F2.
  3. Set variables: Make the front radius, the cemented radius, and the back radius variable.
  4. Set operands: Set a target for an EFL of 100 mm, and target 0 RMS spot size across three wavelengths (486 nm, 587 nm, 656 nm).
  5. Optimise: Run the optimiser. The lenses will bend to balance the positive power of the crown glass with the negative power of the flint, correcting the chromatic error.

Tolerancing

A lens that works in simulation might be impossible to build. Manufacturing always introduces errors. Photonica includes a Monte-Carlo tolerancing engine to predict real-world yield.

You specify tolerances for radii, thicknesses, tilts, and decenters. Photonica then generates hundreds of random, perturbed systems. For each system, it can optionally adjust a compensator (like the final detector position, simulating a technician refocusing the lens) before evaluating the final performance.

Zemax Import

If you already have designs from industry-standard tools, you don't need to rebuild them from scratch. Photonica supports importing .zmx lens prescriptions.

Drag and drop a .zmx file into the window. Photonica will map standard surfaces, glasses, and apertures.

Next steps