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())
def test_get_kz_nparray(self): index_init = np.array([1.5, 1.0]) angle_init = np.array([0.0, np.pi / 4.0]) wavelengths = np.array([0.5, 1.0]) * sm.Units.um kz_calc = sm.get_kz(index_init, angle_init, wavelengths) kz_predict = np.array([18.849555, 4.4428829]) * 10**6 ratio = kz_calc / kz_predict npt.assert_array_almost_equal(ratio, np.array([1.0, 1.0]), decimal=5)
def test_get_kz_complex(self): kz_calc = sm.get_kz(1.2 - 1.0j, 0.5 + 0.1j, 1.0 * sm.Units.um) kz_predict = (6.34819404 - 5.903688016j) * 10**6 ratio = kz_calc / kz_predict self.assertAlmostEqual(ratio, 1.0, places=5)
def test_get_kz_with_angle(self): kz_calc = sm.get_kz(1.5, np.pi / 3.0, 1.0 * sm.Units.um) kz_predict = 4.712388898 * 10**6 ratio = kz_calc / kz_predict self.assertAlmostEqual(ratio, 1.0, places=5)
def test_get_kz_angle_0(self): kz_calc = sm.get_kz(1.5, 0.0, 1.0 * sm.Units.um) kz_predict = 9.42477796 * 10**6 ratio = kz_calc / kz_predict self.assertAlmostEqual(ratio, 1.0, places=5)