SIZE_CV_GAS
Overview
The SIZE_CV_GAS function calculates the flow coefficient (Kv) required for a control valve to pass a compressible gas at specified conditions. This sizing calculation follows the international standard IEC 60534-2-1 (also published as ISA-75.01.01), which provides equations for predicting the flow capacity of control valves handling compressible fluids.
The flow coefficient is a dimensionless measure of a valve’s flow capacity. The metric Kv represents the flow rate of water (in m³/hr) that passes through the valve with a pressure drop of 1 bar. For reference, the imperial equivalent Cv can be obtained using the relationship C_v = 1.156 \cdot K_v. See the Flow coefficient article for more background.
This implementation uses the fluids library, an open-source Python package for fluid dynamics and chemical engineering calculations. The underlying function size_control_valve_g handles both turbulent and laminar flow regimes, and automatically detects choked (critical) flow conditions where the flow velocity reaches sonic limits. For complete details, see the fluids control valve documentation.
The sizing equation for gas flow accounts for:
- Gas compressibility through the compressibility factor (Z) and specific heat ratio (γ)
- Expansion effects as the gas flows through the valve restriction
- Viscous effects through the dynamic viscosity at inlet conditions
- Molecular weight which affects the gas density and flow behavior
The function requires inlet conditions including temperature (K), pressure (Pa), and the volumetric flow rate at standard conditions (273.15 K and 1 atm). The pressure differential between inlet and outlet drives the flow, and the function returns the required Kv to achieve that flow rate under the specified conditions.
This example function is provided as-is without any representation of accuracy.
Excel Usage
=SIZE_CV_GAS(t, mw, mu, gamma, z, p_in, p_out, q)
t(float, required): Temperature of the gas at the inlet [K]mw(float, required): Molecular weight of the gas [g/mol]mu(float, required): Viscosity of the fluid at inlet conditions [Pa*s]gamma(float, required): Specific heat capacity ratio [-]z(float, required): Compressibility factor at inlet conditions [-]p_in(float, required): Inlet pressure of the gas before valves and reducers [Pa]p_out(float, required): Outlet pressure of the gas after valves and reducers [Pa]q(float, required): Volumetric flow rate of the gas at STP [m^3/s]
Returns (float): Kv - Metric Kv valve flow coefficient [m^3/hr], or error message (str) if input is invalid.
Examples
Example 1: Demo case 1
Inputs:
| t | mw | mu | gamma | z | p_in | p_out | q |
|---|---|---|---|---|---|---|---|
| 433 | 44.01 | 0.00014665 | 1.3 | 0.988 | 680000 | 310000 | 1.0555555555555556 |
Excel formula:
=SIZE_CV_GAS(433, 44.01, 0.00014665, 1.3, 0.988, 680000, 310000, 1.0555555555555556)
Expected output:
58.6
Example 2: Demo case 2
Inputs:
| t | mw | mu | gamma | z | p_in | p_out | q |
|---|---|---|---|---|---|---|---|
| 320 | 39.95 | 0.00005625 | 1.67 | 1 | 280000 | 130000 | 0.0001277777777777778 |
Excel formula:
=SIZE_CV_GAS(320, 39.95, 0.00005625, 1.67, 1, 280000, 130000, 0.0001277777777777778)
Expected output:
0.0131
Example 3: Demo case 3
Inputs:
| t | mw | mu | gamma | z | p_in | p_out | q |
|---|---|---|---|---|---|---|---|
| 300 | 28.97 | 0.000018 | 1.4 | 1 | 500000 | 200000 | 0.1 |
Excel formula:
=SIZE_CV_GAS(300, 28.97, 0.000018, 1.4, 1, 500000, 200000, 0.1)
Expected output:
4.93
Example 4: Demo case 4
Inputs:
| t | mw | mu | gamma | z | p_in | p_out | q |
|---|---|---|---|---|---|---|---|
| 250 | 16.04 | 0.00001 | 1.3 | 0.95 | 400000 | 300000 | 0.05 |
Excel formula:
=SIZE_CV_GAS(250, 16.04, 0.00001, 1.3, 0.95, 400000, 300000, 0.05)
Expected output:
2.59
Python Code
import micropip
await micropip.install(["fluids"])
from math import isfinite
from fluids.control_valve import size_control_valve_g as fluids_size_control_valve_g
def size_cv_gas(t, mw, mu, gamma, z, p_in, p_out, q):
"""
Calculates flow coefficient of a control valve passing a gas according to IEC 60534 using fluids.control_valve.size_control_valve_g.
See: https://fluids.readthedocs.io/fluids.control_valve.html#fluids.control_valve.size_control_valve_g
This example function is provided as-is without any representation of accuracy.
Args:
t (float): Temperature of the gas at the inlet [K]
mw (float): Molecular weight of the gas [g/mol]
mu (float): Viscosity of the fluid at inlet conditions [Pa*s]
gamma (float): Specific heat capacity ratio [-]
z (float): Compressibility factor at inlet conditions [-]
p_in (float): Inlet pressure of the gas before valves and reducers [Pa]
p_out (float): Outlet pressure of the gas after valves and reducers [Pa]
q (float): Volumetric flow rate of the gas at STP [m^3/s]
Returns:
float: Kv - Metric Kv valve flow coefficient [m^3/hr], or error message (str) if input is invalid.
"""
# Validate input parameters
try:
t = float(t)
mw = float(mw)
mu = float(mu)
gamma = float(gamma)
z = float(z)
p_in = float(p_in)
p_out = float(p_out)
q = float(q)
except (TypeError, ValueError):
return "Error: All parameters must be numeric values."
# Check for non-finite values
if not all(isfinite(val) for val in [t, mw, mu, gamma, z, p_in, p_out, q]):
return "Error: All parameters must be finite numbers."
# Check for invalid values
if t <= 0:
return "Error: Temperature (t) must be positive."
if mw <= 0:
return "Error: Molecular weight (mw) must be positive."
if mu < 0:
return "Error: Viscosity (mu) must be non-negative."
if gamma <= 0:
return "Error: Specific heat capacity ratio (gamma) must be positive."
if z <= 0:
return "Error: Compressibility factor (z) must be positive."
if p_in <= 0:
return "Error: Inlet pressure (p_in) must be positive."
if p_out < 0:
return "Error: Outlet pressure (p_out) must be non-negative."
if q < 0:
return "Error: Volumetric flow rate (q) must be non-negative."
if p_in == p_out:
return "Error: Inlet pressure (p_in) and outlet pressure (p_out) cannot be equal."
try:
result = fluids_size_control_valve_g(T=t, MW=mw, mu=mu, gamma=gamma, Z=z, P1=p_in, P2=p_out, Q=q)
if isinstance(result, dict):
result = result.get('Kv')
if result is None or not isinstance(result, (int, float)):
return f"Error: Fluids library returned invalid result: {result}"
if not isfinite(result):
return "Error: Calculated flow coefficient is not finite."
return float(result)
except Exception as e:
return f"Error: Failed to compute gas valve sizing: {str(e)}"