CP_SAT_ANC
This function calls CoolProp’s saturation ancillary equations for a chosen fluid, output property, and quality branch. It is useful for quickly generating saturation-curve values without a full state solve.
The ancillary evaluation is:
y = g(\text{name}, \text{output}, Q, \text{input}, x)
where Q selects the liquid or vapor branch and x is the specified input value.
Excel Usage
=CP_SAT_ANC(name, output, Q, input, value)
name(str, required): CoolProp fluid name.output(str, required): Requested ancillary output property code.Q(int, required): Quality branch selector (typically 0 for liquid, 1 for vapor).input(str, required): Input variable code used by the ancillary equation.value(float, required): Input value for the ancillary equation in SI units.
Returns (float): Saturation ancillary property value for the requested fluid and branch.
Example 1: Water vapor pressure ancillary from temperature
Inputs:
| name | output | Q | input | value |
|---|---|---|---|---|
| Water | p | 1 | T | 373.15 |
Excel formula:
=CP_SAT_ANC("Water", "p", 1, "T", 373.15)
Expected output:
101414
Example 2: Water saturation temperature ancillary from pressure
Inputs:
| name | output | Q | input | value |
|---|---|---|---|---|
| Water | T | 0 | P | 101325 |
Excel formula:
=CP_SAT_ANC("Water", "T", 0, "P", 101325)
Expected output:
373.125
Example 3: R134a saturation temperature ancillary from pressure
Inputs:
| name | output | Q | input | value |
|---|---|---|---|---|
| R134a | T | 0 | P | 702801 |
Excel formula:
=CP_SAT_ANC("R134a", "T", 0, "P", 702801)
Expected output:
300
Python Code
Show Code
import CoolProp.CoolProp as CP
def cp_sat_anc(name, output, Q, input, value):
"""
Evaluate a CoolProp saturation ancillary property for a fluid and branch quality.
See: https://coolprop.org/apidoc/CoolProp.CoolProp.html#CoolProp.CoolProp.saturation_ancillary
This example function is provided as-is without any representation of accuracy.
Args:
name (str): CoolProp fluid name.
output (str): Requested ancillary output property code.
Q (int): Quality branch selector (typically 0 for liquid, 1 for vapor).
input (str): Input variable code used by the ancillary equation.
value (float): Input value for the ancillary equation in SI units.
Returns:
float: Saturation ancillary property value for the requested fluid and branch.
"""
try:
def normalize_code(code: str) -> str:
# CoolProp parameter codes are case-sensitive. Map common lower-case aliases to the correct codes.
if not isinstance(code, str):
return code
code_str = code.strip()
lcode = code_str.lower()
if lcode in ("p", "pressure"):
return "P"
if lcode in ("rho", "density", "d", "dmass", "dmolar"):
return "D"
if lcode in ("t", "temperature"):
return "T"
if lcode in ("h", "enthalpy"):
return "Hmass"
if lcode in ("s", "entropy"):
return "Smass"
if lcode in ("u", "internal_energy"):
return "Umass"
if lcode in ("cp", "cpmass"):
return "Cpmass"
if lcode in ("cv", "cvmass"):
return "Cvmass"
return code_str
output_norm = normalize_code(output)
input_norm = normalize_code(input)
# CoolProp's saturation_ancillary does not support calculating density directly from temperature.
# For density outputs (D/Dmass) with temperature input, compute the saturation pressure first,
# then evaluate density at that pressure.
if output_norm == "D" and input_norm == "T":
p_sat = CP.saturation_ancillary(name, "P", Q, "T", value)
return CP.saturation_ancillary(name, output_norm, Q, "P", p_sat)
return CP.saturation_ancillary(name, output_norm, Q, input_norm, value)
except Exception as e:
return f"Error: {str(e)}"Online Calculator
CoolProp fluid name.
Requested ancillary output property code.
Quality branch selector (typically 0 for liquid, 1 for vapor).
Input variable code used by the ancillary equation.
Input value for the ancillary equation in SI units.