Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

Optical Diffraction and Interference (scalar and vectorial)

Project description

Python Diffraction-Interference module Documentation Status logo.png


Diffratio is a Python library for Diffraction and Interference Optics.

It implements Scalar and paraxial vector Optics. The main algorithms used are Rayleigh Sommerfeld (RS), Beam Propagation Method (BPM) and Fast Fourier Transform (FFT). When possible, multiprocessing is implemented for a faster computation.

The scalar propagations techniques are implemented to:

  • X - fields are defined in the x axis.
  • XZ - fields are defined in the xz plane, being z the propagation direction.
  • XY - fields are defined in the xy transversal plane.
  • XYZ - fields are defined in the xyz volume.

Each technique present three modules:

  • sources: Generation of light.
  • masks: Masks and Diffractive Optical elements.
  • fields: Propagation techniques, parameters and general functions.

The paraxial vector propagation techniques are implemented to:

  • XY - fields are defined in the xy transversal plane.


One main part of this software is the generation of optical fields such as:

  • Plane waves.
  • Spherical waves.
  • Gaussian beams.
  • Bessel beams.
  • Aberrated beams.

Also, in the XY module the following sources are defined:

  • Vortex beams.
  • Laguerre beams.
  • Hermite-Gauss beams.
  • Zernike beams.
  • Bessel beams.


Another important part of Diffractio is the generation of masks and Diffractive Optical Elements such as:

  • Slits, double slits
  • Lenses, diffractive lenses, aspherical lenses.
  • Gratings, prisms, biprism
  • Rough surfaces, dust ks are defined as plane. However, in the XZ and XYZ frames, volumetric mask are also defined.
mask1.png mask2.png


In these module, algorithms for propagation of light are implemented. We have implemented the following algorithms for light propagation:

  • Rayleigh-Sommerfeld (RS) which allows in a single step to propagate to a near or far observation plane, which allows fast computations. The fields and the masks must be defined in a plane.
  • Beam propagation method (BPM) which allows to analyze the propation of light in volumetric elements, such as spheres, cylinders and other complex forms.
  • Fast Fourier Transform (FFT) which allows, in a single step to determine the field at the far field.

The fields, masks and sources can be stored in files,

Also drawings can be easily obtained, for intensity, phase, fields, etc.

In some modules, videos can be generated for a better analysis of optical fields.


Other features

  • Intensity, MTF and other parameters are obtained from the optical fields.
  • Fields can be added and interference is produced. Masks can be multiplied, added and substracted in order to make complex structures
  • Resampling fields in order to analyze only areas of interest.
  • Save and load data for future analysis.
  • Rayleigh-Sommerfeld implementation is performed in multiprocessing for fast computation.
  • Polychromatic and extended source problems can also be analyzed using multiprocessing.

Paraxial vector beams

Here, we implement new classes where the fields $E_x$ and $E_y$ are generated and propagted using Rayleigh-Sommerfeld approach. Also, simple and complex polarizing masks can be created.

vector_gauss_radial_fields.png vector_gauss_radial_stokes.png


  • Luis Miguel Sanchez Brea <>

    Universidad Complutense de Madrid, Faculty of Physical Sciences, Department of Optics Plaza de las ciencias 1, ES-28040 Madrid (Spain)



L.M. Sanchez Brea, “Diffratio, python module for diffraction and interference optics”, (2019)


      1. Goodman, Introduction to Fourier optics. McGraw-Hill, 1996.
    1. Shen y A. Wang, «Fast-Fourier-transform based numerical integration method for the Rayleigh-Sommerfeld diffraction formula», Applied Optics, vol. 45, n.º 6, pp. 1102–1110, 2006.
    1. Qiwen, Vectorial optical fields: Fundamentals and applications. World scientific, 2013.
      1. Saleh y M. C. Teich, Fundamentals of photonics. John Wiley & Sons, 2019.
      1. Ogilvy, Theory of Wave Scattering from Random Rough Surfaces.Adam Hilger, 1991.
  • “Numerical Methods in Photonics Lecture Notes”.
  • Beam width:


This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.


0.0.0 (2017-01-01)

Pre-alpha state.

  • I have been developing and using the module diffractio for at least 5 years for teaching and research. It was in python2 version and not completely clear.

0.0.1 (2019-02-09)

Pre-alpha state.

Modules are passed to python3.

0.0.2 (2019-10-01)

Alpha state

  • copyreg removed (previous not worked)
  • change fft to scipy: “from scipy.fftpack import fft, ifft, fftshift”
First release on PyPI in pre-alpha state.

0.0.5 (2019-10-06)

Alpha state

  • Included vector paraxial (fields, sources, masks) modules, tests, and tutorial.
  • Modules = 9/10.
  • Functions = 9/10.
  • Tutorial = 7/10.
  • Examples = 4/10.
  • Tests = 9/10.
  • Drawing = 8/10.

Project details

Download files

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

Files for diffractio, version 0.0.6
Filename, size File type Python version Upload date Hashes
Filename, size diffractio-0.0.6-py2.py3-none-any.whl (127.4 kB) File type Wheel Python version py2.py3 Upload date Hashes View hashes
Filename, size diffractio-0.0.6.tar.gz (5.7 MB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page