.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "api/gallery/fluid_engineering/measurement/plot_01_pitot_tube.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_fluid_engineering_measurement_plot_01_pitot_tube.py: Pitot's tube (1732) =================== In 1732 Henri Pitot lowered a glass tube bent at a right angle into the Seine, its mouth facing upstream, and watched the water inside rise above the river surface. The rise is the velocity head :math:`v^2/(2g)`, and it showed, against the belief of the day, that the current is faster near the surface than at depth. Turned around, the stagnation rise gives the speed, :math:`v = \sqrt{2\Delta p/\rho}` (:func:`~engineeringkit.fluid_engineering.pitot_velocity`). This example reads river and air speeds from a Pitot tube and finds the Mach number at which the incompressible formula starts to mislead an airspeed indicator. .. GENERATED FROM PYTHON SOURCE LINES 17-22 .. code-block:: Python import matplotlib.pyplot as plt import numpy as np from engineeringkit.fluid_engineering import G, dynamic_pressure, pitot_velocity, velocity_head .. GENERATED FROM PYTHON SOURCE LINES 23-25 Water rising in the tube ------------------------ .. GENERATED FROM PYTHON SOURCE LINES 25-32 .. code-block:: Python for v in [0.5, 1.0, 2.0]: print(f"river at {v:.1f} m/s: water rises {100 * velocity_head(v):.1f} cm in the tube") rise = 0.051 print(f"a {100 * rise:.1f} cm rise means {pitot_velocity(998.0 * G * rise, 998.0):.2f} m/s") .. rst-class:: sphx-glr-script-out .. code-block:: none river at 0.5 m/s: water rises 1.3 cm in the tube river at 1.0 m/s: water rises 5.1 cm in the tube river at 2.0 m/s: water rises 20.4 cm in the tube a 5.1 cm rise means 1.00 m/s .. GENERATED FROM PYTHON SOURCE LINES 33-40 Airspeed and compressibility ---------------------------- In a gas the stagnation rise is :math:`p[(1 + \frac{\gamma - 1}{2}M^2)^{\gamma/(\gamma - 1)} - 1]`, larger than :math:`\tfrac12\rho v^2`. Feeding it into the incompressible formula overestimates the speed. .. GENERATED FROM PYTHON SOURCE LINES 40-56 .. code-block:: Python gamma, p, T, R = 1.4, 101325.0, 288.15, 287.05 rho, a = p / (R * T), np.sqrt(gamma * R * T) M = np.linspace(0.01, 0.8, 80) dp = p * ((1 + (gamma - 1) / 2 * M**2) ** (gamma / (gamma - 1)) - 1) error = pitot_velocity(dp, rho) / (M * a) - 1 fig, ax = plt.subplots(figsize=(6, 4)) ax.plot(M, 100 * error) ax.axhline(1, color="k", ls=":") ax.set(xlabel="Mach number", ylabel="overestimate of speed [%]", title="Incompressible Pitot formula in air") fig.tight_layout() M_1pct = np.interp(0.01, error, M) print(f"the error reaches 1% at Mach {M_1pct:.2f}") .. image-sg:: /api/gallery/fluid_engineering/measurement/images/sphx_glr_plot_01_pitot_tube_001.png :alt: Incompressible Pitot formula in air :srcset: /api/gallery/fluid_engineering/measurement/images/sphx_glr_plot_01_pitot_tube_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none the error reaches 1% at Mach 0.28 .. GENERATED FROM PYTHON SOURCE LINES 57-59 The tube inverts the dynamic pressure exactly, and stays within 1% in air below about Mach 0.28. .. GENERATED FROM PYTHON SOURCE LINES 59-65 .. code-block:: Python v = np.array([0.3, 3.0, 30.0]) assert np.allclose(pitot_velocity(dynamic_pressure(998.0, v), 998.0), v) assert 0.25 < M_1pct < 0.3 plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.026 seconds) .. _sphx_glr_download_api_gallery_fluid_engineering_measurement_plot_01_pitot_tube.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/fluid_engineering/measurement/plot_01_pitot_tube.ipynb :alt: Launch JupyterLite :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_01_pitot_tube.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_01_pitot_tube.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_01_pitot_tube.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_