Control Valve

Overview

Control valves are critical components in industrial process control systems that regulate the flow rate, pressure, or temperature of fluids by throttling flow in response to signals from controllers. Unlike simple shut-off valves, control valves modulate flow through variable positioning, making them essential for maintaining process variables within desired setpoints. They appear throughout chemical processing, petroleum refining, power generation, water treatment, HVAC systems, and pharmaceutical manufacturing.

The engineering discipline of control valve sizing and selection requires balancing multiple competing objectives: ensuring adequate flow capacity, maintaining controllability across the operating range, avoiding cavitation and flashing, minimizing noise and vibration, and optimizing energy consumption. Improper valve sizing can lead to process instability, excessive wear, unacceptable noise levels, or complete process failure.

Implementation: These tools implement calculations from the IEC 60534 international standard for industrial-process control valves using the fluids Python library. This standard provides comprehensive methods for valve sizing, noise prediction, and performance characterization.

Flow Coefficient Sizing: The fundamental valve sizing parameter is the flow coefficient (Cv, Kv, or Av), which quantifies how much flow passes through a valve at a given pressure drop. Use SIZE_CV_LIQUID and SIZE_CV_GAS to calculate the required flow coefficient for liquid and gas applications. Convert between coefficient scales using CV_CONVERT_COEFF. Accurate sizing ensures the valve operates in its controllable range rather than being oversized (poor control) or undersized (insufficient capacity).

Valve Characteristics: Control valves exhibit different inherent flow characteristics that define how flow changes with valve position. CV_CHAR_LINEAR provides constant gain across the range, suitable for liquid level control. CV_CHAR_EQ_PERC offers proportional gain relative to flow, ideal for pressure and temperature control with varying process gains. CV_CHAR_QUICK_OP delivers maximum flow quickly, used in on-off control applications. The choice affects control loop stability and performance.

Choked Flow: When pressure drop becomes sufficiently large, flow through the valve reaches a maximum limit called choked or critical flow, beyond which further pressure drop does not increase flow rate. For liquids, choking occurs due to cavitation when pressure drops below vapor pressure. For gases, choking happens when velocity reaches sonic conditions. Use IS_CHOKED_LIQ and IS_CHOKED_GAS to determine if flow is choked, and CV_CHOKE_PRESS_LIQ and CV_CHOKE_PRESS_GAS to calculate the pressure at which choking begins.

Cavitation: Liquid cavitation occurs when local pressure drops below the vapor pressure, forming vapor bubbles that subsequently collapse violently when pressure recovers downstream. The cavitation index quantifies proximity to damaging cavitation conditions. Calculate it using CV_CAV_INDEX and the critical pressure ratio factor using FF_CRIT_PRESS_L. Severe cavitation causes noise, vibration, and rapid erosion of valve trim.

Noise Prediction: Control valves can generate significant noise, particularly with high-pressure drops in gas service or cavitating liquid service. Use CV_NOISE_GAS_2011 and CV_NOISE_LIQ_2015 to predict A-weighted sound pressure levels according to IEC standards. Noise predictions help ensure compliance with occupational safety limits and identify where acoustic treatment is needed.

Reynolds Number Effects: At low flow rates or with high-viscosity fluids, the valve Reynolds number becomes important as it affects the flow coefficient. Calculate the valve Reynolds number using REYNOLDS_VALVE and the Reynolds number correction factor using REYNOLDS_FACTOR. These tools account for viscous effects that reduce valve capacity below manufacturer’s water-based ratings.

Piping Configuration: The piping configuration around a control valve affects pressure drop calculations. Use LOSS_COEFF_PIPING to calculate loss coefficients for reducers and expanders commonly installed adjacent to valves to match valve size to line size. These losses must be included in total system pressure drop calculations.

CV_CAV_INDEX

Computes the valve cavitation index for a liquid from upstream pressure, downstream pressure, and saturation pressure.

The cavitation index is:

\sigma = \frac{P_1 - P_{sat}}{P_1 - P_2}

Larger values generally indicate greater margin from cavitation onset under the specified conditions.

Excel Usage

=CV_CAV_INDEX(p_inlet, p_outlet, p_sat)
  • p_inlet (float, required): Inlet absolute pressure (Pa)
  • p_outlet (float, required): Outlet absolute pressure (Pa)
  • p_sat (float, required): Saturation absolute pressure (Pa)

Returns (float): Cavitation index sigma (-)

Example 1: Documentation example

Inputs:

p_inlet p_outlet p_sat
1000000 800000 200000

Excel formula:

=CV_CAV_INDEX(1000000, 800000, 200000)

Expected output:

4

Example 2: Low outlet pressure

Inputs:

p_inlet p_outlet p_sat
1000000 100000 50000

Excel formula:

=CV_CAV_INDEX(1000000, 100000, 50000)

Expected output:

1.05556

Example 3: Near saturation

Inputs:

p_inlet p_outlet p_sat
1000000 500000 990000

Excel formula:

=CV_CAV_INDEX(1000000, 500000, 990000)

Expected output:

0.02

Example 4: High index (low delta P)

Inputs:

p_inlet p_outlet p_sat
1000000 990000 100000

Excel formula:

=CV_CAV_INDEX(1000000, 990000, 100000)

Expected output:

90

Python Code

Show Code
from fluids.control_valve import cavitation_index

def cv_cav_index(p_inlet, p_outlet, p_sat):
    """
    Calculates the cavitation index of a control valve.

    See: https://fluids.readthedocs.io/fluids.control_valve.html#fluids.control_valve.cavitation_index

    This example function is provided as-is without any representation of accuracy.

    Args:
        p_inlet (float): Inlet absolute pressure (Pa)
        p_outlet (float): Outlet absolute pressure (Pa)
        p_sat (float): Saturation absolute pressure (Pa)

    Returns:
        float: Cavitation index sigma (-)
    """
    try:
      p_inlet = float(p_inlet)
      p_outlet = float(p_outlet)
      p_sat = float(p_sat)

      if p_inlet <= p_outlet:
        return "Error: Inlet pressure must be greater than outlet pressure."
      if p_inlet <= p_sat:
        return "Error: Inlet pressure must be greater than saturation pressure."

      return float(cavitation_index(P1=p_inlet, P2=p_outlet, Psat=p_sat))
    except Exception as e:
      return f"Error: {str(e)}"

Online Calculator

Inlet absolute pressure (Pa)
Outlet absolute pressure (Pa)
Saturation absolute pressure (Pa)

CV_CHAR_EQ_PERC

Computes the normalized equal-percentage valve characteristic as a function of fractional opening.

Equal-percentage valves provide a near-constant percentage change in flow coefficient for equal increments in stem travel, producing a highly nonlinear characteristic.

The returned value is a dimensionless normalized coefficient fraction between approximately 0 and 1 over the practical opening range.

Excel Usage

=CV_CHAR_EQ_PERC(opening)
  • opening (float, required): Fractional opening of the valve [0-1].

Returns (float): Flow coefficient characteristic fraction [0-1].

Example 1: Zero opening

Inputs:

opening
0

Excel formula:

=CV_CHAR_EQ_PERC(0)

Expected output:

1.35226e-19

Example 2: Full opening

Inputs:

opening
1

Excel formula:

=CV_CHAR_EQ_PERC(1)

Expected output:

1

Example 3: Half opening

Inputs:

opening
0.5

Excel formula:

=CV_CHAR_EQ_PERC(0.5)

Expected output:

0.163588

Example 4: Large opening (0.9)

Inputs:

opening
0.9

Excel formula:

=CV_CHAR_EQ_PERC(0.9)

Expected output:

0.859939

Python Code

Show Code
from fluids.control_valve import Cv_char_equal_percentage

def cv_char_eq_perc(opening):
    """
    Calculates the flow coefficient characteristic for an equal percentage control valve.

    See: https://fluids.readthedocs.io/fluids.control_valve.html#fluids.control_valve.Cv_char_equal_percentage

    This example function is provided as-is without any representation of accuracy.

    Args:
        opening (float): Fractional opening of the valve [0-1].

    Returns:
        float: Flow coefficient characteristic fraction [0-1].
    """
    try:
      val = float(opening)
      if val < 0 or val > 1:
        return "Error: opening must be between 0 and 1"
      return float(Cv_char_equal_percentage(val))
    except Exception as e:
      return f"Error: {str(e)}"

Online Calculator

Fractional opening of the valve [0-1].

CV_CHAR_LINEAR

Computes the normalized linear valve characteristic as a function of fractional opening.

For a linear characteristic, the flow coefficient fraction changes proportionally with valve travel, so equal changes in opening produce equal changes in normalized coefficient.

The relation is approximately:

C_{v,rel} = x

where x is the fractional opening.

Excel Usage

=CV_CHAR_LINEAR(opening)
  • opening (float, required): Fractional opening of the valve [0-1].

Returns (float): Flow coefficient characteristic fraction [0-1].

Example 1: Zero opening

