FRICTION_FACTOR

Calculates pipe-flow friction factor using the fluids library’s collection of exact and approximate correlations. For Re < 2040 the laminar result is returned automatically, while higher Reynolds numbers can be evaluated with the default Clamond solution or one of the named turbulent correlations.

For laminar flow, the wrapper follows:

f_d = \frac{64}{Re}

For turbulent flow, the selected method evaluates a rough-pipe relation based on Re and relative roughness \epsilon/D. This makes the function a general front door for straight-pipe friction-factor calculations when you want one consistent API across many correlations.

Excel Usage

=FRICTION_FACTOR(Re, eD, friction_method, Darcy)
  • Re (float, required): Reynolds number, [-]
  • eD (float, optional, default: 0): Relative roughness (roughness/diameter), [-]
  • friction_method (str, optional, default: “Clamond”): Calculation method for friction factor
  • Darcy (bool, optional, default: true): If true, returns Darcy friction factor; otherwise Fanning factor (1/4 of Darcy)

Returns (float): Darcy or Fanning friction factor for straight-pipe flow [-]

Example 1: Laminar flow (Re < 2040)

Inputs:

Re eD
1000 0

Excel formula:

=FRICTION_FACTOR(1000, 0)

Expected output:

0.064

Example 2: Turbulent flow in smooth pipe

Inputs:

Re eD
100000 0.0001

Excel formula:

=FRICTION_FACTOR(100000, 0.0001)

Expected output:

0.0185139

Example 3: Turbulent flow with Haaland method

Inputs:

Re eD friction_method
100000 0.001 Haaland

Excel formula:

=FRICTION_FACTOR(100000, 0.001, "Haaland")

Expected output:

0.0219662

Example 4: Return Fanning friction factor

Inputs:

Re eD Darcy
100000 0.0001 false

Excel formula:

=FRICTION_FACTOR(100000, 0.0001, FALSE)

Expected output:

0.00462847

Python Code

Show Code
from fluids.friction import friction_factor as fluids_friction_factor

def friction_factor(Re, eD=0, friction_method='Clamond', Darcy=True):
    """
    Calculate the Darcy friction factor for fluid flow in a pipe using various correlations, automatically selecting appropriate method based on Reynolds number and relative roughness.

    See: https://fluids.readthedocs.io/fluids.friction.html#fluids.friction.friction_factor

    This example function is provided as-is without any representation of accuracy.

    Args:
        Re (float): Reynolds number, [-]
        eD (float, optional): Relative roughness (roughness/diameter), [-] Default is 0.
        friction_method (str, optional): Calculation method for friction factor Valid options: Clamond, Colebrook, Moody, Churchill_1977, Haaland, Swamee_Jain_1976, Jain_1976, Alshul_1952, Wood_1966, Churchill_1973, Eck_1973, Chen_1979, Round_1980, Shacham_1980, Barr_1981, Zigrang_Sylvester_1, Zigrang_Sylvester_2, Serghides_1, Serghides_2, Tsal_1989, Manadilli_1997, Romeo_2002, Sonnad_Goudar_2006, Rao_Kumar_2007, Buzzelli_2008, Avci_Karagoz_2009, Papaevangelo_2010, Brkic_2011_1, Brkic_2011_2, Fang_2011. Default is 'Clamond'.
        Darcy (bool, optional): If true, returns Darcy friction factor; otherwise Fanning factor (1/4 of Darcy) Default is True.

    Returns:
        float: Darcy or Fanning friction factor for straight-pipe flow [-]
    """
    try:
      Re = float(Re)
      eD = float(eD)
      friction_method = str(friction_method)
      Darcy = bool(Darcy)

      if Re <= 0:
        return "Error: Reynolds number must be positive."

      if eD < 0:
        return "Error: Relative roughness must be non-negative."

      result = fluids_friction_factor(Re=Re, eD=eD, Method=friction_method, Darcy=Darcy)

      if result != result:
        return "Error: Result is NaN."
      if result == float('inf') or result == float('-inf'):
        return "Error: Result is not finite."

      return float(result)
    except Exception as e:
      return f"Error: {str(e)}"

Online Calculator

Reynolds number, [-]
Relative roughness (roughness/diameter), [-]
Calculation method for friction factor
If true, returns Darcy friction factor; otherwise Fanning factor (1/4 of Darcy)