Ejemplo n.º 1
0
def sample1():
    """
    Here's a thin non-absorbing layer, on top of a thick absorbing layer, with
    air on both sides. Plotting reflected intensity versus wavenumber, at two
    different incident angles.
    """
    # list of layer thicknesses in nm
    d_list = [inf, 100, 300, inf]
    # list of refractive indices
    n_list = [1, 2.2, 3.3 + 0.3j, 1]
    # list of wavenumbers to plot in nm^-1
    ks = linspace(0.0001, .01, num=400)
    # initialize lists of y-values to plot
    Rnorm = []
    R45 = []
    for k in ks:
        # For normal incidence, s and p polarizations are identical.
        # I arbitrarily decided to use 's'.
        Rnorm.append(coh_tmm('s', n_list, d_list, 0, 1 / k)['R'])
        R45.append(unpolarized_RT(n_list, d_list, 45 * degree, 1 / k)['R'])
    kcm = ks * 1e7  #ks in cm^-1 rather than nm^-1
    plt.figure()
    plt.plot(kcm, Rnorm, 'blue', kcm, R45, 'purple')
    plt.xlabel('k (cm$^{-1}$)')
    plt.ylabel('Fraction reflected')
    plt.title('Reflection of unpolarized light at 0$^\circ$ incidence (blue), '
              '45$^\circ$ (purple)')
    plt.show()
Ejemplo n.º 2
0
 def get_R(self, wavelengths, thickness, theta, void_percent):
     thicknesses = [inf, thickness, inf]
     mat = self.mat_df.ix[wavelengths]
     mat = mat[self.layers]
     theta0 = theta*sp.pi/180
     self.brug_transform(mat, self.layers[1], mat['Air'], void_percent)
     self.index_array = np.array(mat)
     self.data = tmm.unpolarized_RT(self.index_array, thicknesses, theta0, wavelengths)
     R = self.data['R']
     R -= min(R)
     R /= max(R)
     return R
Ejemplo n.º 3
0
 def run(self, thicknesses, theta0, polarization=None):
     """
     runs the model with specified parameters
     :param thicknesses: list of thicknesses, first and last must be inf
     :param theta0: input angle
     :param polarization: polarization state 's', 'p', or None
     :return: void
     """
     self.index_array = np.array(self.mat_df[self.layers])
     if polarization is None:
         self.data = tmm.unpolarized_RT(self.index_array, thicknesses, theta0, self.wavelength)
     elif polarization in ['p', 's']:
         self.data = tmm.coh_tmm(polarization, self.index_array, thicknesses, theta0, self.wavelength)
Ejemplo n.º 4
0
def sample1():
    """
    Here's a thin non-absorbing layer, on top of a thick absorbing layer, with
    air on both sides. Plotting reflected intensity versus wavenumber, at two
    different incident angles.
    """
    # list of layer thicknesses in nm
    d_list = [inf, 100, 80, 100, 80, 100, 80, 100, 80, 100, 80, 100, 80, inf]
    # list of refractive indices
    n_list = [
        1, 1.68 + 0.03j, 1.55 + 0.14j, 1.68 + 0.03j, 1.55 + 0.14j,
        1.68 + 0.03j, 1.55 + 0.14j, 1.68 + 0.03j, 1.55 + 0.14j, 1.68 + 0.03j,
        1.55 + 0.14j, 1.68 + 0.03j, 1.55 + 0.14j, 1.61 + 0.085j
    ]
    # list of wavenumbers to plot in nm^-1
    ks = linspace(0.0025, .00125, num=800)
    # initialize lists of y-values to plot
    Rnorm = []
    R37 = []
    for k in ks:
        # For normal incidence, s and p polarizations are identical.
        # I arbitrarily decided to use 's'.
        Rnorm.append(coh_tmm('s', n_list, d_list, 0, 1 / k)['R'])
        R37.append(unpolarized_RT(n_list, d_list, 37 * degree, 1 / k)['R'])
    kcm = ks * 1e7  #ks in cm^-1 rather than nm^-1
    lamb = 1 / ks
    plt.figure()
    plt.plot(lamb, Rnorm, 'blue', lamb, R37, 'purple')
    plt.xlabel('Wavelength (/nm)')
    plt.ylabel('Fraction reflected')
    plt.title('Reflection of unpolarized light at 0$^\circ$ incidence (blue), '
              '37$^\circ$ (purple)')

    # data file
    import numpy
    datafile_path = "/users/Olimpia/Desktop/datafile.txt"
    datafile_id = open(datafile_path, 'w+')
    data = numpy.array([lamb, Rnorm])
    data = data.T
    numpy.savetxt(datafile_id, data, fmt=['%.4f', '%.4f'])
    datafile_id.close()