CoolProp 8.0.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
12#include "CoolProp/Exceptions.h"
13#include <string_view>
14namespace CoolProp {
15
17{
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 !!
64enum parameters : int
65{
67
68 // General parameters
87
88 // Bulk properties
95
96 // Molar specific thermodynamic properties
112
113 // Mass specific thermodynamic properties
126
127 // Transport properties
132
133 // Derivative-based terms
138
139 // Fundamental derivative of gas dynamics
141
142 // Derivatives of the residual non-dimensionalized Helmholtz energy with respect to the EOS variables
146
147 // Derivatives of the ideal-gas non-dimensionalized Helmholtz energy with respect to the EOS variables
153
154 // Other functions and derivatives
161
162 // Accessors for incompressibles
166
167 // Environmental parameters
177
179// !! If you add a parameter, update the map in the corresponding CPP file !!
180// !! Also update phase_lookup_string() in CoolProp.cpp !!
181
183enum phases : int
184{
194};
195
198{
206
209{
217 i4c
219
223[[nodiscard]] std::string get_parameter_information(int key, std::string_view info);
224
226[[nodiscard]] parameters get_parameter_index(const std::string& param_name);
227
231bool is_valid_phase(const std::string& phase_name, phases& iOutput);
232
234phases get_phase_index(const std::string& param_name);
235
239bool is_valid_scheme(const std::string& scheme_name, schemes& iOutput);
240
242schemes get_scheme_index(const std::string& scheme_name);
243
245bool is_trivial_parameter(int key);
246
248bool is_valid_parameter(const std::string& name, parameters& iOutput);
249
253bool is_valid_first_derivative(const std::string& name, parameters& iOf, parameters& iWrt, parameters& iConstant);
254
258bool is_valid_first_saturation_derivative(const std::string& name, parameters& iOf, parameters& iWrt);
259
263bool is_valid_second_derivative(const std::string& name, parameters& iOf1, parameters& iWrt1, parameters& iConstant1, parameters& iWrt2,
264 parameters& iConstant2);
265
267std::string get_csv_parameter_list();
268
271{
278
281{
289
290// !! If you add a parameter, update the map in the corresponding CPP file !!
292enum input_pairs : int
293{
294 INPUT_PAIR_INVALID = 0, // Default (invalid) value
311
313
322
331
336
343};
344// !! If you add or remove a parameter, update the map in the corresponding CPP file !!
345
346inline bool match_pair(parameters key1, parameters key2, parameters x1, parameters x2, bool& swap) {
347 swap = !(key1 == x1);
348 return ((key1 == x1 && key2 == x2) || (key2 == x1 && key1 == x2));
349};
350
353 switch (p) {
354 case QmassT_INPUTS:
355 case PQmass_INPUTS:
362 return true;
363 default:
364 return false;
365 }
366}
380template <class T>
381[[nodiscard]] CoolProp::input_pairs generate_update_pair(parameters key1, const T& value1, parameters key2, const T& value2, T& out1,
382 T& out2) noexcept {
384 bool swap;
385
386 if (match_pair(key1, key2, iQ, iT, swap)) {
387 pair = QT_INPUTS;
388 } else if (match_pair(key1, key2, iQmass, iT, swap)) {
389 pair = QmassT_INPUTS;
390 } else if (match_pair(key1, key2, iP, iQ, swap)) {
391 pair = PQ_INPUTS;
392 } else if (match_pair(key1, key2, iP, iQmass, swap)) {
393 pair = PQmass_INPUTS;
394 } else if (match_pair(key1, key2, iP, iT, swap)) {
395 pair = PT_INPUTS;
396 } else if (match_pair(key1, key2, iDmolar, iT, swap)) {
397 pair = DmolarT_INPUTS; // Molar density in mol/m^3, Temperature in K
398 } else if (match_pair(key1, key2, iDmass, iT, swap)) {
399 pair = DmassT_INPUTS; // Mass density in kg/m^3, Temperature in K
400 } else if (match_pair(key1, key2, iHmolar, iT, swap)) {
401 pair = HmolarT_INPUTS; // Enthalpy in J/mol, Temperature in K
402 } else if (match_pair(key1, key2, iHmass, iT, swap)) {
403 pair = HmassT_INPUTS; // Enthalpy in J/kg, Temperature in K
404 } else if (match_pair(key1, key2, iSmolar, iT, swap)) {
405 pair = SmolarT_INPUTS; // Entropy in J/mol/K, Temperature in K
406 } else if (match_pair(key1, key2, iSmass, iT, swap)) {
407 pair = SmassT_INPUTS; // Entropy in J/kg/K, Temperature in K
408 } else if (match_pair(key1, key2, iT, iUmolar, swap)) {
409 pair = TUmolar_INPUTS; // Temperature in K, Internal energy in J/mol
410 } else if (match_pair(key1, key2, iT, iUmass, swap)) {
411 pair = TUmass_INPUTS; // Temperature in K, Internal energy in J/kg
412 } else if (match_pair(key1, key2, iDmass, iHmass, swap)) {
413 pair = DmassHmass_INPUTS; // Mass density in kg/m^3, Enthalpy in J/kg
414 } else if (match_pair(key1, key2, iDmolar, iHmolar, swap)) {
415 pair = DmolarHmolar_INPUTS; // Molar density in mol/m^3, Enthalpy in J/mol
416 } else if (match_pair(key1, key2, iDmass, iSmass, swap)) {
417 pair = DmassSmass_INPUTS; // Mass density in kg/m^3, Entropy in J/kg/K
418 } else if (match_pair(key1, key2, iDmolar, iSmolar, swap)) {
419 pair = DmolarSmolar_INPUTS; // Molar density in mol/m^3, Entropy in J/mol/K
420 } else if (match_pair(key1, key2, iDmass, iUmass, swap)) {
421 pair = DmassUmass_INPUTS; // Mass density in kg/m^3, Internal energy in J/kg
422 } else if (match_pair(key1, key2, iDmolar, iUmolar, swap)) {
423 pair = DmolarUmolar_INPUTS; // Molar density in mol/m^3, Internal energy in J/mol
424 } else if (match_pair(key1, key2, iDmass, iP, swap)) {
425 pair = DmassP_INPUTS; // Mass density in kg/m^3, Pressure in Pa
426 } else if (match_pair(key1, key2, iDmolar, iP, swap)) {
427 pair = DmolarP_INPUTS; // Molar density in mol/m^3, Pressure in Pa
428 } else if (match_pair(key1, key2, iDmass, iQ, swap)) {
429 pair = DmassQ_INPUTS; // Mass density in kg/m^3, molar vapor quality
430 } else if (match_pair(key1, key2, iDmass, iQmass, swap)) {
431 pair = DmassQmass_INPUTS; // Mass density in kg/m^3, mass-basis vapor quality
432 } else if (match_pair(key1, key2, iDmolar, iQ, swap)) {
433 pair = DmolarQ_INPUTS; // Molar density in mol/m^3, molar vapor quality
434 } else if (match_pair(key1, key2, iDmolar, iQmass, swap)) {
435 pair = DmolarQmass_INPUTS; // Molar density in mol/m^3, mass-basis vapor quality
436 } else if (match_pair(key1, key2, iHmass, iP, swap)) {
437 pair = HmassP_INPUTS; // Enthalpy in J/kg, Pressure in Pa
438 } else if (match_pair(key1, key2, iHmolar, iP, swap)) {
439 pair = HmolarP_INPUTS; // Enthalpy in J/mol, Pressure in Pa
440 } else if (match_pair(key1, key2, iP, iSmass, swap)) {
441 pair = PSmass_INPUTS; // Pressure in Pa, Entropy in J/kg/K
442 } else if (match_pair(key1, key2, iP, iSmolar, swap)) {
443 pair = PSmolar_INPUTS; // Pressure in Pa, Entropy in J/mol/K
444 } else if (match_pair(key1, key2, iP, iUmass, swap)) {
445 pair = PUmass_INPUTS; // Pressure in Pa, Internal energy in J/kg
446 } else if (match_pair(key1, key2, iP, iUmolar, swap)) {
447 pair = PUmolar_INPUTS; // Pressure in Pa, Internal energy in J/mol
448 } else if (match_pair(key1, key2, iHmass, iSmass, swap)) {
449 pair = HmassSmass_INPUTS; // Enthalpy in J/kg, Entropy in J/kg/K
450 } else if (match_pair(key1, key2, iHmolar, iSmolar, swap)) {
451 pair = HmolarSmolar_INPUTS; // Enthalpy in J/mol, Entropy in J/mol/K
452 } else if (match_pair(key1, key2, iSmass, iUmass, swap)) {
453 pair = SmassUmass_INPUTS;
454 } else if (match_pair(key1, key2, iSmolar, iUmolar, swap)) {
455 pair = SmolarUmolar_INPUTS;
456 } else {
457 pair = INPUT_PAIR_INVALID;
458 return pair;
459 }
460
461 if (!swap) {
462 out1 = value1;
463 out2 = value2;
464 } else {
465 out1 = value2;
466 out2 = value1;
467 }
468 return pair;
469};
470
472input_pairs get_input_pair_index(const std::string& input_pair_name);
473
475const std::string& get_input_pair_short_desc(input_pairs pair);
476
478const std::string& get_input_pair_long_desc(input_pairs pair);
479
482
483extern void apply_simple_mixing_rule(const std::string& identifier1, const std::string& identifier2, const std::string& rule);
484extern void set_interaction_parameters(const std::string& string_data);
485
486extern std::string get_mixture_binary_pair_data(const std::string& CAS1, const std::string& CAS2, const std::string& param);
487extern void set_mixture_binary_pair_data(const std::string& CAS1, const std::string& CAS2, const std::string& param, const double val);
488extern std::string get_mixture_binary_pair_pcsaft(const std::string& CAS1, const std::string& CAS2, const std::string& param);
489extern void set_mixture_binary_pair_pcsaft(const std::string& CAS1, const std::string& CAS2, const std::string& param, const double val);
490
492// !! If you add a parameter, update the map in the corresponding CPP file !!
494{
509enum backends : int
510{
527
529void extract_backend_families(const std::string& backend_string, backend_families& f1, backend_families& f2);
530void extract_backend_families_string(std::string backend_string, backend_families& f1, std::string& f2);
531std::string get_backend_string(backends backend);
532
533#if !defined(NO_FMTLIB) && FMT_VERSION >= 90000
535inline int format_as(parameters parameter) {
536 return fmt::underlying(parameter);
537}
538
539inline int format_as(phases phase) {
540 return fmt::underlying(phase);
541}
542
543inline int format_as(schemes scheme) {
544 return fmt::underlying(scheme);
545}
546
547inline int format_as(composition_types type) {
548 return fmt::underlying(type);
549}
550
551inline int format_as(fluid_types type) {
552 return fmt::underlying(type);
553}
554
555inline int format_as(input_pairs pair) {
556 return fmt::underlying(pair);
557}
558
559inline int format_as(backend_families family) {
560 return fmt::underlying(family);
561}
562
563inline int format_as(backends backend) {
564 return fmt::underlying(backend);
565}
566#endif
567
568} /* namespace CoolProp */
569#endif /* DATASTRUCTURES_H_ */