snells_law#
- optika.materials.snells_law(direction, index_refraction, index_refraction_new, normal=None, is_mirror=False)[source]#
-
- Parameters:
direction (AbstractCartesian3dVectorArray) – The propagation direction of the incoming light
index_refraction (float | AbstractScalar) – The index of refraction in the current propagation medium, \(n_1\).
index_refraction_new (float | AbstractScalar) – The index of refraction in the new propagation medium, \(n_2\).
normal (None | AbstractCartesian3dVectorArray) – The unit vector perpendicular to the interface between \(n_1\) and \(n_2\).
is_mirror (bool | AbstractScalar) – A boolean flag controlling whether to compute the direction of the reflected ray or the transmitted ray. The default is to compute the transmitted ray.
- Return type:
Examples
Plot the reflected and transmitted rays from a specified input ray.
import numpy as np import matplotlib.pyplot as plt import astropy.units as u import named_arrays as na import optika # Define the propagation direction of the # incident ray angle = 45 * u.deg direction = na.Cartesian3dVectorArray( x=np.sin(angle), y=0, z=-np.cos(angle), ) # Define the keyword arguments that are common # to both the reflected and transmitted ray kwargs = dict( direction=direction, index_refraction=1, normal=na.Cartesian3dVectorArray(0, 0, 1), ) # Calculate the propagation direction of the # reflected ray direction_reflected = optika.materials.snells_law( is_mirror=True, index_refraction_new=1, **kwargs, ) # Calculate the propagation direction of the # transmitted ray direction_transmitted = optika.materials.snells_law( is_mirror=False, index_refraction_new=2, **kwargs, ) # Plot the incident, reflected, and transmitted rays fig, ax = plt.subplots() na.plt.plot( na.stack([-direction, 0], axis="plot"), axis="plot", components=("x", "z"), label="incident", ); na.plt.plot( na.stack([0, direction_transmitted], axis="plot"), axis="plot", components=("x", "z"), label="transmitted", ); na.plt.plot( na.stack([0, direction_reflected], axis="plot"), axis="plot", components=("x", "z"), label="reflected", ); ax.set_aspect("equal"); ax.axvline(0, linestyle="dashed", color="black"); ax.axhspan(ymin=-2, ymax=0, color="lightgray"); ax.set_ylim(-1, None); ax.legend();
Notes
Our goal is to derive a 3D version of Snell’s law that can model the refraction of light in a homogenous material. To start, consider an incident wave of the form:
(1)#\[E_1(\mathbf{r}) = A_1 e^{i \mathbf{k}_1 \cdot \mathbf{r}},\]where \(E_1\) is the magnitude of the incident electric field, \(A_1\) is the amplitude of the incident wave, \(\mathbf{k}_1\) is the incident wavevector, and \(\mathbf{r}\) is a vector from the origin to the test point. Now we define an interface at \(z = 0\), where the index of refraction changes from \(n_1\) to \(n_2\). When the incident wave interacts with this interface, it will create an output wave of the form:
(2)#\[E_2(\mathbf{r}) = A_2 e^{i \mathbf{k}_2 \cdot \mathbf{r}},\]where \(E_2\) is the magnitude of the output electric field, \(A_2\) is the amplitude of the output wave, and \(\mathbf{k}_2\) is the output wavevector. Note in this case we care about only the reflected or the transmitted wave, not both, since we’re only concerned with sequential optics. At the \(z = 0\) interface, \(E_1\) and \(E_2\) satisfy homogenous Dirichlet boundary conditions,
(3)#\[A_1 \exp\left[i \mathbf{k}_1 \cdot (x \hat{\mathbf{x}} + y \hat{\mathbf{y}}) \right] = A_2 \exp\left[i \mathbf{k}_2 \cdot (x \hat{\mathbf{x}} + y \hat{\mathbf{y}}) \right].\]For Equation (3) to be true everywhere in the \(x\)-\(y\) plane, the exponents must be equal:
(4)#\[\mathbf{k}_1 \cdot (x \hat{\mathbf{x}} + y \hat{\mathbf{y}}) = \mathbf{k}_2 \cdot (x \hat{\mathbf{x}} + y \hat{\mathbf{y}}).\]If we take \(\mathbf{k}_i = k_i \hat{\mathbf{k}}_i = n_i k_0 \hat{\mathbf{k}}_i\) for \(i=(1,2)\), where \(k_i\) is the incident/output wavenumber, \(n_i\) is the incident/output index of refraction, \(k_0\) is the wavenumber in vacuum, and \(\hat{\mathbf{k}}_i\) is the incident/output propagation direction, we get an expression in terms of the output direction, \(\hat{\mathbf{k}}_2\):
(5)#\[n_1 \hat{\mathbf{k}}_1 \cdot (x \hat{\mathbf{x}} + y \hat{\mathbf{y}}) = n_2 \hat{\mathbf{k}}_2 \cdot (x \hat{\mathbf{x}} + y \hat{\mathbf{y}}).\]Now, Equation (5) can only be satisfied if the components are separately equal since if \(y=0\)
(6)#\[n_1 \hat{\mathbf{k}}_1 \cdot \hat{\mathbf{x}} = n_2 \hat{\mathbf{k}}_2 \cdot \hat{\mathbf{x}},\]and if \(x=0\)
(7)#\[n_1 \hat{\mathbf{k}}_1 \cdot \hat{\mathbf{y}} = n_2 \hat{\mathbf{k}}_2 \cdot \hat{\mathbf{y}}.\]We can collect Equations (6) and (7) into a single vector equation,
(8)#\[n_1 [ \mathbf{k}_1 - ( \mathbf{k}_1 \cdot \hat{\mathbf{n}} ) \hat{\mathbf{n}} ] = n_2 [ \hat{\mathbf{k}}_2 - ( \hat{\mathbf{k}}_2 \cdot \hat{\mathbf{n}} ) \hat{\mathbf{n}} ],\]where \(\hat{\mathbf{n}} = \hat{\mathbf{z}}\) is the vector normal to the interface. Now we can solve Equation (8) for the output propagation direction, \(\hat{\mathbf{k}}_2\), and the only unknown is the component of the output propagation direction parallel to the surface normal vector, \((\hat{\mathbf{k}}_2 \cdot \hat{\mathbf{n}} )\). We can write this in terms of a cross product,
(9)#\[\hat{\mathbf{k}}_2 \cdot \hat{\mathbf{n}} = \pm \sqrt{1 - |\hat{\mathbf{k}}_2 \times \hat{\mathbf{n}}|^2},\]where the \(\pm\) represents a transmission or reflection, and the cross product \(\mathbf{k}_2 \times \hat{\mathbf{n}}\) can be found by crossing Equation (8) with \(\hat{\mathbf{n}}\),
(10)#\[\hat{\mathbf{k}}_2 \times \hat{\mathbf{n}} = \frac{n_1}{n_2} \mathbf{k}_1 \times \hat{\mathbf{n}},\]which leads to Equation (9) becoming:
(11)#\[\begin{split}\mathbf{k}_2 \cdot \hat{\mathbf{n}} &= \pm \sqrt{1 - \left( \frac{n_1}{n_2} \right)^2 |\mathbf{k}_1 \times \hat{\mathbf{n}}|^2} \\ &= \pm \frac{n_1}{n_2} \sqrt{\left( n_2 / n_1 \right)^2 + (\mathbf{k}_1 \cdot \hat{\mathbf{n}})^2 - k_1^2 }\end{split}\]By plugging Equation (11) into Equation (8), and solving for \(\hat{\mathbf{k}}_2\), we achieve our goal, an expression for the output ray in terms of the input ray and other known quantities.
\[\boxed{\hat{\mathbf{k}}_2 = \frac{n_1}{n_2} \left[ \mathbf{k}_1 + \left( \left( -\mathbf{k}_1 \cdot \hat{\mathbf{n}} \right) \pm \sqrt{\left( n_2 / n_1 \right)^2 + (\mathbf{k}_1 \cdot \hat{\mathbf{n}})^2 - k_1^2 } \right) \hat{\mathbf{n}} \right]}\]References to
optika.materials.snells_law