Calculating the rate at which gas escapes from a vessel or pipe through a hole is a fundamental aspect of process safety engineering, risk assessment, and environmental impact analysis. This calculator uses standard orifice flow equations to estimate the mass flow rate of a gas leak based on system parameters.
Key Parameters Explained
Parameter
Description
Typical Values
Orifice Diameter
The size of the hole or leak path.
Pinhole (1-5mm) to Rupture (Full bore)
Source Pressure
The pressure inside the containment system.
Process Dependent (e.g., 5-100 bar)
Specific Heat Ratio (k)
Ratio of heat capacity at constant pressure to constant volume (Cp/Cv).
Air: 1.4, Methane: 1.32, Propane: 1.13
Discharge Coefficient (Cd)
A factor accounting for friction and flow profile contraction.
Sharp edge: ~0.61, Nozzle: ~0.95, General Leak: ~0.8
Choked vs. Subsonic Flow
The calculation determines whether the gas flow is Choked (Sonic) or Subsonic. This distinction is critical for accuracy:
Choked Flow: Occurs when the pressure ratio between the source and the exterior is high enough that the gas velocity reaches the speed of sound at the orifice. Increasing the source pressure further increases the mass flow rate, but reducing the downstream pressure has no effect.
Subsonic Flow: Occurs at lower pressure ratios. In this regime, the flow rate is dependent on both the upstream and downstream pressures.
Calculation Methodology
This tool utilizes the ideal gas law and isentropic flow equations. It first calculates the Critical Pressure Ratio to determine the flow regime. Based on the regime, it selects the appropriate mass flow equation (Saint-Venant/Wantzel for subsonic or the critical flow equation for sonic conditions).
Importance in Safety
Accurate release rate estimation is vital for:
HAZOP & LOPA Studies: Determining the severity of potential loss of containment events.
Relief Valve Sizing: Ensuring safety devices can handle the maximum required flow.
Dispersion Modeling: Predicting the size of flammable or toxic clouds.
Fire Consequence Analysis: Estimating jet fire lengths and heat radiation levels.
function calculateGasRate() {
var diameter = parseFloat(document.getElementById('grr-diameter').value);
var p1_bar = parseFloat(document.getElementById('grr-pressure-source').value);
var p2_bar = parseFloat(document.getElementById('grr-pressure-back').value);
var tempC = parseFloat(document.getElementById('grr-temp').value);
var mw = parseFloat(document.getElementById('grr-mw').value);
var k = parseFloat(document.getElementById('grr-k').value);
var cd = parseFloat(document.getElementById('grr-cd').value);
var errorMsg = document.getElementById('grr-error-msg');
var resultBox = document.getElementById('grr-result');
// Validation
if (isNaN(diameter) || isNaN(p1_bar) || isNaN(p2_bar) || isNaN(tempC) || isNaN(mw) || isNaN(k) || isNaN(cd)) {
errorMsg.style.display = 'block';
errorMsg.innerHTML = "Please fill in all fields with valid numbers.";
resultBox.style.display = 'none';
return;
}
if (diameter <= 0 || p1_bar <= 0 || mw <= 0 || k <= 1 || cd 1.";
resultBox.style.display = 'none';
return;
}
if (p1_bar <= p2_bar) {
errorMsg.style.display = 'block';
errorMsg.innerHTML = "Source Pressure must be higher than Back Pressure for flow to occur.";
resultBox.style.display = 'none';
return;
}
errorMsg.style.display = 'none';
// Constants and Unit Conversions
var R_universal = 8314.46; // J/(kmol·K)
var area = Math.PI * Math.pow((diameter / 1000) / 2, 2); // m^2
var p1_pa = p1_bar * 100000; // Pa
var p2_pa = p2_bar * 100000; // Pa
var tempK = tempC + 273.15; // Kelvin
// MW is typically used in kg/kmol for standard equations where R is 8314
// No conversion needed for MW if using R = 8314 and M in kg/kmol (which is same num as g/mol)
// 1. Calculate Critical Pressure Ratio
var criticalRatio = Math.pow((2 / (k + 1)), (k / (k – 1)));
// 2. Determine Flow Regime
var actualRatio = p2_pa / p1_pa;
var isChoked = actualRatio < criticalRatio;
var massFlowRate = 0; // kg/s
// 3. Calculate Mass Flow Rate
if (isChoked) {
// Choked (Sonic) Flow Equation
var term1 = k * mw;
var term2 = R_universal * tempK;
var term3 = Math.pow((2 / (k + 1)), ((k + 1) / (k – 1)));
massFlowRate = cd * area * p1_pa * Math.sqrt( (term1 / term2) * term3 );
} else {
// Subsonic Flow Equation
var term1 = (2 * mw) / (R_universal * tempK);
var term2 = k / (k – 1);
var term3 = Math.pow(actualRatio, (2 / k));
var term4 = Math.pow(actualRatio, ((k + 1) / k));
massFlowRate = cd * area * p1_pa * Math.sqrt( term1 * term2 * (term3 – term4) );
}
// 4. Conversions for Output
var massFlowHr = massFlowRate * 3600;
// Normal Volumetric Flow (Nm3/h at 0C, 1 atm)
// Density at STP (0C, 101325 Pa) = P*MW / (R*T)
var rho_stp = (101325 * mw) / (R_universal * 273.15);
var volFlowStd = massFlowHr / rho_stp;
// Display Results
document.getElementById('res-regime').innerText = isChoked ? "Choked (Sonic)" : "Subsonic";
document.getElementById('res-mass-sec').innerText = massFlowRate.toFixed(4) + " kg/s";
document.getElementById('res-mass-hr').innerText = massFlowHr.toFixed(2) + " kg/h";
document.getElementById('res-vol-std').innerText = volFlowStd.toFixed(2) + " Nm³/h";
resultBox.style.display = 'block';
}