CoolProp  6.6.0
An open-source fluid property and humid air property database
DataStructures.h
Go to the documentation of this file.
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;
20  fill(_HUGE);
21  }
22  void fill(double v) {
23  rhomolar = v;
24  T = v;
25  p = v;
26  hmolar = v;
27  smolar = v;
28  umolar = v;
29  Q = v;
30  }
31  bool is_valid() {
33  }
34 };
35 
37 {
38  bool stable;
39  CriticalState() : stable(false) {
40  fill(_HUGE);
41  }
42 };
43 
46 {
48  {
52  };
55 };
56 
62 //
63 // !! If you add a parameter, update the map in the corresponding CPP file !!
65 {
67 
68  // General parameters
87 
88  // Bulk properties
89  iT,
90  iP,
91  iQ,
92  iTau,
94 
95  // Molar specific thermodynamic properties
108 
109  // Mass specific thermodynamic properties
119 
120  // Transport properties
125 
126  // Derivative-based terms
131 
132  // Fundamental derivative of gas dynamics
134 
135  // Derivatives of the residual non-dimensionalized Helmholtz energy with respect to the EOS variables
139 
140  // Derivatives of the ideal-gas non-dimensionalized Helmholtz energy with respect to the EOS variables
146 
147  // Other functions and derivatives
152  iZ,
154 
155  // Accessors for incompressibles
159 
160  // Environmental parameters
164  iFH,
165  iHH,
166  iPH,
170 
171 };
172 // !! If you add a parameter, update the map in the corresponding CPP file !!
173 // !! Also update phase_lookup_string() in CoolProp.cpp !!
174 
176 enum phases
177 {
187 };
188 
191 {
192  i1,
199  i4c
200 };
201 
205 std::string get_parameter_information(int key, const std::string& info);
206 
208 parameters get_parameter_index(const std::string& param_name);
209 
213 bool is_valid_phase(const std::string& phase_name, phases& iOutput);
214 
216 phases get_phase_index(const std::string& param_name);
217 
221 bool is_valid_scheme(const std::string &scheme_name, schemes &iOutput);
222 
224 schemes get_scheme_index(const std::string &scheme_name);
225 
227 bool is_trivial_parameter(int key);
228 
230 bool is_valid_parameter(const std::string& name, parameters& iOutput);
231 
235 bool is_valid_first_derivative(const std::string& name, parameters& iOf, parameters& iWrt, parameters& iConstant);
236 
240 bool is_valid_first_saturation_derivative(const std::string& name, parameters& iOf, parameters& iWrt);
241 
245 bool is_valid_second_derivative(const std::string& name, parameters& iOf1, parameters& iWrt1, parameters& iConstant1, parameters& iWrt2,
246  parameters& iConstant2);
247 
249 std::string get_csv_parameter_list();
250 
253 {
258  IFRAC_PURE
259 };
260 
263 {
270 };
271 
272 // !! If you add a parameter, update the map in the corresponding CPP file !!
275 {
276  INPUT_PAIR_INVALID = 0, // Default (invalid) value
285 
287 
296 
305 
310 
317 };
318 // !! If you add or remove a parameter, update the map in the corresponding CPP file !!
319 
320 inline bool match_pair(parameters key1, parameters key2, parameters x1, parameters x2, bool& swap) {
321  swap = !(key1 == x1);
322  return ((key1 == x1 && key2 == x2) || (key2 == x1 && key1 == x2));
323 };
337 template <class T>
338 CoolProp::input_pairs generate_update_pair(parameters key1, T value1, parameters key2, T value2, T& out1, T& out2) throw() {
340  bool swap;
341 
342  if (match_pair(key1, key2, iQ, iT, swap)) {
343  pair = QT_INPUTS;
344  } else if (match_pair(key1, key2, iP, iQ, swap)) {
345  pair = PQ_INPUTS;
346  } else if (match_pair(key1, key2, iP, iT, swap)) {
347  pair = PT_INPUTS;
348  } else if (match_pair(key1, key2, iDmolar, iT, swap)) {
349  pair = DmolarT_INPUTS; // Molar density in mol/m^3, Temperature in K
350  } else if (match_pair(key1, key2, iDmass, iT, swap)) {
351  pair = DmassT_INPUTS; // Mass density in kg/m^3, Temperature in K
352  } else if (match_pair(key1, key2, iHmolar, iT, swap)) {
353  pair = HmolarT_INPUTS; // Enthalpy in J/mol, Temperature in K
354  } else if (match_pair(key1, key2, iHmass, iT, swap)) {
355  pair = HmassT_INPUTS; // Enthalpy in J/kg, Temperature in K
356  } else if (match_pair(key1, key2, iSmolar, iT, swap)) {
357  pair = SmolarT_INPUTS; // Entropy in J/mol/K, Temperature in K
358  } else if (match_pair(key1, key2, iSmass, iT, swap)) {
359  pair = SmassT_INPUTS; // Entropy in J/kg/K, Temperature in K
360  } else if (match_pair(key1, key2, iT, iUmolar, swap)) {
361  pair = TUmolar_INPUTS; // Temperature in K, Internal energy in J/mol
362  } else if (match_pair(key1, key2, iT, iUmass, swap)) {
363  pair = TUmass_INPUTS; // Temperature in K, Internal energy in J/kg
364  } else if (match_pair(key1, key2, iDmass, iHmass, swap)) {
365  pair = DmassHmass_INPUTS; // Mass density in kg/m^3, Enthalpy in J/kg
366  } else if (match_pair(key1, key2, iDmolar, iHmolar, swap)) {
367  pair = DmolarHmolar_INPUTS; // Molar density in mol/m^3, Enthalpy in J/mol
368  } else if (match_pair(key1, key2, iDmass, iSmass, swap)) {
369  pair = DmassSmass_INPUTS; // Mass density in kg/m^3, Entropy in J/kg/K
370  } else if (match_pair(key1, key2, iDmolar, iSmolar, swap)) {
371  pair = DmolarSmolar_INPUTS; // Molar density in mol/m^3, Entropy in J/mol/K
372  } else if (match_pair(key1, key2, iDmass, iUmass, swap)) {
373  pair = DmassUmass_INPUTS; // Mass density in kg/m^3, Internal energy in J/kg
374  } else if (match_pair(key1, key2, iDmolar, iUmolar, swap)) {
375  pair = DmolarUmolar_INPUTS; // Molar density in mol/m^3, Internal energy in J/mol
376  } else if (match_pair(key1, key2, iDmass, iP, swap)) {
377  pair = DmassP_INPUTS; // Mass density in kg/m^3, Pressure in Pa
378  } else if (match_pair(key1, key2, iDmolar, iP, swap)) {
379  pair = DmolarP_INPUTS; // Molar density in mol/m^3, Pressure in Pa
380  } else if (match_pair(key1, key2, iDmass, iQ, swap)) {
381  pair = DmassQ_INPUTS; // Mass density in kg/m^3, molar vapor quality
382  } else if (match_pair(key1, key2, iDmolar, iQ, swap)) {
383  pair = DmolarQ_INPUTS; // Molar density in mol/m^3, molar vapor quality
384  } else if (match_pair(key1, key2, iHmass, iP, swap)) {
385  pair = HmassP_INPUTS; // Enthalpy in J/kg, Pressure in Pa
386  } else if (match_pair(key1, key2, iHmolar, iP, swap)) {
387  pair = HmolarP_INPUTS; // Enthalpy in J/mol, Pressure in Pa
388  } else if (match_pair(key1, key2, iP, iSmass, swap)) {
389  pair = PSmass_INPUTS; // Pressure in Pa, Entropy in J/kg/K
390  } else if (match_pair(key1, key2, iP, iSmolar, swap)) {
391  pair = PSmolar_INPUTS; // Pressure in Pa, Entropy in J/mol/K
392  } else if (match_pair(key1, key2, iP, iUmass, swap)) {
393  pair = PUmass_INPUTS; // Pressure in Pa, Internal energy in J/kg
394  } else if (match_pair(key1, key2, iP, iUmolar, swap)) {
395  pair = PUmolar_INPUTS; // Pressure in Pa, Internal energy in J/mol
396  } else if (match_pair(key1, key2, iHmass, iSmass, swap)) {
397  pair = HmassSmass_INPUTS; // Enthalpy in J/kg, Entropy in J/kg/K
398  } else if (match_pair(key1, key2, iHmolar, iSmolar, swap)) {
399  pair = HmolarSmolar_INPUTS; // Enthalpy in J/mol, Entropy in J/mol/K
400  } else if (match_pair(key1, key2, iSmass, iUmass, swap)) {
401  pair = SmassUmass_INPUTS;
402  } else if (match_pair(key1, key2, iSmolar, iUmolar, swap)) {
403  pair = SmolarUmolar_INPUTS;
404  } else {
405  pair = INPUT_PAIR_INVALID;
406  return pair;
407  }
408 
409  if (!swap) {
410  out1 = value1;
411  out2 = value2;
412  } else {
413  out1 = value2;
414  out2 = value1;
415  }
416  return pair;
417 };
418 
420 input_pairs get_input_pair_index(const std::string& input_pair_name);
421 
423 const std::string& get_input_pair_short_desc(input_pairs pair);
424 
426 const std::string& get_input_pair_long_desc(input_pairs pair);
427 
430 
431 extern std::string get_mixture_binary_pair_data(const std::string& CAS1, const std::string& CAS2, const std::string& param);
432 extern void set_mixture_binary_pair_data(const std::string& CAS1, const std::string& CAS2, const std::string& param, const double val);
433 extern std::string get_mixture_binary_pair_pcsaft(const std::string& CAS1, const std::string& CAS2, const std::string& param);
434 extern void set_mixture_binary_pair_pcsaft(const std::string& CAS1, const std::string& CAS2, const std::string& param, const double val);
435 
437 // !! If you add a parameter, update the map in the corresponding CPP file !!
439 {
452 };
454 {
469 };
470 
472 void extract_backend_families(std::string backend_string, backend_families& f1, backend_families& f2);
473 void extract_backend_families_string(std::string backend_string, backend_families& f1, std::string& f2);
474 std::string get_backend_string(backends backend);
475 
476 #if !defined(NO_FMTLIB) && FMT_VERSION >= 90000
478 inline int format_as(parameters parameter) {
479  return fmt::underlying(parameter);
480 }
481 
482 inline int format_as(phases phase) {
483  return fmt::underlying(phase);
484 }
485 
486 inline int format_as(schemes scheme) {
487  return fmt::underlying(scheme);
488 }
489 
490 inline int format_as(composition_types type) {
491  return fmt::underlying(type);
492 }
493 
494 inline int format_as(fluid_types type) {
495  return fmt::underlying(type);
496 }
497 
498 inline int format_as(input_pairs pair) {
499  return fmt::underlying(pair);
500 }
501 
502 inline int format_as(backend_families family) {
503  return fmt::underlying(family);
504 }
505 
506 inline int format_as(backends backend) {
507  return fmt::underlying(backend);
508 }
509 #endif
510 
511 } /* namespace CoolProp */
512 #endif /* DATASTRUCTURES_H_ */