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.1.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.1-py3-none-any.whl (90.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for svetlanna-2.0.1.tar.gz
Algorithm Hash digest
SHA256 694734c515c5bab057c6f054715042cac5cf9ac8bf39ff2c3d1cd8558f2a3574
MD5 2b5edf85adecf440fbabf28bf270f2de
BLAKE2b-256 af31c8b4610ead922872fdff013f57944fbe6ab07af78f6349e118151a3b874c

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for svetlanna-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b598750fdbbaaef4f40e03164c47bc3d5c8d3dbeb24406b0a02d1888fbbe6d13
MD5 9369d410829a98da58c2b61b9a97d554
BLAKE2b-256 6bf57aeca75a8fb2c22d37c4cfea79e2cf063d67606f81b781d80ec9fb82230c

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