Skip to Content

FF_CRITICAL_PRESSURE_RATIO_L

Overview

The FF_CRITICAL_PRESSURE_RATIO_L function calculates FF, the liquid critical pressure ratio factor, for use in IEC 60534 liquid valve sizing calculations. This factor is a key parameter used in control valve sizing to account for the behavior of liquids under different pressure conditions.

The liquid critical pressure ratio factor is calculated using the formula:

FF=0.960.28sqrtfracPsatPcFF = 0.96 - 0.28 \\sqrt{\\frac{P_{sat}}{P_c}}

where:

  • PsatP_{sat} is the saturation pressure of the liquid at inlet temperature
  • PcP_c is the critical pressure of the liquid

For more details, see the fluids library FF_critical_pressure_ratio_l documentation .

This function handles potential Excel inputs that might be passed as 2D lists with a single element, converting them to scalars before processing. The function also performs input validation to ensure all values are positive and finite. This example function is provided as-is without any representation of accuracy.

Usage

To use the function in Excel:

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

The function returns a float representing the liquid critical pressure ratio factor (dimensionless), or an error message if the input is invalid.

Examples

Example 1: Basic Calculation

Inputs:

psatpc
70100.022120000.0

Excel formula:

=FF_CRITICAL_PRESSURE_RATIO_L(70100.0, 22120000.0)

Expected output: 0.944

Example 2: Higher Pressure Ratio

Inputs:

psatpc
1000000.020000000.0

Excel formula:

=FF_CRITICAL_PRESSURE_RATIO_L(1000000.0, 20000000.0)

Expected output: 0.888

Example 3: Lower Pressure Ratio

Inputs:

psatpc
10000.025000000.0

Excel formula:

=FF_CRITICAL_PRESSURE_RATIO_L(10000.0, 25000000.0)

Expected output: 0.957

Example 4: Saturation Pressure Equal to Example

Inputs:

psatpc
70100.022120000.0

Excel formula:

=FF_CRITICAL_PRESSURE_RATIO_L(70100.0, 22120000.0)

Expected output: 0.944

Python Code

from typing import Union import math try: from fluids.control_valve import FF_critical_pressure_ratio_l as fluids_ff_critical_pressure_ratio_l except ImportError: fluids_ff_critical_pressure_ratio_l = None def ff_critical_pressure_ratio_l(psat: float, pc: float) -> Union[float, str]: """ 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. Args: psat: Saturation pressure of the liquid at inlet temperature [Pa] pc: Critical pressure of the liquid [Pa] Returns: float: FF - Liquid critical pressure ratio factor [-], or an error message (str) if input is invalid. This example function is provided as-is without any representation of accuracy. """ def _normalize_scalar(value, name): """Normalize a value that might be passed as a 2D list with single element to a scalar.""" if isinstance(value, list): # Check if it's a 2D list with a single element like [[5]] if len(value) == 1 and isinstance(value[0], list) and len(value[0]) == 1: value = value[0][0] else: return f"Invalid input: {name} must be a scalar or 2D list with a single element." return value # Normalize inputs that might be passed as 2D lists (Excel behavior) psat = _normalize_scalar(psat, "psat") if isinstance(psat, str): return psat # Return error message if normalization failed pc = _normalize_scalar(pc, "pc") if isinstance(pc, str): return pc # Return error message if normalization failed # Validate that inputs are now numeric try: psat = float(psat) pc = float(pc) except (ValueError, TypeError): return "Invalid input: psat and pc must be numeric values." # Validate that inputs are positive if psat <= 0: return "Invalid input: psat must be positive." if pc <= 0: return "Invalid input: pc must be positive." # Validate that inputs are finite if not math.isfinite(psat) or not math.isfinite(pc): return "Invalid input: psat and pc must be finite numbers." # Check for division by zero if pc == 0: return "Invalid input: pc cannot be zero (would cause division by zero)." # Use the fluids library function if available, otherwise use the formula from the spec if fluids_ff_critical_pressure_ratio_l is not None: try: result = fluids_ff_critical_pressure_ratio_l(psat, pc) if not math.isfinite(result): return "Error: Calculation resulted in a non-finite value." return result except Exception as e: return f"Error: Fluids library calculation failed: {str(e)}" else: # Use the formula provided in the specification # FF = 0.96 - 0.28 * sqrt(Psat / Pc) try: ratio = psat / pc if ratio < 0: return "Error: Ratio of psat to pc is negative." result = 0.96 - 0.28 * math.sqrt(ratio) if not math.isfinite(result): return "Error: Calculation resulted in a non-finite value." return result except Exception as e: return f"Error: Calculation failed: {str(e)}"
Last updated on