Transfer-matrix method to calculate reflectance, transmittance and the electric field strength across an optical multilayer. For a thorough derivation of the method see, for instance: C. C. Katsidis, D. I. Siapkas. Applied Optics, 41, 3978 (2002), https://doi.org/10.1364/AO.41.003978.
$ git clone https://github.com/andibarg/optical-field-transfer-matrix.git
$ cd optical-field-transfer-matrix
This repository includes implementations both in Matlab (.m files) and in Python (.py file).
The function 'tmm.m' takes as inputs the wavelength, layer refractive indices ni and layer widths wi. It returns the amplitude reflection coefficient r and the transmission coefficient t, as well as arrays to plot the electric field strength E vs position x.
As an example, the script 'example_dbr.m' calculates the field in a lossless dielectric mirror on a glass substrate, where the coating materials are magnesium fluoride (nMgF2 = 1.38) and zinc sulfide (nZnS = 2.32). The following figure shows the normalized electric field strength across 8 alternating layers, each with a thickness of ni wi = λ/4, where λ = 1 μm is the wavelength.
For the same mirror the following figure shows the reflectance as a function of wavelengths.