Skip to content

Comprehensive optical design, optimization, and analysis in Python, including GPU-accelerated and differentiable ray tracing via PyTorch.

License

Notifications You must be signed in to change notification settings

HarrisonKramer/optiland

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Tests Documentation Status codecov Maintainability Stars License: MIT DOI Python Versions

Table of Contents
  1. Introduction
  2. Documentation
  3. Installation
  4. Functionalities
  5. Learning Guide
  6. Roadmap
  7. License
  8. Contact and Support

Introduction

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.

U.S. patent 2959100

Python code to generate this 3D visualization:

from optiland.samples.objectives import ReverseTelephoto
lens = ReverseTelephoto()
lens.draw3D()

๐Ÿš€ Quickstart

  1. ๐ŸŒŸ Quickstart Tutorial โ€“ build your first lens in 5 minutes
  2. ๐Ÿ“š Full Learning Guide โ€“ in-depth guide to mastering Optiland
  3. ๐Ÿ–ผ๏ธ Example Gallery โ€“ visual showcase of designs and core features
  4. ๐Ÿ“ Cheat Sheet - an up-to-date cheat sheet to get you started ASAP with your first optical system

Documentation

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.

Installation

  • 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.

Key Features

  • 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.

Learning Guide

This guide gives a step-by-step approach to learning how to use Optiland.

  1. Introduction to Optiland
  2. Real Raytracing & Analysis
  3. Aberrations
  4. Optical Path Difference (OPD), Point Spread Functions (PSF) & Modulation Transfer Function (MTF)
  5. Optimization
  6. Coatings & Polarization
  7. Advanced Optical Design
  8. Tolerancing
  9. Lens Catalogue Integration
  10. Extending Optiland
  11. Machine Learning in Optical Design - note that these notebooks are hosted in the LensAI repository

Roadmap

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...

Currently Under Development

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).

Community Contributions

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.

License

Distributed under the MIT License. See LICENSE for more information.

Contact and Support

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