CoolProp 7.2.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>
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 !!
65{
67
68 // General parameters
87
88 // Bulk properties
94
95 // Molar specific thermodynamic properties
111
112 // Mass specific thermodynamic properties
125
126 // Transport properties
131
132 // Derivative-based terms
137
138 // Fundamental derivative of gas dynamics
140
141 // Derivatives of the residual non-dimensionalized Helmholtz energy with respect to the EOS variables
145
146 // Derivatives of the ideal-gas non-dimensionalized Helmholtz energy with respect to the EOS variables
152
153 // Other functions and derivatives
160
161 // Accessors for incompressibles
165
166 // Environmental parameters
176
178// !! If you add a parameter, update the map in the corresponding CPP file !!
179// !! Also update phase_lookup_string() in CoolProp.cpp !!
180
183{
193};
194
197{
205 i4c
207
211std::string get_parameter_information(int key, const std::string& info);
212
214parameters get_parameter_index(const std::string& param_name);
215
219bool is_valid_phase(const std::string& phase_name, phases& iOutput);
220
222phases get_phase_index(const std::string& param_name);
223
227bool is_valid_scheme(const std::string& scheme_name, schemes& iOutput);
228
230schemes get_scheme_index(const std::string& scheme_name);
231
233bool is_trivial_parameter(int key);
234
236bool is_valid_parameter(const std::string& name, parameters& iOutput);
237
241bool is_valid_first_derivative(const std::string& name, parameters& iOf, parameters& iWrt, parameters& iConstant);
242
246bool is_valid_first_saturation_derivative(const std::string& name, parameters& iOf, parameters& iWrt);
247
251bool is_valid_second_derivative(const std::string& name, parameters& iOf1, parameters& iWrt1, parameters& iConstant1, parameters& iWrt2,
252 parameters& iConstant2);
253
255std::string get_csv_parameter_list();
256
259{
266
269{
277
278// !! If you add a parameter, update the map in the corresponding CPP file !!
281{
282 INPUT_PAIR_INVALID = 0, // Default (invalid) value
291
293
302
311
316
323};
324// !! If you add or remove a parameter, update the map in the corresponding CPP file !!
325
326inline bool match_pair(parameters key1, parameters key2, parameters x1, parameters x2, bool& swap) {
327 swap = !(key1 == x1);
328 return ((key1 == x1 && key2 == x2) || (key2 == x1 && key1 == x2));
329};
343template <class T>
344CoolProp::input_pairs generate_update_pair(parameters key1, T value1, parameters key2, T value2, T& out1, T& out2) throw() {
346 bool swap;
347
348 if (match_pair(key1, key2, iQ, iT, swap)) {
349 pair = QT_INPUTS;
350 } else if (match_pair(key1, key2, iP, iQ, swap)) {
351 pair = PQ_INPUTS;
352 } else if (match_pair(key1, key2, iP, iT, swap)) {
353 pair = PT_INPUTS;
354 } else if (match_pair(key1, key2, iDmolar, iT, swap)) {
355 pair = DmolarT_INPUTS; // Molar density in mol/m^3, Temperature in K
356 } else if (match_pair(key1, key2, iDmass, iT, swap)) {
357 pair = DmassT_INPUTS; // Mass density in kg/m^3, Temperature in K
358 } else if (match_pair(key1, key2, iHmolar, iT, swap)) {
359 pair = HmolarT_INPUTS; // Enthalpy in J/mol, Temperature in K
360 } else if (match_pair(key1, key2, iHmass, iT, swap)) {
361 pair = HmassT_INPUTS; // Enthalpy in J/kg, Temperature in K
362 } else if (match_pair(key1, key2, iSmolar, iT, swap)) {
363 pair = SmolarT_INPUTS; // Entropy in J/mol/K, Temperature in K
364 } else if (match_pair(key1, key2, iSmass, iT, swap)) {
365 pair = SmassT_INPUTS; // Entropy in J/kg/K, Temperature in K
366 } else if (match_pair(key1, key2, iT, iUmolar, swap)) {
367 pair = TUmolar_INPUTS; // Temperature in K, Internal energy in J/mol
368 } else if (match_pair(key1, key2, iT, iUmass, swap)) {
369 pair = TUmass_INPUTS; // Temperature in K, Internal energy in J/kg
370 } else if (match_pair(key1, key2, iDmass, iHmass, swap)) {
371 pair = DmassHmass_INPUTS; // Mass density in kg/m^3, Enthalpy in J/kg
372 } else if (match_pair(key1, key2, iDmolar, iHmolar, swap)) {
373 pair = DmolarHmolar_INPUTS; // Molar density in mol/m^3, Enthalpy in J/mol
374 } else if (match_pair(key1, key2, iDmass, iSmass, swap)) {
375 pair = DmassSmass_INPUTS; // Mass density in kg/m^3, Entropy in J/kg/K
376 } else if (match_pair(key1, key2, iDmolar, iSmolar, swap)) {
377 pair = DmolarSmolar_INPUTS; // Molar density in mol/m^3, Entropy in J/mol/K
378 } else if (match_pair(key1, key2, iDmass, iUmass, swap)) {
379 pair = DmassUmass_INPUTS; // Mass density in kg/m^3, Internal energy in J/kg
380 } else if (match_pair(key1, key2, iDmolar, iUmolar, swap)) {
381 pair = DmolarUmolar_INPUTS; // Molar density in mol/m^3, Internal energy in J/mol
382 } else if (match_pair(key1, key2, iDmass, iP, swap)) {
383 pair = DmassP_INPUTS; // Mass density in kg/m^3, Pressure in Pa
384 } else if (match_pair(key1, key2, iDmolar, iP, swap)) {
385 pair = DmolarP_INPUTS; // Molar density in mol/m^3, Pressure in Pa
386 } else if (match_pair(key1, key2, iDmass, iQ, swap)) {
387 pair = DmassQ_INPUTS; // Mass density in kg/m^3, molar vapor quality
388 } else if (match_pair(key1, key2, iDmolar, iQ, swap)) {
389 pair = DmolarQ_INPUTS; // Molar density in mol/m^3, molar vapor quality
390 } else if (match_pair(key1, key2, iHmass, iP, swap)) {
391 pair = HmassP_INPUTS; // Enthalpy in J/kg, Pressure in Pa
392 } else if (match_pair(key1, key2, iHmolar, iP, swap)) {
393 pair = HmolarP_INPUTS; // Enthalpy in J/mol, Pressure in Pa
394 } else if (match_pair(key1, key2, iP, iSmass, swap)) {
395 pair = PSmass_INPUTS; // Pressure in Pa, Entropy in J/kg/K
396 } else if (match_pair(key1, key2, iP, iSmolar, swap)) {
397 pair = PSmolar_INPUTS; // Pressure in Pa, Entropy in J/mol/K
398 } else if (match_pair(key1, key2, iP, iUmass, swap)) {
399 pair = PUmass_INPUTS; // Pressure in Pa, Internal energy in J/kg
400 } else if (match_pair(key1, key2, iP, iUmolar, swap)) {
401 pair = PUmolar_INPUTS; // Pressure in Pa, Internal energy in J/mol
402 } else if (match_pair(key1, key2, iHmass, iSmass, swap)) {
403 pair = HmassSmass_INPUTS; // Enthalpy in J/kg, Entropy in J/kg/K
404 } else if (match_pair(key1, key2, iHmolar, iSmolar, swap)) {
405 pair = HmolarSmolar_INPUTS; // Enthalpy in J/mol, Entropy in J/mol/K
406 } else if (match_pair(key1, key2, iSmass, iUmass, swap)) {
407 pair = SmassUmass_INPUTS;
408 } else if (match_pair(key1, key2, iSmolar, iUmolar, swap)) {
409 pair = SmolarUmolar_INPUTS;
410 } else {
411 pair = INPUT_PAIR_INVALID;
412 return pair;
413 }
414
415 if (!swap) {
416 out1 = value1;
417 out2 = value2;
418 } else {
419 out1 = value2;
420 out2 = value1;
421 }
422 return pair;
423};
424
426input_pairs get_input_pair_index(const std::string& input_pair_name);
427
429const std::string& get_input_pair_short_desc(input_pairs pair);
430
432const std::string& get_input_pair_long_desc(input_pairs pair);
433
436
437extern void apply_simple_mixing_rule(const std::string& identifier1, const std::string& identifier2, const std::string& rule);
438extern void set_interaction_parameters(const std::string& string_data);
439
440extern std::string get_mixture_binary_pair_data(const std::string& CAS1, const std::string& CAS2, const std::string& param);
441extern void set_mixture_binary_pair_data(const std::string& CAS1, const std::string& CAS2, const std::string& param, const double val);
442extern std::string get_mixture_binary_pair_pcsaft(const std::string& CAS1, const std::string& CAS2, const std::string& param);
443extern void set_mixture_binary_pair_pcsaft(const std::string& CAS1, const std::string& CAS2, const std::string& param, const double val);
444
446// !! If you add a parameter, update the map in the corresponding CPP file !!
448{
463{
479
481void extract_backend_families(std::string backend_string, backend_families& f1, backend_families& f2);
482void extract_backend_families_string(std::string backend_string, backend_families& f1, std::string& f2);
483std::string get_backend_string(backends backend);
484
485#if !defined(NO_FMTLIB) && FMT_VERSION >= 90000
487inline int format_as(parameters parameter) {
488 return fmt::underlying(parameter);
489}
490
491inline int format_as(phases phase) {
492 return fmt::underlying(phase);
493}
494
495inline int format_as(schemes scheme) {
496 return fmt::underlying(scheme);
497}
498
499inline int format_as(composition_types type) {
500 return fmt::underlying(type);
501}
502
503inline int format_as(fluid_types type) {
504 return fmt::underlying(type);
505}
506
507inline int format_as(input_pairs pair) {
508 return fmt::underlying(pair);
509}
510
511inline int format_as(backend_families family) {
512 return fmt::underlying(family);
513}
514
515inline int format_as(backends backend) {
516 return fmt::underlying(backend);
517}
518#endif
519
520} /* namespace CoolProp */
521#endif /* DATASTRUCTURES_H_ */