DP_GRAV
Calculates the gravitational contribution to single-phase pressure drop in an inclined pipe from the pipe angle, fluid density, pipe length, and gravitational acceleration. It can be used either as a per-unit-length head term or as a total pressure difference over a finite segment.
The underlying relations are:
-\left(\frac{dP}{dz}\right)_{grav} = \rho g \sin\theta
-\Delta P_{grav} = L\rho g\sin\theta
Positive values correspond to an uphill pressure-drop contribution, while negative values indicate pressure recovery for downhill flow.
Excel Usage
=DP_GRAV(angle, rho, L, g)
angle(float, required): Pipe angle relative to horizontal [degrees]rho(float, required): Fluid density [kg/m³]L(float, optional, default: 1): Pipe length [m]g(float, optional, default: 9.80665): Gravitational acceleration [m/s²]
Returns (float): Gravitational pressure-drop component, returned as [Pa/m] when L=1 or [Pa] otherwise
Example 1: Horizontal pipe (no gravitational drop)
Inputs:
| angle | rho |
|---|---|
| 0 | 1000 |
Excel formula:
=DP_GRAV(0, 1000)
Expected output:
0
Example 2: Upward flow at 45 degrees (water)
Inputs:
| angle | rho |
|---|---|
| 45 | 1000 |
Excel formula:
=DP_GRAV(45, 1000)
Expected output:
6934.35
Example 3: Downward flow at -30 degrees (oil)
Inputs:
| angle | rho | L |
|---|---|---|
| -30 | 850 | 10 |
Excel formula:
=DP_GRAV(-30, 850, 10)
Expected output:
-41678.3
Example 4: Vertical pipe (90 degrees, air)
Inputs:
| angle | rho | L | g |
|---|---|---|---|
| 90 | 2.6 | 4 | 9.80665 |
Excel formula:
=DP_GRAV(90, 2.6, 4, 9.80665)
Expected output:
101.989
Python Code
Show Code
from fluids.friction import one_phase_dP_gravitational as fluids_dp_grav
def dp_grav(angle, rho, L=1, g=9.80665):
"""
Calculate gravitational pressure drop component for single-phase flow in inclined pipes.
See: https://fluids.readthedocs.io/fluids.friction.html#fluids.friction.one_phase_dP_gravitational
This example function is provided as-is without any representation of accuracy.
Args:
angle (float): Pipe angle relative to horizontal [degrees]
rho (float): Fluid density [kg/m³]
L (float, optional): Pipe length [m] Default is 1.
g (float, optional): Gravitational acceleration [m/s²] Default is 9.80665.
Returns:
float: Gravitational pressure-drop component, returned as [Pa/m] when L=1 or [Pa] otherwise
"""
try:
angle = float(angle)
rho = float(rho)
L = float(L)
g = float(g)
if rho <= 0:
return "Error: Fluid density (rho) must be positive."
if L <= 0:
return "Error: Pipe length (L) must be positive."
if g <= 0:
return "Error: Gravitational acceleration (g) must be positive."
result = fluids_dp_grav(angle=angle, rho=rho, L=L, g=g)
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)}"