Using CoolProp#

All of the examples in this book will use Cantera to handle the thermodynamic properties, but another option is to use CoolProp. CoolProp has a large database of equations of state and properties for 122 fluids.

You may need to install CoolProp, which you can do with pip or conda:

pip install coolprop

or

conda install --channel conda-forge coolprop

Once installed, we can import and then evaluate properties:

In some rare cases, we may need to rely on CoolProp to determine the thermodynamic state when Cantera does not support the combination of properties needed.

import CoolProp.CoolProp as CP
fluid = 'Water'

temp = 300 # K
pres = 101325 # Pa

# Specify the temperature and pressure to fix the state
density = CP.PropsSI('D', 'T', temp, 'P', pres, fluid)
phase = CP.PhaseSI('T', temp, 'P', pres, fluid)

print(f'Density: {density: .2f} kg/m^3')
print(f'Phase: {phase}')
Density:  996.56 kg/m^3
Phase: liquid

CoolProp has a lot of fluids in its database. For example, we can examine the properties of toluene (C\(_6\)H\(_5\)CH\(_3\)), an aromatic hydrocarbon used as a solvent and also as an octane booster in fuels:

Check out CoolProp’s documentation for more examples, and a table of string inputs to the PropsSI function.

from pint import UnitRegistry
ureg = UnitRegistry()
Q_ = ureg.Quantity

fluid = 'toluene'

temp = Q_(200, 'degC')
pres = Q_(1, 'atm')

# Specify the temperature and pressure to fix the state
density = CP.PropsSI(
    'D', 'T', temp.to('K').magnitude, 'P', 
    pres.to('Pa').magnitude, fluid
    )
phase = CP.PhaseSI(
    'T', temp.to('K').magnitude, 
    'P', pres.to('Pa').magnitude, fluid
    )

print(f'Density: {density: .2f} kg/m^3')
print(f'Phase: {phase}')
Density:  2.42 kg/m^3
Phase: gas