8000 GitHub - edavidfs/optiland: Lens design, optimization, and analysis in Python
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

edavidfs/optiland

 
 

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
  • Apodization Support
  • 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

About

Lens design, optimization, and analysis in Python

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%
0