NIST RefProp Legacy API Functions |
The NIST RefProp Add-in Custom Functions make calls to th NIST RefProp fluid properties DLL. All RefProp functions are prefixed with rp_ followed by the function name. Please note that a fluid string must be passed as the first parameter to any fluid property functions. A description of the functions follows below.
"fluid_string" - All property functions are called with a fluid string as the first parameter.
The fluids file must be loaded from the NIST RefProp installation directory. Typically,
C:\Program Files (x86)\RefPropor from another path identified by the user's environment variable, NIST_PATH.
NOTE: Each fluid property function makes a call internally to the RefProp SETUP routine which loads the fluid file from the database location. However, if the requested fluid is already loaded, no action is taken; dramatically cutting down on overhead.
Details:
"fluid_string" specifies the fluid (or pseudo fluid or mixture) file to be loaded from the "fluids\" (or "mixtures\") directory. REFPROP 9.1 calls must include this relative prefix in the "fluid_string"; REFPROP 10 or later can not include this relative path as it is determined automatically. It can (optionally) end with an extension of ".fld". If the suffix is omitted, RefProp will assume an extension of ".fld" and look for the fluid in the "fluids\" directory. If the fluid is a pseudo-pure fluid, the extension ".ppf" must be supplied. Predefined mixtures MUST include the "mixtures\" prefix (REFPROP 9.1 only) and the ".mix" extension.
e.g. to load the properties for HELIUM, define a variable such as:
fluid := "HELIUM.fld".
- or -
fluid := "HELIUM".
As of NIST RefProp 9.1, the valid pure fluid files shown below in Table 1, pseudo-pure fluid files are shown in Table 2, and predefined mixture files in Table 3. Current REFPROP documentation should be referenced for the complete list.
Table 1 : RefProp Pure Fluid Files
![]()
Table 2 : RefProp Pseudo-Pure Fluid Files
![]()
Table 3 : RefProp Predefined Mixture Files
![]()
RefProp provides facility for embedding multiple mixture components right in the fluid string passed to the interface functions. The Mathcad Add-In interface, takes this a step further and allows not only the component names, but also the mole fractions of each component to be embedded in the fluid string. The format for mixture fluids is as follows. Within the fluid string,
For example, a binary representation for Air could be input with the following fluid string:
- Separate each component with an "&" character,
- Follow each component with its mole fraction, surrounded by "[" and "]",
- Limit number of components to 20, although more components makes the flash calculations harder and they may fail in the RefProp solver,
- Zero mole fraction components will be parsed out,
- Total of mole fractions must sum exactly to one (1.0).
"Oxygen[0.21]&Nitrogen[0.79]"
A more accurate representation for Air could be input with the following quaternary mixture string:
"Oxygen[0.20948]&Nitrogen[0.78084]&Argon[0.00934]&CO2[0.00034]"
rp_extrap(flag) sets a flag that allows extrapolation to 1.5 x Tmax and returns a verification string.
Argument:
flag condition to be set; 0 for no extrapolation past Tmax; 1 to extrapolate all functions to 1.5 x Tmax. Any other value simply returns the current extrapolation state.
rp_getname(flstr,icomp) returns the full name of the fluid or mixture previously loaded by rp_function calls.
Argument:
flstr is a string containing the pure fluid or pseudo-pure fluid file name as defined above.
icomp is the mixture component number; 1 for a pure fluid. For mixtures, supply the individual component number or 0 for the mixture name stored in the .mix file.
rp_getname(flstr,icomp) returns the CAS number of the fluid previously loaded by rp_function calls.
Argument:
flstr is a string containing the pure fluid or pseudo-pure fluid file name as defined above.
icomp is the mixture component number; 1 for a pure fluid.
rp_getvers(idum) returns the version of the RefProp Mathcad Add-in.
Argument:
idum is an arbitrary number (i.e. 0).
rp_getNIST(idum) returns the full version of the NIST REFPROP library as a string.
Argument:
idum is an arbitrary number (i.e. 0).
rp_getRPnum(idum) returns the version of the loaded NIST REFPROP library as a numeric value for easy comparison calculations.
Argument:
idum is an arbitrary number (i.e. 0).
rp_getpath(idum) returns the path to the NIST REFPROP DLL in use. This will be either the path to REFPROP.DLL (32-bit, used by Mathcad 15) or REFPRP64.DLL (64-bit, used by Mathcad Prime).
Argument:
idum is an arbitrary number (i.e. 0).
rp_getx(fluid) returns the composition of a loaded mixture in a vector of mole fractions, one for each component in the mixture.
Argument:
fluid is string with the mixture file (.mix extension required) or the ad-hoc mixture in use. To leave the mixture component fluids unchanged, this parameter can contain and empty string (\"\") or a space (\"\"). If a mixture file is provided and it is unchanged from the previously loaded mixture, then the files is not loaded again. If a new mixture file is specified, then the new mixture will be loaded and the mole fraction array from the new mixture will be returned.
rp_setx(mfrac) sets a new composition for the currently loaded mixture without changing the loaded mixture component fluids. Returns a text message indicating that the new composition has been set. SATSPLN will be called automatically for the new mixture composition.
If a changing the component fluids, do not call this function. Simply call another low-level function with the new mixture file or ad-hoc mixture string.Argument:
mfrac is an array of the mole fractions to be set as the new composition. The number of elements in the array must match the number of components in the already loaded mixture.
rp_wmol(flstr,icomp) returns the current fluid molecular weight [gm/mol] or [kg/kmol].
Argument:
flstr is a string containing the pure fluid, pseudo-pure fluid, or mixture file name as defined above.
icomp is the mixture component number; 1 for a pure fluid; 0 for the mixture property. For pure fluids, 0 defaults to 1.
rp_ttrip(flstr,icomp) returns the current fluid triple point temperature [K].
Argument:
flstr is a string containing the pure fluid, pseudo-pure fluid, or mixture file name as defined above.
icomp is the mixture component number; 1 for a pure fluid; 0 for the mixture property. For pure fluids, 0 defaults to 1.
rp_ptrip(flstr,icomp) returns the current fluid triple point pressure [MPa].
Argument:
flstr is a string containing the pure fluid, pseudo-pure fluid, or mixture file name as defined above.
icomp is the mixture component number; 1 for a pure fluid; 0 for the mixture property. For pure fluids, 0 defaults to 1.
rp_rhotrip(flstr,icomp) returns the current fluid triple point density [kg/m³].
Argument:
flstr is a string containing the pure fluid, pseudo-pure fluid, or mixture file name as defined above.
icomp is the mixture component number; 1 for a pure fluid; 0 for the mixture property. For pure fluids, 0 defaults to 1.
rp_tcrit(flstr,icomp) returns the current fluid critical point temperature [K].
Argument:
flstr is a string containing the pure fluid, pseudo-pure fluid, or mixture file name as defined above.
icomp is the mixture component number; 1 for a pure fluid; 0 for the mixture property. For pure fluids, 0 defaults to 1.
rp_pcrit(flstr,icomp) returns the current fluid critical point pressure [MPa].
Argument:
flstr is a string containing the pure fluid, pseudo-pure fluid, or mixture file name as defined above.
icomp is the mixture component number; 1 for a pure fluid; 0 for the mixture property. For pure fluids, 0 defaults to 1.
rp_rhocrit(flstr,icomp) returns the current fluid critical point density [kg/m³].
Argument:
flstr is a string containing the pure fluid, pseudo-pure fluid, or mixture file name as defined above.
icomp is the mixture component number; 1 for a pure fluid; 0 for the mixture property. For pure fluids, 0 defaults to 1.
rp_zcrit(flstr,icomp) returns the current fluid critical point compressibility [dimensionless].
Argument:
flstr is a string containing the pure fluid, pseudo-pure fluid, or mixture file name as defined above.
icomp is the mixture component number; 1 for a pure fluid; 0 for the mixture property. For pure fluids, 0 defaults to 1.
rp_rgas(flstr,icomp) Returns the ideal gas constant used by the loaded fluid [J/(mol*K)] or [kJ/(kmol*K)].
This function is provided because there may be slight differences in the ideal gas constant in the definition of each fluid. The "mixture" constant is calculated as the mole weighted average of each component model's value.Argument:
flstr is a string containing the pure fluid or pseudo-pure fluid file name as defined above.
icomp is the mixture component number; 1 for a pure fluid; 0 for the mixture property. For pure fluids, 0 defaults to 1.
rp_maxX(flstr,X) Returns an array containing the temperature [K], pressure [MPa], and density [kg/m³] at the point of maximum saturation pressure (Cricondenbar) or maximum saturation temperature (Cricondentherm), depending on the character passed in X.
Argument:
flstr is a string containing the mixture file name or ad-hoc mixture string as defined above. If a pure fluid (or pseudo-pure fluid) is passed, this function just returns the values at the critical point.
X is a single character string passed in double quotes. If X = "P", the values at maximum saturation pressure (Cricondenbar) are returned. If X = "T", the values at maximum saturation temperature (Cricondentherm) are returned.
rp_tsatp(flstr,p) returns the saturation temperature [K] of the pure fluid, as a function of the saturation pressure, p.
Argument:
flstr is a string containing the pure fluid or pseudo-pure fluid file name as defined above. If a mixture name is passed, will returned the saturated liquid value.
p is the input saturation pressure [MPa]. Must be between the triple point and critical point values or the function returns an error.
rp_tsatpf(flstr,p) returns the liquid saturation temperature [K] of the mixture, as a function of the saturation pressure, p.
Argument:
flstr is a string containing the mixture file (.mix) or ad-hoc mixture string as defined above. If a pure fluid is passed, there is no difference between the saturation values returned by rp_tsatp(flstr,p) or rp_tsatpg(flstr,p).
p is the input saturation pressure [MPa]. Must be between the triple point and critical point values or the function returns an error.
rp_tsatpg(flstr,p) returns the vapor saturation temperature [K] of the fluid or mixture, as a function of the saturation pressure, p.
Argument:
flstr is a string containing the mixture file (.mix) or ad-hoc mixture string as defined above. If a pure fluid is passed, there is no difference between the saturation values returned by rp_tsatp or rp_tsatpf.
p is the input saturation pressure [MPa]. Must be between the triple point and critical point values or the function returns an error.
rp_psatt(flstr,t) returns the saturation pressure [MPa] of the fluid or mixture, as a function of the saturation temperature, t.
Argument:
flstr is a string containing the pure fluid or pseudo-pure fluid file name as defined above. If a mixture name is passed, will returned the saturated liquid value.
t is the input saturation temperature [K]. Must be between the triple point and critical point values or the function returns an error.
rp_psattf(flstr,p) returns the liquid saturation temperature [K] of the mixture, as a function of the saturation pressure, p.
Argument:
flstr is a string containing the mixture file (.mix) or ad-hoc mixture string as defined above. If a pure fluid is passed, there is no difference between the saturation values returned by rp_psatt(flstr,p) or rp_psattg(flstr,p).
p is the input saturation pressure [MPa]. Must be between the triple point and critical point values or the function returns an error.
rp_psattg(flstr,p) returns the vapor saturation temperature [K] of the fluid or mixture, as a function of the saturation pressure, p.
Argument:
flstr is a string containing the mixture file (.mix) or ad-hoc mixture string as defined above. If a pure fluid is passed, there is no difference between the saturation values returned by rp_psatt or rp_psattf.
p is the input saturation pressure [MPa]. Must be between the triple point and critical point values or the function returns an error.
The fluid property functions all follow a standard naming convention.
All functions begin with rp_ followed by the property symbol (rho, h, u, s, Cp, Cv, w, k, mu).
The property symbol is followed by
f, for the saturated liquid value
g, for the saturated vapor value
(none), for the sub-cooled liquid or superheated vapor value
The phase character is then followed by the required parameter symbol(s) (ie. t, p, tp, ph, ps).
The table below lists a summary of all the thermodynamic and transport property
functions with the units of the returned quantity and the required input
variables.
Please note that each function requires a fluid string (see above) as
the first parameter, in addition to the parameters listed in the table.
| Phase | Saturated Liquid | Saturated Vapor | Sub-cooled Liquid or Superheated Vapor |
||
| Input Parameter(s): | T [K] | P [MPa] | T [K] | P [MPa] | T [K], P [MPa] |
| Density, rho [kg/m³] |
rp_rhoft | rp_rhofp | rp_rhogt | rp_rhogp | tp_rhotp |
| Enthalpy, h [kJ/kg] |
rp_hft | rp_hfp | rp_hgt | rp_hgp | tp_htp |
| Internal Energy, u [kJ/kg] |
rp_uft | rp_ufp | rp_ugt | rp_ugp | tp_utp |
| Entropy, s [kJ/(kg-K)] |
rp_sft | rp_sfp | rp_sgt | rp_sgp | tp_stp |
| Specific Heat, Cp (isobaric) [kJ/(kg-K)] |
rp_cpft | rp_cpfp | rp_cpgt | rp_cpgp | tp_cptp |
| Specific Heat, Cv (isochoric) [kJ/(kg-K)] |
rp_cvft | rp_cvfp | rp_cvgt | rp_cvgp | tp_cvtp |
| Sonic Velocity, w [m/s] |
rp_wft | rp_wfp | rp_wgt | rp_wgp | tp_wtp |
| Thermal Conductivity, k [W/m-K] |
rp_kft | rp_kfp | rp_kgt | rp_kgp | tp_ktp |
| Viscosity, µ [µPa-s] |
rp_muft | rp_mufp | rp_mugt | rp_mugp | tp_mutp |
| Prandtl Number, Pr [-] |
rp_prft | rp_prfp | rp_prgt | rp_prgp | tp_prtp |
| Compressibility, Z [-] |
rp_zft | rp_zfp | rp_zgt | rp_zgp | tp_ztp |
| Thermal Expansion Coef., Beta [1/K] |
rp_betaft | rp_betafp | rp_betagt | rp_betagp | tp_betatp |
| Cp/Cv Ratio, Gamma [-] |
rp_gammaft | rp_gammafp | rp_gammagt | rp_gammagp | tp_gammatp |
| surface tension, s [kg/s²] |
rp_surften | n/a* | rp_surften | n/a* | n/a* |
*Surface Tension is only a function of temperature, and only valid at the liquid/vapor interface along the saturation curve (ie. Ttrip < T < Tcrit)
Standard engineering calculations sometimes require the reverse calculation of temperature or pressure in terms of other thermodynamic properties. Only the two most common functions are implemented here. These functions perform an iterative search for the temperature and may be slower than the other thermodynamic functions.
rp_tph(flstr,p,h) returns the temperature [K] of the fluid or mixture, as a function of the pressure and enthalpy. The state point specified may be in any single phase vapor or liquid region, or in the two phase vapor/liquid region.
Arguments:
flstr is a string containing the pure fluid or pseudo-pure fluid file name as defined above.
p is the input pressure [MPa].
h is the input enthalpy [kJ/kg].
rp_tps(flstr,p,s) returns the temperature [K] of the fluid or mixture, as a function of the pressure and entropy. The state point specified may be in any single phase vapor or liquid region, or in the two phase vapor/liquid region.
Arguments:
flstr is a string containing the pure fluid or pseudo-pure fluid file name as defined above.
p is the input pressure [MPa].
s is the input entropy [kJ/(kg-K)].
rp_ths(flstr,p,s) Returns the fluid temperature [K] in any phase, as a function of the enthalpy and entropy. The state point specified may be in any single phase vapor or liquid region, or in the two phase vapor/liquid region.
Arguments:
flstr is a string containing the pure fluid or pseudo-pure fluid file name as defined above.
h is the input enthalpy [kJ/kg].
s is the input entropy [kJ/(kg-K)].
rp_phs(flstr,h,s) Returns the fluid pressure [MPa] in any phase, as a function of the enthalpy and entropy. The state point specified may be in any single phase vapor or liquid region, or in the two phase vapor/liquid region.
Arguments:
flstr is a string containing the pure fluid or pseudo-pure fluid file name as defined above.
h is the input enthalpy [kJ/kg].
s is the input entropy [kJ/(kg-K)].
rp_pth(flstr,t,h,r) Returns the fluid pressure [MPa] in any phase, as a function of the temperatures and enthalpy. The state point specified may be in any single phase vapor or liquid region, or in the two phase vapor/liquid region.
Arguments:
flstr is a string containing the pure fluid or pseudo-pure fluid file name as defined above.
t is the input temperature [K].
h is the input enthalpy [kJ/kg].
r is the requested root. Lower density root is returned if r=1, while the higher density root is returned if r=2.
rp_pts(flstr,t,s,r) Returns the fluid pressure [MPa] in any phase, as a function of the temperatures and entropy. The state point specified may be in any single phase vapor or liquid region, or in the two phase vapor/liquid region.
Arguments:
flstr is a string containing the pure fluid or pseudo-pure fluid file name as defined above.
t is the input temperature [K].
s is the input entropy [kJ/(kg-K)].
r is the requested root. Lower density root is returned if r=1, while the higher density root is returned if r=2.
rp_rhoth(flstr,t,h,r) Returns the fluid density [kg/m³] in any phase, as a function of the temperature and enthalpy. The state point specified may be in any single phase vapor or liquid region, or in the two phase vapor/liquid region.
Arguments:
flstr is a string containing the pure fluid or pseudo-pure fluid file name as defined above.
t is the input temperature [K].
h is the input enthalpy [kJ/kg].
r is the requested root. Lower density root is returned if r=1, while the higher density root is returned if r=2.
rp_rhots(flstr,t,s,r) Returns the fluid density [kg/m³] in any phase, as a function of the temperature and entropy. The state point specified may be in any single phase vapor or liquid region, or in the two phase vapor/liquid region.
Arguments:
flstr is a string containing the pure fluid or pseudo-pure fluid file name as defined above.
t is the input temperature [K].
s is the input entropy [kJ/(kg-K)].
r is the requested root. Lower density root is returned if r=1, while the higher density root is returned if r=2.
rp_rhoph(flstr,p,h) Returns the fluid density [kg/m³] in any phase, as a function of the pressure and enthalpy. The state point specified may be in any single phase vapor or liquid region, or in the two phase vapor/liquid region.
Arguments:
flstr is a string containing the pure fluid or pseudo-pure fluid file name as defined above.
p is the input pressure [MPa].
h is the input enthalpy [kJ/kg].
rp_rhops(flstr,p,s) Returns the fluid density [kg/m³] in any phase, as a function of the pressure and entropy. The state point specified may be in any single phase vapor or liquid region, or in the two phase vapor/liquid region.
Arguments:
flstr is a string containing the pure fluid or pseudo-pure fluid file name as defined above.
p is the input pressure [MPa].
s is the input entropy [kJ/(kg-K)].
rp_sph(flstr,p,h) Returns the fluid entropy [kJ/(kg-K)] in any phase, as a function of the pressure and enthalpy. The state point specified may be in any single phase vapor or liquid region, or in the two phase vapor/liquid region.
Arguments:
flstr is a string containing the pure fluid or pseudo-pure fluid file name as defined above.
p is the input pressure [MPa].
h is the input enthalpy [kJ/kg].
rp_hps(flstr,p,s) Returns the fluid enthalpy [kJ/(kg-K)] in any phase, as a function of the pressure and entropy. The state point specified may be in any single phase vapor or liquid region, or in the two phase vapor/liquid region.
Arguments:
flstr is a string containing the pure fluid or pseudo-pure fluid file name as defined above.
p is the input pressure [MPa].
s is the input entropy [kJ/(kg-K)].
rp_sth(flstr,t,h,r) Returns the fluid entropy [kJ/(kg-K)] in any phase, as a function of the temperature and enthalpy. The state point specified may be in any single phase vapor or liquid region, or in the two phase vapor/liquid region. This function is not single valued so the desired root must be specified as well using the parameter r.
Arguments:
flstr is a string containing the pure fluid or pseudo-pure fluid file name as defined above.
t is the input temperature [K].
h is the input enthalpy [kJ/kg].
r is the requested root. Lower density root is returned if r=1, while the higher density root is returned if r=2.
rp_hts(flstr,t,s) Returns the fluid enthalpy [kJ/(kg-K)] in any phase, as a function of the temperature and entropy. The state point specified may be in any single phase vapor or liquid region, or in the two phase vapor/liquid region.
Arguments:
flstr is a string containing the pure fluid or pseudo-pure fluid file name as defined above.
p is the input temperature [K].
s is the input entropy [kJ/(kg-K)].