CoolProp  4.2.5
An open-source fluid property and humid air property database
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions | Variables
CoolProp.cpp File Reference
#include "CoolProp.h"
#include "REFPROP.h"
#include <iostream>
#include <stdlib.h>
#include <vector>
#include <exception>
#include <stdio.h>
#include "string.h"
#include "FluidClass.h"
#include "CoolPropTools.h"
#include "CPExceptions.h"
#include "Brine.h"
#include "Solvers.h"
#include "CPState.h"
#include "IncompLiquid.h"
#include "TTSE.h"
#include "purefluids/R290.h"
#include "purefluids/R134a.h"
#include "AllFluids.h"
#include "gitrevision.h"
#include "version.h"
#include "Catch/catch.hpp"

Go to the source code of this file.

Functions

double _CoolProp_Fluid_PropsSI (long iOutput, long iName1, double Value1, long iName2, double Value2, Fluid *pFluid)
 The lower-level methods that can throw exceptions. More...
 
double _PropsSI (std::string Output, std::string Name1, double Prop1, std::string Name2, double Prop2, std::string Ref)
 
double _Props1SI (std::string FluidName, std::string Output)
 
void set_warning (std::string warning)
 
int _get_standard_unit_system ()
 
void _set_standard_unit_system (int unit_sys)
 
std::map< std::string, longparam_map (map_data, map_data+sizeof map_data/sizeof map_data[0])
 
void set_err_string (std::string error_string)
 
void set_phase (std::string Phase_str)
 Nearly deprecated function. More...
 
Fluidget_fluid (long iFluid)
 
long get_Fluid_index (std::string FluidName)
 
bool add_REFPROP_fluid (std::string FluidName)
 Add a REFPROP fluid to the fluid listing in CoolProp. More...
 
std::string get_ASHRAE34 (std::string fluid)
 
long get_param_index (std::string param)
 
long getFluidType (std::string FluidName)
 
EXPORT_CODE int CONVENTION IsFluidType (const char *Ref, const char *Type)
 
double _T_hp_secant (std::string Ref, double h, double p, double T_guess)
 
std::string Phase_Trho (std::string Fluid, double T, double rho)
 
std::string Phase (std::string Fluid, double T, double p)
 
std::string Phase_Tp (std::string Fluid, double T, double p)
 
double _Props1 (std::string FluidName, std::string Output)
 
double Props1SI (std::string FluidName, std::string Output)
 
double Props1 (std::string FluidName, std::string Output)
 
EXPORT_CODE double CONVENTION IProps (long iOutput, long iName1, double Prop1, long iName2, double Prop2, long iFluid)
 
EXPORT_CODE double CONVENTION IPropsSI (long iOutput, long iName1, double Prop1, long iName2, double Prop2, long iFluid)
 
double PropsSI (std::string Output, std::string Name1, double Prop1, std::string Name2, double Prop2, std::string Ref)
 
double Props (std::string Output, std::string Name1, double Prop1, std::string Name2, double Prop2, std::string Ref)
 
double Props (std::string Output, char Name1, double Prop1, char Name2, double Prop2, std::string Ref)
 
double _CoolProp_Deriv_Terms (long iTerm, double T, double rho, Fluid *pFluid)
 Calculate some interesting derivatives. More...
 
double DerivTerms (long iTerm, double T, double rho, Fluid *pFluid)
 
double DerivTerms (std::string Term, double T, double rho, std::string Fluidname)
 
int set_reference_stateS (std::string Ref, std::string reference_state)
 
int set_reference_stateP (Fluid *pFluid, std::string reference_state)
 
int set_reference_stateD (std::string Ref, double T, double rho, double h0, double s0)
 
std::string get_BibTeXKey (std::string Ref, std::string item)
 
std::string get_global_param_string (std::string ParamName)
 
std::string get_fluid_param_string (std::string FluidName, std::string ParamName)
 
 TEST_CASE ("Check ancillaries and surface tension","[fast]")
 

Variables

int global_Phase = -1
 
bool global_SinglePhase = false
 
bool global_SaturatedL = false
 
bool global_SaturatedV = false
 
