Skip to main content

SVETlANNa is an open-source Python library for simulation of free-space optical set-ups and neuromorphic systems such as Diffractive Neural Networks.

Project description

en ru

SVETlANNa

SVETlANNa is an open-source Python library for simulating free-space optical setups and neuromorphic systems such as Diffractive Neural Networks. It is built on the PyTorch framework, leveraging key features such as tensor-based computations and automatic differentiation.

At its core, SVETlANNa relies on Fourier optics and includes several optical elements such as free space, apertures, phase masks, thin lenses, and Spatial Light Modulators (SLMs).

The library name combines the Russian word "svet" ("light" in English) and the abbreviation ANN (artificial neural network). At the same time, the full word sounds like the Slavic female name Svetlana.

Documentation

Documentation for SVETlANNa is available at compphyslab.github.io/SVETlANNa.docs.

There is also a supporting GitHub repository, SVETlANNa.docs, containing numerous application examples in Jupyter notebook format.

Quick Start

import torch
import svetlanna as sv
from svetlanna.units import ureg

# define the computational grid and the wavelength of light
sim_params = sv.SimulationParameters(
    x=torch.linspace(-5 * ureg.mm, 5 * ureg.mm, 256),
    y=torch.linspace(-5 * ureg.mm, 5 * ureg.mm, 256),
    wavelength=10 * ureg.um,
)

setup = sv.LinearOpticalSetup([
    sv.elements.RoundAperture(sim_params, radius=2 * ureg.mm),
    sv.elements.FreeSpace(sim_params, distance=10 * ureg.cm, method='ASM'),
])

incident_field = sv.Wavefront.plane_wave(sim_params)
output_field = setup(incident_field)

Features

  • Free-space propagation solvers, including the Angular spectrum method (ASM) and the Rayleigh-Sommerfeld convolution (RSC). See this work for a definition of the methods and a comparison between them.
  • Support for solving classical diffractive optical element and SLM optimization problems with the Gerchberg-Saxton and Hybrid Input-Output algorithms.
  • Flexible API that supports custom elements.
  • Native GPU acceleration for all computations.
  • Visualization tools.

Possible applications

  • Modeling and optimization of optical systems and optical beams propagating in free space.
  • Calculation of phase-mask, Diffractive Optical Element (DOE), and SLM parameters for both classical optical systems and neuromorphic optical computers.
  • Modeling and optimization of Optical Neural Network and Diffractive Optical Neural Network parameters for different tasks.

Installation

You can install SVETlANNa from PyPI using pip:

pip install svetlanna

You should install PyTorch separately, following the instructions on the PyTorch website, to ensure compatibility with your system and desired features (e.g., CUDA support).

Examples

Result of training a feed-forward optical neural network for the MNIST classification task: the image of the digit "8" is passed through a stack of 10 phase plates with adjusted phase masks. Selected detector regions correspond to different classes of digits. The predicted class is identified by the detector region with the maximum optical intensity.

Examples of visualization of optical setups and optical fields:

drawing

Example of a five-layer Diffractive Optical Neural Network trained to recognize numbers from the MNIST database:

drawing drawing drawing

Contributing

Contributions are always welcome! See CONTRIBUTING.md for ways to get started.

Acknowledgements

The initial work on this repository was supported by the Foundation for Assistance to Small Innovative Enterprises.

Authors

License

Mozilla Public License Version 2.0

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

svetlanna-2.0.2.tar.gz (70.6 kB view details)

Uploaded Source

Built Distribution

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

svetlanna-2.0.2-py3-none-any.whl (90.5 kB view details)

Uploaded Python 3

File details

Details for the file svetlanna-2.0.2.tar.gz.

File metadata

  • Download URL: svetlanna-2.0.2.tar.gz
  • Upload date:
  • Size: 70.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.11.15 Linux/6.17.0-1020-azure

File hashes

Hashes for svetlanna-2.0.2.tar.gz
Algorithm Hash digest
SHA256 546c83ed72bbb48558a1f2e25ed66d8e20ed0bc2a202237f4dbe3784cdc7e673
MD5 d8ad9f3f5f593968ba819837d24bcc94
BLAKE2b-256 d86781d2c66a8fe0a2554e3a3c9af454eb220c2ed64949905dc48ee1b3ba09b8

See more details on using hashes here.

File details

Details for the file svetlanna-2.0.2-py3-none-any.whl.

File metadata

  • Download URL: svetlanna-2.0.2-py3-none-any.whl
  • Upload date:
  • Size: 90.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.11.15 Linux/6.17.0-1020-azure

File hashes

Hashes for svetlanna-2.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7c4a3aca2c3f398540fe9139bac44f2219b2e718513fca457849736ee8ef1fb6
MD5 ce77edd35bdfed33244743361d2a8310
BLAKE2b-256 b78b64d3dcde2a361b3d76b03fb15a201cac0927d65cef4e9bdd65e3b5ba5429

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