.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "api/gallery/aerodynamics/compressible/plot_02_mach_cone.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 or to run this example in your browser via JupyterLite. .. rst-class:: sphx-glr-example-title .. _sphx_glr_api_gallery_aerodynamics_compressible_plot_02_mach_cone.py: Ernst Mach's shock photographs and the Mach cone ================================================ In 1887 Ernst Mach and Peter Salcher photographed a supersonic bullet and saw a conical wave trailing from its nose. A source moving faster than sound outruns its own wavefronts; their envelope is a cone of half-angle :math:`\mu = \arcsin(1/M)` (:func:`~engineeringkit.aerodynamics.mach_angle`). This example draws the wavefronts emitted along the path and checks that the envelope matches the Mach angle. .. GENERATED FROM PYTHON SOURCE LINES 14-19 .. code-block:: Python import matplotlib.pyplot as plt import numpy as np from engineeringkit.aerodynamics import mach_angle .. GENERATED FROM PYTHON SOURCE LINES 20-25 Wavefronts from a moving source ------------------------------- A pulse emitted at time :math:`t_i` is a circle of radius :math:`a(t - t_i)` centred where the source was. .. GENERATED FROM PYTHON SOURCE LINES 25-47 .. code-block:: Python a = 1.0 fig, axes = plt.subplots(1, 3, figsize=(11, 3.4)) for ax, M in zip(axes, [0.6, 1.0, 2.0], strict=True): t_now = 4.0 for ti in np.arange(0, t_now, 0.4): circle = plt.Circle((M * a * ti, 0), a * (t_now - ti), fill=False, color="C0", lw=0.8) ax.add_patch(circle) x_src = M * a * t_now ax.plot(x_src, 0, "ko") if M >= 1: mu = mach_angle(M) length = 5 ax.plot([x_src, x_src - length * np.cos(mu)], [0, length * np.sin(mu)], "C3") ax.plot([x_src, x_src - length * np.cos(mu)], [0, -length * np.sin(mu)], "C3") print(f"M = {M}: Mach angle {np.degrees(mu):.1f} deg") ax.set(xlim=(-4.5, 9), ylim=(-4.5, 4.5), title=f"M = {M}") ax.set_aspect("equal") ax.set_xticks([]) ax.set_yticks([]) fig.tight_layout() .. image-sg:: /api/gallery/aerodynamics/compressible/images/sphx_glr_plot_02_mach_cone_001.png :alt: M = 0.6, M = 1.0, M = 2.0 :srcset: /api/gallery/aerodynamics/compressible/images/sphx_glr_plot_02_mach_cone_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none M = 1.0: Mach angle 90.0 deg M = 2.0: Mach angle 30.0 deg .. GENERATED FROM PYTHON SOURCE LINES 48-53 The envelope is the Mach cone ----------------------------- The tangent from the source to the oldest wavefront makes angle :math:`\arcsin(r/d) = \arcsin(a t/(M a t)) = \arcsin(1/M)`. .. GENERATED FROM PYTHON SOURCE LINES 53-59 .. code-block:: Python for M in [1.2, 2.0, 5.0]: d, r = M * a * 4.0, a * 4.0 assert np.isclose(np.arcsin(r / d), mach_angle(M)) plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.103 seconds) .. _sphx_glr_download_api_gallery_aerodynamics_compressible_plot_02_mach_cone.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: lite-badge .. image:: images/jupyterlite_badge_logo.svg :target: ../../../../lite/lab/index.html?path=api/gallery/aerodynamics/compressible/plot_02_mach_cone.ipynb :alt: Launch JupyterLite :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_02_mach_cone.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_02_mach_cone.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_02_mach_cone.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_