Inputs:

opening
0

Excel formula:

=CV_CHAR_LINEAR(0)

Expected output:

0

Example 2: Full opening

Inputs:

opening
1

Excel formula:

=CV_CHAR_LINEAR(1)

Expected output:

1

Example 3: Half opening

Inputs:

opening
0.5

Excel formula:

=CV_CHAR_LINEAR(0.5)

Expected output:

0.5

Example 4: Quarter opening

Inputs:

opening
0.25

Excel formula:

=CV_CHAR_LINEAR(0.25)

Expected output:

0.25

Python Code

Show Code
from fluids.control_valve import Cv_char_linear

def cv_char_linear(opening):
    """
    Calculates the flow coefficient characteristic for a linear control valve.

    See: https://fluids.readthedocs.io/fluids.control_valve.html#fluids.control_valve.Cv_char_linear

    This example function is provided as-is without any representation of accuracy.

    Args:
        opening (float): Fractional opening of the valve [0-1].

    Returns:
        float: Flow coefficient characteristic fraction [0-1].
    """
    try:
      val = float(opening)
      if val < 0 or val > 1:
        return "Error: opening must be between 0 and 1"
      return float(Cv_char_linear(val))
    except Exception as e:
      return f"Error: {str(e)}"

Online Calculator

Fractional opening of the valve [0-1].

CV_CHAR_QUICK_OP

Computes the normalized quick-opening valve characteristic as a function of fractional opening.

Quick-opening valves produce a large fraction of their total coefficient increase at small openings, then flatten as opening approaches the maximum.

The result is a dimensionless normalized coefficient fraction that is typically near 0 at closed position and near 1 at full opening.

Excel Usage

=CV_CHAR_QUICK_OP(opening)
  • opening (float, required): Fractional opening of the valve [0-1].

Returns (float): Flow coefficient characteristic fraction [0-1].

Example 1: Zero opening

Inputs:

opening
0

Excel formula:

=CV_CHAR_QUICK_OP(0)

Expected output:

-3.24793e-19

Example 2: Full opening

Inputs:

opening
1

Excel formula:

=CV_CHAR_QUICK_OP(1)

Expected output:

1

Example 3: Half opening

Inputs:

opening
0.5

Excel formula:

=CV_CHAR_QUICK_OP(0.5)

Expected output:

0.902547

Example 4: Quarter opening

Inputs:

opening
0.25

Excel formula:

=CV_CHAR_QUICK_OP(0.25)

Expected output:

0.788538

Python Code

Show Code
from fluids.control_valve import Cv_char_quick_opening

def cv_char_quick_op(opening):
    """
    Calculates the flow coefficient characteristic for a quick opening control valve.

    See: https://fluids.readthedocs.io/fluids.control_valve.html#fluids.control_valve.Cv_char_quick_opening

    This example function is provided as-is without any representation of accuracy.

    Args:
        opening (float): Fractional opening of the valve [0-1].

    Returns:
        float: Flow coefficient characteristic fraction [0-1].
    """
    try:
      val = float(opening)
      if val < 0 or val > 1:
        return "Error: opening must be between 0 and 1"
      return float(Cv_char_quick_opening(val))
    except Exception as e:
      return f"Error: {str(e)}"

Online Calculator

Fractional opening of the valve [0-1].

CV_CHOKE_PRESS_GAS

Solves for either upstream or downstream pressure at the choking limit for gas flow through a control valve.

The governing relationships are:

P_1 = -\frac{7P_2}{5\gamma x_T - 7}, \quad P_2 = \frac{P_1}{7}(-5\gamma x_T + 7)

Provide one pressure (p_inlet or p_outlet) with x_T and \gamma to compute the corresponding choked pressure.

Excel Usage

=CV_CHOKE_PRESS_GAS(xt_factor, gamma, p_inlet, p_outlet)
  • xt_factor (float, required): Pressure difference ratio factor (-)
  • gamma (float, required): Specific heat capacity ratio (-)
  • p_inlet (float, optional, default: null): Inlet pressure (Pa)
  • p_outlet (float, optional, default: null): Outlet pressure (Pa)

Returns (float): Choked pressure (Pa)

Example 1: Docs example (given P1)

Inputs:

xt_factor gamma p_inlet
1 1.3 100000

Excel formula:

=CV_CHOKE_PRESS_GAS(1, 1.3, 100000)

Expected output:

7142.86

Example 2: Docs example (given P2)

Inputs:

xt_factor gamma p_outlet
1 1.3 7142.86

Excel formula:

=CV_CHOKE_PRESS_GAS(1, 1.3, 7142.86)

Expected output:

100000

Example 3: Air at 1.0 XT

Inputs:

xt_factor gamma p_inlet
1 1.4 100000

Excel formula:

=CV_CHOKE_PRESS_GAS(1, 1.4, 100000)

Expected output:

0

Example 4: Nitrogen at 0.7 XT

Inputs:

xt_factor gamma p_inlet
0.7 1.4 100000

Excel formula:

=CV_CHOKE_PRESS_GAS(0.7, 1.4, 100000)

Expected output:

30000

Python Code

Show Code
from fluids.control_valve import control_valve_choke_P_g

def cv_choke_press_gas(xt_factor, gamma, p_inlet=None, p_outlet=None):
    """
    Calculates the pressure at which choked flow occurs in a gas control valve.

    See: https://fluids.readthedocs.io/fluids.control_valve.html#fluids.control_valve.control_valve_choke_P_g

    This example function is provided as-is without any representation of accuracy.

    Args:
        xt_factor (float): Pressure difference ratio factor (-)
        gamma (float): Specific heat capacity ratio (-)
        p_inlet (float, optional): Inlet pressure (Pa) Default is None.
        p_outlet (float, optional): Outlet pressure (Pa) Default is None.

    Returns:
        float: Choked pressure (Pa)
    """
    try:
      xt_factor = float(xt_factor)
      gamma = float(gamma)
      if p_inlet is not None:
        p_inlet = float(p_inlet)
      if p_outlet is not None:
        p_outlet = float(p_outlet)

      if xt_factor <= 0:
        return "Error: XT factor must be positive."
      if gamma <= 1:
        return "Error: Specific heat capacity ratio must be greater than 1."

      if p_inlet is None and p_outlet is None:
        return "Error: Either inlet pressure or outlet pressure must be provided."

      return float(control_valve_choke_P_g(xT=xt_factor, gamma=gamma, P1=p_inlet, P2=p_outlet))
    except Exception as e:
      return f"Error: {str(e)}"

Online Calculator

Pressure difference ratio factor (-)
Specific heat capacity ratio (-)
Inlet pressure (Pa)
Outlet pressure (Pa)

CV_CHOKE_PRESS_LIQ

Solves for either upstream or downstream pressure at the choking limit for liquid flow through a control valve.

The calculation uses the IEC liquid critical pressure ratio factor F_F together with F_L:

P_1 = \frac{F_FF_L^2P_{sat} - P_2}{F_L^2 - 1}, \quad P_2 = F_FF_L^2P_{sat} - F_L^2P_1 + P_1

Provide p_inlet or p_outlet and the function returns the corresponding choked pressure.

Excel Usage

=CV_CHOKE_PRESS_LIQ(p_sat, p_crit, fl_factor, p_inlet, p_outlet)
  • p_sat (float, required): Saturation pressure (Pa)
  • p_crit (float, required): Critical pressure (Pa)
  • fl_factor (float, required): Liquid pressure recovery factor (-)
  • p_inlet (float, optional, default: null): Inlet pressure (Pa)
  • p_outlet (float, optional, default: null): Outlet pressure (Pa)

Returns (float): Choked pressure (Pa)

Example 1: Docs example (given P1)

Inputs:

p_sat p_crit fl_factor p_inlet
69682.89 22048320 0.6 680000

Excel formula:

=CV_CHOKE_PRESS_LIQ(69682.89, 22048320, 0.6, 680000)

Expected output:

458888

Example 2: Docs example (given P2)

Inputs:

p_sat p_crit fl_factor p_outlet
69682.89 22048320 0.6 458887.53

Excel formula:

=CV_CHOKE_PRESS_LIQ(69682.89, 22048320, 0.6, 458887.53)

Expected output:

680000

Example 3: Water at 100C

Inputs:

p_sat p_crit fl_factor p_inlet
101325 22064000 0.9 1000000

Excel formula:

=CV_CHOKE_PRESS_LIQ(101325, 22064000, 0.9, 1000000)

Expected output:

267233

Example 4: Ethanol at 25C

Inputs:

p_sat p_crit fl_factor p_inlet
7900 6140000 0.8 500000

Excel formula:

=CV_CHOKE_PRESS_LIQ(7900, 6140000, 0.8, 500000)

Expected output:

184803

Python Code

Show Code
from fluids.control_valve import control_valve_choke_P_l