int unit_system = UNIT_SYSTEM_KSI
 
std::pair< std::string, longmap_data []
 
FluidsContainer Fluids = FluidsContainer()
 

Function Documentation

double _CoolProp_Deriv_Terms ( long  iTerm,
double  T,
double  rho,
Fluid pFluid 
)

Calculate some interesting derivatives.

Definition at line 913 of file CoolProp.cpp.

double _CoolProp_Fluid_PropsSI ( long  iOutput,
long  iName1,
double  Value1,
long  iName2,
double  Value2,
Fluid pFluid 
)

The lower-level methods that can throw exceptions.

Definition at line 765 of file CoolProp.cpp.

int _get_standard_unit_system ( )

Returns the value for the integer flag corresponding to the current set of units

Returns
val The integer value for the current set of units, one of enumerated values UNIT_SYSTEM_SI, UNIT_SYSTEM_KSI (see GlobalConstants.h)

Definition at line 61 of file CoolProp.cpp.

double _Props1 ( std::string  FluidName,
std::string  Output 
)

Definition at line 556 of file CoolProp.cpp.

double _Props1SI ( std::string  FluidName,
std::string  Output 
)

Definition at line 514 of file CoolProp.cpp.

double _PropsSI ( std::string  Output,
std::string  Name1,
double  Prop1,
std::string  Name2,
double  Prop2,
std::string  Ref 
)

Definition at line 613 of file CoolProp.cpp.

void _set_standard_unit_system ( int  )

Sets the flag for the integer flag corresponding to the current set of units

Parameters
valThe integer value for the current set of units, one of enumerated values UNIT_SYSTEM_SI, UNIT_SYSTEM_KSI (see GlobalConstants.h)

Definition at line 62 of file CoolProp.cpp.

double _T_hp_secant ( std::string  Ref,
double  h,
double  p,
double  T_guess 
)

Definition at line 448 of file CoolProp.cpp.

bool add_REFPROP_fluid ( std::string  FluidName)

Add a REFPROP fluid to the fluid listing in CoolProp.

Definition at line 253 of file CoolProp.cpp.

double DerivTerms ( long  iTerm,
double  T,
double  rho,
Fluid pFluid 
)

Return some low level derivative terms, see source for a complete list

Parameters
iTermlong desired output
TTemperature [K]
rhoDensity [kg/m^3]
pFluidPointer to Fluid instance

Definition at line 1001 of file CoolProp.cpp.

double DerivTerms ( std::string  Term,
double  T,
double  rho,
std::string  FluidName 
)

Return some low level derivative terms, see source for a complete list

Parameters
TermString, some options are "phir" (residual Helmholtz energy),"dphir_dDelta", "dphir_dTau", etc.
TTemperature [K]
rhoDensity [kg/m^3]
FluidNameString

Definition at line 1004 of file CoolProp.cpp.

std::string get_ASHRAE34 ( std::string  fluid)

Definition at line 275 of file CoolProp.cpp.

std::string get_BibTeXKey ( std::string  FluidName,
std::string  item 
)

Returns the BibTeX key from the bibtex library of CoolProp corresponding to the item requested

Parameters
FluidNameThe name of the fluid
itemString, one of "EOS","CP0", "VISCOSITY", "CONDUCTIVITY", "ECS_LENNARD_JONES", "ECS_FITS", "SURFACE_TENSION"
Returns
key the BibTeX key

Definition at line 1122 of file CoolProp.cpp.

Fluid* get_fluid ( long  iFluid)

Get a pointer to a fluid that has been loaded

Parameters
iFluidThe integer index for the fluid (get from get_Fluid_index)
Returns
pFluid A pointer to a Fluid instance

Definition at line 236 of file CoolProp.cpp.

long get_Fluid_index ( std::string  FluidName)

Get the fluid index for a given fluid name

Parameters
FluidNameThe name for a fluid
Returns
index The fluid index (for use in IProps or elsewhere); -1 if not found

Definition at line 239 of file CoolProp.cpp.

std::string get_fluid_param_string ( std::string  FluidName,
std::string  ParamName 
)

Get a string for a value from a fluid (numerical values can be obtained from Props1 function)

