CoolProp
CoolProp is an open-source thermophysical property database that provides functions to calculate thermodynamic and transport properties of various fluids, including refrigerants, pure fluids, pseudo-pure fluids, and humid air. It offers functionality similar to commercial software like REFPROP but is free and open-source. The library currently ships as version 7.2.0 and sees regular releases with performance improvements, bug fixes, and support for newer Python versions.
Warnings
- breaking CoolProp v7.0.0 introduced significant changes, including new superancillary functions for pure fluids and a revised Equation of State (EOS) for methanol to align with REFPROP. These changes can lead to different numerical results for properties calculated using previous versions.
- deprecated The n-dimensional input functionality for Python was removed in CoolProp v6.4.1 due to an excessive number of bugs. Attempting to use this feature will likely result in errors.
- gotcha Integrating with the commercial REFPROP library requires setting specific configuration variables (`ALTERNATIVE_REFPROP_PATH` or `ALTERNATIVE_REFPROP_LIBRARY_PATH`) to point to your REFPROP installation. Failure to correctly set these paths will prevent CoolProp from using REFPROP's backend and can lead to `ValueError` exceptions.
- gotcha Historically, some users encountered installation issues (e.g., `ERROR: Command errored out with exit status 1`) with `pip install CoolProp` on certain Python versions (e.g., 3.8, 3.9) due to build system complexities.
- gotcha CoolProp can issue non-fatal warning messages via Python's `warnings` module for improper function usage or deprecated features. These can be verbose.
Install
-
pip install CoolProp
Imports
- CP
import CoolProp.CoolProp as CP
- PropsSI
from CoolProp.CoolProp import PropsSI
- HAPropsSI
from CoolProp.HumidAirProp import HAPropsSI
Quickstart
import CoolProp.CoolProp as CP
# Get density of carbon dioxide at 100 bar and 25 degrees C
density = CP.PropsSI('D', 'T', 298.15, 'P', 100e5, 'CO2')
print(f"Density of CO2: {density:.2f} kg/m^3")
# Get saturated vapor enthalpy of R134a at 25 degrees C
enthalpy = CP.PropsSI('H', 'T', 298.15, 'Q', 1, 'R134a')
print(f"Saturated vapor enthalpy of R134a: {enthalpy:.2f} J/kg")