Estimate the mass flow and volumetric loss from a pipe puncture or orifice.
Compressed Air
Natural Gas (Methane)
Nitrogen
Propane
Hydrogen
Flow Regime:–
Mass Flow Rate:–
Volumetric Flow (Normal Conditions):–
Total Gas Lost (over duration):–
Understanding Gas Leak Calculations
Estimating the rate of gas leakage from a pipe is critical for safety assessments, environmental reporting, and economic loss evaluation. The rate at which gas escapes depends heavily on the system pressure, the size of the hole, and the physical properties of the gas involved.
The Physics: Choked vs. Subsonic Flow
Gas leaks generally fall into one of two flow regimes based on the pressure difference between the inside of the pipe and the outside atmosphere:
Choked Flow (Sonic): When the internal pressure is sufficiently high (typically about 2 times the atmospheric pressure or ~1.9 bar absolute), the gas reaches the speed of sound at the exit point. Increasing the pressure further increases the mass flow rate, but the velocity remains capped at sonic speed. Most industrial compressed air and gas leaks occur in this regime.
Subsonic Flow: If the pressure difference is low, the gas velocity is below the speed of sound, and the flow rate is more sensitive to back-pressure.
Key Factors Influencing Leak Rate
To accurately calculate the leak rate, this calculator utilizes the orifice equation for compressible flow. The key variables include:
Hole Diameter: The area of the leak is proportional to the square of the diameter. A 4mm hole leaks four times as much gas as a 2mm hole, not twice as much.
Discharge Coefficient (Cd): This factor accounts for the shape of the hole and turbulence. For a sharp-edged circular hole typical of punctures, a value of 0.60 to 0.62 is standard.
Specific Gravity: Lighter gases (like Hydrogen) leak at different mass rates compared to heavier gases (like Propane) under the same pressure conditions due to differences in density and molecular weight.
Why Detect and Repair Leaks?
Beyond the obvious explosion or toxicity hazards associated with flammable or hazardous gases, leaks represent a significant financial loss. For compressed air systems, leaks can waste 20-30% of compressor output, directly inflating electricity bills. For natural gas pipelines, even pinhole leaks contribute to methane emissions and lost product revenue.
function calculateGasLeak() {
// 1. Get Input Values
var diameterMm = parseFloat(document.getElementById('glc-diameter').value);
var pressureBarG = parseFloat(document.getElementById('glc-pressure').value);
var tempC = parseFloat(document.getElementById('glc-temp').value);
var gasType = document.getElementById('glc-gas').value;
var cd = parseFloat(document.getElementById('glc-cd').value);
var hours = parseFloat(document.getElementById('glc-hours').value);
// Error Handling
if (isNaN(diameterMm) || diameterMm <= 0) {
alert("Please enter a valid hole diameter.");
return;
}
if (isNaN(pressureBarG) || pressureBarG Absolute Pascal
// 1 bar = 100,000 Pa
var P1_abs = (pressureBarG * 100000) + Pa_atm;
var P2_abs = Pa_atm; // Discharging to atmosphere
// Area Calculation (m^2)
var diameterM = diameterMm / 1000;
var area = Math.PI * Math.pow((diameterM / 2), 2);
// Gas Properties: [Molar Mass (kg/kmol), Isentropic Exp Factor (k)]
// Air: M=28.97, k=1.4
// Natural Gas (Methane): M=16.04, k=1.3
// Nitrogen: M=28.01, k=1.4
// Propane: M=44.1, k=1.13
// Hydrogen: M=2.016, k=1.41
var gasProps = {
"air": { M: 28.97, k: 1.4, name: "Air" },
"natural": { M: 16.04, k: 1.3, name: "Natural Gas" },
"nitrogen": { M: 28.01, k: 1.4, name: "Nitrogen" },
"propane": { M: 44.1, k: 1.13, name: "Propane" },
"hydrogen": { M: 2.016, k: 1.41, name: "Hydrogen" }
};
var gas = gasProps[gasType];
var R_specific = 8314.46 / gas.M; // J/(kg K)
var rho1 = P1_abs / (R_specific * tempK); // Density at inlet (kg/m3)
// 3. Determine Flow Regime (Choked vs Subsonic)
// Critical Pressure Ratio: (P2/P1)crit = (2/(k+1))^(k/(k-1))
var criticalRatio = Math.pow((2 / (gas.k + 1)), (gas.k / (gas.k – 1)));
var actualRatio = P2_abs / P1_abs;
var massFlowRate = 0; // kg/s
var isChoked = false;
if (actualRatio < criticalRatio) {
// CHOKED FLOW (Sonic)
isChoked = true;
// Formula: m_dot = Cd * A * sqrt( k * rho1 * P1 * (2/(k+1))^((k+1)/(k-1)) )
// Simplified equivalent: m_dot = Cd * A * P1 / sqrt(R*T) * sqrt(k) * (2/(k+1))^((k+1)/(2(k-1)))
var term1 = gas.k / (R_specific * tempK);
var term2 = Math.pow((2 / (gas.k + 1)), ((gas.k + 1) / (gas.k – 1)));
massFlowRate = cd * area * P1_abs * Math.sqrt(term1 * term2);
} else {
// SUBSONIC FLOW
isChoked = false;
// Saint-Venant / Wantzel equation for unchoked flow
// m_dot = Cd * A * sqrt( 2 * P1 * rho1 * (k/(k-1)) * [ (P2/P1)^(2/k) – (P2/P1)^((k+1)/k) ] )
var r = actualRatio; // P2/P1
var exponent1 = 2 / gas.k;
var exponent2 = (gas.k + 1) / gas.k;
var bracket = Math.pow(r, exponent1) – Math.pow(r, exponent2);
// Safety check for very low pressure diff (avoid sqrt negative due to float precision)
if (bracket kg/hr
var massFlowKgHr = massFlowRate * 3600;
// Volumetric Flow (Normal Cubic Meters – Nm3/hr)
// Normal conditions: 0°C (273.15K), 1 atm (101325 Pa)
// Density at Normal Conditions
var rho_normal = 101325 / (R_specific * 273.15);
var volFlowNm3Hr = massFlowKgHr / rho_normal;
// Total Loss
var totalVolLost = volFlowNm3Hr * hours;
// 5. Display Results
document.getElementById('glc-results').style.display = 'block';
document.getElementById('res-regime').innerText = isChoked ? "Choked (Sonic)" : "Subsonic";
document.getElementById('res-mass').innerText = massFlowKgHr.toFixed(2) + " kg/hr";
document.getElementById('res-vol').innerText = volFlowNm3Hr.toFixed(2) + " Nm³/hr";
document.getElementById('res-total').innerText = totalVolLost.toFixed(2) + " Nm³";
// Warning for low pressure
var warningDiv = document.getElementById('glc-warning');
if (pressureBarG < 0.1) {
warningDiv.style.display = 'block';
warningDiv.innerText = "Warning: Pressure difference is very low. Results may be less accurate.";
} else {
warningDiv.style.display = 'none';
}
}