SIZE_CONTROL_VALVE_L
Overview
The SIZE_CONTROL_VALVE_L function calculates the flow coefficient of a control valve passing a liquid according to IEC 60534 using the fluids.control_valve.size_control_valve_l function. This function is critical for sizing control valves in liquid service applications, taking into account various fluid properties and valve characteristics to determine the metric Kv valve flow coefficient. The Kv coefficient represents the flow rate of water at a pressure drop of 1 bar and is used to characterize valve capacity.
The sizing model accounts for factors such as fluid density, saturation pressure, critical pressure, viscosity, inlet and outlet pressures, and flow rate. It also incorporates the liquid pressure recovery factor (FL) and valve style modifier (Fd) to account for valve geometry and flow characteristics. The model handles both turbulent and laminar flow regimes and can model choked flow conditions.
For more details, see the fluids.control_valve.size_control_valve_l documentation .
This function simplifies the interface by exposing only the most commonly used parameters and does not include diameter parameters (D1, D2, d) or advanced options (allow_choked, allow_laminar, full_output). This example function is provided as-is without any representation of accuracy.
Usage
To use the function in Excel:
=SIZE_CONTROL_VALVE_L(rho, psat, pc, mu, p_in, p_out, q, [fl], [fd])rho(float, required): Density of the liquid at the inlet [kg/m^3]psat(float, required): Saturation pressure of the fluid at inlet temperature [Pa]pc(float, required): Critical pressure of the fluid [Pa]mu(float, required): Viscosity of the fluid [Pa*s]p_in(float, required): Inlet pressure of the fluid before valves and reducers [Pa]p_out(float, required): Outlet pressure of the fluid after valves and reducers [Pa]q(float, required): Volumetric flow rate of the fluid [m^3/s]fl(float, optional, default=0.9): Liquid pressure recovery factor (normally 0.8-0.9 at full open and decreasing as opened further to below 0.5; use default very cautiously!) []fd(float, optional, default=1.0): Valve style modifier (0.1 to 1; varies tremendously depending on the type of valve and position; do not use the default at all!) []
The function returns a float representing the metric Kv valve flow coefficient [m^3/hr], or an error message (string) if the input is invalid.
Examples
Example 1: Basic Control Valve Sizing
Inputs:
| rho | psat | pc | mu | p_in | p_out | q | fl | fd |
|---|---|---|---|---|---|---|---|---|
| 965.4 | 70100.0 | 221200000.0 | 3.1472e-04 | 680000.0 | 220000.0 | 0.1 | 0.9 | 0.46 |
Excel formula:
=SIZE_CONTROL_VALVE_L(965.4, 70100.0, 221200000.0, 3.1472e-04, 680000.0, 220000.0, 0.1, 0.9, 0.46)Expected output: 165.000
Example 2: With Default FL and FD Values
Inputs:
| rho | psat | pc | mu | p_in | p_out | q |
|---|---|---|---|---|---|---|
| 1000.0 | 2337.0 | 22064000.0 | 0.001 | 500000.0 | 300000.0 | 0.05 |
Excel formula:
=SIZE_CONTROL_VALVE_L(1000.0, 2337.0, 22064000.0, 0.001, 500000.0, 300000.0, 0.05)Expected output: 127.000
Example 3: Different FL and FD Values
Inputs:
| rho | psat | pc | mu | p_in | p_out | q | fl | fd |
|---|---|---|---|---|---|---|---|---|
| 965.4 | 70100.0 | 221200000.0 | 3.1472e-04 | 680000.0 | 220000.0 | 0.1 | 0.6 | 0.98 |
Excel formula:
=SIZE_CONTROL_VALVE_L(965.4, 70100.0, 221200000.0, 3.1472e-04, 680000.0, 220000.0, 0.1, 0.6, 0.98)Expected output: 238.000
Example 4: Low Flow Rate Application
Inputs:
| rho | psat | pc | mu | p_in | p_out | q | fl | fd |
|---|---|---|---|---|---|---|---|---|
| 800.0 | 1000.0 | 15000000.0 | 0.0005 | 400000.0 | 350000.0 | 0.001 | 0.85 | 0.9 |
Excel formula:
=SIZE_CONTROL_VALVE_L(800.0, 1000.0, 15000000.0, 0.0005, 400000.0, 350000.0, 0.001, 0.85, 0.9)Expected output: 4.560
Python Code
from fluids.control_valve import size_control_valve_l as fluids_size_control_valve_l
from typing import List, Optional, Union
import math
ExcelNumeric = Union[int, float, bool, str]
ExcelColumn = List[List[Union[float, str]]]
def size_control_valve_l(rho: float, psat: float, pc: float, mu: float, p_in: float, p_out: float, q: float, fl: float = 0.9, fd: float = 1.0) -> Union[float, str]:
"""
Calculates flow coefficient of a control valve passing a liquid according to IEC 60534 using fluids.control_valve.size_control_valve_l. See https://fluids.readthedocs.io/fluids.control_valve.html#fluids.control_valve.size_control_valve_l for details.
Args:
rho: Density of the liquid at the inlet [kg/m^3]
psat: Saturation pressure of the fluid at inlet temperature [Pa]
pc: Critical pressure of the fluid [Pa]
mu: Viscosity of the fluid [Pa*s]
p_in: Inlet pressure of the fluid before valves and reducers [Pa]
p_out: Outlet pressure of the fluid after valves and reducers [Pa]
q: Volumetric flow rate of the fluid [m^3/s]
fl: Liquid pressure recovery factor [optional, default 0.9]
fd: Valve style modifier [optional, default 1.0]
Returns:
float: Kv - Metric Kv valve flow coefficient [m^3/hr], or an error message (str) if input is invalid.
This example function is provided as-is without any representation of accuracy.
"""
def _error(message: str) -> str:
return message
# Validate input parameters
try:
rho = float(rho)
if rho <= 0:
return _error("Invalid input: rho must be a positive number.")
except (ValueError, TypeError):
return _error("Invalid input: rho must be a numeric value.")
try:
psat = float(psat)
if psat < 0:
return _error("Invalid input: psat must be a non-negative number.")
except (ValueError, TypeError):
return _error("Invalid input: psat must be a numeric value.")
try:
pc = float(pc)
if pc <= 0:
return _error("Invalid input: pc must be a positive number.")
except (ValueError, TypeError):
return _error("Invalid input: pc must be a numeric value.")
try:
mu = float(mu)
if mu <= 0:
return _error("Invalid input: mu must be a positive number.")
except (ValueError, TypeError):
return _error("Invalid input: mu must be a numeric value.")
try:
p_in = float(p_in)
if p_in < 0:
return _error("Invalid input: p_in must be a non-negative number.")
except (ValueError, TypeError):
return _error("Invalid input: p_in must be a numeric value.")
try:
p_out = float(p_out)
if p_out < 0:
return _error("Invalid input: p_out must be a non-negative number.")
except (ValueError, TypeError):
return _error("Invalid input: p_out must be a numeric value.")
if p_out > p_in:
return _error("Invalid input: p_out must be less than or equal to p_in.")
try:
q = float(q)
if q < 0:
return _error("Invalid input: q must be a non-negative number.")
except (ValueError, TypeError):
return _error("Invalid input: q must be a numeric value.")
try:
fl = float(fl)
if fl <= 0 or fl > 1:
return _error("Invalid input: fl must be a positive number between 0 and 1.")
except (ValueError, TypeError):
return _error("Invalid input: fl must be a numeric value.")
try:
fd = float(fd)
if fd <= 0 or fd > 1:
return _error("Invalid input: fd must be a positive number between 0 and 1.")
except (ValueError, TypeError):
return _error("Invalid input: fd must be a numeric value.")
# Check for non-finite values
if any(not math.isfinite(val) for val in [rho, psat, pc, mu, p_in, p_out, q, fl, fd]):
return _error("Invalid input: All parameters must be finite numbers.")
# Call the actual function from the fluids library
try:
# Note: the original function expects P1 and P2 instead of p_in and p_out
result = fluids_size_control_valve_l(rho=rho, Psat=psat, Pc=pc, mu=mu,
P1=p_in, P2=p_out, Q=q,
FL=fl, Fd=fd)
if not isinstance(result, (int, float)) or not math.isfinite(result):
return _error("Calculation error: Result is not a finite number.")
return result
except Exception as e:
return _error(f"Calculation error: {str(e)}")