def cv_choke_press_liq(p_sat, p_crit, fl_factor, p_inlet=None, p_outlet=None):
    """
    Calculates the pressure at which choked flow occurs in a liquid control valve.

    See: https://fluids.readthedocs.io/fluids.control_valve.html#fluids.control_valve.control_valve_choke_P_l

    This example function is provided as-is without any representation of accuracy.

    Args:
        p_sat (float): Saturation pressure (Pa)
        p_crit (float): Critical pressure (Pa)
        fl_factor (float): Liquid pressure recovery factor (-)
        p_inlet (float, optional): Inlet pressure (Pa) Default is None.
        p_outlet (float, optional): Outlet pressure (Pa) Default is None.

    Returns:
        float: Choked pressure (Pa)
    """
    try:
      p_sat = float(p_sat)
      p_crit = float(p_crit)
      fl_factor = float(fl_factor)
      if p_inlet is not None:
        p_inlet = float(p_inlet)
      if p_outlet is not None:
        p_outlet = float(p_outlet)

      if p_sat <= 0:
        return "Error: Saturation pressure must be positive."
      if p_crit <= 0:
        return "Error: Critical pressure must be positive."
      if fl_factor <= 0:
        return "Error: Liquid pressure recovery factor must be positive."

      if p_inlet is None and p_outlet is None:
        return "Error: Either inlet pressure or outlet pressure must be provided."

      return float(control_valve_choke_P_l(Psat=p_sat, Pc=p_crit, FL=fl_factor, P1=p_inlet, P2=p_outlet, check_choking=True))
    except Exception as e:
      return f"Error: {str(e)}"

Online Calculator

Saturation pressure (Pa)
Critical pressure (Pa)
Liquid pressure recovery factor (-)
Inlet pressure (Pa)
Outlet pressure (Pa)

CV_CONVERT_COEFF

Converts a valve flow coefficient between the supported scales Kv, Cv, and Av.

The conversion applies fixed scale relationships so the same physical valve capacity is preserved across unit systems.

This is useful when moving between IEC-style K_v, US-style C_v, and SI-area-style A_v specifications.

Excel Usage

=CV_CONVERT_COEFF(coeff, old_scale, new_scale)
  • coeff (float, required): Flow coefficient value to convert.
  • old_scale (str, required): Original scale (e.g., Kv, Cv, Av).
  • new_scale (str, required): Target scale (e.g., Kv, Cv, Av).

Returns (float): Converted flow coefficient.

Example 1: Kv to Cv

Inputs:

coeff old_scale new_scale
10 Kv Cv

Excel formula:

=CV_CONVERT_COEFF(10, "Kv", "Cv")

Expected output:

11.561

Example 2: Cv to Kv

Inputs:

coeff old_scale new_scale
11.56 Cv Kv

Excel formula:

=CV_CONVERT_COEFF(11.56, "Cv", "Kv")

Expected output:

9.99914

Example 3: Kv to Av

Inputs:

coeff old_scale new_scale
10 Kv Av

Excel formula:

=CV_CONVERT_COEFF(10, "Kv", "Av")

Expected output:

0.000277653

Example 4: Same scale

Inputs:

coeff old_scale new_scale
50 Cv Cv

Excel formula:

=CV_CONVERT_COEFF(50, "Cv", "Cv")

Expected output:

50

Python Code

Show Code
from fluids.control_valve import convert_flow_coefficient

def cv_convert_coeff(coeff, old_scale, new_scale):
    """
    Converts between different flow coefficient scales (Kv, Cv, Av).

    See: https://fluids.readthedocs.io/fluids.control_valve.html#fluids.control_valve.convert_flow_coefficient

    This example function is provided as-is without any representation of accuracy.

    Args:
        coeff (float): Flow coefficient value to convert.
        old_scale (str): Original scale (e.g., Kv, Cv, Av). Valid options: Kv (metric), Cv (US), Av (SI).
        new_scale (str): Target scale (e.g., Kv, Cv, Av). Valid options: Kv (metric), Cv (US), Av (SI).

    Returns:
        float: Converted flow coefficient.
    """
    try:
      coeff = float(coeff)

      if coeff < 0:
        return "Error: Flow coefficient cannot be negative."

      return float(convert_flow_coefficient(coeff, old_scale, new_scale))
    except Exception as e:
      return f"Error: {str(e)}"

Online Calculator

Flow coefficient value to convert.
Original scale (e.g., Kv, Cv, Av).
Target scale (e.g., Kv, Cv, Av).

CV_NOISE_GAS_2011

This function estimates aerodynamic control-valve noise for gas service using the IEC 60534-8-3 (2011) method. It computes the A-weighted sound pressure level at 1 m from the downstream pipe wall based on flow rate, pressures, thermophysical properties, valve coefficient, and piping geometry.

The reported noise level is expressed in decibels using the logarithmic sound-pressure relation:

L_p = 20\log_{10}\left(\frac{p_{\mathrm{rms}}}{p_0}\right)

where p_0=2\times10^{-5} Pa is the reference sound pressure. Optional coefficients such as attached-fitting recovery factors and outlet temperature can be provided to refine the prediction.

Excel Usage

=CV_NOISE_GAS_2011(m, p_in, p_out, t_in, rho, gamma, mw, kv, d, di, t_pipe, fd, fl, flp, fp, rho_pipe, c_pipe, p_air, rho_air, c_air, an, stp, t_out, beta)
  • m (float, required): Mass flow rate of gas through the control valve (kg/s)
  • 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)
  • t_in (float, required): Inlet gas temperature (K)
  • rho (float, required): Density of the gas at the inlet (kg/m³)
  • gamma (float, required): Specific heat capacity ratio (dimensionless)
  • mw (float, required): Molecular weight of the gas (g/mol)
  • kv (float, required): Metric Kv valve flow coefficient (m³/hr)
  • d (float, required): Diameter of the valve (m)
  • di (float, required): Internal diameter of the pipe before and after the valve (m)
  • t_pipe (float, required): Wall thickness of the pipe after the valve (m)
  • fd (float, required): Valve style modifier (dimensionless)
  • fl (float, required): Liquid pressure recovery factor (dimensionless)
  • flp (float, optional, default: null): Liquid pressure recovery factor with piping geometry factor (dimensionless)
  • fp (float, optional, default: null): Piping geometry factor (dimensionless)
  • rho_pipe (float, optional, default: 7800): Density of the pipe wall material (kg/m³)
  • c_pipe (float, optional, default: 5000): Speed of sound in the pipe wall material (m/s)
  • p_air (float, optional, default: 101325): Standard atmospheric pressure (Pa)
  • rho_air (float, optional, default: 1.2): Density of air at standard conditions (kg/m³)
  • c_air (float, optional, default: 343): Speed of sound in air (m/s)
  • an (float, optional, default: -3.8): Constant for gas noise calculation
  • stp (float, optional, default: 0.2): Strouhal number for gas noise calculation
  • t_out (float, optional, default: null): Outlet gas temperature (K)
  • beta (float, optional, default: 0.93): Correction factor for gas properties

Returns (float): LpAe1m - A-weighted sound pressure level [dB], or an error message (str) if input is invalid.

Example 1: IEC example-style gas noise calculation with attached fittings

Inputs:

m p_in p_out t_in rho gamma mw kv d di t_pipe fd fl flp fp
2.22 1000000 720000 450 5.3 1.22 19.8 77.85 0.1 0.2031 0.008 0.296 0.792 0.792 0.98

Excel formula:

=CV_NOISE_GAS_2011(2.22, 1000000, 720000, 450, 5.3, 1.22, 19.8, 77.85, 0.1, 0.2031, 0.008, 0.296, 0.792, 0.792, 0.98)

Expected output:

91.733

Example 2: Lower pressure-drop gas noise scenario

Inputs:

m p_in p_out t_in rho gamma mw kv d di t_pipe fd fl
1.5 800000 700000 300 3 1.3 20 50 0.08 0.15 0.006 0.3 0.8

Excel formula:

=CV_NOISE_GAS_2011(1.5, 800000, 700000, 300, 3, 1.3, 20, 50, 0.08, 0.15, 0.006, 0.3, 0.8)

Expected output:

80.131

Example 3: Higher flow and pressure-drop gas noise scenario

Inputs:

m p_in p_out t_in rho gamma mw kv d di t_pipe fd fl flp fp
3 1200000 600000 500 6 1.25 18 100 0.12 0.25 0.01 0.25 0.75 0.8 0.95

Excel formula:

=CV_NOISE_GAS_2011(3, 1200000, 600000, 500, 6, 1.25, 18, 100, 0.12, 0.25, 0.01, 0.25, 0.75, 0.8, 0.95)

Expected output:

97.5904

Example 4: Low-flow gas noise scenario

Inputs:

m p_in p_out t_in rho gamma mw kv d di t_pipe fd fl
0.5 500000 400000 293 1.2 1.4 28.96 20 0.05 0.1 0.004 0.4 0.85

Excel formula:

=CV_NOISE_GAS_2011(0.5, 500000, 400000, 293, 1.2, 1.4, 28.96, 20, 0.05, 0.1, 0.004, 0.4, 0.85)

Expected output:

73.4581

Python Code

Show Code
import math
from fluids.control_valve import control_valve_noise_g_2011 as fluids_control_valve_noise_g_2011

def cv_noise_gas_2011(m, p_in, p_out, t_in, rho, gamma, mw, kv, d, di, t_pipe, fd, fl, flp=None, fp=None, rho_pipe=7800, c_pipe=5000, p_air=101325, rho_air=1.2, c_air=343, an=-3.8, stp=0.2, t_out=None, beta=0.93):
    """
    Calculate the A-weighted sound pressure level for gas flow through a control valve per IEC 60534-8-3 (2011).

    See: https://fluids.readthedocs.io/fluids.control_valve.html#fluids.control_valve.control_valve_noise_g_2011

    This example function is provided as-is without any representation of accuracy.

    Args:
        m (float): Mass flow rate of gas through the control valve (kg/s)
        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)
        t_in (float): Inlet gas temperature (K)
        rho (float): Density of the gas at the inlet (kg/m³)
        gamma (float): Specific heat capacity ratio (dimensionless)
        mw (float): Molecular weight of the gas (g/mol)
        kv (float): Metric Kv valve flow coefficient (m³/hr)
        d (float): Diameter of the valve (m)
        di (float): Internal diameter of the pipe before and after the valve (m)
        t_pipe (float): Wall thickness of the pipe after the valve (m)
        fd (float): Valve style modifier (dimensionless)
        fl (float): Liquid pressure recovery factor (dimensionless)
        flp (float, optional): Liquid pressure recovery factor with piping geometry factor (dimensionless) Default is None.
        fp (float, optional): Piping geometry factor (dimensionless) Default is None.
        rho_pipe (float, optional): Density of the pipe wall material (kg/m³) Default is 7800.
        c_pipe (float, optional): Speed of sound in the pipe wall material (m/s) Default is 5000.
        p_air (float, optional): Standard atmospheric pressure (Pa) Default is 101325.
        rho_air (float, optional): Density of air at standard conditions (kg/m³) Default is 1.2.
        c_air (float, optional): Speed of sound in air (m/s) Default is 343.
        an (float, optional): Constant for gas noise calculation Default is -3.8.
        stp (float, optional): Strouhal number for gas noise calculation Default is 0.2.
        t_out (float, optional): Outlet gas temperature (K) Default is None.
        beta (float, optional): Correction factor for gas properties Default is 0.93.

    Returns:
        float: LpAe1m - A-weighted sound pressure level [dB], or an error message (str) if input is invalid.
    """
    try:
      # Validate required inputs
      required_params = [m, p_in, p_out, t_in, rho, gamma, mw, kv, d, di, t_pipe, fd, fl]
      if not all(isinstance(x, (int, float)) for x in required_params):
        return "Error: All required parameters must be numeric."

      if any(not math.isfinite(x) for x in required_params):
        return "Error: All required parameters must be finite numbers."

      if m < 0:
        return "Error: Mass flow rate (m) must be non-negative."
      if p_in <= 0 or p_out <= 0:
        return "Error: Pressures must be positive."
      if t_in <= 0:
        return "Error: Inlet temperature (t_in) must be positive."
      if rho <= 0:
        return "Error: Gas density (rho) must be positive."
      if gamma <= 0:
        return "Error: Specific heat capacity ratio (gamma) must be positive."
      if mw <= 0:
        return "Error: Molecular weight (mw) must be positive."
      if kv <= 0:
        return "Error: Valve flow coefficient (kv) must be positive."
      if d <= 0:
        return "Error: Valve diameter (d) must be positive."
      if di <= 0:
        return "Error: Pipe internal diameter (di) must be positive."
      if t_pipe <= 0:
        return "Error: Pipe wall thickness (t_pipe) must be positive."
      if fd <= 0:
        return "Error: Valve style modifier (fd) must be positive."
      if fl <= 0:
        return "Error: Liquid pressure recovery factor (fl) must be positive."

      # Validate optional numeric inputs with defaults
      other_numeric_params = [rho_pipe, c_pipe, p_air, rho_air, c_air, an, stp, beta]
      if not all(isinstance(x, (int, float)) for x in other_numeric_params):
        return "Error: All numeric parameters must be numeric."

      if any(not math.isfinite(x) for x in other_numeric_params):
        return "Error: All numeric parameters must be finite numbers."

      if rho_pipe <= 0 or c_pipe <= 0 or p_air <= 0 or rho_air <= 0 or c_air <= 0:
        return "Error: Material property values must be positive."

      # Validate optional parameters without defaults
      if flp is not None:
        if not isinstance(flp, (int, float)) or not math.isfinite(flp) or flp <= 0:
          return "Error: flp must be a positive finite number if provided."
      if fp is not None:
        if not isinstance(fp, (int, float)) or not math.isfinite(fp) or fp <= 0:
          return "Error: fp must be a positive finite number if provided."
      if t_out is not None:
        if not isinstance(t_out, (int, float)) or not math.isfinite(t_out) or t_out <= 0:
          return "Error: Outlet temperature (t_out) must be a positive finite number if provided."

      try:
        # Prepare the function call with all parameters
        kwargs = {
          'm': m, 'P1': p_in, 'P2': p_out, 'T1': t_in, 'rho': rho, 'gamma': gamma, 'MW': mw,
          'Kv': kv, 'd': d, 'Di': di, 't_pipe': t_pipe, 'Fd': fd, 'FL': fl,
          'rho_pipe': rho_pipe, 'c_pipe': c_pipe, 'P_air': p_air,
          'rho_air': rho_air, 'c_air': c_air, 'An': an, 'Stp': stp, 'beta': beta
        }

        # Add optional parameters if they are provided
        if flp is not None:
          kwargs['FLP'] = flp
        if fp is not None:
          kwargs['FP'] = fp
        if t_out is not None:
          kwargs['T2'] = t_out

        result = fluids_control_valve_noise_g_2011(**kwargs)
        if not math.isfinite(result):
          return "Error: Function returned non-finite value."
        return result
      except Exception as e:
        return f"Error: Failed to compute gas noise: {str(e)}"
    except Exception as e:
      return f"Error: {str(e)}"

Online Calculator

Mass flow rate of gas through the control valve (kg/s)
Inlet pressure of the gas before valves and reducers (Pa)
Outlet pressure of the gas after valves and reducers (Pa)
Inlet gas temperature (K)
Density of the gas at the inlet (kg/m³)
Specific heat capacity ratio (dimensionless)
Molecular weight of the gas (g/mol)
Metric Kv valve flow coefficient (m³/hr)
Diameter of the valve (m)
Internal diameter of the pipe before and after the valve (m)
Wall thickness of the pipe after the valve (m)
Valve style modifier (dimensionless)
Liquid pressure recovery factor (dimensionless)
Liquid pressure recovery factor with piping geometry factor (dimensionless)
Piping geometry factor (dimensionless)
Density of the pipe wall material (kg/m³)
Speed of sound in the pipe wall material (m/s)
Standard atmospheric pressure (Pa)
Density of air at standard conditions (kg/m³)
Speed of sound in air (m/s)
Constant for gas noise calculation
Strouhal number for gas noise calculation
Outlet gas temperature (K)
Correction factor for gas properties

CV_NOISE_LIQ_2015

This function predicts hydrodynamic control-valve noise for liquid service using the IEC 60534-8-4 (2015) method. It returns the A-weighted sound pressure level at 1 m downstream of the valve, using operating pressures, liquid properties, valve capacity, and pipe/acoustic parameters.

Sound level is represented on a logarithmic decibel scale:

L_p = 20\log_{10}\left(\frac{p_{\mathrm{rms}}}{p_0}\right)

with reference pressure p_0=2\times10^{-5} Pa. The optional cavitation sensitivity factor x_{Fz} can be supplied directly when available.

Excel Usage

=CV_NOISE_LIQ_2015(m, p_in, p_out, psat, rho, c, kv, d, di, fl, fd, t_pipe, rho_pipe, c_pipe, rho_air, c_air, xfz, an)
  • m (float, required): Mass flow rate of liquid through the control valve (kg/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)
  • psat (float, required): Saturation pressure of the fluid at inlet temperature (Pa)
  • rho (float, required): Density of the liquid at the inlet (kg/m^3)
  • c (float, required): Speed of sound of the liquid at the inlet conditions (m/s)
  • kv (float, required): Metric Kv valve flow coefficient (m^3/hr)
  • d (float, required): Diameter of the valve (m)
  • di (float, required): Internal diameter of the pipe before and after the valve (m)
  • fl (float, required): Liquid pressure recovery factor (-)
  • fd (float, required): Valve style modifier (-)
  • t_pipe (float, required): Wall thickness of the pipe after the valve (m)
  • rho_pipe (float, optional, default: 7800): Density of the pipe wall material at flowing conditions (kg/m^3)
  • c_pipe (float, optional, default: 5000): Speed of sound of the pipe wall material at flowing conditions (m/s)
  • rho_air (float, optional, default: 1.293): Density of the air surrounding the valve and pipe wall (kg/m^3)
  • c_air (float, optional, default: 343): Speed of sound of the air surrounding the valve and pipe wall (m/s)
  • xfz (float, optional, default: null): If specified, this value is used instead of estimated (-)
  • an (float, optional, default: -4.6): Valve correction factor for acoustic efficiency (-)

