
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "auto_examples/fluid_dynamics/plot_darcy_friction_factor.py"
.. LINE NUMBERS ARE GIVEN BELOW.

.. only:: html

    .. note::
        :class: sphx-glr-download-link-note

        :ref:`Go to the end <sphx_glr_download_auto_examples_fluid_dynamics_plot_darcy_friction_factor.py>`
        to download the full example code.

.. rst-class:: sphx-glr-example-title

.. _sphx_glr_auto_examples_fluid_dynamics_plot_darcy_friction_factor.py:


================================
Darcy Friction Factor
================================

This example generates a Moody diagram using the Darcy friction factor function

.. GENERATED FROM PYTHON SOURCE LINES 9-39



.. image-sg:: /auto_examples/fluid_dynamics/images/sphx_glr_plot_darcy_friction_factor_001.png
   :alt: Moody diagram
   :srcset: /auto_examples/fluid_dynamics/images/sphx_glr_plot_darcy_friction_factor_001.png
   :class: sphx-glr-single-img





.. code-block:: Python

    import warnings

    import matplotlib.pyplot as plt
    import pandas as pd
    import numpy as np

    from indsl.fluid_dynamics import Darcy_friction_factor

    # suppress "No frequency information was given" warning - Frequency information is derived from datetime index
    warnings.filterwarnings("ignore")

    n = 1000
    Re = pd.Series(np.power(10, np.linspace(2, 8, n)))


    roughness_scaled_parameters = [0, 1e-6, 1e-5, 1e-4, 1e-3]

    fig = plt.figure(figsize=(10, 8))
    for roughness_scaled_parameter in roughness_scaled_parameters:
        roughness_scaled = pd.Series(roughness_scaled_parameter * np.ones(n))
        friction_factor = Darcy_friction_factor(Re, roughness_scaled, laminar_limit=2300.0, turbulent_limit=4000.0)
        plt.loglog(Re.array, friction_factor.array, "-", label=r"$\epsilon$=%1.2g" % (roughness_scaled_parameter))
    plt.xlabel("Reynolds number [-]")
    plt.ylabel("Friction factor [-]")
    plt.grid(1)
    plt.xlim([min(Re.array), max(Re.array)])
    plt.legend(loc=0, title="Relative wall roughness")
    plt.title("Moody diagram")
    plt.tight_layout()
    plt.show()


.. rst-class:: sphx-glr-timing

   **Total running time of the script:** (0 minutes 1.359 seconds)


.. _sphx_glr_download_auto_examples_fluid_dynamics_plot_darcy_friction_factor.py:

.. only:: html

  .. container:: sphx-glr-footer sphx-glr-footer-example

    .. container:: sphx-glr-download sphx-glr-download-jupyter

      :download:`Download Jupyter notebook: plot_darcy_friction_factor.ipynb <plot_darcy_friction_factor.ipynb>`

    .. container:: sphx-glr-download sphx-glr-download-python

      :download:`Download Python source code: plot_darcy_friction_factor.py <plot_darcy_friction_factor.py>`

    .. container:: sphx-glr-download sphx-glr-download-zip

      :download:`Download zipped: plot_darcy_friction_factor.zip <plot_darcy_friction_factor.zip>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_
