Skip to main content

A scalar diffraction simulation package

Project description

openphoton

The latest version allows you to simulate light propagation from a laser, passing through lens, and passing through your test object. More features will be added soon.

Examples of How To Use (Alpha Version)

Add openphoton to your operating system or python virtual environment :

pip install openphoton

Create a laser beam :

import openphoton as op

# side length (m)
# aperture radius (m)
u0 = op.devices.laser_beam(
    side_length=0.06,
    aperture_radius=0.026,
    pixels=1024)

In order to forward propagate the wave field, you must choose between fresnel (near-field) approximation and fraunhoffer (far-field) approximation. To determine which approximation is best for your system, you have to calculate the Fresnel number F_N. If F_N = [1, +infinity], then use fresnel approximation. Otherwise, use fraunhoffer approximation.

# uo = wave field to propagate
# L = source plane side length (m)
# wavelength = wavelength of light (m)
# z = propagation distance (m)
# u1 = resulting wave field after propagation
u1 = op.rayleigh_sommerfeld.fresnel_approx(
    u0, L, wavelength, z)

Apply converging lens or diverging lens on the laser beam :

import numpy as np

# u1 = wave field before the lens
# L = u1 side length (m)
# wavelength of light (m)
# f_length = lens focal length (m)
# u2 = wave field after the lens
u2 = np.multiply(u1, op.lenses.converging_lens(u1,L,wavelength,f_length))

Apply SLM or test object on the laser beam :

import numpy as np

# filename = image of test object file name
filename : str = "USAF_1951_1024p.png"

# SLM_amplitude() converts RGB image into numpy array
# pixel_size = number of pixels of image, ideally this must be the same with u1
test_object = op.devices.SLM_amplitude(filename, pixel_size)

# u1 = wave field before the test object
# L = u1 side length (m)
# wavelength of light (m)
# u2 = wave field after the test object
u2 = np.multiply(u1, test_object)

References:

  • Shen, Fabin, and Anbo Wang. "Fast-Fourier-transform based numerical integration method for the Rayleigh-Sommerfeld diffraction formula." Applied optics 45, no. 6 (2006): 1102-1110.
  • Schmidt, Jason D. "Numerical simulation of optical wave propagation with examples in MATLAB." SPIE (2010).
  • Voelz, David G., and Michael C. Roggemann. "Digital simulation of scalar optical diffraction: revisiting chirp function sampling criteria and consequences." Applied optics 48, no. 32 (2009): 6132-6142.

Check out: https://www.youtube.com/c/boyfriendnibluefairy

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

openphoton-0.1.2.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

openphoton-0.1.2-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file openphoton-0.1.2.tar.gz.

File metadata

  • Download URL: openphoton-0.1.2.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for openphoton-0.1.2.tar.gz
Algorithm Hash digest
SHA256 e99cd402edb2e7592dedf2fc13f897a201bcb1515483ca9fb11f6b20514bb1f6
MD5 8c6104c050a3785b77244fc2d6f2c9ef
BLAKE2b-256 1b653ae5db4258e72c4c2a60d659c047bcf46c89065a87262babef052c4b1f11

See more details on using hashes here.

File details

Details for the file openphoton-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: openphoton-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 6.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for openphoton-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 11deecd0c77a4967d9c7cd5ae17c769bcbfaf6203e2d3402330a742bfdaa0b06
MD5 8be171bf7fb30b71d6915966f470230d
BLAKE2b-256 849b2516c26c1229ee4395327bd0ae380bf9f8e7f8eaefbb87e2b3a13cb2e69e

See more details on using hashes here.

Supported by

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