예제 #1
0
 def test_transmission_angle_reversable(self):
     angle_init = np.pi / 5.0
     angle_fwd = sm.transmission_angle(1.0 - 1.5j, 2.0 - 2.5j, angle_init)
     angle_reverse = sm.transmission_angle(2.0 - 2.5j, 1.0 - 1.5j,
                                           angle_fwd)
     ratio = angle_reverse / angle_init
     self.assertAlmostEqual(ratio, 1.0, places=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_transmission_angle_nparray(self):
     angle_init = np.array([np.pi / 3.0, np.pi / 4.0])
     index1 = np.array([1.0, 1.0])
     index2 = np.array([1.5, 1.75])
     angle_calc = sm.transmission_angle(index1, index2, angle_init)
     angle_predict = np.array([0.61547970867, 0.415952087])
     ratio = angle_calc / angle_predict
     npt.assert_array_almost_equal(ratio, np.array([1.0, 1.0]), decimal=5)
예제 #4
0
 def test_transmission_angle_complex(self):
     angle_calc = sm.transmission_angle(1.2 - 1.0j, 1.5 - 1.5j, np.pi / 4.0)
     angle_predict = 0.544230 + 0.0550733j
     ratio = angle_calc / angle_predict
     self.assertAlmostEqual(ratio, 1.0, places=5)
예제 #5
0
 def test_transmission_angle_total_internal_reflection(self):
     angle_calc = sm.transmission_angle(1.5, 1.0, np.pi / 3.0)
     angle_predict = 1.570796327 + 0.7552738756j
     #Because both +/- the imaginary are valid solutions
     ratio = (angle_calc.real + abs(angle_calc.imag) * 1.0j) / angle_predict
     self.assertAlmostEqual(ratio, 1.0, places=5)
예제 #6
0
 def test_transmission_angle_1to1dot5_at_angle(self):
     angle_calc = sm.transmission_angle(1.0, 1.5, np.pi / 3.0)
     angle_predict = 0.61547970867
     ratio = angle_calc / angle_predict
     self.assertAlmostEqual(ratio, 1.0, places=5)
예제 #7
0
 def test_transmission_angle_zero(self):
     self.assertAlmostEqual(sm.transmission_angle(1.0, 1.5, 0.0), 0.0)