.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "api/gallery/optics/polarization/plot_brewster_fresnel_equations.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_api_gallery_optics_polarization_plot_brewster_fresnel_equations.py: Brewster's angle and Fresnel's equations ======================================== David Brewster found in 1815 that light reflected from glass is completely polarized at one angle of incidence, :math:`\tan\theta_B = n_2/n_1`, at which the reflected and refracted rays are perpendicular. Augustin-Jean Fresnel explained it in 1823 from his transverse-wave theory: the components polarized perpendicular (s) and parallel (p) to the plane of incidence reflect with different amplitudes, .. math:: r_s = \frac{n_1\cos\theta_1 - n_2\cos\theta_2}{n_1\cos\theta_1 + n_2\cos\theta_2}, \qquad r_\parallel = \frac{n_2\cos\theta_1 - n_1\cos\theta_2}{n_1\cos\theta_2 + n_2\cos\theta_1}, and :math:`r_\parallel` vanishes at Brewster's angle. Going from glass into air, :math:`\cos\theta_2` turns imaginary beyond the critical angle :math:`\sin\theta_c = n_2/n_1`, all the light is reflected, and the s and p waves come back with a phase difference .. math:: \tan\frac{\delta}{2} = \frac{\cos\theta\sqrt{\sin^2\theta - n^2}}{\sin^2\theta}, \qquad n = n_2/n_1. Fresnel used two such reflections of :math:`\delta = 45^\circ` each in a glass rhomb to turn linear light into circular light, a quarter-wave retarder with no crystal. physicskit's :func:`~physicskit.optics.fresnel_coefficients` returns :math:`r_p = -r_\parallel`, so that :math:`r_p = r_s` at normal incidence, the convention of the characteristic-matrix method in :func:`~physicskit.optics.multilayer_response`; this example checks the two against each other. .. GENERATED FROM PYTHON SOURCE LINES 36-46 .. code-block:: Python import matplotlib.pyplot as plt import numpy as np from physicskit.optics import brewster_angle, critical_angle, fresnel_coefficients, multilayer_response n_glass = 1.5 theta = np.radians(np.linspace(0, 89.9, 900)) fig, axes = plt.subplots(1, 3, figsize=(15, 4.2)) .. image-sg:: /api/gallery/optics/polarization/images/sphx_glr_plot_brewster_fresnel_equations_001.png :alt: plot brewster fresnel equations :srcset: /api/gallery/optics/polarization/images/sphx_glr_plot_brewster_fresnel_equations_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 47-49 External reflection: air to glass --------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 49-60 .. code-block:: Python ext = fresnel_coefficients(1.0, n_glass, theta) theta_B = brewster_angle(1.0, n_glass) axes[0].plot(np.degrees(theta), ext["R_s"], color="steelblue", lw=2, label="$R_s$") axes[0].plot(np.degrees(theta), ext["R_p"], color="crimson", lw=2, label="$R_p$") axes[0].axvline(np.degrees(theta_B), color="k", ls=":", lw=1) axes[0].annotate(rf"$\theta_B = {np.degrees(theta_B):.2f}^\circ$", (np.degrees(theta_B), 0.3), (20, 0.5), arrowprops={"arrowstyle": "->"}) axes[0].set_xlabel("angle of incidence (deg)") axes[0].set_ylabel("reflectance") axes[0].set_title("Air to glass (n = 1.5)") axes[0].legend(fontsize=8) .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 61-63 Internal reflection: glass to air --------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 63-75 .. code-block:: Python internal = fresnel_coefficients(n_glass, 1.0, theta) theta_c = critical_angle(n_glass, 1.0) theta_B_int = brewster_angle(n_glass, 1.0) axes[1].plot(np.degrees(theta), internal["R_s"], color="steelblue", lw=2, label="$R_s$") axes[1].plot(np.degrees(theta), internal["R_p"], color="crimson", lw=2, label="$R_p$") axes[1].axvspan(np.degrees(theta_c), 90, color="0.9") axes[1].text(np.degrees(theta_c) + 2, 0.5, f"total internal\nreflection\nbeyond {np.degrees(theta_c):.2f} deg", fontsize=8) axes[1].axvline(np.degrees(theta_B_int), color="k", ls=":", lw=1) axes[1].set_xlabel("angle of incidence (deg)") axes[1].set_title("Glass to air") axes[1].legend(fontsize=8, loc="center left") .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 76-80 The phase difference under total internal reflection: Fresnel's rhomb --------------------------------------------------------------------- Crown glass of n = 1.51 gives delta = 45 degrees near 48.6 and 54.6 degrees; Fresnel's rhomb uses two reflections at 54.6 degrees. .. GENERATED FROM PYTHON SOURCE LINES 80-96 .. code-block:: Python n_rhomb = 1.51 tir = np.radians(np.linspace(np.degrees(critical_angle(n_rhomb, 1.0)) + 1e-6, 89.9, 600)) c = fresnel_coefficients(n_rhomb, 1.0, tir) delta = np.angle(c["r_s"] / -c["r_p"]) # relative to Hecht's r_parallel = -r_p n_rel = 1.0 / n_rhomb delta_closed = 2 * np.arctan(np.cos(tir) * np.sqrt(np.sin(tir) ** 2 - n_rel**2) / np.sin(tir) ** 2) axes[2].plot(np.degrees(tir), np.degrees(delta), color="purple", lw=2, label="fresnel_coefficients") axes[2].plot(np.degrees(tir[::40]), np.degrees(delta_closed[::40]), "ko", ms=4, label="closed form") axes[2].axhline(45, color="k", ls=":", lw=1) axes[2].set_xlabel("angle of incidence (deg)") axes[2].set_ylabel(r"$\delta = \varphi_s - \varphi_\parallel$ (deg)") axes[2].set_title("Phase difference on total reflection (n = 1.51)") axes[2].legend(fontsize=8) plt.tight_layout() plt.show() .. image-sg:: /api/gallery/optics/polarization/images/sphx_glr_plot_brewster_fresnel_equations_002.png :alt: plot brewster fresnel equations :srcset: /api/gallery/optics/polarization/images/sphx_glr_plot_brewster_fresnel_equations_002.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 97-98 Two reflections at 54.6 degrees retard s by a quarter wave relative to p. .. GENERATED FROM PYTHON SOURCE LINES 98-103 .. code-block:: Python theta_rhomb = np.radians(54.6) c_rhomb = fresnel_coefficients(n_rhomb, 1.0, theta_rhomb) delta_rhomb = 2 * np.angle(c_rhomb["r_s"] / -c_rhomb["r_p"]) print(f"two reflections at 54.6 deg: delta = {np.degrees(delta_rhomb):.2f} deg") .. rst-class:: sphx-glr-script-out .. code-block:: none two reflections at 54.6 deg: delta = 90.02 deg .. GENERATED FROM PYTHON SOURCE LINES 104-106 The same interface from the characteristic-matrix method -------------------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 106-113 .. code-block:: Python max_err = 0.0 for n1, n2, coeffs in [(1.0, n_glass, ext), (n_glass, 1.0, internal)]: for pol in "sp": m = [multilayer_response([], [], 550.0, n1, n2, t, pol) for t in theta] max_err = max(max_err, np.max(np.abs(coeffs[f"r_{pol}"] - np.array([x["r"] for x in m])))) print(f"largest |r_fresnel - r_multilayer| = {max_err:.1e}") .. rst-class:: sphx-glr-script-out .. code-block:: none largest |r_fresnel - r_multilayer| = 8.4e-14 .. GENERATED FROM PYTHON SOURCE LINES 114-116 Check ----- .. GENERATED FROM PYTHON SOURCE LINES 116-125 .. code-block:: Python assert abs(ext["R_s"][0] - 0.04) < 1e-12 and abs(ext["R_p"][0] - 0.04) < 1e-12 assert abs(np.degrees(theta_B) - 56.31) < 5e-3 and fresnel_coefficients(1.0, n_glass, theta_B)["R_p"] < 1e-30 assert abs(np.degrees(theta_c) - 41.81) < 5e-3 beyond = theta > theta_c assert np.allclose(internal["R_s"][beyond], 1, atol=1e-12) and np.allclose(internal["R_p"][beyond], 1, atol=1e-12) assert np.all(internal["R_s"][~beyond] < 1) assert np.allclose(delta, delta_closed, atol=1e-12) assert abs(np.degrees(delta_rhomb) - 90) < 0.5 assert max_err < 1e-12 .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.101 seconds) .. _sphx_glr_download_api_gallery_optics_polarization_plot_brewster_fresnel_equations.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_brewster_fresnel_equations.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_brewster_fresnel_equations.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_brewster_fresnel_equations.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_