Skip to main content

A vectorized implementation of the transfer matrix method

Project description

Vectorized Transfer Matrix Method Python

The transfer matrix method (TMM) is an analytic approach for obtaining the reflection and transmission coefficients in stratified media. vtmmpy is a vectorised implementation of the TMM written in Python. It has a focus on speed and ease of use.

Installation


pip install vtmmpy 

Usage


Import the vtmmpy module.

import vtmmpy

Create an instance of the TMM class.

freq = np.linspace(170, 210, 30) 
theta = np.array(0, 60, 60) 

tmm = vtmmpy.TMM(freq, 
                theta, 
                f_scale=1e12, 
                l_scale=1e-9, 
                incident_medium="air", 
                transmitted_medium="air") 
  • freq: a numpy array representing the spectral range of interest.
  • theta: a numpy array of one or more angles of incidence.
  • f_scale (optional): input frequency scale, default is terahertz.
  • l_scale (optional): input length scale, default is nanometers.
  • incident_medium (optional): incident medium, default is air.
  • transmitted_medium (optional): transmitted medium, default is air.

Add multilayer metamaterial designs with the addDesign() method.

materials   = ["Ag", "SiO2", "Ag", "SiO2", "Ag", "SiO2"] 
thicknesses = [15, 85, 15, 85, 15, 85] 

tmm.addDesign(materials, thicknesses)
  • materials: list of materials
  • thicknesses: list of the corresponding material thicknesses

Internally, vtmmpy uses the regidx Python package to download refractive index data from refractiveindex.info for your choosen materials and spectral range. At this point, you will be presented with a few options corresponding to the data source ("Page" dropdown on refractiveindex.info). Study these carefully and refer to refractiveindex.info for more detailed information about how the data were obtained. Your choice here could greatly impact the accuracy of your results.

Optionally call the summary() and/or designs() methods to view the data currently held by the instance.

tmm.summary() 
tmm.designs() 

Additionally, the tmm.opticalProperties() method can be used to obtain a dictionary of optical properties of the materials entered in the frequency range specified.

props = tmm.opticalProperties()

print(props.keys()) # output: dict_keys(['air', 'SiO2', 'Ag'])
print(props["Ag"]["n"]) # ouput is the refractive index of Ag
print(props["Ag"]["beta"]) # ouput is the propagation constant of Ag

Calculate the reflection/transmission coefficients by calling the appropriate method. You should specify wether you want the transverse magnetic/electric polarization by supplying the "TM" or "TE" flag, respectively.

RTM = tmm.reflection("TM") 
RTE = tmm.reflection("TE") 
TTM = tmm.transmission("TM") 
TTE = tmm.transmission("TE") 

Tips:

  • The reflection() and transmission() methods return both complex parts. Use Python's built-in abs() function to obtain the magnitude.
  • The intensity is the square of the magnitude (eg. abs(reflection("TM"))**2).
  • reflection() and transmission() return an ndarray with a minimum of 2 dimensions. The first dimension always corresponds to the number of designs. Therefore, when printing/plotting results, you must always index the first dimension (even if you only have 1 design).

Examples


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

vtmmpy-1.0.6.tar.gz (17.3 kB view details)

Uploaded Source

Built Distribution

vtmmpy-1.0.6-py3-none-any.whl (17.4 kB view details)

Uploaded Python 3

File details

Details for the file vtmmpy-1.0.6.tar.gz.

File metadata

  • Download URL: vtmmpy-1.0.6.tar.gz
  • Upload date:
  • Size: 17.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.7

File hashes

Hashes for vtmmpy-1.0.6.tar.gz
Algorithm Hash digest
SHA256 d2a7ee8f0ba20bebe216a631b3433db5bdfb18cf65f27e552b6ce0c3d01bf457
MD5 c7ae88f75dad90603325e9271cdc3e69
BLAKE2b-256 e4ec9253ad6b0bd78045cf1fab363962ab14fc7420654736b3fabf5562714994

See more details on using hashes here.

File details

Details for the file vtmmpy-1.0.6-py3-none-any.whl.

File metadata

  • Download URL: vtmmpy-1.0.6-py3-none-any.whl
  • Upload date:
  • Size: 17.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.7

File hashes

Hashes for vtmmpy-1.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 0836400acd00537ca0ce5655c662e005f24186318cfe0bfe3cd2a50f1ec2f99c
MD5 c43ee2d309d5bc661751afdafa5ebf57
BLAKE2b-256 188b2e12f15915133ef649535a093070e37627c5ec6cb8c6f7f79d679a34670d

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