Returns (float): A-weighted sound pressure level at 1 meter (dB), or an error message (str) if input is invalid.

Example 1: Basic noise calculation with default parameters

Inputs:

m p_in p_out psat rho c kv d di fl fd t_pipe rho_pipe c_pipe rho_air c_air an
40 1000000 650000 2320 997 1400 77.848 0.1 0.1071 0.92 0.42 0.0036 7800 5000 1.293 343 -4.6

Excel formula:

=CV_NOISE_LIQ_2015(40, 1000000, 650000, 2320, 997, 1400, 77.848, 0.1, 0.1071, 0.92, 0.42, 0.0036, 7800, 5000, 1.293, 343, -4.6)

Expected output:

81.582

Example 2: Noise calculation with specified xFz value

Inputs:

m p_in p_out psat rho c kv d di fl fd t_pipe xfz
50 1500000 850000 3200 995 1350 90 0.12 0.127 0.88 0.38 0.004 0.05

Excel formula:

=CV_NOISE_LIQ_2015(50, 1500000, 850000, 3200, 995, 1350, 90, 0.12, 0.127, 0.88, 0.38, 0.004, 0.05)

Expected output:

117.24

Example 3: Noise calculation with different An correction factor

Inputs:

m p_in p_out psat rho c kv d di fl fd t_pipe an
30 1200000 720000 2500 1000 1450 65 0.08 0.0889 0.9 0.4 0.003 -4

Excel formula:

=CV_NOISE_LIQ_2015(30, 1200000, 720000, 2500, 1000, 1450, 65, 0.08, 0.0889, 0.9, 0.4, 0.003, -4)

Expected output:

92.1424

Example 4: Noise calculation with only required parameters

Inputs:

m p_in p_out psat rho c kv d di fl fd t_pipe
25 1000000 700000 2000 998 1420 55 0.09 0.095 0.85 0.45 0.0035

Excel formula:

=CV_NOISE_LIQ_2015(25, 1000000, 700000, 2000, 998, 1420, 55, 0.09, 0.095, 0.85, 0.45, 0.0035)

Expected output:

72.6988

Python Code

Show Code
from fluids.control_valve import control_valve_noise_l_2015 as fluids_control_valve_noise_l_2015
import math

def cv_noise_liq_2015(m, p_in, p_out, psat, rho, c, kv, d, di, fl, fd, t_pipe, rho_pipe=7800, c_pipe=5000, rho_air=1.293, c_air=343, xfz=None, an=-4.6):
    """
    Calculates the sound made by a liquid flowing through a control valve according to the standard IEC 60534-8-4 (2015) using fluids.control_valve.control_valve_noise_l_2015.

    See: https://fluids.readthedocs.io/fluids.control_valve.html#fluids.control_valve.control_valve_noise_l_2015

    This example function is provided as-is without any representation of accuracy.

    Args:
        m (float): Mass flow rate of liquid through the control valve (kg/s)
        p_in (float): Inlet pressure of the fluid before valves and reducers (Pa)
        p_out (float): Outlet pressure of the fluid after valves and reducers (Pa)
        psat (float): Saturation pressure of the fluid at inlet temperature (Pa)
        rho (float): Density of the liquid at the inlet (kg/m^3)
        c (float): Speed of sound of the liquid at the inlet conditions (m/s)
        kv (float): Metric Kv valve flow coefficient (m^3/hr)
        d (float): Diameter of the valve (m)
        di (float): Internal diameter of the pipe before and after the valve (m)
        fl (float): Liquid pressure recovery factor (-)
        fd (float): Valve style modifier (-)
        t_pipe (float): Wall thickness of the pipe after the valve (m)
        rho_pipe (float, optional): Density of the pipe wall material at flowing conditions (kg/m^3) Default is 7800.
        c_pipe (float, optional): Speed of sound of the pipe wall material at flowing conditions (m/s) Default is 5000.
        rho_air (float, optional): Density of the air surrounding the valve and pipe wall (kg/m^3) Default is 1.293.
        c_air (float, optional): Speed of sound of the air surrounding the valve and pipe wall (m/s) Default is 343.
        xfz (float, optional): If specified, this value is used instead of estimated (-) Default is None.
        an (float, optional): Valve correction factor for acoustic efficiency (-) Default is -4.6.

    Returns:
        float: A-weighted sound pressure level at 1 meter (dB), or an error message (str) if input is invalid.
    """
    try:

      # Validate and convert input parameters to float
      try:
        m = float(m)
        p_in = float(p_in)
        p_out = float(p_out)
        psat = float(psat)
        rho = float(rho)
        c = float(c)
        kv = float(kv)
        d = float(d)
        di = float(di)
        fl = float(fl)
        fd = float(fd)
        t_pipe = float(t_pipe)
        rho_pipe = float(rho_pipe)
        c_pipe = float(c_pipe)
        rho_air = float(rho_air)
        c_air = float(c_air)
        if xfz is not None:
          xfz = float(xfz)
        an = float(an)
      except (TypeError, ValueError):
        return "Error: All parameters must be numeric values."

      # Check for non-finite values
      values = [m, p_in, p_out, psat, rho, c, kv, d, di, fl, fd, t_pipe, rho_pipe, c_pipe, rho_air, c_air, an]
      if xfz is not None:
        values.append(xfz)
      if any(not math.isfinite(v) for v in values):
        return "Error: All parameters must be finite numbers."

      # Call the fluids package implementation
      try:
        result = fluids_control_valve_noise_l_2015(
          m=m,
          P1=p_in,
          P2=p_out,
          Psat=psat,
          rho=rho,
          c=c,
          Kv=kv,
          d=d,
          Di=di,
          FL=fl,
          Fd=fd,
          t_pipe=t_pipe,
          rho_pipe=rho_pipe,
          c_pipe=c_pipe,
          rho_air=rho_air,
          c_air=c_air,
          xFz=xfz,
          An=an
        )
        return result
      except Exception as exc:
        return f"Error: Failed to compute liquid noise: {exc}"
    except Exception as e:
      return f"Error: {str(e)}"

Online Calculator

Mass flow rate of liquid through the control valve (kg/s)
Inlet pressure of the fluid before valves and reducers (Pa)
Outlet pressure of the fluid after valves and reducers (Pa)
Saturation pressure of the fluid at inlet temperature (Pa)
Density of the liquid at the inlet (kg/m^3)
Speed of sound of the liquid at the inlet conditions (m/s)
Metric Kv valve flow coefficient (m^3/hr)
Diameter of the valve (m)
Internal diameter of the pipe before and after the valve (m)
Liquid pressure recovery factor (-)
Valve style modifier (-)
Wall thickness of the pipe after the valve (m)
Density of the pipe wall material at flowing conditions (kg/m^3)
Speed of sound of the pipe wall material at flowing conditions (m/s)
Density of the air surrounding the valve and pipe wall (kg/m^3)
Speed of sound of the air surrounding the valve and pipe wall (m/s)
If specified, this value is used instead of estimated (-)
Valve correction factor for acoustic efficiency (-)

FF_CRIT_PRESS_L

Computes the IEC 60534 liquid critical pressure ratio factor F_F from saturation pressure and critical pressure.

The factor is calculated as:

F_F = 0.96 - 0.28\sqrt{\frac{P_{sat}}{P_c}}

This dimensionless ratio is used in downstream liquid control-valve choking and sizing calculations.

Excel Usage

=FF_CRIT_PRESS_L(psat, pc)
  • psat (float, required): Saturation pressure of the liquid at inlet temperature [Pa]
  • pc (float, required): Critical pressure of the liquid [Pa]

Returns (float): FF - Liquid critical pressure ratio factor (dimensionless), or an error message (str) if input is invalid.

Example 1: Water at 90°C

Inputs:

psat pc
70100 22120000

Excel formula:

=FF_CRIT_PRESS_L(70100, 22120000)

Expected output:

0.944238

Example 2: High pressure ratio

Inputs:

psat pc
1000000 20000000

Excel formula:

=FF_CRIT_PRESS_L(1000000, 20000000)

Expected output:

0.89739

Example 3: Low pressure ratio

Inputs:

psat pc
10000 25000000

Excel formula:

=FF_CRIT_PRESS_L(10000, 25000000)

Expected output:

0.9544

Example 4: Near critical conditions

Inputs:

psat pc
5000000 22120000

Excel formula:

