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

Optiland GUI

Screenshot of Optilandโ€™s GUI showing a reverse telephoto system.

Table of Contents
  1. Introduction
  2. Documentation
  3. Installation
  4. Functionalities
  5. Functionalities
  6. Roadmap
  7. Roadmap
  8. License
  9. 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, and includes a powerful graphical interface for interactive design and analysis (see above).

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.

๐Ÿš€ 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
  • Core + GUI

    pip install optiland[gui]
  • 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 at a Glance

Feature Category Capabilities
๐Ÿ› ๏ธ Design & Modeling Build systems using spherical, aspheric, conic, and freeform surfaces. Configure fields, wavelengths, apertures.
๐Ÿงฎ Differentiable Core Switch between NumPy (CPU) and PyTorch (GPU/autograd) seamlessly for hybrid physics-ML workflows.
๐Ÿ”ฌ Ray Tracing Trace paraxial and real rays through sequential systems with support for polarization, birefringence, and coatings.
๐Ÿ“Š Optical Analysis Generate spot diagrams, wavefront error maps, ray fans, PSF/MTF plots, Zernike decompositions, distortion plots, etc.
๐Ÿง  Optimization Local & global optimizers, autograd support, operand-based merit functions, and GlassExpert for categorical variable search.
๐Ÿ“ˆ Tolerancing Monte Carlo and parametric sensitivity analysis to evaluate robustness and manufacturability.
๐Ÿ“š Material Library Integrated access to refractiveindex.info. Support for custom dispersion models and material creation.
๐Ÿ–ผ๏ธ Visualization 2D plots via matplotlib, 3D interactive scenes with VTK, and debugging tools to inspect ray behavior.
๐Ÿงฉ Interoperability Import Zemax files, save/load systems in JSON, use full Python API for scripting and automation.
๐Ÿš€ Performance GPU-accelerated ray tracing (150M+ ray-surfaces/s), Numba-optimized NumPy backend, JIT-compiled computations.
๐Ÿค– ML Integration Compatible with PyTorch pipelines for deep learning, differentiable modeling, and end-to-end training.

โœจ For a full breakdown of Optilandโ€™s functionalities, see the complete feature list.

Note

The code itself is in constant flux and new functionalities are always being added.

Learning Guide

Optiland has a rich set of tutorials and guides to help you learn optical design, analysis, and optimization step-by-step.

๐Ÿ‘‰ View the Learning Guide ยป

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) - Initial version available, ongoing enhancements.
  • 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
  • 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 GitHub Issues before starting work. If youโ€™d like to work on something, comment on the issue to let others know. You can find more about how to coordinate in our contributing guide.

Feature / Topic Contributor(s) Status Discussion / Issue
Core
Forbes Surface Type @manuelFragata ๐Ÿšง In Progress -
(extended) Sources @manuelFragata ๐Ÿšง In Progress #224
Multi Sequence Tracing @HarrisonKramer ๐Ÿ” Under Review #89
Image Simulation Analysis @HarrisonKramer ๐Ÿšง In Progress #153
Diffraction Gratings and DOEs @Hhsoj @mattemilio ๐Ÿšง In Progress #161 #188 #225
Paraxial to Thick Lens @HarrisonKramer ๐Ÿšง In Progress #221
Analysis & Visualization
Huygens MTF @HarrisonKramer ๐Ÿšง In Progress #222
Sag Surface Analysis @manuelFragata โœ… Done #183
GUI
GUI First Iteration @manuelFragata โœ… Done -
GUI - Console/Terminal @manuelFragata โœ… Done -

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

Contributing

We welcome contributions of all kinds โ€” features, bugfixes, docs, and discussions! ๐ŸŽ‰

To get started, please check out the contributing guide for best practices and coordination tips.

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 - [email protected]