REFPROP Interface

The thermophysical property library REFPROP developed by researchers at the National Institute of Standards and Technology in Boulder, Colorado is the gold standard in thermophysical properties. It is mature and stable, and is currently the library most used in industry and for scientific applications.

CoolProp allows for full interaction with the REFPROP library, while using the nicely abstracted C++ interface for all target languages that CoolProp supports.

The core difference between using CoolProp’s internal routines and REFPROP’s routines is that you have to change the backend from HEOS to REFPROP. In the high-level interface this is demonstrated as:

In [1]: from CoolProp.CoolProp import PropsSI

# This one uses CoolProp's internal routines to calculate NBP of water
In [2]: PropsSI("T","P",101325,"Q",0,"HEOS::Water")
Out[2]: 373.1242958476844

# This one uses REFPROP's internal routines to calculate NBP of water
In [3]: PropsSI("T","P",101325,"Q",0,"REFPROP::Water")
Out[3]: 373.1242958476988

The list of input keys that can be used in the PropsSI function are given here: Table of string inputs to PropsSI function.

In the low-level interface (significantly faster once you have constructed the class!), this would be

In [4]: import CoolProp

In [5]: HEOS = CoolProp.AbstractState('HEOS','Water')

In [6]: REFPROP = CoolProp.AbstractState('REFPROP','Water')

# This one uses CoolProp's internal routines
In [7]: HEOS.update(CoolProp.PQ_INPUTS, 101325, 0)

In [8]: HEOS.T()
Out[8]: 373.1242958476844

# This one uses REFPROP's internal routines
In [9]: REFPROP.update(CoolProp.PQ_INPUTS, 101325, 0)

In [10]: REFPROP.T()
Out[10]: 373.1242958476988

Other flash routines (see CoolProp::input_pairs) proceed in exactly the same fashion. Most of the methods available for CoolProp are also available for REFPROP. For instance, you can generate phase envelopes with both CoolProp and REFPROP, or evaluate the dewpoint of mixtures. Here are a few examples of the mapping between CoolProp and REFPROP for some more interesting applications:

In [11]: import CoolProp

In [12]: HEOS = CoolProp.AbstractState('HEOS','R32&R125'); HEOS.set_mole_fractions([0.5,0.5])

In [13]: REFPROP = CoolProp.AbstractState('REFPROP','R32&R125'); REFPROP.set_mole_fractions([0.5,0.5])

# CoolProp calculates the thermodynamically correct temperature
In [14]: HEOS.T_critical()
Out[14]: 342.42902885251635

# The default in REFPROP is to interpolate the phase envelope
In [15]: REFPROP.T_critical()
Out[15]: 342.42766875

# Here we calculate and obtain the phase envelope for the mixture using the routines in CoolProp
In [16]: HEOS.build_phase_envelope(""); PE_HEOS = HEOS.get_phase_envelope_data()

# Here we calculate and obtain the phase envelope for the mixture using the routines in REFPROP
In [17]: REFPROP.build_phase_envelope(""); PE_REFPROP = REFPROP.get_phase_envelope_data()

Path Issues

Warning

In order for REFPROP to be able to be loaded by CoolProp, the default logic for each operating system is used to load the REFPROP shared library. This means that on windows, the PATH environmental variable is searched for the REFPROP.dll (32-bit applications) or REFPRP64.dll (64-bit applications). On linux/OSX, the default shared library loading protocol is used. If your REFPROP is installed in a non-standard location (not on the path), make sure that when you run code that uses REFPROP, that you add (temporarily) the location of the REFPROP shared library to your path.

REFPROP needs to be able to find the fluid and mixture files at runtime, at a location specified on your computer. CoolProp allows you to avoid the pains of decoding REFPROP’s internal logic for finding these files by explicitly specifying the path that it should tell REFPROP to look for the fluid files.

Warning

These configuration variables should be set at the beginning of your script and then not touched again. Otherwise, you can get some weird behavior!

The configuration key for setting the REFPROP path (see Configuration Variables) is ALTERNATIVE_REFPROP_PATH, and you can set it doing something like this in python:

In [18]: import json, CoolProp.CoolProp as CP

In [19]: CP.set_config_string(CP.ALTERNATIVE_REFPROP_PATH, 'c:\\Program Files\\REFPROP\\')

If you do this, internally CoolProp will call the SETPATH function in REFPROP to tell REFPROP that it should find the fluids and mixtures directories within this directory. If you don’t do this, CoolProp will use whatever default logic REFPROP uses to find the fluid files.

If you are playing around with mixture parameters, you might want to set a different path to the HMX.BNC file which contains the interaction parameters for the mixture. You can do that by changing the configuration variable (see Configuration Variables) ALTERNATIVE_REFPROP_HMX_BNC_PATH

In [20]: import json, CoolProp.CoolProp as CP

In [21]: CP.set_config_string(CP.ALTERNATIVE_REFPROP_HMX_BNC_PATH, 'c:\\Program Files\\REFPROP\\fluids\\HMX.BNC')

If you have set both the ALTERNATIVE_REFPROP_PATH and ALTERNATIVE_REFPROP_HMX_BNC_PATH variables, ALTERNATIVE_REFPROP_PATH_HMX_BNC_PATH “wins”, and this path will be used when loading mixture interaction parameters

And now we set them back to their default values

In [22]: import json, CoolProp.CoolProp as CP

In [23]: CP.set_config_string(CP.ALTERNATIVE_REFPROP_HMX_BNC_PATH, '')

In [24]: CP.set_config_string(CP.ALTERNATIVE_REFPROP_PATH, '')

Other Features

If you want to determine the version of REFPROP that you are actually using, you can do:

In [25]: import CoolProp.CoolProp as CP

In [26]: CP.get_global_param_string("REFPROP_version")
Out[26]: u'9.1.1.10'

If you want to use the GERG-2008 model, you can do this at the beginning of your code:

In [27]: import CoolProp.CoolProp as CP

In [28]: CP.set_config_bool(CP.REFPROP_USE_GERG, True)

Subsquently, all calculations will be done with the simplified EOS from the GERG-2008 model

And now we set them back to their default values

In [29]: import json, CoolProp.CoolProp as CP

In [30]: CP.set_config_bool(CP.REFPROP_USE_GERG, False)