=FF_CRIT_PRESS_L(5000000, 22120000)

Expected output:

0.826878

Python Code

Show Code
from math import isfinite
from fluids.control_valve import FF_critical_pressure_ratio_l as fluids_ff_critical_pressure_ratio_l

def ff_crit_press_l(psat, pc):
    """
    Calculates FF, the liquid critical pressure ratio factor, for use in IEC 60534 liquid valve sizing calculations using fluids.control_valve.FF_critical_pressure_ratio_l. See https://fluids.readthedocs.io/fluids.control_valve.html#fluids.control_valve.FF_critical_pressure_ratio_l for details.

    See: https://fluids.readthedocs.io/fluids.control_valve.html#fluids.control_valve.FF_critical_pressure_ratio_l

    This example function is provided as-is without any representation of accuracy.

    Args:
        psat (float): Saturation pressure of the liquid at inlet temperature [Pa]
        pc (float): Critical pressure of the liquid [Pa]

    Returns:
        float: FF - Liquid critical pressure ratio factor (dimensionless), or an error message (str) if input is invalid.
    """
    try:
      psat = float(psat)
      pc = float(pc)

      if not isfinite(psat) or not isfinite(pc):
        return "Error: psat and pc must be finite numbers."

      if psat <= 0:
        return "Error: psat must be positive."
      if pc <= 0:
        return "Error: pc must be positive."

      result = fluids_ff_critical_pressure_ratio_l(psat, pc)
      if not isfinite(result):
        return "Error: Calculation resulted in a non-finite value."
      return float(result)
    except Exception as e:
      return f"Error: {str(e)}"

Online Calculator

Saturation pressure of the liquid at inlet temperature [Pa]
Critical pressure of the liquid [Pa]

IS_CHOKED_GAS

Evaluates whether a gas valve operating point is choked (critical) using IEC 60534 inequalities.

Choking is detected when either condition is met, depending on provided factor:

x \ge F_\gamma x_T

x \ge F_\gamma x_{TP}

The function returns True for choked flow and False otherwise.

Excel Usage

=IS_CHOKED_GAS(x, Fgamma, xT, xTP)
  • x (float, required): Differential pressure ratio (dP/P1) [-]
  • Fgamma (float, required): Specific heat ratio factor [-]
  • xT (float, optional, default: null): Pressure difference ratio factor of a valve without fittings [-]
  • xTP (float, optional, default: null): Pressure difference ratio factor of a valve with fittings [-]

Returns (bool): True if flow is choked (critical), False otherwise.

Example 1: Non-choked flow example

Inputs:

x Fgamma xT
0.544 0.929 0.6

Excel formula:

=IS_CHOKED_GAS(0.544, 0.929, 0.6)

Expected output:

false

Example 2: Choked flow example

Inputs:

x Fgamma xT
0.6 0.929 0.6

Excel formula:

=IS_CHOKED_GAS(0.6, 0.929, 0.6)

Expected output:

true

Example 3: Non-choked with fittings

Inputs:

x Fgamma xTP
0.544 0.929 0.625

Excel formula:

=IS_CHOKED_GAS(0.544, 0.929, 0.625)

Expected output:

false

Example 4: Choked with fittings

Inputs:

x Fgamma xTP
0.8 0.929 0.625

Excel formula:

=IS_CHOKED_GAS(0.8, 0.929, 0.625)

Expected output:

true

Python Code

Show Code
from fluids.control_valve import is_choked_turbulent_g as fluids_is_choked

def is_choked_gas(x, Fgamma, xT=None, xTP=None):
    """
    Determines if a gas flow in a control valve is choked (critical) or not according to IEC 60534.

    See: https://fluids.readthedocs.io/fluids.control_valve.html#fluids.control_valve.is_choked_turbulent_g

    This example function is provided as-is without any representation of accuracy.

    Args:
        x (float): Differential pressure ratio (dP/P1) [-]
        Fgamma (float): Specific heat ratio factor [-]
        xT (float, optional): Pressure difference ratio factor of a valve without fittings [-] Default is None.
        xTP (float, optional): Pressure difference ratio factor of a valve with fittings [-] Default is None.

    Returns:
        bool: True if flow is choked (critical), False otherwise.
    """
    try:
      x = float(x)
      Fgamma = float(Fgamma)

      if xT is not None:
        xT = float(xT)
      if xTP is not None:
        xTP = float(xTP)

      if x < 0:
        return "Error: Differential pressure ratio must be non-negative."
      if Fgamma <= 0:
        return "Error: Fgamma must be positive."

      if xT is None and xTP is None:
        return "Error: Either xT or xTP must be provided."

      return fluids_is_choked(x=x, Fgamma=Fgamma, xT=xT, xTP=xTP)
    except Exception as e:
      return f"Error: {str(e)}"

Online Calculator

Differential pressure ratio (dP/P1) [-]
Specific heat ratio factor [-]
Pressure difference ratio factor of a valve without fittings [-]
Pressure difference ratio factor of a valve with fittings [-]

IS_CHOKED_LIQ

Evaluates whether a liquid valve operating point is choked (critical) using IEC 60534 criteria.

Depending on available factors, choking is determined by:

\Delta P > F_L^2(P_1 - F_FP_{sat})

or

\Delta P \ge \left(\frac{F_{LP}}{F_P}\right)^2(P_1 - F_FP_{sat})

The function returns True when the supplied condition indicates choked flow.

Excel Usage

=IS_CHOKED_LIQ(dP, P_up, Psat, FF, FL, FLP, FP)
  • dP (float, required): Pressure drop across the valve [Pa]
  • P_up (float, required): Upstream absolute pressure [Pa]
  • Psat (float, required): Liquid vapor pressure at inlet temperature [Pa]
  • FF (float, required): Liquid critical pressure ratio factor [-]
  • FL (float, optional, default: null): Liquid pressure recovery factor of a valve without attached fittings [-]
  • FLP (float, optional, default: null): Combined liquid pressure recovery factor with attached fittings [-]
  • FP (float, optional, default: null): Piping geometry factor [-]

Returns (bool): True if flow is choked (critical), False otherwise.

Example 1: Choked flow scenario

Inputs:

dP P_up Psat FF FL
1000000 2000000 100000 0.9 0.5

Excel formula:

=IS_CHOKED_LIQ(1000000, 2000000, 100000, 0.9, 0.5)

Expected output:

true

Example 2: Non-choked flow scenario

Inputs:

dP P_up Psat FF FL
10000 2000000 100000 0.9 0.9

Excel formula:

=IS_CHOKED_LIQ(10000, 2000000, 100000, 0.9, 0.9)

Expected output:

false

Example 3: Choked with fittings (FLP/FP)

Inputs:

dP P_up Psat FF FLP FP
800000 1000000 50000 0.8 0.4 0.9

Excel formula:

=IS_CHOKED_LIQ(800000, 1000000, 50000, 0.8, 0.4, 0.9)

Expected output:

true

Example 4: Non-choked with fittings

Inputs:

dP P_up Psat FF FLP FP
50000 1000000 50000 0.8 0.8 0.9

Excel formula:

=IS_CHOKED_LIQ(50000, 1000000, 50000, 0.8, 0.8, 0.9)

Expected output:

false

Python Code

Show Code
from fluids.control_valve import is_choked_turbulent_l as fluids_is_choked

def is_choked_liq(dP, P_up, Psat, FF, FL=None, FLP=None, FP=None):
    """
    Determines if a liquid flow in a control valve is choked (critical) or not according to IEC 60534.

    See: https://fluids.readthedocs.io/fluids.control_valve.html#fluids.control_valve.is_choked_turbulent_l

    This example function is provided as-is without any representation of accuracy.

    Args:
        dP (float): Pressure drop across the valve [Pa]
        P_up (float): Upstream absolute pressure [Pa]
        Psat (float): Liquid vapor pressure at inlet temperature [Pa]
        FF (float): Liquid critical pressure ratio factor [-]
        FL (float, optional): Liquid pressure recovery factor of a valve without attached fittings [-] Default is None.
        FLP (float, optional): Combined liquid pressure recovery factor with attached fittings [-] Default is None.
        FP (float, optional): Piping geometry factor [-] Default is None.

    Returns:
        bool: True if flow is choked (critical), False otherwise.
    """
    try:
      dP = float(dP)
      P_up = float(P_up)
      Psat = float(Psat)
      FF = float(FF)

      if FL is not None:
        FL = float(FL)
      if FLP is not None:
        FLP = float(FLP)
      if FP is not None:
        FP = float(FP)

      if dP < 0:
        return "Error: Pressure drop must be non-negative."
      if P_up <= 0:
        return "Error: Upstream pressure must be positive."
      if Psat < 0:
        return "Error: Saturation pressure must be non-negative."
      if FF <= 0:
        return "Error: FF must be positive."
      if FL is not None and FL <= 0:
        return "Error: FL must be positive."
      if FLP is not None and FLP <= 0:
        return "Error: FLP must be positive."
      if FP is not None and FP <= 0:
        return "Error: FP must be positive."

      if FL is None and (FLP is None or FP is None):
        return "Error: Provide FL or both FLP and FP."

      return fluids_is_choked(dP=dP, P1=P_up, Psat=Psat, FF=FF, FL=FL, FLP=FLP, FP=FP)
    except Exception as e:
      return f"Error: {str(e)}"