Parameters
FluidNameThe name of the fluid
ParamNameA string, one of "aliases", "CAS", "CAS_number", "ASHRAE34", "REFPROPName","REFPROP_name", "TTSE_mode"
Returns
str The string, or an error message if not valid input

Definition at line 1173 of file CoolProp.cpp.

std::string get_global_param_string ( std::string  ParamName)

Get a globally-defined string

Parameters
ParamNameA string, one of "version", "errstring", "warnstring", "gitrevision", "FluidsList", "fluids_list"
Returns
str The string, or an error message if not valid input

Definition at line 1142 of file CoolProp.cpp.

long get_param_index ( std::string  param)

Get the parameter index for a given parameter

Parameters
paramThe string for an input or output parameter
Returns
index The parameter index (for use in IProps or elsewhere); -1 if not found

Definition at line 288 of file CoolProp.cpp.

long getFluidType ( std::string  FluidName)

Get a long that represents the fluid type

Parameters
FluidNameThe fluid name as a string
Returns
long element from global type enumeration

Definition at line 369 of file CoolProp.cpp.

EXPORT_CODE double CONVENTION IProps ( long  iOutput,
long  iName1,
double  Prop1,
long  iName2,
double  Prop2,
long  iFluid 
)

Definition at line 758 of file CoolProp.cpp.

EXPORT_CODE double CONVENTION IPropsSI ( long  iOutput,
long  iName1,
double  Prop1,
long  iName2,
double  Prop2,
long  iFluid 
)

Definition at line 861 of file CoolProp.cpp.

