function calculateFlowRate() {
// Clear previous results and errors
document.getElementById('errorMessage').style.display = 'none';
document.getElementById('resultContainer').style.display = 'none';
// 1. Get Input Values
var d = parseFloat(document.getElementById('pipeDiameter').value);
var L = parseFloat(document.getElementById('pipeLength').value);
var p1_psig = parseFloat(document.getElementById('inletPressure').value);
var p2_psig = parseFloat(document.getElementById('outletPressure').value);
var G = parseFloat(document.getElementById('specificGravity').value);
var T_f = parseFloat(document.getElementById('gasTemp').value);
// 2. Validate Inputs
if (isNaN(d) || isNaN(L) || isNaN(p1_psig) || isNaN(p2_psig) || isNaN(G) || isNaN(T_f)) {
showError("Please fill in all fields with valid numbers.");
return;
}
if (d <= 0 || L <= 0 || G = p1_psig) {
showError("Inlet Pressure must be greater than Outlet Pressure to generate flow.");
return;
}
// 3. Convert Units for Calculation
// Pressure: psig to psia (Absolute Pressure)
var P1 = p1_psig + 14.7;
var P2 = p2_psig + 14.7;
// Temperature: Fahrenheit to Rankine
var T = T_f + 460;
// 4. Constants for Weymouth Equation (Simplified High Pressure)
// Base Temperature (Tb) = 520 R (60 F)
// Base Pressure (Pb) = 14.73 psia
var Tb = 520;
var Pb = 14.73;
// Efficiency Factor (E) – typical pipeline efficiency 0.92
var E = 0.92;
// Compressibility Factor (Z) – approximation for estimation (0.9 is a common average for calculation without gas composition analysis)
var Z = 0.9;
// 5. The Calculation (Weymouth Equation)
// Q = 433.5 * E * (Tb/Pb) * [ (P1^2 – P2^2) / (G * T * L * Z) ]^0.5 * D^(2.667)
var constant = 433.5;
var pressureTerm = Math.pow(P1, 2) – Math.pow(P2, 2);
var denominatorTerm = G * T * L * Z;
var rootTerm = Math.pow((pressureTerm / denominatorTerm), 0.5);
var diameterTerm = Math.pow(d, 2.667);
var Q_SCFD = constant * E * (Tb / Pb) * rootTerm * diameterTerm;
// 6. Formatting Results
var Q_MMSCFD = Q_SCFD / 1000000;
// Display Logic
document.getElementById('resultSCFD').innerText = Math.round(Q_SCFD).toLocaleString();
document.getElementById('resultMMSCFD').innerText = Q_MMSCFD.toFixed(3) + " MMSCFD";
document.getElementById('resultContainer').style.display = 'block';
}
function showError(msg) {
var errDiv = document.getElementById('errorMessage');
errDiv.innerText = msg;
errDiv.style.display = 'block';
}
Understanding Natural Gas Flow Rate Calculation
Calculating the flow rate of natural gas through a pipeline is a critical task in the oil and gas industry, necessary for pipeline sizing, compressor station design, and custody transfer. The flow rate determines the volume of gas that can be transported over a specific distance given the pressure differential and pipe properties.
This calculator utilizes the Weymouth Equation, a standard industry formula widely used for sizing high-pressure natural gas gathering and transmission lines.
The Weymouth Equation Explained
The Weymouth equation relates the flow rate to pipe diameter, length, gas properties, and pressure drop. It is most accurate for high-pressure flow in large diameter pipes where the flow is fully turbulent.
The simplified relationship calculated here is primarily driven by:
Differential Pressure ($P_1^2 – P_2^2$): The driving force of the flow. A higher inlet pressure ($P_1$) relative to the outlet pressure ($P_2$) results in higher flow rates.
Pipe Diameter ($D$): Flow rate increases exponentially with diameter. In the Weymouth equation, flow is proportional to $D^{2.667}$. Even a small increase in diameter significantly boosts capacity.
Pipe Length ($L$): Flow rate is inversely proportional to the square root of the length. Longer pipes result in more friction and lower flow rates.
Input Parameters Definition
Parameter
Description
Typical Units
Inlet/Outlet Pressure
The gauge pressure at the start and end of the pipe segment. The calculator converts this to absolute pressure (psia) automatically.
psig
Specific Gravity
The density of the gas relative to air. Natural gas (mostly methane) is lighter than air.
0.60 – 0.70
Flow Temperature
The average temperature of the gas flowing through the pipeline. High temperatures slightly reduce flow capacity due to gas expansion.
°F
Compressibility ($Z$)
A factor accounting for how real gases deviate from ideal gas behavior. This tool assumes an average $Z$ of 0.9.
Dimensionless
Interpreting the Results
The output is provided in SCFD (Standard Cubic Feet per Day) and MMSCFD (Million Standard Cubic Feet per Day). "Standard" refers to the volume the gas would occupy at standard conditions (usually 60°F and 14.73 psia), allowing for consistent buying and selling of gas volume regardless of the actual pressure in the pipe.
Limitations
While the Weymouth equation is robust, engineering designs should also consider:
Elevation Changes: Significant changes in terrain can affect pressure drops.
Gas Composition: "Rich" gas with heavy hydrocarbons has a higher specific gravity, affecting flow.
Pipe Roughness: This calculator assumes an efficiency factor of 0.92, which accounts for typical steel pipe roughness and installation conditions.