Online Calculator

Pressure drop across the valve [Pa]
Upstream absolute pressure [Pa]
Liquid vapor pressure at inlet temperature [Pa]
Liquid critical pressure ratio factor [-]
Liquid pressure recovery factor of a valve without attached fittings [-]
Combined liquid pressure recovery factor with attached fittings [-]
Piping geometry factor [-]

LOSS_COEFF_PIPING

Computes the total piping loss coefficient contribution from inlet/outlet reducers and expanders around a control valve.

The combined loss coefficient is:

\Sigma\xi = \xi_1 + \xi_2 + \xi_{B1} - \xi_{B2}

where each term depends on valve diameter and upstream/downstream pipe diameters.

Excel Usage

=LOSS_COEFF_PIPING(d_valve, d_pipe_in, d_pipe_out)
  • d_valve (float, required): Valve diameter (m)
  • d_pipe_in (float, optional, default: null): Inlet pipe diameter (m)
  • d_pipe_out (float, optional, default: null): Outlet pipe diameter (m)

Returns (float): Sum of loss coefficients (-)

Example 1: Example from documentation

Inputs:

d_valve d_pipe_in d_pipe_out
0.05 0.08 0.1

Excel formula:

=LOSS_COEFF_PIPING(0.05, 0.08, 0.1)

Expected output:

0.658081

Example 2: Inlet reducer only

Inputs:

d_valve d_pipe_in
0.05 0.08

Excel formula:

=LOSS_COEFF_PIPING(0.05, 0.08)

Expected output:

1.03308

Example 3: Outlet expander only

Inputs:

d_valve d_pipe_out
0.05 0.1

Excel formula:

=LOSS_COEFF_PIPING(0.05, 0.1)

Expected output:

-0.375

Example 4: No fittings (same diameters)

Inputs:

d_valve d_pipe_in d_pipe_out
0.05 0.05 0.05

Excel formula:

=LOSS_COEFF_PIPING(0.05, 0.05, 0.05)

Expected output:

0

Python Code

Show Code
from fluids.control_valve import loss_coefficient_piping

def loss_coeff_piping(d_valve, d_pipe_in=None, d_pipe_out=None):
    """
    Calculates the sum of loss coefficients for reducers/expanders around a control valve.

    See: https://fluids.readthedocs.io/fluids.control_valve.html#fluids.control_valve.loss_coefficient_piping

    This example function is provided as-is without any representation of accuracy.

    Args:
        d_valve (float): Valve diameter (m)
        d_pipe_in (float, optional): Inlet pipe diameter (m) Default is None.
        d_pipe_out (float, optional): Outlet pipe diameter (m) Default is None.

    Returns:
        float: Sum of loss coefficients (-)
    """
    try:
      d_valve = float(d_valve)
      if d_pipe_in is not None:
        d_pipe_in = float(d_pipe_in)
      if d_pipe_out is not None:
        d_pipe_out = float(d_pipe_out)

      if d_valve <= 0:
        return "Error: Valve diameter must be positive."
      if d_pipe_in is not None and d_pipe_in <= 0:
        return "Error: Inlet pipe diameter must be positive."
      if d_pipe_out is not None and d_pipe_out <= 0:
        return "Error: Outlet pipe diameter must be positive."

      return float(loss_coefficient_piping(d=d_valve, D1=d_pipe_in, D2=d_pipe_out))
    except Exception as e:
      return f"Error: {str(e)}"

Online Calculator

Valve diameter (m)
Inlet pipe diameter (m)
Outlet pipe diameter (m)

REYNOLDS_FACTOR

Calculates the IEC 60534 Reynolds correction factor F_R for valve sizing in laminar or transitional regimes.

The factor is a function of valve Reynolds number, valve coefficient, diameter, pressure recovery factor, and trim style.

It applies different correlations for full trim and reduced trim to determine the effective correction used in capacity calculations.

Excel Usage

=REYNOLDS_FACTOR(fl_factor, kv, d_valve, re_valve, full_trim)
  • fl_factor (float, required): Liquid pressure recovery factor (-)
  • kv (float, required): Flow coefficient Kv (m³/hr)
  • d_valve (float, required): Valve diameter (m)
  • re_valve (float, required): Valve Reynolds number (-)
  • full_trim (bool, optional, default: true): Whether the valve has full trim

Returns (float): Reynolds number factor FR [-]

Example 1: Full trim case

Inputs:

fl_factor kv d_valve re_valve full_trim
0.9 10 0.05 1000 true

Excel formula:

=REYNOLDS_FACTOR(0.9, 10, 0.05, 1000, TRUE)

Expected output:

0.686935

Example 2: Reduced trim case

Inputs:

fl_factor kv d_valve re_valve full_trim
0.9 10 0.05 1000 false

Excel formula:

=REYNOLDS_FACTOR(0.9, 10, 0.05, 1000, FALSE)

Expected output:

0.977157

Example 3: High Reynolds

Inputs:

fl_factor kv d_valve re_valve full_trim
0.9 10 0.05 1000000 true

Excel formula:

=REYNOLDS_FACTOR(0.9, 10, 0.05, 1000000, TRUE)

Expected output:

1.62613

Example 4: Low Reynolds

Inputs:

fl_factor kv d_valve re_valve full_trim
0.7 50 0.1 10 true

Excel formula:

=REYNOLDS_FACTOR(0.7, 50, 0.1, 10, TRUE)

Expected output:

0.117456

Python Code

Show Code
from fluids.control_valve import Reynolds_factor

def reynolds_factor(fl_factor, kv, d_valve, re_valve, full_trim=True):
    """
    Calculates the Reynolds number factor FR for a valve according to IEC 60534.

    See: https://fluids.readthedocs.io/fluids.control_valve.html#fluids.control_valve.Reynolds_factor

    This example function is provided as-is without any representation of accuracy.

    Args:
        fl_factor (float): Liquid pressure recovery factor (-)
        kv (float): Flow coefficient Kv (m³/hr)
        d_valve (float): Valve diameter (m)
        re_valve (float): Valve Reynolds number (-)
        full_trim (bool, optional): Whether the valve has full trim Default is True.

    Returns:
        float: Reynolds number factor FR [-]
    """
    try:
      fl_factor = float(fl_factor)
      kv = float(kv)
      d_valve = float(d_valve)
      re_valve = float(re_valve)

      if fl_factor <= 0:
        return "Error: Liquid pressure recovery factor must be positive."
      if kv <= 0:
        return "Error: Flow coefficient Kv must be positive."
      if d_valve <= 0:
        return "Error: Valve diameter must be positive."
      if re_valve < 0:
        return "Error: Reynolds number cannot be negative."

      return float(Reynolds_factor(FL=fl_factor, C=kv, d=d_valve, Rev=re_valve, full_trim=full_trim))
    except Exception as e:
      return f"Error: {str(e)}"

Online Calculator

Liquid pressure recovery factor (-)
Flow coefficient Kv (m³/hr)
Valve diameter (m)
Valve Reynolds number (-)
Whether the valve has full trim

REYNOLDS_VALVE

Computes the valve Reynolds number used in IEC 60534 valve sizing from fluid viscosity, flow rate, geometry, and valve factors.

The implemented relation is:

Re_v = \frac{N_4F_dQ}{\nu\sqrt{CF_L}}\left(\frac{F_L^2C^2}{N_2D_1^4}+1\right)^{1/4}

The resulting Re_v supports downstream determination of laminar/transitional correction effects.

Excel Usage

=REYNOLDS_VALVE(nu, q_flow, d_pipe, fl_factor, fd_modifier, kv)
  • nu (float, required): Kinematic viscosity (m²/s)
  • q_flow (float, required): Volumetric flow rate (m³/s)
  • d_pipe (float, required): Pipe diameter (m)
  • fl_factor (float, required): Liquid pressure recovery factor (-)
  • fd_modifier (float, required): Valve style modifier (-)
  • kv (float, required): Flow coefficient Kv (m³/hr)

Returns (float): Valve Reynolds number [-]

Example 1: Standard case

Inputs:

nu q_flow d_pipe fl_factor fd_modifier kv
3.26e-7 360 150 0.9 0.46 165

Excel formula:

=REYNOLDS_VALVE(3.26e-7, 360, 150, 0.9, 0.46, 165)

Expected output:

2966980

Example 2: Lower flow

Inputs:

nu q_flow d_pipe fl_factor fd_modifier kv
0.000001 10 0.05 0.85 0.4 50

Excel formula:

=REYNOLDS_VALVE(0.000001, 10, 0.05, 0.85, 0.4, 50)

