Table of Contents
Optiland provides a flexible Python interface for optical system designโwhether you're tracing rays through traditional lenses or training differentiable models with PyTorch. It supports both classical engineering workflows and cutting-edge research needs.
It lets you:
- โ๏ธ Build lens and mirror systems with a clean, object-oriented API
- ๐ Trace rays through multi-surface optical assemblies, including aspherics and freeforms
- ๐ Analyze paraxial properties, wavefront errors, PSFs/MTFs, and scatter behavior
- ๐ง Optimize via traditional merit functions or autograd-enabled differentiable backends
- ๐จ Visualize interactively in 2D (Matplotlib) and 3D (VTK)
Under the hood, Optiland uses NumPy for fast CPU calculations and PyTorch for GPU acceleration and automatic differentiation. Switch between engines depending on your use caseโwith the same interface.
Python code to generate this 3D visualization:
from optiland.samples.objectives import ReverseTelephoto
lens = ReverseTelephoto()
lens.draw3D()
๐ Quickstart
- ๐ Quickstart Tutorial โ build your first lens in 5 minutes
- ๐ Full Learning Guide โ in-depth guide to mastering Optiland
- ๐ผ๏ธ Example Gallery โ visual showcase of designs and core features
- ๐ Cheat Sheet - an up-to-date cheat sheet to get you started ASAP with your first optical system
Optiland's full documentation is available on Read the Docs.
Whether you're just getting started or exploring advanced features, here are the best entry points:
- ๐ Quick Start: The Cheat Sheet offers a concise overview of core concepts and commands.
- ๐งช Example Gallery: Browse the Gallery for real-world lens designs, visualizations, and analysis workflows using Optiland.
- ๐ ๏ธ Developer Resources:
- The Developer's Guide explains the internal architecture and design of Optiland.
- The API Reference provides detailed documentation for all public classes, functions, and modules.
-
Core only
pip install optiland
-
With CPUโonly PyTorch
pip install optiland[torch]
-
GPUโenabled PyTorch
- After installing Optiland, install a CUDA build of PyTorch manually:
pip install optiland pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
For more details, see the installation guide in the docs.
-
Differentiable & Configurable Backends
Swap seamlessly between NumPy (CPU) and PyTorch (GPU + autograd). Enables integration of optical simulations into ML/DL pipelines. -
Flexible Lens Construction
Easily define optical systems, with support for spherical, aspheric, and freeform geometries. -
2D and 3D Visualization
Visualize optical layouts with matplotlib and VTK. -
Ray Tracing (Paraxial and Real)
Supports paraxial approximations and full real-ray tracing, with accurate handling of aspheric and freeform surfaces. -
Polarization Ray Tracing
Track polarization effects using vectorial ray tracing, including birefringence and coating interactions. -
Aberration and Paraxial Analysis
Tools for classical paraxial analysis and low-order aberration extraction, including chief and marginal ray tracing. -
Full Real Analysis Suite
Compute spot diagrams, OPD and ray aberration fans, PSF, MTF, and Zernike coefficients across fields and wavelengths. -
Material and Glass Catalogues
Built-in access to refractiveindex.info data, plus support for custom material models. -
Design Optimization
Local gradient-based and global stochastic optimization, with customizable merit functions and constraint handling. -
Tolerancing Framework
Monte Carlo and sensitivity analyses for evaluating robustness under manufacturing and alignment variations. -
Coating and Scattering Support
Evaluate BSDF-based surface scatter and multilayer coatings using both built-in and user-defined models. -
Zemax File Import
Convert legacy designs from Zemax files into Optilandโs internal representation for further simulation or analysis.
The code itself is in constant flux and new functionalities are always being added.
This guide gives a step-by-step approach to learning how to use Optiland.
- Introduction to Optiland
- Tutorial 1a - Optiland for Beginners
- Lens entry
- Material selection
- Aperture, field and wavelength selection
- Drawing a lens in 2D and 3D
- Tutorial 1b - Determining Lens Properties
- Focal length
- Magnification
- F-Number, Entrance/Exit pupil sizes & positions
- Focal, Principal, and Nodal points, etc.
- Tutorial 1c - Saving and Loading Lenses
- Saving and loading lens files in a json format
- Tutorial 1d - Using the Material Database
- Defining materials for glass, chemicals, organics, gases, or using ideal or parameterized materials.
- Tutorial 1e - Non-rotationally Symmetric Systems
- Coordinate systems in Optiland and how to design non-rotationally symmetric systems
- Tutorial 1f - Differentiable Raytracing Hello World
- Your first steps with DRT using the PyTorch backend.
- Tutorial 1a - Optiland for Beginners
- Real Raytracing & Analysis
- Tutorial 2a - Tracing & Analyzing Rays
- How to trace rays through a system
- Analyzing ray paths & properties
- Tutorial 2b - Tilting & De-centering Components
- Tracing rays through misaligned components
- Tutorial 2c - Monte Carlo Raytracing Methods
- How variations in lens properties impact lens performance
- Tutorial 2d - Aspheric Components
- Modeling even aspheres
- Tutorial 2a - Tracing & Analyzing Rays
- Aberrations
- Tutorial 3a - Common aberration analyses/plots
- Spot diagrams
- Ray fans
- Y-Ybar plots
- Distortion / Grid distortion plots
- Field curvature plots
- RMS spot size & wavefront error vs. field
- Pupil aberration
- Tutorial 3b - 1st & 3rd-Order Aberrations
- Calculation of seidel, 1st & 3rd-order aberrations
- Tutorial 3c - Chromatic Aberrations
- Achromatic doublet to reduce chromatic aberrations
- Tutorial 3a - Common aberration analyses/plots
- Optical Path Difference (OPD), Point Spread Functions (PSF) & Modulation Transfer Function (MTF)
- Tutorial 4a - Optical Path Difference
- OPD fans and plots
- Tutorial 4b - PSF & MTF Calculation
- Geometric MTF
- FFT-based PSF/MTF
- Huygens PSF
- Tutorial 4c - Zernike Decomposition
- Decomposing wavefront using Zernike polynomials
- Coefficient types: Zernike standard, Zernike fringe, Zernike Noll
- Tutorial 4a - Optical Path Difference
- Optimization
- Tutorial 5a - Simple Optimization
- Operand and variable definition
- Local optimization
- Tutorial 5b - Advanced Optimization
- Global optimization
- Tutorial 5c - Optimization Case Study
- Complete process of designing a Cooke triplet
- Tutorial 5d - User-defined Optimization Metrics
- Customized optimization
- Tutorial 5a - Simple Optimization
- Coatings & Polarization
- Tutorial 6a - Introduction to Coatings
- Simple coatings in Optiland
- Impact of coatings on system performance
- Tutorial 6b - Introduction to Polarization
- Basics of polarization in Optiland
- Analyzing polarization performance
- Tutorial 6a - Introduction to Coatings
- Advanced Optical Design
- Tutorial 7a - Lithographic Projection System
- Optimizing and Analyzing a Complex Lithography System
- Tutorial 7b - Surface Roughness & Scattering
- Lambertian and Gaussian scatter models
- Tutorial 7c - Freeform Surfaces
- Designing non-standard optical systems with freeform surfaces
- Tutorial 7d - Three Mirror Anastigmat
- Off-axis reflective telescope with freeform surfaces
- Tutorial 7a - Lithographic Projection System
- Tolerancing
- Tutorial 8a - Introduction to Tolerancing
- Sensitivity studies
- Tutorial 8b - Advanced Tolerancing
- Monte Carlo-based Tolerancing
- Tutorial 8a - Introduction to Tolerancing
- Lens Catalogue Integration
- Tutorial 9a - Edmund Optics Catalogue
- Reading Zemax files
- Reading and analyzing an aspheric lens
- Tutorial 9b - Thorlabs Catalogue
- Reading and analyzing an achromatic doublet pair lens
- Tutorial 9a - Edmund Optics Catalogue
- Extending Optiland
- Tutorial 10a - Custom Surface Types
- Adding new surface types
- Tutorial 10b - Custom Coating Types
- Adding new coating types
- Tutorial 10c - Custom Optimization Algorithms
- Creating a "random walk optimizer" to optimize an aspheric singlet
- Tutorial 10a - Custom Surface Types
- Machine Learning in Optical Design - note that these notebooks are hosted in the LensAI repository
- Tutorial 11a - Random Forest Regressor to Predict Optimal Lens Properties
- Demonstrates how to build and train a random forest regressor to predict the radius of curvature of a plano-convex lens in order to minimize the RMS spot size.
- Tutorial 11b - Ray Path Failure Classification Model
- Uses logistic regression to predict ray path failures in a Cooke triplet design.
- Tutorial 11c - Surrogate Ray Tracing Model Using Neural Networks
- Builds a neural network surrogate ray tracing model to increase effective "ray tracing" speed by 10,000x.
- Tutorial 11d - Super-Resolution Generative Adversarial Network to Enhance Wavefront Map Data
- Utilizes a super-resolution GAN (SRGAN) to upscale low-resolution wavefront data into high-resolution data.
- Tutorial 11e - Optimization of Aspheric Lenses via Reinforcement Learning
- Reinforcement learning is applied to the optimization of aspheric singlet lenses to generate new lens designs.
- Tutorial 11a - Random Forest Regressor to Predict Optimal Lens Properties
Optiland is continually evolving to provide new functionalities for optical design and analysis. Below are some of the planned features and enhancements we aim to implement in future versions:
- GUI (PySide6-based)
- Multi-Path Sequential Ray Tracing
- Multiple Configurations (Zoom Lenses)
- Thin Film Design and Optimization
- Diffractive Optical Elements
- Additional Backends: JAX, CuPy
- Jones Pupils
- Additional Freeforms (Superconic, etc.)
- Image Simulation
- Huygens MTF
- Interferogram Analysis
- Additional Tutorials/Examples
- Non-sequential ray tracing
- Glass Expert
- Insert your idea here...
Welcome, contributors! This section outlines the major features and tasks that are currently in progress. To avoid duplicated effort, please check this table and the linked GitHub Issues before starting on a new feature. If you'd like to take on an unassigned help wanted
task, please comment on the relevant issue first.
Feature / Topic | Contributor(s) | Status | Discussion / Issue |
---|---|---|---|
Core | |||
Forbes Surface Type | @manuelFragata | ๐ง In Progress | - |
Multi Sequence Tracing | @HarrisonKramer | ๐ Under Review | #89 |
Image Simulation Analysis | @HarrisonKramer | ๐ง In Progress | #153 |
Diffraction Gratings and DOEs | Seeking contributor(s) | โจ Help Wanted | #161 #188 |
Analysis & Visualization | |||
Sag Surface Analysis | @manuelFragata | ๐ง In Progress | #183 |
GUI | |||
GUI First Iteration | @manuelFragata | โ Done | - |
GUI - Console/Terminal | @manuelFragata | ๐ง In Progress | - |
Status Key:
- โจ Help Wanted: We are actively looking for contributors for this task!
- ๐ง In Progress: Actively being worked on.
- ๐ Under Review: A pull request has been submitted and is being reviewed.
- ๐ Blocked: Progress is blocked by another issue.
- โ Done: Completed and merged. (You can remove these after a while).
We welcome suggestions for additional features! If there's something you'd like to see in Optiland, feel free to open an issue or discussion.
Distributed under the MIT License. See LICENSE for more information.
If you have questions, find a bug, have suggestions for new features, or need help, please open an issue in the GitHub repository. This ensures that your concern is visible to others, can be discussed collaboratively, and helps build a public archive of solutions for similar inquiries in the future.
While I prefer issues as the primary means of communication, you may also contact me via email if necessary.
Kramer Harrison - kdanielharrison@gmail.com