Quickstart
This guide walks through the core AutoLens workflow: loading a lens, analyzing its performance, tracing rays, and running optimization.
Load a Lens
GeoLens is the primary lens model — a differentiable multi-element refractive lens loaded from a JSON, Zemax .zmx, or Code V .seq file.
Analyze a Lens
Run a full optical analysis — spot diagrams, RMS error, MTF, distortion, and ray fan plots:
For individual evaluations:
# Spot diagram across field
lens.draw_spot_map()
# MTF curves
lens.draw_mtf()
# 2D lens layout with ray fans
lens.draw_layout()
Trace Rays
Sample rays from a point source at a given field angle and trace them through the lens:
# Sample rays at 10-degree half-field angle
ray = lens.sample_from_fov(fov_x=0.0, fov_y=10.0, num_rays=1000, wvln=0.587)
# Trace to sensor
ray_out = lens.trace2sensor(ray)
# RMS spot size
print(f"RMS: {ray_out.rms_error().item():.4f} mm")
Compute a PSF
The point spread function (PSF) describes how the lens images a point source at a given field angle and wavelength.
# Geometric PSF at on-axis field
psf = lens.psf(point=[0.0, 0.0, -20000.0], ks=64, wvln=0.587)
# PSF map across the full field
psf_map = lens.psf_map(ks=64)
Optimize a Lens
Fine-tune an existing lens design using gradient descent:
lens = GeoLens(filename="lens_zoo/cellphone.json")
lens.optimize(
lrs=[1e-3, 1e-4, 1e-2, 1e-4], # [lr_d, lr_c, lr_k, lr_ai]
iterations=500,
test_per_iter=50,
result_dir="results/optimize",
)
Key Optical Parameters
| Parameter | Description | Typical Range |
|---|---|---|
foclen |
Effective focal length (mm) | 3 -- 200 |
fnum |
F-number (focal length / aperture diameter) | 1.4 -- 8.0 |
rfov |
Half-diagonal field of view (radians) | 0.1 -- 1.0 |
sensor_size |
Physical sensor size, W x H (mm) | 5 x 5 -- 43 x 43 |
d_sensor |
Back focal distance (mm) | 1 -- 100 |
Next Steps
- Architecture — how the optimization pipeline works
- API Reference — full documentation for all classes
- Examples — automated design, batch optimization, and more