ONE_PHASE_DP

Overview

The ONE_PHASE_DP function calculates single-phase pressure drop in a pipe using the Darcy-Weisbach equation, the most accurate and universally applicable formula for pipe flow resistance. This equation relates pressure loss due to viscous friction along a pipe to fluid properties, flow rate, and pipe geometry.

The underlying calculation is provided by the fluids library, an open-source Python package for fluid dynamics and heat transfer. For detailed documentation, see the fluids.friction module.

The Darcy-Weisbach equation expresses pressure drop as:

\Delta P = f_D \cdot \frac{L}{D} \cdot \frac{\rho v^2}{2}

where \Delta P is the pressure drop (Pa), f_D is the Darcy friction factor, L is pipe length (m), D is pipe diameter (m), \rho is fluid density (kg/m³), and v is flow velocity (m/s).

The friction factor f_D depends on the flow regime. For laminar flow (Reynolds number Re < 2040), the friction factor is calculated analytically as f_D = 64/Re. For turbulent flow, the function uses one of several correlation methods to solve for the friction factor based on the Colebrook equation. The default method, Clamond, provides an exact analytical solution accurate to machine precision, as described by Clamond (2009).

Available friction factor methods include Clamond (default), Colebrook, Moody, Churchill_1977, Haaland, and Swamee_Jain_1976. These correlations account for both smooth and rough pipe surfaces through the relative roughness parameter \varepsilon/D, where \varepsilon is the pipe wall roughness height.

This function is suitable for process engineering applications including pipeline design, pump sizing, and hydraulic system analysis where accurate frictional pressure loss calculations are required.

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

Excel Usage

=ONE_PHASE_DP(m, rho, mu, D, roughness, L, dp_method)
  • m (float, required): Mass flow rate of fluid, [kg/s]
  • rho (float, required): Density of fluid, [kg/m³]
  • mu (float, required): Dynamic viscosity of fluid, [Pa·s]
  • D (float, required): Pipe inner diameter, [m]
  • roughness (float, optional, default: 0): Pipe wall roughness, [m]
  • L (float, optional, default: 1): Pipe length, [m]
  • dp_method (str, optional, default: “Clamond”): Friction factor calculation method to use

Returns (float): Pressure drop, [Pa] str: Error message if inputs are invalid.

Examples

Example 1: Laminar flow pressure drop

Inputs:

m rho mu D roughness L
0.01 1000 0.001 0.01 0 1

Excel formula:

=ONE_PHASE_DP(0.01, 1000, 0.001, 0.01, 0, 1)

Expected output:

40.7437

Example 2: Turbulent flow in smooth pipe

Inputs:

m rho mu D roughness L
10 1000 0.00001 0.1 0 1

Excel formula:

=ONE_PHASE_DP(10, 1000, 0.00001, 0.1, 0, 1)

Expected output:

63.4345

Example 3: Turbulent flow in rough pipe

Inputs:

m rho mu D roughness L
10 1000 0.00001 0.1 0.0001 10

Excel formula:

=ONE_PHASE_DP(10, 1000, 0.00001, 0.1, 0.0001, 10)

Expected output:

1593.603

Example 4: Turbulent flow using Haaland method

Inputs:

m rho mu D roughness L dp_method
5 800 0.001 0.05 0.00005 5 Haaland

Excel formula:

=ONE_PHASE_DP(5, 800, 0.001, 0.05, 0.00005, 5, "Haaland")

Expected output:

8726.5482

Python Code

import micropip
await micropip.install(["fluids"])
from fluids.friction import one_phase_dP as fluids_one_phase_dP

def one_phase_dp(m, rho, mu, D, roughness=0, L=1, dp_method='Clamond'):
    """
    Calculate single-phase pressure drop in a pipe using the Darcy-Weisbach equation.

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

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

    Args:
        m (float): Mass flow rate of fluid, [kg/s]
        rho (float): Density of fluid, [kg/m³]
        mu (float): Dynamic viscosity of fluid, [Pa·s]
        D (float): Pipe inner diameter, [m]
        roughness (float, optional): Pipe wall roughness, [m] Default is 0.
        L (float, optional): Pipe length, [m] Default is 1.
        dp_method (str, optional): Friction factor calculation method to use Valid options: Clamond, Colebrook, Moody, Churchill_1977, Haaland, Swamee_Jain_1976. Default is 'Clamond'.

    Returns:
        float: Pressure drop, [Pa] str: Error message if inputs are invalid.
    """
    try:
        m = float(m)
        rho = float(rho)
        mu = float(mu)
        D = float(D)
        roughness = float(roughness)
        L = float(L)
        dp_method = str(dp_method)
    except (ValueError, TypeError):
        return "Error: Could not convert parameters to required types."

    # Validate diameter
    if D <= 0:
        return "Error: Pipe diameter must be positive."

    # Validate density
    if rho <= 0:
        return "Error: Density must be positive."

    # Validate viscosity
    if mu <= 0:
        return "Error: Viscosity must be positive."

    # Validate roughness
    if roughness < 0:
        return "Error: Roughness must be non-negative."

    # Validate length
    if L <= 0:
        return "Error: Pipe length must be positive."

    # Handle zero mass flow rate
    if m == 0:
        return 0.0

    try:
        result = fluids_one_phase_dP(
            m=m,
            rho=rho,
            mu=mu,
            D=D,
            roughness=roughness,
            L=L,
            Method=dp_method
        )

        # Handle NaN and infinity
        if result != result:  # NaN check
            return "nan"
        if result == float('inf'):
            return "inf"
        if result == float('-inf'):
            return "-inf"

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

Online Calculator