CoolProp
DataStructures.h
1 /*
2  * DataStructures.h
3  *
4  * Created on: 21 Dec 2013
5  * Author: jowr
6  */
7 
8 #ifndef DATASTRUCTURES_H_
9 #define DATASTRUCTURES_H_
10 
11 #include "CPnumerics.h"
12 #include "Exceptions.h"
13 #include <map>
14 namespace CoolProp {
15 
17 {
18  double rhomolar, T, p, hmolar, smolar, umolar, Q;
19  SimpleState() { fill(_HUGE); }
20  void fill(double v){
21  rhomolar = v; T = v; p = v; hmolar = v; smolar = v; umolar = v; Q = v;
22  }
23  bool is_valid(){return ValidNumber(rhomolar) && ValidNumber(T) && ValidNumber(hmolar) && ValidNumber(p);}
24 };
25 
27 {
28  bool stable;
29  CriticalState() :stable(false){ fill(_HUGE); }
30 
31 };
32 
35 {
36  enum SsatSimpleStateEnum {SSAT_MAX_NOT_SET=0, SSAT_MAX_DOESNT_EXIST, SSAT_MAX_DOES_EXIST};
37  SsatSimpleStateEnum exists;
38  SsatSimpleState() : exists(SSAT_MAX_NOT_SET) {}
39 };
40 
41 
47 //
48 // !! If you add a parameter, update the map in the corresponding CPP file !!
50  INVALID_PARAMETER = 0,
51 
52  // General parameters
71 
72  // Bulk properties
73  iT,
74  iP,
75  iQ,
76  iTau,
78 
79  // Molar specific thermodynamic properties
92 
93  // Mass specific thermodynamic properties
103 
104  // Transport properties
109 
110  // Derivative-based terms
115 
116  // Fundamental derivative of gas dynamics
118 
119  // Derivatives of the residual non-dimensionalized Helmholtz energy with respect to the EOS variables
120  ialphar,
121  idalphar_dtau_constdelta,
122  idalphar_ddelta_consttau,
123 
124  // Derivatives of the ideal-gas non-dimensionalized Helmholtz energy with respect to the EOS variables
125  ialpha0,
126  idalpha0_dtau_constdelta,
127  idalpha0_ddelta_consttau,
128 
129  // Other functions and derivatives
134  iZ,
136 
137  // Accessors for incompressibles
141 
142  // Environmental parameters
146  iFH,
147  iHH,
148  iPH,
152 
153 };
154 // !! If you add a parameter, update the map in the corresponding CPP file !!
155 // !! Also update phase_lookup_string() in CoolProp.cpp !!
156 
166  iphase_not_imposed};
167 
171 std::string get_parameter_information(int key, const std::string &info);
172 
174 parameters get_parameter_index(const std::string &param_name);
175 
179 bool is_valid_phase(const std::string &phase_name, phases &iOutput);
180 
182 phases get_phase_index(const std::string &param_name);
183 
185 bool is_trivial_parameter(int key);
186 
188 bool is_valid_parameter(const std::string & name, parameters & iOutput);
189 
193 bool is_valid_first_derivative(const std::string & name, parameters &iOf, parameters &iWrt, parameters &iConstant);
194 
198 bool is_valid_first_saturation_derivative(const std::string & name, parameters &iOf, parameters &iWrt);
199 
203 bool is_valid_second_derivative(const std::string & name, parameters &iOf1, parameters &iWrt1, parameters &iConstant1, parameters &iWrt2, parameters &iConstant2);
204 
206 std::string get_csv_parameter_list();
207 
209 enum composition_types{IFRAC_MASS, IFRAC_MOLE, IFRAC_VOLUME, IFRAC_UNDEFINED, IFRAC_PURE};
210 
212 enum fluid_types{FLUID_TYPE_PURE, FLUID_TYPE_PSEUDOPURE, FLUID_TYPE_REFPROP, FLUID_TYPE_INCOMPRESSIBLE_LIQUID, FLUID_TYPE_INCOMPRESSIBLE_SOLUTION, FLUID_TYPE_UNDEFINED};
213 
214 // !! If you add a parameter, update the map in the corresponding CPP file !!
217  INPUT_PAIR_INVALID = 0, // Default (invalid) value
226 
228 
237 
246 
251 
258 };
259 // !! If you add or remove a parameter, update the map in the corresponding CPP file !!
260 
261 inline bool match_pair(parameters key1, parameters key2, parameters x1, parameters x2, bool &swap)
262 {
263  swap = !(key1 == x1);
264  return ((key1 == x1 && key2 == x2) || (key2 == x1 && key1 == x2));
265 };
279 template<class T> CoolProp::input_pairs generate_update_pair(parameters key1, T value1, parameters key2, T value2, T &out1, T &out2) throw()
280  {
282  bool swap;
283 
284  if (match_pair(key1, key2, iQ, iT, swap)){
285  pair = QT_INPUTS;
286  }
287  else if (match_pair(key1, key2, iP, iQ, swap)){
288  pair = PQ_INPUTS;
289  }
290  else if (match_pair(key1, key2, iP, iT, swap)){
291  pair = PT_INPUTS;
292  }
293  else if (match_pair(key1, key2, iDmolar, iT, swap)){
294  pair = DmolarT_INPUTS; // Molar density in mol/m^3, Temperature in K
295  }
296  else if (match_pair(key1, key2, iDmass, iT, swap)){
297  pair = DmassT_INPUTS; // Mass density in kg/m^3, Temperature in K
298  }
299  else if (match_pair(key1, key2, iHmolar, iT, swap)){
300  pair = HmolarT_INPUTS; // Enthalpy in J/mol, Temperature in K
301  }
302  else if (match_pair(key1, key2, iHmass, iT, swap)){
303  pair = HmassT_INPUTS; // Enthalpy in J/kg, Temperature in K
304  }
305  else if (match_pair(key1, key2, iSmolar, iT, swap)){
306  pair = SmolarT_INPUTS; // Entropy in J/mol/K, Temperature in K
307  }
308  else if (match_pair(key1, key2, iSmass, iT, swap)){
309  pair = SmassT_INPUTS; // Entropy in J/kg/K, Temperature in K
310  }
311  else if (match_pair(key1, key2, iT, iUmolar, swap)){
312  pair = TUmolar_INPUTS; // Temperature in K, Internal energy in J/mol
313  }
314  else if (match_pair(key1, key2, iT, iUmass, swap)){
315  pair = TUmass_INPUTS; // Temperature in K, Internal energy in J/kg
316  }
317  else if (match_pair(key1, key2, iDmass, iHmass, swap)){
318  pair = DmassHmass_INPUTS; // Mass density in kg/m^3, Enthalpy in J/kg
319  }
320  else if (match_pair(key1, key2, iDmolar, iHmolar, swap)){
321  pair = DmolarHmolar_INPUTS; // Molar density in mol/m^3, Enthalpy in J/mol
322  }
323  else if (match_pair(key1, key2, iDmass, iSmass, swap)){
324  pair = DmassSmass_INPUTS; // Mass density in kg/m^3, Entropy in J/kg/K
325  }
326  else if (match_pair(key1, key2, iDmolar, iSmolar, swap)){
327  pair = DmolarSmolar_INPUTS; // Molar density in mol/m^3, Entropy in J/mol/K
328  }
329  else if (match_pair(key1, key2, iDmass, iUmass, swap)){
330  pair = DmassUmass_INPUTS; // Mass density in kg/m^3, Internal energy in J/kg
331  }
332  else if (match_pair(key1, key2, iDmolar, iUmolar, swap)){
333  pair = DmolarUmolar_INPUTS; // Molar density in mol/m^3, Internal energy in J/mol
334  }
335  else if (match_pair(key1, key2, iDmass, iP, swap)){
336  pair = DmassP_INPUTS; // Mass density in kg/m^3, Pressure in Pa
337  }
338  else if (match_pair(key1, key2, iDmolar, iP, swap)){
339  pair = DmolarP_INPUTS; // Molar density in mol/m^3, Pressure in Pa
340  }
341  else if (match_pair(key1, key2, iDmass, iQ, swap)){
342  pair = DmassQ_INPUTS; // Mass density in kg/m^3, molar vapor quality
343  }
344  else if (match_pair(key1, key2, iDmolar, iQ, swap)){
345  pair = DmolarQ_INPUTS; // Molar density in mol/m^3, molar vapor quality
346  }
347  else if (match_pair(key1, key2, iHmass, iP, swap)){
348  pair = HmassP_INPUTS; // Enthalpy in J/kg, Pressure in Pa
349  }
350  else if (match_pair(key1, key2, iHmolar, iP, swap)){
351  pair = HmolarP_INPUTS; // Enthalpy in J/mol, Pressure in Pa
352  }
353  else if (match_pair(key1, key2, iP, iSmass, swap)){
354  pair = PSmass_INPUTS; // Pressure in Pa, Entropy in J/kg/K
355  }
356  else if (match_pair(key1, key2, iP, iSmolar, swap)){
357  pair = PSmolar_INPUTS; // Pressure in Pa, Entropy in J/mol/K
358  }
359  else if (match_pair(key1, key2, iP, iUmass, swap)){
360  pair = PUmass_INPUTS; // Pressure in Pa, Internal energy in J/kg
361  }
362  else if (match_pair(key1, key2, iP, iUmolar, swap)){
363  pair = PUmolar_INPUTS; // Pressure in Pa, Internal energy in J/mol
364  }
365  else if (match_pair(key1, key2, iHmass, iSmass, swap)){
366  pair = HmassSmass_INPUTS; // Enthalpy in J/kg, Entropy in J/kg/K
367  }
368  else if (match_pair(key1, key2, iHmolar, iSmolar, swap)){
369  pair = HmolarSmolar_INPUTS; // Enthalpy in J/mol, Entropy in J/mol/K
370  }
371  else if (match_pair(key1, key2, iSmass, iUmass, swap)){
372  pair = SmassUmass_INPUTS;
373  }
374  else if (match_pair(key1, key2, iSmolar, iUmolar, swap)){
375  pair = SmolarUmolar_INPUTS;
376  }
377  else{
378  pair = INPUT_PAIR_INVALID; return pair;
379  }
380 
381  if (!swap){
382  out1 = value1; out2 = value2;
383  }
384  else{
385  out1 = value2; out2 = value1;
386  }
387  return pair;
388  };
389 
391 input_pairs get_input_pair_index(const std::string &input_pair_name);
392 
394 const std::string& get_input_pair_short_desc(input_pairs pair);
395 
397 const std::string& get_input_pair_long_desc(input_pairs pair);
398 
401 
402 extern std::string get_mixture_binary_pair_data(const std::string &CAS1, const std::string &CAS2, const std::string &param);
403 extern void set_mixture_binary_pair_data(const std::string &CAS1, const std::string &CAS2, const std::string &param, const double val);
404 extern std::string get_mixture_binary_pair_pcsaft(const std::string &CAS1, const std::string &CAS2, const std::string &param);
405 extern void set_mixture_binary_pair_pcsaft(const std::string &CAS1, const std::string &CAS2, const std::string &param, const double val);
406 
408 // !! If you add a parameter, update the map in the corresponding CPP file !!
410  INVALID_BACKEND_FAMILY = 0,
411  HEOS_BACKEND_FAMILY,
412  REFPROP_BACKEND_FAMILY,
413  INCOMP_BACKEND_FAMILY,
414  IF97_BACKEND_FAMILY,
415  TREND_BACKEND_FAMILY,
416  TTSE_BACKEND_FAMILY,
417  BICUBIC_BACKEND_FAMILY,
418  SRK_BACKEND_FAMILY,
419  PR_BACKEND_FAMILY,
420  VTPR_BACKEND_FAMILY,
421  PCSAFT_BACKEND_FAMILY
422 };
423 enum backends {
424  INVALID_BACKEND = 0,
425  HEOS_BACKEND_PURE,
426  HEOS_BACKEND_MIX,
427  REFPROP_BACKEND_PURE,
428  REFPROP_BACKEND_MIX,
429  INCOMP_BACKEND,
430  IF97_BACKEND,
431  TREND_BACKEND,
432  TTSE_BACKEND,
433  BICUBIC_BACKEND,
434  SRK_BACKEND,
435  PR_BACKEND,
436  VTPR_BACKEND,
437  PCSAFT_BACKEND
438 };
439 
441 void extract_backend_families(std::string backend_string, backend_families &f1, backend_families &f2);
442 void extract_backend_families_string(std::string backend_string, backend_families &f1, std::string &f2);
443 std::string get_backend_string(backends backend);
444 
445 } /* namespace CoolProp */
446 #endif /* DATASTRUCTURES_H_ */
Mass-based internal energy.
Definition: DataStructures.h:100
Molar density in mol/m^3, Entropy in J/mol/K.
Definition: DataStructures.h:255
The 500-year global warming potential.
Definition: DataStructures.h:145
The fundamental derivative of gas dynamics.
Definition: DataStructures.h:117
Minimum temperature.
Definition: DataStructures.h:66
Enthalpy in J/mol, Entropy in J/mol/K.
Definition: DataStructures.h:248
Supercritical liquid (p > pc, T < Tc)
Definition: DataStructures.h:161
Derivative of third virial coefficient with temperature.
Definition: DataStructures.h:133
The phase index of the given state.
Definition: DataStructures.h:150
Molar density in mol/m^3, Temperature in K.
Definition: DataStructures.h:230
Molar density in mol/m^3, Enthalpy in J/mol.
Definition: DataStructures.h:253
Fire hazard index.
Definition: DataStructures.h:146
Health hazard index.
Definition: DataStructures.h:147
Pressure in Pa, Entropy in J/mol/K.
Definition: DataStructures.h:243
bool is_valid_first_derivative(const std::string &name, parameters &iOf, parameters &iWrt, parameters &iConstant)
Returns true if the string corresponds to a valid first derivative.
Definition: DataStructures.cpp:232
Mass-based enthalpy.
Definition: DataStructures.h:95
bool is_valid_second_derivative(const std::string &name, parameters &iOf1, parameters &iWrt1, parameters &iConstant1, parameters &iWrt2, parameters &iConstant2)
Returns true if the string corresponds to a valid second derivative.
Definition: DataStructures.cpp:296
fluid_types
These are unit types for the fluid.
Definition: DataStructures.h:212
Temperature at the critical point.
Definition: DataStructures.h:59
Molar density used for the critical point.
Definition: DataStructures.h:57
The maximum fraction (mole,mass,volume) for incompressibles.
Definition: DataStructures.h:139
Subcritical liquid.
Definition: DataStructures.h:158
Supercritical gas (p < pc, T > Tc)
Definition: DataStructures.h:160
Mole-based Gibbs energy.
Definition: DataStructures.h:87
Dipole moment.
Definition: DataStructures.h:70
Mass-based Helmholtz energy.
Definition: DataStructures.h:102
Definition: DataStructures.h:26
Pressure in Pa, Molar quality.
Definition: DataStructures.h:219
phases
These are constants for the phases of the fluid.
Definition: DataStructures.h:158
Enthalpy in J/mol, Temperature in K.
Definition: DataStructures.h:231
Second virial coefficient.
Definition: DataStructures.h:130
The residual molar enthalpy.
Definition: DataStructures.h:89
Reciprocal reduced temperature.
Definition: DataStructures.h:76
Pressure at the critical point.
Definition: DataStructures.h:62
Mass-based density.
Definition: DataStructures.h:94
Temperature at the reducing state.
Definition: DataStructures.h:58
Temperature in K, Internal energy in J/mol.
Definition: DataStructures.h:235
Mass density in kg/m^3, Temperature in K.
Definition: DataStructures.h:229
The residual molar Gibbs energy.
Definition: DataStructures.h:91
Ideal-gas constant.
Definition: DataStructures.h:53
Unknown phase.
Definition: DataStructures.h:165
Entropy in J/kg/K, Temperature in K.
Definition: DataStructures.h:234
Entropy in J/mol/K, Temperature in K.
Definition: DataStructures.h:233
std::string get_mixture_binary_pair_data(const std::string &CAS1, const std::string &CAS2, const std::string &param)
Get a string for the given binary pair.
Definition: MixtureParameters.cpp:291
Maximum temperature.
Definition: DataStructures.h:67
Mass-based ideal-gas specific heat.
Definition: DataStructures.h:98
void extract_backend_families(std::string backend_string, backend_families &f1, backend_families &f2)
Convert a string into the enum values.
Definition: DataStructures.cpp:605
Mole-based constant-volume specific heat.
Definition: DataStructures.h:85
Molar quality, Entropy in J/kg/K.
Definition: DataStructures.h:221
Pressure in Pa, Temperature in K.
Definition: DataStructures.h:227
Physical hazard index.
Definition: DataStructures.h:148
A modified class for the state point at the maximum saturation entropy on the vapor curve...
Definition: DataStructures.h:34
std::string get_parameter_information(int key, const std::string &info)
Return information about the parameter.
Definition: DataStructures.cpp:173
Enthalpy in J/kg, Molar quality.
Definition: DataStructures.h:223
composition_types
These are constants for the compositions.
Definition: DataStructures.h:209
Isobaric expansion coefficient.
Definition: DataStructures.h:113
std::string get_csv_parameter_list()
Get a comma separated list of parameters.
Definition: DataStructures.cpp:208
void set_mixture_binary_pair_data(const std::string &CAS1, const std::string &CAS2, const std::string &param, const double val)
Set a parameter for the given binary pair.
Definition: MixtureParameters.cpp:330
Molar density in mol/m^3, Pressure in Pa.
Definition: DataStructures.h:239
Entropy in J/mol/K, Internal energy in J/mol.
Definition: DataStructures.h:250
backend_families
The structure is taken directly from the AbstractState class.
Definition: DataStructures.h:409
At the critical point.
Definition: DataStructures.h:162
Pressure in Pa, Entropy in J/kg/K.
Definition: DataStructures.h:242
CoolProp::input_pairs generate_update_pair(parameters key1, T value1, parameters key2, T value2, T &out1, T &out2)
Generate an update pair from key, value pairs.
Definition: DataStructures.h:279
Density in mol/m^3, Molar quality.
Definition: DataStructures.h:224
Enthalpy in J/kg, Temperature in K.
Definition: DataStructures.h:232
const std::string & get_input_pair_short_desc(input_pairs pair)
Return the short description of an input pair key ("DmolarT_INPUTS" for instance) ...
Definition: DataStructures.cpp:485
The Prandtl number.
Definition: DataStructures.h:108
parameters get_parameter_index(const std::string &param_name)
Return the enum key corresponding to the parameter name ("Dmolar" for instance)
Definition: DataStructures.cpp:393
Isentropic expansion coefficient.
Definition: DataStructures.h:114
Mass density in kg/m^3, Internal energy in J/kg.
Definition: DataStructures.h:256
Pressure in Pa, Internal energy in J/mol.
Definition: DataStructures.h:245
The compressibility factor Z = p*v/(R*T)
Definition: DataStructures.h:134
The phase identification parameter of Venkatarathnam and Oellrich.
Definition: DataStructures.h:135
Mass density at the critical point.
Definition: DataStructures.h:61
input_pairs
These are input pairs that can be used for the update function (in each pair, input keys are sorted a...
Definition: DataStructures.h:216
The 100-year global warming potential.
Definition: DataStructures.h:144
Mass density in kg/m^3, Pressure in Pa.
Definition: DataStructures.h:238
The residual molar entropy (as a function of temperature and density)
Definition: DataStructures.h:90
Subcritical gas.
Definition: DataStructures.h:163
Mass-based constant-volume specific heat.
Definition: DataStructures.h:99
Triple point temperature.
Definition: DataStructures.h:64
Third virial coefficient.
Definition: DataStructures.h:131
Molar quality, Temperature in K.
Definition: DataStructures.h:218
Entropy in J/kg/K, Internal energy in J/kg.
Definition: DataStructures.h:249
phases get_phase_index(const std::string &param_name)
Return the enum key corresponding to the phase name ("phase_liquid" for instance) ...
Definition: DataStructures.cpp:383
Molar mass.
Definition: DataStructures.h:54
Enthalpy in J/kg, Pressure in Pa.
Definition: DataStructures.h:240
bool is_valid_first_saturation_derivative(const std::string &name, parameters &iOf, parameters &iWrt)
Returns true if the string corresponds to a valid first saturation derivative - e.g.
Definition: DataStructures.cpp:264
Derivative of second virial coefficient with temperature.
Definition: DataStructures.h:132
Mass density in kg/m^3, Entropy in J/kg/K.
Definition: DataStructures.h:254
Enthalpy in J/kg, Entropy in J/kg/K.
Definition: DataStructures.h:247
Mass-based entropy.
Definition: DataStructures.h:96
The last parameter, so we can check that all parameters are described in DataStructures.cpp.
Definition: DataStructures.h:151
Viscosity.
Definition: DataStructures.h:105
Molar density used for the reducing state.
Definition: DataStructures.h:56
Acentric factor.
Definition: DataStructures.h:55
Mole-based density.
Definition: DataStructures.h:80
void split_input_pair(input_pairs pair, parameters &p1, parameters &p2)
Split an input pair into parameters for the two parts that form the pair.
Definition: DataStructures.cpp:493
Mass density at the reducing state.
Definition: DataStructures.h:60
Mole-based constant-pressure specific heat.
Definition: DataStructures.h:83
Mole-based entropy.
Definition: DataStructures.h:82
Pressure.
Definition: DataStructures.h:74
Density in kg/m^3, Molar quality.
Definition: DataStructures.h:225
Speed of sound.
Definition: DataStructures.h:111
Isothermal compressibility.
Definition: DataStructures.h:112
Enthalpy in J/mol, Pressure in Pa.
Definition: DataStructures.h:241
Mole-based ideal-gas constant-pressure specific heat.
Definition: DataStructures.h:84
Twophase.
Definition: DataStructures.h:164
The freezing temperature for incompressibles.
Definition: DataStructures.h:140
const std::string & get_input_pair_long_desc(input_pairs pair)
Return the long description of an input pair key ("Molar density in mol/m^3, Temperature in K" for in...
Definition: DataStructures.cpp:489
Pressure at the reducing point.
Definition: DataStructures.h:63
Temperature in K, Internal energy in J/kg.
Definition: DataStructures.h:236
bool is_valid_phase(const std::string &phase_name, phases &iOutput)
Return true if passed phase name is valid, otherwise false.
Definition: DataStructures.cpp:368
Triple point pressure.
Definition: DataStructures.h:65
The minimum fraction (mole, mass, volume) for incompressibles.
Definition: DataStructures.h:138
input_pairs get_input_pair_index(const std::string &input_pair_name)
Get the input pair index associated with its string representation.
Definition: DataStructures.cpp:474
Thermal conductivity.
Definition: DataStructures.h:106
Minimum pressure.
Definition: DataStructures.h:69
Mole-based internal energy.
Definition: DataStructures.h:86
Surface tension.
Definition: DataStructures.h:107
Ozone depletion potential (R-11 = 1.0)
Definition: DataStructures.h:149
Enthalpy in J/mol, Molar quality.
Definition: DataStructures.h:222
Mass-based Gibbs energy.
Definition: DataStructures.h:101
Supercritical (p > pc, T > Tc)
Definition: DataStructures.h:159
This file contains flash routines in which the state is unknown, and a solver of some kind must be us...
Definition: AbstractState.h:19
Mole-based Helmholtz energy.
Definition: DataStructures.h:88
Molar density in mol/m^3, Internal energy in J/mol.
Definition: DataStructures.h:257
The 20-year global warming potential.
Definition: DataStructures.h:143
Molar quality, Entropy in J/mol/K.
Definition: DataStructures.h:220
parameters
Define some constants that will be used throughout These are constants for the input and output para...
Definition: DataStructures.h:49
Reduced density.
Definition: DataStructures.h:77
Mole-based enthalpy.
Definition: DataStructures.h:81
Temperature.
Definition: DataStructures.h:73
Maximum pressure.
Definition: DataStructures.h:68
Mass-based constant-pressure specific heat.
Definition: DataStructures.h:97
bool is_valid_parameter(const std::string &name, parameters &iOutput)
Returns true if a valid parameter, and sets value in the variable iOutput.
Definition: DataStructures.cpp:217
Mass density in kg/m^3, Enthalpy in J/kg.
Definition: DataStructures.h:252
Vapor quality.
Definition: DataStructures.h:75
Pressure in Pa, Internal energy in J/kg.
Definition: DataStructures.h:244
bool is_trivial_parameter(int key)
Returns true if the input is trivial (constants, critical parameters, etc.)
Definition: DataStructures.cpp:157
Definition: DataStructures.h:16