Expected output:

28280000

Example 3: Higher viscosity

Inputs:

nu q_flow d_pipe fl_factor fd_modifier kv
0.0001 50 0.1 0.7 0.6 200

Excel formula:

=REYNOLDS_VALVE(0.0001, 50, 0.1, 0.7, 0.6, 200)

Expected output:

1060500

Example 4: Different recovery factor

Inputs:

nu q_flow d_pipe fl_factor fd_modifier kv
0.000001 100 0.2 0.5 0.3 100

Excel formula:

=REYNOLDS_VALVE(0.000001, 100, 0.2, 0.5, 0.3, 100)

Expected output:

53025000

Python Code

Show Code
from fluids.control_valve import Reynolds_valve

def reynolds_valve(nu, q_flow, d_pipe, fl_factor, fd_modifier, kv):
    """
    Calculates the Reynolds number of a control valve according to IEC 60534.

    See: https://fluids.readthedocs.io/fluids.control_valve.html#fluids.control_valve.Reynolds_valve

    This example function is provided as-is without any representation of accuracy.

    Args:
        nu (float): Kinematic viscosity (m²/s)
        q_flow (float): Volumetric flow rate (m³/s)
        d_pipe (float): Pipe diameter (m)
        fl_factor (float): Liquid pressure recovery factor (-)
        fd_modifier (float): Valve style modifier (-)
        kv (float): Flow coefficient Kv (m³/hr)

    Returns:
        float: Valve Reynolds number [-]
    """
    try:
      nu = float(nu)
      q_flow = float(q_flow)
      d_pipe = float(d_pipe)
      fl_factor = float(fl_factor)
      fd_modifier = float(fd_modifier)
      kv = float(kv)

      if nu <= 0:
        return "Error: Kinematic viscosity must be positive."
      if q_flow < 0:
        return "Error: Volumetric flow rate must be non-negative."
      if d_pipe <= 0:
        return "Error: Pipe diameter must be positive."
      if fl_factor <= 0:
        return "Error: Liquid pressure recovery factor must be positive."
      if fd_modifier <= 0:
        return "Error: Valve style modifier must be positive."
      if kv <= 0:
        return "Error: Flow coefficient Kv must be positive."

      return float(Reynolds_valve(nu=nu, Q=q_flow, D1=d_pipe, FL=fl_factor, Fd=fd_modifier, C=kv))
    except Exception as e:
      return f"Error: {str(e)}"

Online Calculator

Kinematic viscosity (m²/s)
Volumetric flow rate (m³/s)
Pipe diameter (m)
Liquid pressure recovery factor (-)
Valve style modifier (-)
Flow coefficient Kv (m³/hr)

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)}"

Online Calculator

Temperature of the gas at the inlet [K]
Molecular weight of the gas [g/mol]
Viscosity of the fluid at inlet conditions [Pa*s]
Specific heat capacity ratio [-]
Compressibility factor at inlet conditions [-]
Inlet pressure of the gas before valves and reducers [Pa]
Outlet pressure of the gas after valves and reducers [Pa]
Volumetric flow rate of the gas at STP [m^3/s]

SIZE_CV_LIQUID

This function calculates the required metric control-valve coefficient K_v for liquid service using the IEC 60534 liquid sizing method. It evaluates the required valve capacity from liquid properties, vapor-pressure limits, pressure conditions, viscosity, and target volumetric flow.

The sizing objective can be represented as:

K_v = g\left(\rho, P_{sat}, P_c, \mu, P_1, P_2, Q\right)

where g(\cdot) is the IEC-compliant liquid-flow model that captures pressure-recovery effects and cavitation-related constraints through valve factors.

Excel Usage

=SIZE_CV_LIQUID(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 (0 < fl <= 1)
  • fd (float, optional, default: 1): Valve style modifier (0 < fd <= 1)

Returns (float): Metric Kv valve coefficient (float), or error message string.

Example 1: Basic control valve sizing

Inputs:

rho psat pc mu p_in p_out q fl fd
965.4 70100 221200000 0.00031472 680000 220000 0.1 0.9 0.46

Excel formula:

=SIZE_CV_LIQUID(965.4, 70100, 221200000, 0.00031472, 680000, 220000, 0.1, 0.9, 0.46)

Expected output:

164.995

Example 2: With default FL and FD values

Inputs:

rho psat pc mu p_in p_out q
1000 2337 22064000 0.001 500000 300000 0.05

Excel formula:

=SIZE_CV_LIQUID(1000, 2337, 22064000, 0.001, 500000, 300000, 0.05)

Expected output:

127.336

Example 3: Different FL and FD values

Inputs:

rho psat pc mu p_in p_out q fl fd
965.4 70100 221200000 0.00031472 680000 220000 0.1 0.6 0.98

Excel formula:

=SIZE_CV_LIQUID(965.4, 70100, 221200000, 0.00031472, 680000, 220000, 0.1, 0.6, 0.98)

Expected output:

238.205

Example 4: Low flow rate application

Inputs:

rho psat pc mu p_in p_out q fl fd
800 1000 15000000 0.0005 400000 350000 0.001 0.85 0.9

Excel formula:

=SIZE_CV_LIQUID(800, 1000, 15000000, 0.0005, 400000, 350000, 0.001, 0.85, 0.9)

Expected output:

4.55572

Python Code

Show Code
import math

from fluids.control_valve import size_control_valve_l as fluids_size_control_valve_l

def size_cv_liquid(rho, psat, pc, mu, p_in, p_out, q, fl=0.9, fd=1):
    """
    Calculates the flow coefficient (Kv) of a control valve passing a liquid according to IEC 60534.

    See: https://fluids.readthedocs.io/fluids.control_valve.html#fluids.control_valve.size_control_valve_l

    This example function is provided as-is without any representation of accuracy.

    Args:
        rho (float): Density of the liquid at the inlet [kg/m^3]
        psat (float): Saturation pressure of the fluid at inlet temperature [Pa]
        pc (float): Critical pressure of the fluid [Pa]
        mu (float): Viscosity of the fluid [Pa*s]
        p_in (float): Inlet pressure of the fluid before valves and reducers [Pa]
        p_out (float): Outlet pressure of the fluid after valves and reducers [Pa]
        q (float): Volumetric flow rate of the fluid [m^3/s]
        fl (float, optional): Liquid pressure recovery factor (0 < fl <= 1) Default is 0.9.
        fd (float, optional): Valve style modifier (0 < fd <= 1) Default is 1.

    Returns:
        float: Metric Kv valve coefficient (float), or error message string.
    """
    try:
      def validate_positive(value, name):
        try:
          val = float(value)
          if val <= 0:
            return None, f"Error: {name} must be a positive number."
          return val, None
        except (ValueError, TypeError):
          return None, f"Error: {name} must be a numeric value."

      def validate_non_negative(value, name):
        try:
          val = float(value)
          if val < 0:
            return None, f"Error: {name} must be a non-negative number."
          return val, None
        except (ValueError, TypeError):
          return None, f"Error: {name} must be a numeric value."

      def validate_range(value, name, low, high):
        try:
          val = float(value)
          if val <= low or val > high:
            return None, f"Error: {name} must be between {low} (exclusive) and {high} (inclusive)."
          return val, None
        except (ValueError, TypeError):
          return None, f"Error: {name} must be a numeric value."

      # Validate input parameters
      rho, err = validate_positive(rho, "rho")
      if err:
        return err

      psat, err = validate_non_negative(psat, "psat")
      if err:
        return err

      pc, err = validate_positive(pc, "pc")
      if err:
        return err

      mu, err = validate_positive(mu, "mu")
      if err:
        return err

      p_in, err = validate_non_negative(p_in, "p_in")
      if err:
        return err

      p_out, err = validate_non_negative(p_out, "p_out")
      if err:
        return err

      if p_out > p_in:
        return "Error: p_out must be less than or equal to p_in."

      q, err = validate_non_negative(q, "q")
      if err:
        return err

      fl, err = validate_range(fl, "fl", 0, 1)
      if err:
        return err

      fd, err = validate_range(fd, "fd", 0, 1)
      if err:
        return err

      # 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: All parameters must be finite numbers."

      # Call the actual function from the fluids library
      try:
        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: Result is not a finite number."

        return result
      except Exception as e:
        return f"Error: Failed to compute liquid valve sizing: {str(e)}"
    except Exception as e:
      return f"Error: {str(e)}"

Online Calculator

Density of the liquid at the inlet [kg/m^3]
Saturation pressure of the fluid at inlet temperature [Pa]
Critical pressure of the fluid [Pa]
Viscosity of the fluid [Pa*s]
Inlet pressure of the fluid before valves and reducers [Pa]
Outlet pressure of the fluid after valves and reducers [Pa]
Volumetric flow rate of the fluid [m^3/s]
Liquid pressure recovery factor (0 < fl <= 1)
Valve style modifier (0 < fd <= 1)