Documentation

Engineering

Lens design & the optimiser

Designing a lens is choosing surfaces that satisfy several demands at once. Photonica does it the way commercial design codes do: a merit function, and damped least squares to minimise it.

The Optimise and tolerance panel mid-design
Demo 16, 'Design an achromat': three operands, five variables, converged in seven iterations.

How it works

You give the optimiser two lists. Variables are the things it may change. Operands are the things you want to be true. Every operand contributes weight × (value − target) to the merit function; spot-size operands add one residual per traced ray. The solver then walks downhill until it cannot improve further.

Variables

VariableChanges
curv1 / curv2The curvature (1/R) of the front or back surface. Bounded so the surface still covers the aperture
thicknessCentre thickness, keeping the front vertex fixed
axialPosition along the part’s own optical axis
conic1 / conic2Conic constant of a surface — how aspheric it is
a4_1 / a4_2The fourth-order aspheric term
tilt / pitchYaw and pitch of the element
screen_axialWhere the screen sits — the classic refocus compensator

Operands

OperandTargets
spot_screenRMS spot size on a screen. Target 0 for the sharpest possible image
spot_best_focusRMS spot at the system’s own best focus, ignoring where the screen is
eflEffective focal length in mm
collimationSpread of the outgoing ray angles — target 0 for a perfectly parallel output
width_ratioOutput beam width ÷ input width, for beam expanders
beam_deviationHow far the beam has been turned, in degrees
chromatic_focusBlue-minus-red focal shift. Target 0 to make an achromat

A worked example

To build an achromatic doublet — a lens with a chosen focal length and no first-order colour error:

  1. Put a positive crown-glass lens and a negative flint-glass lens close together on the beam.
  2. Add variables: curv1 and curv2 on both elements.
  3. Add operands: efl with your target focal length, chromatic_focus targeting 0, and spot_best_focus targeting 0 to keep it sharp.
  4. Give the focal length a low weight (0.05 is enough — it is easy to hit) and the others 1.
  5. Press OPTIMISE.

The merit log shows the value falling per iteration. Demo 16 does exactly this and improves the merit by a factor of 1320 in seven iterations. Undo puts the design back if you do not like where it went.