Created
October 24, 2017 20:08
-
-
Save Chronum94/e625723f5c190e13130d4d6b67ae2d35 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
""" | |
Created on Tue Oct 24 14:17:58 2017 | |
@author: Chronum | |
""" | |
import numpy as np | |
import matplotlib.pyplot as plt | |
def filmstack_reflectivities(rix_array, film_thickness_array, wavelengths, | |
theta = 0, polarization = 'te'): | |
num_layers = len(film_thickness_array) | |
if num_layers != len(rix_array)-2: # Rix array has 2 extra rix values. | |
print("Error!: Array of layer thickness must have 2 fewer v" | |
"alues than array of rix values.") | |
raise IndexError | |
layer_cos_projection = np.sqrt(1-(rix_array[0]/rix_array*np.sin(theta))**2) | |
if polarization.lower() == 'te': | |
effective_rix_array = rix_array*layer_cos_projection | |
else: | |
effective_rix_array = rix_array/layer_cos_projection | |
effective_film_thickness = film_thickness_array*layer_cos_projection[1:-1] | |
fresnel_coeff_array = np.diff(effective_rix_array)/\ | |
(effective_rix_array[0:-1]+effective_rix_array[1:]) | |
reflectivity = fresnel_coeff_array[-1]*np.ones_like(wavelengths) | |
for j in range(num_layers-1, -1, -1): | |
phase_exponent = 2*np.pi*effective_film_thickness[j]/wavelengths | |
phase_shift = np.exp(2j*phase_exponent) | |
reflectivity = (fresnel_coeff_array[j]+reflectivity*phase_shift)/\ | |
(1+fresnel_coeff_array[j]*reflectivity*phase_shift) | |
return reflectivity | |
rixes = np.array([1, 1.4, 1.6, 1.9, 1.6, 1.4, 1.6, 1.9, 1.6, 1.4, 1]) | |
lens = np.array([1, 1, 1, 1, 1.0, 9, 1, 1, 1]) | |
wlens = np.linspace(1.2, 1.6, 1000) | |
# plt.plot(rixes) | |
refl = filmstack_reflectivities(rixes, lens, wlens) | |
plt.plot(wlens, -refl) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment