Skip to main content

Optical scattering matrix library

Project description

Optical Scattering Matrix Library

This implements a simple 1D scattering matrix algorithm for the calculation of reflection, transmission, and absorption of optical films and filters. It is an alternative to the transfer matrix algorithm and is known for being less prone to issues with highly absorbing films.

Getting Started

These instructions will get you a copy of the project up and running on your local machine.

Prerequisites

This library makes heavy use of the numpy and scipy libraries. You should have:

  • python version >3.x
  • numpy version >x.y
  • scipy version >x.y

(testing is ongoing for version compatibility)

Installing

The best way to install is via pip. This is a python3 library, so the recommend install is either

pip install scatteringmatrix

or

pip3 install scatteringmatrix

Examples

Right now there is a single example file in the examples directory. It is exactly the same as the code below.

"""
This file implements finding the transmission and reflection for various
wavelengths for a single index lyaer on a glass substrate.
"""

import scatteringmatrix as sm
import numpy as np

'''
Declare Structure
'''

#Defining index functions. Any function that returns a complex value given
#a specific wavelength (in meters) can be used. Here, we declare functions that
#always return the same index, regardless of wavelength
index_air = sm.single_index_function(1.0)
index_glass = sm.single_index_function(1.5)
index_Si3N4 = sm.single_index_function(2.0)

#A 1D optical structure is a list of layers. We declare two of the layers here
film = sm.SingleLayer(index_Si3N4, 60.0*sm.Units.NANOMETERS)
substrate = sm.SingleLayer(index_glass, 1.1*sm.Units.MILLIMETERS)

#Here we declare the actual list and append the layers.
structure = sm.LayerList()
structure.append(sm.SingleLayer(index_air, sm.Units.MICROMETERS))
structure.append(film)
structure.append(substrate)
structure.append(sm.SingleLayer(index_air, sm.Units.MICROMETERS))

'''
Calculate transmission and reflection at 0 degrees
'''

wavelengths = np.linspace(300.0, 1200.0, 91)*sm.Units.NANOMETERS
#Data is returned in an array of arrays.
results = sm.scattering_matrix_calculation(structure, wavelengths)
print("Selected Wavelength Data")
print("----------------------------")
print("Incident Angle:", results[4])
print("Mode:", results[5])
print("Wavelengths (nm):", '{0:.1f}'.format(results[3][30]/sm.Units.NANOMETERS),
      ",", '{0:.1f}'.format(results[3][60]/sm.Units.NANOMETERS))
print("Transmission @ 600 nm, 900 nm:", '{0:.6f}'.format(results[0][30]),
      ",", '{0:.6f}'.format(results[0][60]))
print("Reflection @ 600 nm, 900 nm:", '{0:.6f}'.format(results[1][30]),
      ",", '{0:.6f}'.format(results[1][60]))
print("Absorption @ 600 nm, 900 nm:", '{0:.6f}'.format(results[2][30]),
      ",", '{0:.6f}'.format(results[2][60]))

Running this file should result in an output of:

Selected Wavelength Data
----------------------------
Incident Angle: 0.0
Mode: TE
Wavelengths (nm): 600.0 , 900.0
Transmission @ 600 nm, 900 nm: 0.662785 , 0.964672
Reflection @ 600 nm, 900 nm: 0.337215 , 0.035328
Absorption @ 600 nm, 900 nm: 0.000000 , 0.000000

Running unit tests

Go into the directory where you have the library installed to run the basic unit tests. This can be done via the command line with

python3 -m unittest

which should result in an output similar to:

Ran 80 tests in 0.026s

OK

Deployment

This is enitrely a python module, so no special deployment steps are required.

Contributing

Please contact the lead author andrew.flood@mail.utoronto.ca if you wish to join the project.

Versions

We have only had development and alpha versions up until now, so it will still stay at 0.1.0 for the time being.

Authors

  • Andrew Flood - Initial work and current project lead

License

This project is licensed under the MIT License - see the LICENSE.txt file for details

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 scatteringmatrix, version 0.1.0a3
Filename, size File type Python version Upload date Hashes
Filename, size scatteringmatrix-0.1.0a3.tar.gz (13.8 kB) 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