IAPWS95_SATURATION
This function solves the IAPWS-95 vapor-liquid saturation equations at a specified temperature and returns saturation pressure and both phase densities.
The solved saturation state is:
(P_{sat}, \rho_l, \rho_g) = f(T, x_{tol}, \rho_{l,guess}, \rho_{g,guess})
where T is saturation temperature and optional solver settings control numerical convergence.
Excel Usage
=IAPWS95_SATURATION(T, xtol, rhol_guess, rhog_guess)
T(float, required): Water saturation temperature (K).xtol(float, optional, default: 0.00001): Solver tolerance for saturation equations (-).rhol_guess(float, optional, default: null): Optional initial guess for saturated liquid density (kg/m^3).rhog_guess(float, optional, default: null): Optional initial guess for saturated vapor density (kg/m^3).
Returns (dict): Excel data type containing saturation pressure as primary value and saturated liquid and vapor densities as properties.
Example 1: Saturation state at moderate temperature with default settings
Inputs:
| T | xtol | rhol_guess | rhog_guess |
|---|---|---|---|
| 400 | 0.00001 |
Excel formula:
=IAPWS95_SATURATION(400, 0.00001, , )
Expected output:
{"type":"Double","basicValue":245769,"properties":{"Psat":{"type":"Double","basicValue":245769},"Rhol":{"type":"Double","basicValue":937.486},"Rhog":{"type":"Double","basicValue":1.36941}}}
Example 2: Saturation state at elevated temperature with tighter tolerance
Inputs:
| T | xtol | rhol_guess | rhog_guess |
|---|---|---|---|
| 500 | 0.000001 |
Excel formula:
=IAPWS95_SATURATION(500, 0.000001, , )
Expected output:
{"type":"Double","basicValue":2639200,"properties":{"Psat":{"type":"Double","basicValue":2639200},"Rhol":{"type":"Double","basicValue":831.313},"Rhog":{"type":"Double","basicValue":13.1989}}}
Example 3: Near critical saturation with custom density guesses
Inputs:
| T | xtol | rhol_guess | rhog_guess |
|---|---|---|---|
| 640 | 0.00001 | 500 | 150 |
Excel formula:
=IAPWS95_SATURATION(640, 0.00001, 500, 150)
Expected output:
{"type":"Double","basicValue":20265200,"properties":{"Psat":{"type":"Double","basicValue":20265200},"Rhol":{"type":"Double","basicValue":481.526},"Rhog":{"type":"Double","basicValue":177.145}}}
Example 4: Low temperature saturation with custom density guesses
Inputs:
| T | xtol | rhol_guess | rhog_guess |
|---|---|---|---|
| 300 | 0.00001 | 996 | 0.03 |
Excel formula:
=IAPWS95_SATURATION(300, 0.00001, 996, 0.03)
Expected output:
{"type":"Double","basicValue":3536.81,"properties":{"Psat":{"type":"Double","basicValue":3536.81},"Rhol":{"type":"Double","basicValue":996.513},"Rhog":{"type":"Double","basicValue":0.0255897}}}
Python Code
Show Code
from chemicals.iapws import iapws95_saturation as chemicals_iapws95_saturation
def iapws95_saturation(T, xtol=1e-05, rhol_guess=None, rhog_guess=None):
"""
Solve IAPWS-95 saturation state from temperature.
See: https://chemicals.readthedocs.io/chemicals.iapws.html#chemicals.iapws.iapws95_saturation
This example function is provided as-is without any representation of accuracy.
Args:
T (float): Water saturation temperature (K).
xtol (float, optional): Solver tolerance for saturation equations (-). Default is 1e-05.
rhol_guess (float, optional): Optional initial guess for saturated liquid density (kg/m^3). Default is None.
rhog_guess (float, optional): Optional initial guess for saturated vapor density (kg/m^3). Default is None.
Returns:
dict: Excel data type containing saturation pressure as primary value and saturated liquid and vapor densities as properties.
"""
try:
Psat, rhol, rhog = chemicals_iapws95_saturation(T, xtol=xtol, rhol_guess=rhol_guess, rhog_guess=rhog_guess)
return {
"type": "Double",
"basicValue": Psat,
"properties": {
"Psat": {"type": "Double", "basicValue": Psat},
"Rhol": {"type": "Double", "basicValue": rhol},
"Rhog": {"type": "Double", "basicValue": rhog}
}
}
except Exception as e:
return f"Error: {str(e)}"