EXPORT_CODE int CONVENTION IsFluidType ( const char *  Ref,
const char *  Type 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

See also
IsFluidType(std::string, std::string)

Definition at line 390 of file CoolProp.cpp.

std::map<std::string, long> param_map ( map_data  ,
map_data+sizeof map_data/sizeof  map_data[0] 
)
std::string Phase ( std::string  FluidName,
double  T,
double  p 
)

Return the phase of the given state point with temperature, pressure as inputs

Parameters
FluidNameThe name of the fluid
TTemperature [K]
pPressure [kPa]
Returns
Phase as string, one of ""Two-Phase","Supercritical","Gas","Liquid"

Definition at line 490 of file CoolProp.cpp.

std::string Phase_Tp ( std::string  FluidName,
double  T,
double  p 
)

Return the phase of the given state point with temperature, pressure as inputs

Parameters
FluidNameThe name of the fluid
TTemperature [K]
pPressure [kPa]
Returns
Phase as string, one of ""Two-Phase","Supercritical","Gas","Liquid"

Definition at line 504 of file CoolProp.cpp.

std::string Phase_Trho ( std::string  FluidName,
double  T,
double  rho 
)

Return the phase of the given state point with temperature, density as inputs

Parameters
FluidNameThe name of the fluid
TTemperature [K]
rhoDensity [kg/m^3]
Returns
Phase as string, one of ""Two-Phase","Supercritical","Gas","Liquid"

Definition at line 476 of file CoolProp.cpp.

double Props ( std::string  Output,
std::string  Name1,
double  Prop1,
std::string  Name2,
double  Prop2,
std::string  FluidName 
)

Return a value that depends on the thermodynamic state

Parameters
OutputThe output parameter, one of "T","D","H",etc.
Name1The first state variable name, one of "T","D","H",etc.
Prop1The first state variable value
Name2The second state variable name, one of "T","D","H",etc.
Prop2The second state variable value
FluidNameThe fluid name

Definition at line 902 of file CoolProp.cpp.

double Props ( std::string  Output,
char  Name1,
double  Prop1,
char  Name2,
double  Prop2,
std::string  FluidName 
)

Return a value that depends on the thermodynamic state

Parameters
OutputThe output parameter, one of "T","D","H",etc.
Name1The first state variable name, one of "T","D","H",etc.
Prop1The first state variable value
Name2The second state variable name, one of "T","D","H",etc.
Prop2The second state variable value
FluidNameThe fluid name

Definition at line 907 of file CoolProp.cpp.

double Props1 ( std::string  FluidName,
std::string  Output 
)

Return a fluid value that does not depend on the thermodynamic state

Parameters
FluidNameThe name of the fluid
OutputThe name of the output parameter, some options are "Ttriple", "Tcrit", "pcrit", "Tmin", "molemass", "rhocrit", "accentric" (not all parameters are valid for all fluids)
Returns
val The value, or _HUGE if not valid

Definition at line 586 of file CoolProp.cpp.

double Props1SI ( std::string  FluidName,
std::string  Output 
)

Return a fluid value that does not depend on the thermodynamic state

Parameters
FluidNameThe name of the fluid
OutputThe name of the output parameter, some options are "Ttriple", "Tcrit", "pcrit", "Tmin", "molemass", "rhocrit", "accentric" (not all parameters are valid for all fluids)
Returns
val The value, or _HUGE if not valid

Definition at line 570 of file CoolProp.cpp.

double PropsSI ( std::string  Output,
std::string  Name1,
double  Prop1,
std::string  Name2,
double  Prop2,
std::string  FluidName 
)

Return a value that depends on the thermodynamic state

Parameters
OutputThe output parameter, one of "T","D","H",etc.
Name1The first state variable name, one of "T","D","H",etc.
Prop1The first state variable value
Name2The second state variable name, one of "T","D","H",etc.
Prop2The second state variable value
FluidNameThe fluid name

Definition at line 886 of file CoolProp.cpp.

void set_err_string ( std::string  err_string)

Set the global error string

Parameters
err_stringThe error string to use

Definition at line 191 of file CoolProp.cpp.

void set_phase ( std::string  Phase_str)

Nearly deprecated function.

Definition at line 196 of file CoolProp.cpp.

int set_reference_stateD ( std::string  FluidName,
double  T,
double  rho,
double  h0,
double  s0 
)

Set the reference state based on a state point

Parameters
FluidNameThe name of the fluid
TTemperature at reference state [K]
rhoDensity at reference state [kg/m^3]
h0Enthalpy at reference state [kJ/kg]
s0Entropy at references state [kJ/kg/K]

Definition at line 1100 of file CoolProp.cpp.

int set_reference_stateP ( Fluid pFluid,
std::string  reference_state 
)

Set the reference state for a pointer to a fluid (not exposed)

Parameters
pFluidA pointer to a Fluid instance
reference_stateThe reference state to use, one of "IIR" (h=200 kJ/kg, s=1 kJ/kg/K at 0C sat. liq.) "ASHRAE" (h=0,s=0 @ -40C sat liq), "NBP" (h=0,s=0 @ 1.0 bar sat liq.)

Definition at line 1049 of file CoolProp.cpp.

int set_reference_stateS ( std::string  FluidName,
std::string  reference_state 
)

Set the reference state based on a string representation (consistent naming with RFPROP)

Parameters
FluidNameThe name of the fluid
reference_stateThe reference state to use, one of "IIR" (h=200 kJ/kg, s=1 kJ/kg/K at 0C sat. liq.) "ASHRAE" (h=0,s=0 @ -40C sat liq), "NBP" (h=0,s=0 @ 1.0 bar sat liq.)

Definition at line 1037 of file CoolProp.cpp.

void set_warning ( std::string  warning)

An internal function to set the global warning string (API for warnings is not formalized)

Parameters
warningThe string to set as the warning string

Definition at line 59 of file CoolProp.cpp.

TEST_CASE ( "Check ancillaries and surface tension"  ,
""  [fast] 
)

Definition at line 1231 of file CoolProp.cpp.

Variable Documentation

Definition at line 189 of file CoolProp.cpp.

int global_Phase = -1

Definition at line 51 of file CoolProp.cpp.

bool global_SaturatedL = false

Definition at line 53 of file CoolProp.cpp.

bool global_SaturatedV = false

Definition at line 54 of file CoolProp.cpp.

bool global_SinglePhase = false

Definition at line 52 of file CoolProp.cpp.

std::pair<std::string, long> map_data[]

Definition at line 65 of file CoolProp.cpp.

int unit_system = UNIT_SYSTEM_KSI

Definition at line 57 of file CoolProp.cpp.