function calculatePipeFlow() {
// 1. Get Input Values
var diameterInput = document.getElementById("innerDiameter").value;
var diameterUnit = document.getElementById("diameterUnit").value;
var velocityInput = document.getElementById("fluidVelocity").value;
var velocityUnit = document.getElementById("velocityUnit").value;
// 2. Validate Inputs
if (diameterInput === "" || velocityInput === "" || isNaN(diameterInput) || isNaN(velocityInput)) {
alert("Please enter valid numerical values for both Pipe Diameter and Fluid Velocity.");
return;
}
var diameter = parseFloat(diameterInput);
var velocity = parseFloat(velocityInput);
if (diameter <= 0 || velocity < 0) {
alert("Diameter must be greater than 0 and velocity cannot be negative.");
return;
}
// 3. Normalize Inputs to Standard Units (Meters for length, m/s for velocity)
// Convert Diameter to Meters
var diameterInMeters = 0;
if (diameterUnit === "mm") {
diameterInMeters = diameter / 1000;
} else if (diameterUnit === "cm") {
diameterInMeters = diameter / 100;
} else if (diameterUnit === "m") {
diameterInMeters = diameter;
} else if (diameterUnit === "in") {
diameterInMeters = diameter * 0.0254;
}
// Convert Velocity to Meters per Second (m/s)
var velocityInMPS = 0;
if (velocityUnit === "m/s") {
velocityInMPS = velocity;
} else if (velocityUnit === "ft/s") {
velocityInMPS = velocity * 0.3048;
}
// 4. Calculate Area (A = pi * r^2)
var radius = diameterInMeters / 2;
var areaM2 = Math.PI * Math.pow(radius, 2);
// 5. Calculate Flow Rate (Q = A * v) in Cubic Meters per Second (m³/s)
var flowMPS = areaM2 * velocityInMPS;
// 6. Convert Results to Target Units
// Cubic Meters per Hour (m³/h)
var flowCMH = flowMPS * 3600;
// Liters per Minute (L/min)
// 1 m³/s = 60,000 L/min
var flowLPM = flowMPS * 60000;
// US Gallons per Minute (GPM)
// 1 m³/s = 15,850.32314 GPM
var flowGPM = flowMPS * 15850.32314;
// Cubic Feet per Second (cfs)
// 1 m³/s = 35.3147 cfs
var flowCFS = flowMPS * 35.3147;
// Area in cm² for display
var areaCM2 = areaM2 * 10000;
// 7. Display Results with Formatting
document.getElementById("resultGPM").innerHTML = flowGPM.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2}) + " US GPM";
document.getElementById("resultLPM").innerHTML = flowLPM.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2}) + " L/min";
document.getElementById("resultCMH").innerHTML = flowCMH.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2}) + " m³/h";
document.getElementById("resultCFS").innerHTML = flowCFS.toLocaleString(undefined, {minimumFractionDigits: 3, maximumFractionDigits: 3}) + " ft³/s";
document.getElementById("resultArea").innerHTML = areaCM2.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2}) + " cm²";
// Show result container
document.getElementById("resultsArea").style.display = "block";
}
How to Calculate Flow Rate in a Pipe
Understanding the flow rate of fluids through a pipe is critical for engineering, plumbing, irrigation, and industrial processes. Whether you are sizing a pump for a swimming pool or designing a municipal water system, knowing how to determine the volumetric flow rate ensures your system operates efficiently and safely.
This calculator determines the Volumetric Flow Rate (Q) based on the physical dimensions of the pipe and the speed at which the fluid is traveling.
The Flow Rate Formula
The fundamental equation for calculating the flow rate of fluid moving through a pipe is derived from the continuity equation:
Q = A × v
Where:
Q = Volumetric Flow Rate (e.g., m³/s, GPM)
A = Cross-Sectional Area of the pipe
v = Average Velocity of the fluid
Step-by-Step Calculation Logic
To perform this calculation manually, follow these steps:
Determine the Inner Diameter (ID): Always use the inner diameter of the pipe, not the outer diameter (OD). The wall thickness of the pipe reduces the available area for flow.
Calculate the Cross-Sectional Area (A): Since pipes are circular, the area is calculated using the formula A = π × r² or A = π × (d/2)².
Note: Ensure your units match. If diameter is in inches, convert to feet or meters first for easier calculation.
Measure Fluid Velocity (v): This is the speed at which the water or fluid travels through the pipe, typically measured in meters per second (m/s) or feet per second (ft/s).
Multiply Area by Velocity: The result will be your flow volume per unit of time.
Why Inner Diameter Matters
A common mistake when calculating flow rate is using the "Nominal Pipe Size" (NPS) without accounting for the pipe schedule (wall thickness). For example, a "2-inch" Schedule 40 pipe actually has an inner diameter of approximately 2.067 inches, while a Schedule 80 pipe of the same nominal size has a thicker wall and an inner diameter of approximately 1.939 inches. This calculator allows you to input the exact inner diameter for precision.
Common Unit Conversions
Flow rate is expressed in many different units depending on the industry:
GPM (Gallons Per Minute): Standard in the US for plumbing and pumps.
L/min (Liters Per Minute): Common in Europe and scientific applications.
m³/h (Cubic Meters per Hour): Often used for large-scale industrial water treatment or HVAC systems.
Our tool automatically converts the base calculation into these standard units to save you time and prevent conversion errors.