Skip to main content

No project description provided

Project description

DiffinyTrace

DiffinyTrace is a Python library for differentiable ray tracing and optical system optimization using PyTorch. It enables automatic differentiation through optical systems, making it possible to optimize lens designs, mirror configurations, and other optical components using gradient-based methods.

The source code is available at the GitHub repository.

Key Features

Transformation example

Flexible Transformations — apply general transformations such as rotations and translations to optical components, with full control over the parameters and their role in the transformation.

CAD export example

Seamless CAD Export — generate lenses and mirrors that can be exported to standard CAD file formats.

B-spline surface example

Freeform Surfaces — design complex optical elements with advanced B-spline representations for maximum flexibility.

  • Differentiable Ray Tracing: Full automatic differentiation support through optical systems
  • Constraint Optimization: Advanced optimization with PyTorch and SciPy integration
  • Illumination Design: Algorithms for computing lens surfaces to achieve desired illumination profiles
  • GPU Acceleration: CUDA support for high-performance computations

Installation

  1. Create a new Enviroment via conda:

    conda create -n dit python==3.12
    

    activate enviroment via

    conda activate dit
    

    install pip

    conda install pip
    
  2. Install PyTorch

    Check your cuda version with

    nvcc --version
    

    Diffinytrace only has been tested with 2.10.0+cu130. Make sure to install the appropriate version of PyTorch for your system. You can find the installation instructions on the PyTorch website. DiffinyTrace should work for both cpu and cuda versions.

  3. Install DiffinyTrace Install all other dependencies and the library itself via:

    pip install diffinytrace
    

    or directly in the folder via

    pip install -r requirements.txt
    

Basic Usage Example

import diffinytrace as dit
import torch
NBK7 = dit.materials["NBK7"]

wave_len = 1.024
light_transform = dit.transforms.Offset(torch.tensor([0.0,0.0,0.0]))
source = dit.source.CollimatedMonochromatic(light_transform,8.0,wave_len)

plane_surface = dit.Plane()
surface2 = dit.Aspheric(-1/50.)
transf1 = dit.transforms.Distance(10.0,parent_transform=source)
lens1 = dit.Lens(transf1,5.,plane_surface,surface2,NBK7,13.0)
transf2 = dit.transforms.Distance(15.0,parent_transform=lens1)
detector = dit.Detector(transf2,plane_surface,8.0)
system = dit.SequentialOpticalSystem({"source":source, "lens":lens1, "detector":detector})

x,weights = source.sample(10)
O,D,wave_len,_,meta_data = system(x,["source","lens","detector"])
dit.plotting.system2D.plot(system,meta_data)

Documentation

For comprehensive documentation, tutorials, and API reference, visit the full documentation.

License

DiffinyTrace is licensed under the MIT License. See the repository for full license details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

diffinytrace-2.3.tar.gz (78.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

diffinytrace-2.3-py3-none-any.whl (91.4 kB view details)

Uploaded Python 3

File details

Details for the file diffinytrace-2.3.tar.gz.

File metadata

  • Download URL: diffinytrace-2.3.tar.gz
  • Upload date:
  • Size: 78.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.0

File hashes

Hashes for diffinytrace-2.3.tar.gz
Algorithm Hash digest
SHA256 218913c73070a2783aee5a67cd55709c02c439286774514aaa8ceefd18e71b30
MD5 4d76bc8aad9349efbb6a0fdc6b8f202e
BLAKE2b-256 9e92bb96591e12c963c89a720a5386265b049f7ee9c97f14b9f8ca99178b6b62

See more details on using hashes here.

File details

Details for the file diffinytrace-2.3-py3-none-any.whl.

File metadata

  • Download URL: diffinytrace-2.3-py3-none-any.whl
  • Upload date:
  • Size: 91.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.0

File hashes

Hashes for diffinytrace-2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 80243ffab405794fb21c992aa994a1b5d467fe4fb84cf85015f7f6c555c7fdd8
MD5 674dbc6603cdf2e3ade74be63be9a9f1
BLAKE2b-256 bad445536153a08bde880c4cc7c569dd8dcc5b6e230580ffa8ff74cbdc9e67c6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page