.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "api/gallery/fluid_engineering/pipe_flow/plot_02_darcy_weisbach.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_pipe_flow_plot_02_darcy_weisbach.py: Weisbach and Darcy: head loss in pipes (1845-1857) ================================================== Julius Weisbach wrote the friction loss in a pipe in 1845 as :math:`h_f = f\,(L/D)\,v^2/(2g)`, with a coefficient that he fitted to experiments. Henry Darcy's tests on new and incrusted cast-iron mains in Paris, published in 1857, showed that the coefficient depends on the diameter and the state of the wall. The Darcy-Weisbach equation (:func:`~engineeringkit.fluid_engineering.darcy_head_loss`), with loss coefficients for the fittings (:func:`~engineeringkit.fluid_engineering.minor_head_loss`), is still how pipelines are sized. This example follows the energy and hydraulic grade lines of water flowing from a reservoir through two pipes to a nozzle. .. GENERATED FROM PYTHON SOURCE LINES 18-30 .. code-block:: Python import matplotlib.pyplot as plt import numpy as np from engineeringkit.fluid_engineering import ( colebrook_friction_factor, darcy_head_loss, minor_head_loss, reynolds_number, velocity_head, ) from engineeringkit.fluid_engineering.visualizers import plot_grade_lines .. GENERATED FROM PYTHON SOURCE LINES 31-38 The system ---------- A reservoir surface stands 25 m above the outlet. 200 m of 150 mm pipe lead to a contraction and 100 m of 100 mm pipe, ending in a free jet. Water flows at 25 L/s; the entrance has :math:`K = 0.5` and the contraction :math:`K = 0.3` on the downstream velocity. .. GENERATED FROM PYTHON SOURCE LINES 38-53 .. code-block:: Python rho, mu, eps, Q, z_res = 998.0, 1.0e-3, 0.045e-3, 0.025, 25.0 pipes = [(200.0, 0.15), (100.0, 0.10)] v = [Q / (np.pi * D**2 / 4) for _, D in pipes] f = [colebrook_friction_factor(reynolds_number(rho, vi, D, mu), eps / D) for vi, (_, D) in zip(v, pipes)] losses = { "entrance": minor_head_loss(0.5, v[0]), "pipe 1": darcy_head_loss(f[0], pipes[0][0], pipes[0][1], v[0]), "contraction": minor_head_loss(0.3, v[1]), "pipe 2": darcy_head_loss(f[1], pipes[1][0], pipes[1][1], v[1]), } for name, h in losses.items(): print(f"{name:>11}: {h:5.2f} m") .. rst-class:: sphx-glr-script-out .. code-block:: none entrance: 0.05 m pipe 1: 2.40 m contraction: 0.15 m pipe 2: 9.22 m .. GENERATED FROM PYTHON SOURCE LINES 54-60 Grade lines ----------- The energy grade line starts at the reservoir surface and drops at each loss; the hydraulic grade line sits one velocity head below it. The pipe runs along the ground at 0 m. .. GENERATED FROM PYTHON SOURCE LINES 60-68 .. code-block:: Python x = np.array([0, 0, 200, 200, 300]) egl = z_res - np.cumsum([losses["entrance"], 0, losses["pipe 1"], losses["contraction"], losses["pipe 2"]]) hv = velocity_head(np.array([v[0], v[0], v[0], v[1], v[1]])) ax = plot_grade_lines(x, np.zeros(5), egl - hv, hv) ax.set_title("Reservoir to free jet") ax.figure.tight_layout() .. image-sg:: /api/gallery/fluid_engineering/pipe_flow/images/sphx_glr_plot_02_darcy_weisbach_001.png :alt: Reservoir to free jet :srcset: /api/gallery/fluid_engineering/pipe_flow/images/sphx_glr_plot_02_darcy_weisbach_001.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 69-71 The energy left at the outlet is the jet's velocity head; the rest went to friction and fittings. .. GENERATED FROM PYTHON SOURCE LINES 71-85 .. code-block:: Python jet = velocity_head(v[1]) print(f"jet velocity head {jet:.2f} m + losses {sum(losses.values()):.2f} m = {jet + sum(losses.values()):.2f} m available") print(f"friction share of the losses: {(losses['pipe 1'] + losses['pipe 2']) / sum(losses.values()):.0%}") # Head loss in fully rough flow grows as v²: doubling the flow roughly quadruples it. h2 = darcy_head_loss(colebrook_friction_factor(reynolds_number(rho, 2 * v[1], 0.1, mu), eps / 0.1), 100.0, 0.1, 2 * v[1]) print(f"doubling the flow multiplies the pipe-2 loss by {h2 / losses['pipe 2']:.2f}") assert z_res - sum(losses.values()) > jet # the pipe can carry this flow with head to spare assert 3.6 < h2 / losses["pipe 2"] < 4.0 assert np.all(np.diff(egl) <= 0) plt.show() .. rst-class:: sphx-glr-script-out .. code-block:: none jet velocity head 0.52 m + losses 11.82 m = 12.34 m available friction share of the losses: 98% doubling the flow multiplies the pipe-2 loss by 3.84 .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.032 seconds) .. _sphx_glr_download_api_gallery_fluid_engineering_pipe_flow_plot_02_darcy_weisbach.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/pipe_flow/plot_02_darcy_weisbach.ipynb :alt: Launch JupyterLite :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_02_darcy_weisbach.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_02_darcy_weisbach.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_02_darcy_weisbach.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_