Пример #1
0
 def test_scattering_matrix_calculation_fabryperot(self):
     index_air = sm.single_index_function(1.0)
     index_glass = sm.single_index_function(1.5)
     wavelengths = np.array(
         [1.5 * sm.Units.um, 0.75 * sm.Units.um, 6.0 / 5.0 * sm.Units.um])
     structure = sm.LayerList()
     structure.append(sm.SingleLayer(index_air, 1.0 * sm.Units.um))
     structure.append(sm.SingleLayer(index_glass, 1.0 * sm.Units.um))
     structure.append(sm.SingleLayer(index_air, 1.0 * sm.Units.um))
     calculate_powers = sm.scattering_matrix_calculation(
         structure, wavelengths)
     calc_transmission = calculate_powers[0]
     calc_reflection = calculate_powers[1]
     calc_absorption = calculate_powers[2]
     reflection_face = sm.reflected_power_TE(1.0, 1.5, 0.0)
     expected_transmission = np.array([
         1.0, 1.0,
         1.0 - (4 * reflection_face / ((1 + reflection_face)**2.0))
     ])
     #expected_reflection = 1.0-expected_transmission
     ratio_t = calc_transmission / expected_transmission
     #ratio_r = calc_reflection/expected_reflection
     npt.assert_array_almost_equal(ratio_t,
                                   np.array([1.0, 1.0, 1.0]),
                                   decimal=5)
     #npt.assert_array_almost_equal(ratio_r,np.array([1.0]),decimal=5)
     npt.assert_array_almost_equal(calc_absorption,
                                   np.array([0.0, 0.0, 0.0]),
                                   decimal=5)
Пример #2
0
    def test_scattering_matrix_calculation_singlethickness_complex_TM(self):
        i1 = 1.0
        i2 = 1.5 - 2.0j
        angle = np.pi / 3

        #Calculated
        index_air = sm.single_index_function(i1)
        index_complex = sm.single_index_function(i2)
        structure = sm.LayerList()
        structure.append(sm.SingleLayer(index_air, 1.0 * sm.Units.um))
        structure.append(sm.SingleLayer(index_complex, 1.0 * sm.Units.um))
        calculate_powers = sm.scattering_matrix_calculation(
            structure, 1.0 * sm.Units.um, incident_angle=angle, mode="TM")
        calc_transmission = calculate_powers[0]
        calc_reflection = calculate_powers[1]

        #Expected
        t_angle = sm.transmission_angle(i1, i2, angle)
        kz = sm.get_kz(i2, t_angle, 1.0 * sm.Units.um)
        expected_transmission = (
            sm.transmitted_power_TM(1.0, 1.5 - 2.0j, angle) * np.exp(
                (-2.0j * kz * 1.0 * sm.Units.um).real))
        expected_reflection = sm.reflected_power_TM(1.0, 1.5 - 2.0j, angle)

        #Check
        ratio_t = calc_transmission / expected_transmission
        ratio_r = calc_reflection / expected_reflection
        sum_t_r = calc_transmission + calc_reflection
        npt.assert_array_almost_equal(ratio_t, np.array([1.0]), decimal=5)
        npt.assert_array_almost_equal(ratio_r, np.array([1.0]), decimal=5)
        self.assertTrue((sum_t_r < 1.0).all())
Пример #3
0
 def test_MG_mixed_medium(self):
     index1_fcn = sm.single_index_function(1.5)
     index2_fcn = sm.single_index_function(1.0)
     brug_fcn = sm.generate_mixed_medium_approximation(0.5,
                                                       index1_fcn,
                                                       index2_fcn,
                                                       mix_type="MG")
     self.assertAlmostEqual(brug_fcn(sm.Units.um), 1.249489691)
Пример #4
0
    def test_SMthickCalc_energy_conserved(self):
        wavelengths = np.linspace(200.0, 2500.0, 461) * sm.Units.nm
        index_air = sm.single_index_function(1.0)
        index_1 = sm.single_index_function(1.3)
        index_complex = sm.single_index_function(1.5 - 2.0j)
        structure = sm.LayerList()
        structure.append(sm.SingleLayer(index_air, 1.0 * sm.Units.um))
        structure.append(sm.SingleLayer(index_1, 100.0 * sm.Units.nm))
        structure.append(sm.SingleLayer(index_complex, 2.0 * sm.Units.um))
        structure.append(sm.SingleLayer(index_air, 1.0 * sm.Units.um))
        calculate_powers = sm.smatrix_with_thick_layers(structure, wavelengths)
        calc_transmission = calculate_powers[0]
        calc_reflection = calculate_powers[1]

        #Check
        sum_t_r = calc_transmission + calc_reflection
        self.assertTrue((sum_t_r < 1.0).all())
