| Title: | Head Loss Calculations for Pipelines |
|---|---|
| Description: | Provides simple and efficient functions to calculate head loss in pipes using standard hydraulic equations. |
| Authors: | Joao Batista Tolentino Jr. [aut, cre] (ORCID: <https://orcid.org/0000-0003-1303-4202>) |
| Maintainer: | Joao Batista Tolentino Jr. <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.0.0.9000 |
| Built: | 2026-05-13 10:00:36 UTC |
| Source: | https://github.com/joaobtj/hf |
Calculates the required internal pipe diameter iteratively given a specific head loss and flow rate. By taking a functional approach, it supports any friction factor calculation function.
calc_diameter_darcy( loss, length, flow, roughness, friction_fun = NULL, viscosity = 1.004e-06, gravity = 9.81 )calc_diameter_darcy( loss, length, flow, roughness, friction_fun = NULL, viscosity = 1.004e-06, gravity = 9.81 )
loss |
Numeric. The target friction head loss (meters). |
length |
Numeric. The length of the pipe (meters). |
flow |
Numeric. The volumetric flow rate (cubic meters per second). |
roughness |
Numeric. The absolute internal roughness of the pipe (meters). Required unless |
friction_fun |
Function. A function to calculate the friction factor (must accept |
viscosity |
Numeric. Kinematic viscosity of the fluid (sq. meters per sec). Default is 1.004e-6. |
gravity |
Numeric. Acceleration due to gravity (meters per second squared). Default is 9.81. |
A numeric vector representing the required internal diameter in meters.
# Find diameter using the default Colebrook-White function calc_diameter_darcy(loss = 5, length = 100, flow = 0.02, roughness = 0.00026) # Find diameter by injecting Swamee-Jain calc_diameter_darcy( loss = 5, length = 100, flow = 0.02, roughness = 0.00026, friction_fun = calc_friction_sj )# Find diameter using the default Colebrook-White function calc_diameter_darcy(loss = 5, length = 100, flow = 0.02, roughness = 0.00026) # Find diameter by injecting Swamee-Jain calc_diameter_darcy( loss = 5, length = 100, flow = 0.02, roughness = 0.00026, friction_fun = calc_friction_sj )
Calculates the required internal pipe diameter given a specific target head loss, length, flow rate, and Flamant roughness coefficient.
calc_diameter_flamant(loss, length, flow, coef = 0.000135)calc_diameter_flamant(loss, length, flow, coef = 0.000135)
loss |
Numeric. The target friction head loss (meters). |
length |
Numeric. The length of the pipe (meters). |
flow |
Numeric. The volumetric flow rate (cubic meters per second). |
coef |
Numeric. The Flamant roughness coefficient ( |
A numeric vector representing the required internal diameter in meters.
# Find diameter for a 50m pipe with 1.5m allowable head loss and 0.0002 m^3/s flow calc_diameter_flamant(loss = 1.5, length = 50, flow = 0.0002)# Find diameter for a 50m pipe with 1.5m allowable head loss and 0.0002 m^3/s flow calc_diameter_flamant(loss = 1.5, length = 50, flow = 0.0002)
Calculates the required internal pipe diameter given a specific
target head loss, length, flow rate, and roughness coefficient based on the
Hazen-Williams (hw) equation.
calc_diameter_hw(loss, length, flow, coef = 140)calc_diameter_hw(loss, length, flow, coef = 140)
loss |
Numeric. The target friction head loss (meters). |
length |
Numeric. The length of the pipe (meters). |
flow |
Numeric. The volumetric flow rate (cubic meters per second). |
coef |
Numeric. The Hazen-Williams roughness coefficient (dimensionless). Default is 140, which is typical for PVC pipes. |
A numeric vector representing the required internal diameter in meters.
# Find diameter for a 100m pipe with 2m allowable head loss, 0.02 m^3/s flow (C = 140) calc_diameter_hw(loss = 2, length = 100, flow = 0.02)# Find diameter for a 100m pipe with 2m allowable head loss, 0.02 m^3/s flow (C = 140) calc_diameter_hw(loss = 2, length = 100, flow = 0.02)
Calculates the volumetric flow rate iteratively given a specific head loss. This function uses a functional programming approach, allowing the injection of any friction factor function (e.g., Colebrook-White).
calc_flow_darcy( loss, length, diameter, roughness, friction_fun = NULL, viscosity = 1.004e-06, gravity = 9.81 )calc_flow_darcy( loss, length, diameter, roughness, friction_fun = NULL, viscosity = 1.004e-06, gravity = 9.81 )
loss |
Numeric. The target friction head loss (meters). |
length |
Numeric. The length of the pipe (meters). |
diameter |
Numeric. The internal diameter of the pipe (meters). |
roughness |
Numeric. The absolute internal roughness of the pipe (meters). Required unless |
friction_fun |
Function. A function to calculate the friction factor (must accept |
viscosity |
Numeric. Kinematic viscosity of the fluid (sq. meters per sec). Default is 1.004e-6. |
gravity |
Numeric. Acceleration due to gravity (meters per second squared). Default is 9.81. |
A numeric vector representing the volumetric flow rate in cubic meters per second.
# Default: Uses Colebrook-White to find the flow rate calc_flow_darcy(loss = 5, length = 100, diameter = 0.1, roughness = 0.00026) # Injecting Swamee-Jain function calc_flow_darcy( loss = 5, length = 100, diameter = 0.1, roughness = 0.00026, friction_fun = calc_friction_sj )# Default: Uses Colebrook-White to find the flow rate calc_flow_darcy(loss = 5, length = 100, diameter = 0.1, roughness = 0.00026) # Injecting Swamee-Jain function calc_flow_darcy( loss = 5, length = 100, diameter = 0.1, roughness = 0.00026, friction_fun = calc_friction_sj )
Calculates the volumetric flow rate in a pipe given a specific head loss, length, internal diameter, and Flamant coefficient.
calc_flow_flamant(loss, length, diameter, coef = 0.000135)calc_flow_flamant(loss, length, diameter, coef = 0.000135)
loss |
Numeric. The friction head loss (meters). |
length |
Numeric. The length of the pipe (meters). |
diameter |
Numeric. The internal diameter of the pipe (meters). |
coef |
Numeric. The Flamant roughness coefficient ( |
A numeric vector representing the volumetric flow rate in cubic meters per second.
# Find maximum flow rate for a 50m pipe with 15mm diameter and 1.5m head loss calc_flow_flamant(loss = 1.5, length = 50, diameter = 0.015)# Find maximum flow rate for a 50m pipe with 15mm diameter and 1.5m head loss calc_flow_flamant(loss = 1.5, length = 50, diameter = 0.015)
Calculates the volumetric flow rate in a pipe given a specific
head loss, length, internal diameter, and roughness coefficient based on the
Hazen-Williams (hw) equation.
calc_flow_hw(loss, length, diameter, coef = 140)calc_flow_hw(loss, length, diameter, coef = 140)
loss |
Numeric. The friction head loss (meters). |
length |
Numeric. The length of the pipe (meters). |
diameter |
Numeric. The internal diameter of the pipe (meters). |
coef |
Numeric. The Hazen-Williams roughness coefficient (dimensionless). Default is 140, which is typical for PVC pipes. |
A numeric vector representing the volumetric flow rate in cubic meters per second.
# Find flow rate for a 100m pipe with 0.1m diameter, C = 140, and 2m head loss calc_flow_hw(loss = 2, length = 100, diameter = 0.1)# Find flow rate for a 100m pipe with 0.1m diameter, C = 140, and 2m head loss calc_flow_hw(loss = 2, length = 100, diameter = 0.1)
Calculates the Darcy friction factor using the empirical Blasius equation. This formula is highly accurate for smooth pipes (e.g., PVC, glass) and turbulent flows with Reynolds numbers up to 100,000.
calc_friction_blasius(reynolds, roughness, diameter)calc_friction_blasius(reynolds, roughness, diameter)
reynolds |
Numeric. The Reynolds number of the flow (dimensionless). |
roughness |
Numeric. The absolute internal roughness of the pipe (meters). |
diameter |
Numeric. The internal diameter of the pipe (meters). |
A numeric vector representing the Darcy friction factor.
# Calculate friction factor for a Reynolds number of 50,000 calc_friction_blasius(reynolds = 50000, roughness = 0, diameter = 0.1)# Calculate friction factor for a Reynolds number of 50,000 calc_friction_blasius(reynolds = 50000, roughness = 0, diameter = 0.1)
Calculates the Darcy friction factor iteratively using the implicit Colebrook-White equation for turbulent flow. For laminar flow (Re <= 2000), it returns the exact solution (64 / Re).
calc_friction_cw(reynolds, roughness, diameter)calc_friction_cw(reynolds, roughness, diameter)
reynolds |
Numeric. The Reynolds number of the flow (dimensionless). |
roughness |
Numeric. The absolute internal roughness of the pipe (meters). |
diameter |
Numeric. The internal diameter of the pipe (meters). |
A numeric vector representing the Darcy friction factor.
calc_friction_cw(reynolds = 100000, roughness = 0.00026, diameter = 0.1)calc_friction_cw(reynolds = 100000, roughness = 0.00026, diameter = 0.1)
Calculates the Darcy friction factor using the explicit Haaland equation. This formula is a highly accurate explicit approximation of the Colebrook-White equation for turbulent flows.
calc_friction_haaland(reynolds, roughness, diameter)calc_friction_haaland(reynolds, roughness, diameter)
reynolds |
Numeric. The Reynolds number of the flow (dimensionless). |
roughness |
Numeric. The absolute internal roughness of the pipe (meters). |
diameter |
Numeric. The internal diameter of the pipe (meters). |
A numeric vector representing the Darcy friction factor.
# Calculate friction factor for a Reynolds number of 100,000 calc_friction_haaland(reynolds = 100000, roughness = 0.00026, diameter = 0.1)# Calculate friction factor for a Reynolds number of 100,000 calc_friction_haaland(reynolds = 100000, roughness = 0.00026, diameter = 0.1)
Calculates the Darcy friction factor using the explicit Swamee-Jain equation. This is a highly accurate approximation of the Colebrook-White equation that does not require iteration.
calc_friction_sj(reynolds, roughness, diameter)calc_friction_sj(reynolds, roughness, diameter)
reynolds |
Numeric. The Reynolds number of the flow (dimensionless). |
roughness |
Numeric. The absolute internal roughness of the pipe (meters). |
diameter |
Numeric. The internal diameter of the pipe (meters). |
A numeric vector representing the Darcy friction factor.
calc_friction_sj(reynolds = 100000, roughness = 0.00026, diameter = 0.1)calc_friction_sj(reynolds = 100000, roughness = 0.00026, diameter = 0.1)
Calculates the friction head loss in a pipe based on the universal Darcy-Weisbach equation. This function allowing the user to inject any friction factor calculation function (e.g., Colebrook-White or Swamee-Jain). Alternatively, a pre-calculated friction factor can be provided directly.
calc_head_loss_darcy( length, flow, diameter, roughness = NULL, friction_factor = NULL, friction_fun = NULL, viscosity = 1.004e-06, gravity = 9.81 )calc_head_loss_darcy( length, flow, diameter, roughness = NULL, friction_factor = NULL, friction_fun = NULL, viscosity = 1.004e-06, gravity = 9.81 )
length |
Numeric. The length of the pipe (meters). |
flow |
Numeric. The volumetric flow rate (cubic meters per second). |
diameter |
Numeric. The internal diameter of the pipe (meters). |
roughness |
Numeric. The absolute internal roughness of the pipe (meters). Required unless |
friction_factor |
Numeric. An optional pre-calculated Darcy friction factor. If provided, |
friction_fun |
Function. A function to calculate the friction factor (must accept |
viscosity |
Numeric. Kinematic viscosity of the fluid (sq. meters per sec). Default is 1.004e-6. |
gravity |
Numeric. Acceleration due to gravity (meters per second squared). Default is 9.81. |
A numeric vector representing the head loss in meters.
# 1. Default: Uses Colebrook-White function automatically calc_head_loss_darcy(length = 100, flow = 0.02, diameter = 0.1, roughness = 0.00026) # 2. Functional Injection: Pass the Swamee-Jain function as an argument calc_head_loss_darcy( length = 100, flow = 0.02, diameter = 0.1, roughness = 0.00026, friction_fun = calc_friction_sj ) # 3. Direct Value: Provide the friction factor manually calc_head_loss_darcy(length = 100, flow = 0.02, diameter = 0.1, friction_factor = 0.02)# 1. Default: Uses Colebrook-White function automatically calc_head_loss_darcy(length = 100, flow = 0.02, diameter = 0.1, roughness = 0.00026) # 2. Functional Injection: Pass the Swamee-Jain function as an argument calc_head_loss_darcy( length = 100, flow = 0.02, diameter = 0.1, roughness = 0.00026, friction_fun = calc_friction_sj ) # 3. Direct Value: Provide the friction factor manually calc_head_loss_darcy(length = 100, flow = 0.02, diameter = 0.1, friction_factor = 0.02)
Calculates the friction head loss in a pipe based on the empirical Flamant equation. This formula is highly recommended for small-diameter plastic pipes (typically < 50 mm) commonly used in micro-irrigation systems.
calc_head_loss_flamant(length, flow, diameter, coef = 0.000135)calc_head_loss_flamant(length, flow, diameter, coef = 0.000135)
length |
Numeric. The length of the pipe (meters). |
flow |
Numeric. The volumetric flow rate (cubic meters per second). |
diameter |
Numeric. The internal diameter of the pipe (meters). |
coef |
Numeric. The Flamant roughness coefficient ( |
A numeric vector representing the head loss in meters.
# Calculate head loss for a 50m PE pipe with 15mm diameter and 0.2 L/s flow calc_head_loss_flamant(length = 50, flow = 0.0002, diameter = 0.015)# Calculate head loss for a 50m PE pipe with 15mm diameter and 0.2 L/s flow calc_head_loss_flamant(length = 50, flow = 0.0002, diameter = 0.015)
Calculates the friction head loss in a pipe based on the empirical
Hazen-Williams (hw) equation. This is valid only for water at ordinary temperatures.
calc_head_loss_hw(length, flow, diameter, coef = 140)calc_head_loss_hw(length, flow, diameter, coef = 140)
length |
Numeric. The length of the pipe (meters). |
flow |
Numeric. The volumetric flow rate (cubic meters per second). |
diameter |
Numeric. The internal diameter of the pipe (meters). |
coef |
Numeric. The Hazen-Williams roughness coefficient (dimensionless). Default is 140, which is typical for PVC pipes. |
A numeric vector representing the head loss in meters.
# Calculate head loss for a 100m PVC pipe (C = 140) with 0.1m diameter and 0.02 m^3/s flow calc_head_loss_hw(length = 100, flow = 0.02, diameter = 0.1)# Calculate head loss for a 100m PVC pipe (C = 140) with 0.1m diameter and 0.02 m^3/s flow calc_head_loss_hw(length = 100, flow = 0.02, diameter = 0.1)