def test_snellnormal(self): '''Snell's law at normal incidence''' n1 = 1.0 n2 = 1.5 theta_i = 0 snell_out = tf.snell_theta_t(n1, n2, theta_i) self.assertEqual(snell_out, 0)
def test_snellangle(self): '''Snell's law, incident at 45 degrees tested against exact sine values for total internal reflection''' n1 = 2 n2 = np.sqrt(2) theta_i = 45*tf.degrees snell_out = tf.snell_theta_t(n1, n2, theta_i) self.assertAlmostEqual(snell_out, np.pi/2)
def test_fresnel_s_energyconservation(self): '''Energy conservation for reflected and transmitted amplitudes of s poarised light at an air-glass interface''' theta_i = 15 n_1 = 1.0 n_2 = 1.5 theta_t = tf.snell_theta_t(n_1, n_2, theta_i) r = tf.fresnel_r_s(n_1, n_2, theta_i, theta_t) t = tf.fresnel_t_s(n_1, n_2, theta_i, theta_t) R = r**2 T = t**2 * n_2*np.cos(theta_t)/n_1/np.cos(theta_i) test_energy = R + T self.assertAlmostEqual(test_energy, 1)
# Input n_cov = 1.0 n_film = 1.45 n_subs = 3.8 t_film = 800 AOI = 30 lambda_0 = np.arange(500, 1000) # nm # Angles theta_i = AOI * tf.degrees # incident theta_f = tf.snell_theta_t(n_cov, n_film, theta_i) # film theta_t = tf.snell_theta_t(n_film, n_subs, theta_f) # transmitted # Fresnel coefficients for both polarisations fresnel_s = { 'r12': tf.fresnel_r_s(n_cov, n_film, theta_i, theta_f), 'r23': tf.fresnel_r_s(n_film, n_subs, theta_f, theta_t), 't12': tf.fresnel_t_s(n_cov, n_film, theta_i, theta_f), 't21': tf.fresnel_t_s(n_film, n_cov, theta_f, theta_i), } fresnel_p = { 'r12': tf.fresnel_r_p(n_cov, n_film, theta_i, theta_f), 'r23': tf.fresnel_r_p(n_film, n_subs, theta_f, theta_t), 't12': tf.fresnel_t_p(n_cov, n_film, theta_i, theta_f),
import numpy as np import matplotlib.pyplot as plt import thinfilm as tf # Input n_cov = 1.0 n_sub = 1.45 AOI = np.arange(0, 90) # Calculation theta_i = AOI * tf.degrees theta_t = tf.snell_theta_t(n_cov, n_sub, theta_i) r_s = tf.fresnel_r_s(n_cov, n_sub, theta_i, theta_t) r_p = tf.fresnel_r_p(n_cov, n_sub, theta_i, theta_t) # Graphical output fig, ax = plt.subplots() ax.plot(AOI, np.abs(r_s)**2, 'C0--', label="S polarisation") ax.plot(AOI, np.abs(r_p)**2, 'C3--', label="P polarisation") ax.set_xlabel('Angle of incidence (degrees)') ax.set_ylabel('Reflectance') ax.legend() fig.savefig('./example_figures/brewsters.png')