Пример #5
0
    def test_TRParamCalc_energy_conserved(self):
        wavelengths = np.linspace(200.0, 2500.0, 461) * sm.Units.nm

        index_air = sm.single_index_function(1.0)
        index_complex = sm.single_index_function(1.5 - 2.0j)
        structure = sm.LayerList()
        structure.append(sm.SingleLayer(index_air, 1.0 * sm.Units.um))
        structure.append(sm.SingleLayer(index_complex, 1.0 * sm.Units.um))
        structure.append(sm.SingleLayer(index_air, 1.0 * sm.Units.um))
        calculate_powers = sm.calc_TR_parameters(structure, wavelengths)
        calc_transmission_fwd = calculate_powers[0]
        calc_reflection_fwd = calculate_powers[1]
        calc_transmission_rev = calculate_powers[0]
        calc_reflection_rev = calculate_powers[1]

        #Check
        sum_t_r = calc_transmission_fwd + calc_reflection_fwd
        sum_t_r_rev = calc_transmission_fwd + calc_reflection_fwd
        self.assertTrue((sum_t_r < 1.0).all())
        self.assertTrue((sum_t_r_rev < 1.0).all())
Пример #6
0
 def test_scattering_matrix_calculation_singlethickness_complex(self):
     index_air = sm.single_index_function(1.0)
     index_complex = sm.single_index_function(1.5 - 2.0j)
     structure = sm.LayerList()
     structure.append(sm.SingleLayer(index_air, 1.0 * sm.Units.um))
     structure.append(sm.SingleLayer(index_complex, 1.0 * sm.Units.um))
     calculate_powers = sm.scattering_matrix_calculation(
         structure, 1.0 * sm.Units.um)
     calc_transmission = calculate_powers[0]
     calc_reflection = calculate_powers[1]
     expected_transmission = (
         sm.transmitted_power_TE(1.0, 1.5 - 2.0j, 0.0) * np.exp(
             (-4.0 * np.pi) * 2))
     expected_reflection = sm.reflected_power_TE(1.0, 1.5 - 2.0j, 0.0)
     ratio_t = calc_transmission / expected_transmission
     ratio_r = calc_reflection / expected_reflection
     sum_t_r = calc_transmission + calc_reflection
     npt.assert_array_almost_equal(ratio_t, np.array([1.0]), decimal=5)
     npt.assert_array_almost_equal(ratio_r, np.array([1.0]), decimal=5)
     self.assertTrue((sum_t_r < 1.0).all())
Пример #7
0
 def test_scattering_matrix_calculation_singleinterface_complex(self):
     index_air = sm.single_index_function(1.0)
     index_complex = sm.single_index_function(1.5 - 2.0j)
     structure = sm.LayerList()
     structure.append(sm.SingleLayer(index_air, 1.0 * sm.Units.um))
     structure.append(sm.SingleLayer(index_complex, 0.0 * sm.Units.um))
     calculate_powers = sm.scattering_matrix_calculation(
         structure, 1.0 * sm.Units.um)
     calc_transmission = calculate_powers[0]
     calc_reflection = calculate_powers[1]
     calc_absorption = calculate_powers[2]
     expected_transmission = sm.transmitted_power_TE(1.0, 1.5 - 2.0j, 0.0)
     expected_reflection = sm.reflected_power_TE(1.0, 1.5 - 2.0j, 0.0)
     ratio_t = calc_transmission / expected_transmission
     ratio_r = calc_reflection / expected_reflection
     npt.assert_array_almost_equal(ratio_t, np.array([1.0]), decimal=5)
     npt.assert_array_almost_equal(ratio_r, np.array([1.0]), decimal=5)
     npt.assert_array_almost_equal(calc_absorption,
                                   np.array([0.0]),
                                   decimal=5)
Пример #8
0
    def test_scattering_matrix_calculation_energy_conservation_TE(self):
        wavelengths = np.linspace(200.0, 2500.0, 461) * sm.Units.nm
        i1 = 1.0
        i2 = 1.5 - 2.0j
        angle = np.pi / 3

        #Calculated
        index_air = sm.single_index_function(i1)
        index_complex = sm.single_index_function(i2)
        structure = sm.LayerList()
        structure.append(sm.SingleLayer(index_air, 1.0 * sm.Units.um))
        structure.append(sm.SingleLayer(index_complex, 10.0 * sm.Units.nm))
        structure.append(sm.SingleLayer(index_air, 1.0 * sm.Units.um))
        calculate_powers = sm.scattering_matrix_calculation(
            structure, wavelengths, incident_angle=angle, mode="TE")
        calc_transmission = calculate_powers[0]
        calc_reflection = calculate_powers[1]

        #Check
        sum_t_r = calc_transmission + calc_reflection
        self.assertTrue((sum_t_r < 1.0).all())
Пример #9
0
 def test_single_index_real(self):
     index_fcn = sm.single_index_function(1.5)
     self.assertAlmostEqual(index_fcn(sm.Units.um), 1.5)
Пример #10
0
"""
This file implements finding the transmission and reflection for various
wavelengths for a single index layer 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
'''