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
REFPROP. In the high-level interface this is demonstrated as:
In : from CoolProp.CoolProp import PropsSI # This one uses CoolProp's internal routines to calculate NBP of water In : PropsSI("T","P",101325,"Q",0,"HEOS::Water") Out: 373.1242958476844 # This one uses REFPROP's internal routines to calculate NBP of water In : PropsSI("T","P",101325,"Q",0,"REFPROP::Water") Out: 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 : import CoolProp In : HEOS = CoolProp.AbstractState('HEOS','Water') In : REFPROP = CoolProp.AbstractState('REFPROP','Water') # This one uses CoolProp's internal routines In : HEOS.update(CoolProp.PQ_INPUTS, 101325, 0) In : HEOS.T() Out: 373.1242958476844 # This one uses REFPROP's internal routines In : REFPROP.update(CoolProp.PQ_INPUTS, 101325, 0) In : REFPROP.T() Out: 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 : import CoolProp In : HEOS = CoolProp.AbstractState('HEOS','R32&R125'); HEOS.set_mole_fractions([0.5,0.5]) In : REFPROP = CoolProp.AbstractState('REFPROP','R32&R125'); REFPROP.set_mole_fractions([0.5,0.5]) # CoolProp calculates the thermodynamically correct temperature In : HEOS.T_critical() Out: 342.42902885251635 # The default in REFPROP is to interpolate the phase envelope In : REFPROP.T_critical() Out: 342.42766875 # Here we calculate and obtain the phase envelope for the mixture using the routines in CoolProp In : 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 : REFPROP.build_phase_envelope(""); PE_REFPROP = REFPROP.get_phase_envelope_data()
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.
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 : import json, CoolProp.CoolProp as CP In : 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
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)
In : import json, CoolProp.CoolProp as CP In : 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_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 : import json, CoolProp.CoolProp as CP In : CP.set_config_string(CP.ALTERNATIVE_REFPROP_HMX_BNC_PATH, '') In : CP.set_config_string(CP.ALTERNATIVE_REFPROP_PATH, '')
If you want to determine the version of REFPROP that you are actually using, you can do:
In : import CoolProp.CoolProp as CP In : CP.get_global_param_string("REFPROP_version") Out: u'126.96.36.199'
If you want to use the GERG-2008 model, you can do this at the beginning of your code:
In : import CoolProp.CoolProp as CP In : 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 : import json, CoolProp.CoolProp as CP In : CP.set_config_bool(CP.REFPROP_USE_GERG, False)