SIZE_CV_GAS
This function computes the required metric valve coefficient K_v for gas flow using the IEC 60534 gas sizing model. The calculation uses inlet thermodynamic properties, pressure drop, and standard-reference volumetric flow to estimate the valve capacity needed to deliver the specified duty.
In sizing form, the relation is commonly expressed as:
K_v = f\left(T, MW, \mu, \gamma, Z, P_1, P_2, Q\right)
where f(\cdot) denotes the IEC-compliant nonlinear model accounting for gas expansion behavior under the stated process conditions.
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.
Example 1: Baseline gas valve sizing case
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.6107
Example 2: Very small-flow gas sizing case
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.0131229
Example 3: High-pressure-drop gas sizing case
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.93156
Example 4: Low-temperature gas sizing case
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.59016
Python Code
Show Code
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.
"""
try:
# 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)}"
except Exception as e:
return f"Error: {str(e)}"