20 {
iT,
"T",
"IO",
"K",
"Temperature",
false},
21 {
iP,
"P",
"IO",
"Pa",
"Pressure",
false},
22 {
iDmolar,
"Dmolar",
"IO",
"mol/m^3",
"Molar density",
false},
23 {
iHmolar,
"Hmolar",
"IO",
"J/mol",
"Molar specific enthalpy",
false},
24 {
iSmolar,
"Smolar",
"IO",
"J/mol/K",
"Molar specific entropy",
false},
25 {
iUmolar,
"Umolar",
"IO",
"J/mol",
"Molar specific internal energy",
false},
26 {
iGmolar,
"Gmolar",
"O",
"J/mol",
"Molar specific Gibbs energy",
false},
27 {
iHelmholtzmolar,
"Helmholtzmolar",
"O",
"J/mol",
"Molar specific Helmholtz energy",
false},
28 {
iDmass,
"Dmass",
"IO",
"kg/m^3",
"Mass density",
false},
29 {
iHmass,
"Hmass",
"IO",
"J/kg",
"Mass specific enthalpy",
false},
30 {
iSmass,
"Smass",
"IO",
"J/kg/K",
"Mass specific entropy",
false},
31 {
iUmass,
"Umass",
"IO",
"J/kg",
"Mass specific internal energy",
false},
32 {
iGmass,
"Gmass",
"O",
"J/kg",
"Mass specific Gibbs energy",
false},
33 {
iHelmholtzmass,
"Helmholtzmass",
"O",
"J/kg",
"Mass specific Helmholtz energy",
false},
34 {
iQ,
"Q",
"IO",
"mol/mol",
"Molar vapor quality",
false},
35 {
iDelta,
"Delta",
"IO",
"-",
"Reduced density (rho/rhoc)",
false},
36 {
iTau,
"Tau",
"IO",
"-",
"Reciprocal reduced temperature (Tc/T)",
false},
38 {
iCpmolar,
"Cpmolar",
"O",
"J/mol/K",
"Molar specific constant pressure specific heat",
false},
39 {
iCpmass,
"Cpmass",
"O",
"J/kg/K",
"Mass specific constant pressure specific heat",
false},
40 {
iCvmolar,
"Cvmolar",
"O",
"J/mol/K",
"Molar specific constant volume specific heat",
false},
41 {
iCvmass,
"Cvmass",
"O",
"J/kg/K",
"Mass specific constant volume specific heat",
false},
42 {
iCp0molar,
"Cp0molar",
"O",
"J/mol/K",
"Ideal gas molar specific constant pressure specific heat",
false},
43 {
iCp0mass,
"Cp0mass",
"O",
"J/kg/K",
"Ideal gas mass specific constant pressure specific heat",
false},
44 {
iHmolar_residual,
"Hmolar_residual",
"O",
"J/mol/K",
"Residual molar enthalpy",
false},
45 {
iSmolar_residual,
"Smolar_residual",
"O",
"J/mol/K",
"Residual molar entropy (sr/R = s(T,rho) - s^0(T,rho))",
false},
46 {
iGmolar_residual,
"Gmolar_residual",
"O",
"J/mol/K",
"Residual molar Gibbs energy",
false},
47 {
iGWP20,
"GWP20",
"O",
"-",
"20-year global warming potential",
true},
48 {
iGWP100,
"GWP100",
"O",
"-",
"100-year global warming potential",
true},
49 {
iGWP500,
"GWP500",
"O",
"-",
"500-year global warming potential",
true},
50 {
iFH,
"FH",
"O",
"-",
"Flammability hazard",
true},
51 {
iHH,
"HH",
"O",
"-",
"Health hazard",
true},
52 {
iPH,
"PH",
"O",
"-",
"Physical hazard",
true},
53 {
iODP,
"ODP",
"O",
"-",
"Ozone depletion potential",
true},
54 {
iBvirial,
"Bvirial",
"O",
"-",
"Second virial coefficient",
false},
55 {
iCvirial,
"Cvirial",
"O",
"-",
"Third virial coefficient",
false},
56 {
idBvirial_dT,
"dBvirial_dT",
"O",
"-",
"Derivative of second virial coefficient with respect to T",
false},
57 {
idCvirial_dT,
"dCvirial_dT",
"O",
"-",
"Derivative of third virial coefficient with respect to T",
false},
58 {
igas_constant,
"gas_constant",
"O",
"J/mol/K",
"Molar gas constant",
true},
59 {
imolar_mass,
"molar_mass",
"O",
"kg/mol",
"Molar mass",
true},
61 {
idipole_moment,
"dipole_moment",
"O",
"C-m",
"Dipole moment",
true},
62 {
irhomass_reducing,
"rhomass_reducing",
"O",
"kg/m^3",
"Mass density at reducing point",
true},
63 {
irhomolar_reducing,
"rhomolar_reducing",
"O",
"mol/m^3",
"Molar density at reducing point",
true},
64 {
irhomolar_critical,
"rhomolar_critical",
"O",
"mol/m^3",
"Molar density at critical point",
true},
65 {
irhomass_critical,
"rhomass_critical",
"O",
"kg/m^3",
"Mass density at critical point",
true},
66 {
iT_reducing,
"T_reducing",
"O",
"K",
"Temperature at the reducing point",
true},
67 {
iT_critical,
"T_critical",
"O",
"K",
"Temperature at the critical point",
true},
68 {
iT_triple,
"T_triple",
"O",
"K",
"Temperature at the triple point",
true},
69 {
iT_max,
"T_max",
"O",
"K",
"Maximum temperature limit",
true},
70 {
iT_min,
"T_min",
"O",
"K",
"Minimum temperature limit",
true},
71 {
iP_min,
"P_min",
"O",
"Pa",
"Minimum pressure limit",
true},
72 {
iP_max,
"P_max",
"O",
"Pa",
"Maximum pressure limit",
true},
73 {
iP_critical,
"p_critical",
"O",
"Pa",
"Pressure at the critical point",
true},
74 {
iP_reducing,
"p_reducing",
"O",
"Pa",
"Pressure at the reducing point",
true},
75 {
iP_triple,
"p_triple",
"O",
"Pa",
"Pressure at the triple point (pure only)",
true},
76 {
ifraction_min,
"fraction_min",
"O",
"-",
"Fraction (mole, mass, volume) minimum value for incompressible solutions",
true},
77 {
ifraction_max,
"fraction_max",
"O",
"-",
"Fraction (mole, mass, volume) maximum value for incompressible solutions",
true},
78 {
iT_freeze,
"T_freeze",
"O",
"K",
"Freezing temperature for incompressible solutions",
true},
80 {
ispeed_sound,
"speed_of_sound",
"O",
"m/s",
"Speed of sound",
false},
81 {
iviscosity,
"viscosity",
"O",
"Pa-s",
"Viscosity",
false},
82 {
iconductivity,
"conductivity",
"O",
"W/m/K",
"Thermal conductivity",
false},
84 {
iPrandtl,
"Prandtl",
"O",
"-",
"Prandtl number",
false},
89 {
iZ,
"Z",
"O",
"-",
"Compressibility factor",
false},
91 {
iPIP,
"PIP",
"O",
"-",
"Phase identification parameter",
false},
93 {
ialphar,
"alphar",
"O",
"-",
"Residual Helmholtz energy",
false},
94 {
idalphar_dtau_constdelta,
"dalphar_dtau_constdelta",
"O",
"-",
"Derivative of residual Helmholtz energy with tau",
false},
95 {
idalphar_ddelta_consttau,
"dalphar_ddelta_consttau",
"O",
"-",
"Derivative of residual Helmholtz energy with delta",
false},
97 {
ialpha0,
"alpha0",
"O",
"-",
"Ideal Helmholtz energy",
false},
98 {
idalpha0_dtau_constdelta,
"dalpha0_dtau_constdelta",
"O",
"-",
"Derivative of ideal Helmholtz energy with tau",
false},
99 {
idalpha0_ddelta_consttau,
"dalpha0_ddelta_consttau",
"O",
"-",
"Derivative of ideal Helmholtz energy with delta",
false},
100 {
id2alpha0_ddelta2_consttau,
"d2alpha0_ddelta2_consttau",
"O",
"-",
"Second derivative of ideal Helmholtz energy with delta",
false},
101 {
id3alpha0_ddelta3_consttau,
"d3alpha0_ddelta3_consttau",
"O",
"-",
"Third derivative of ideal Helmholtz energy with delta",
false},
103 {
iPhase,
"Phase",
"O",
"-",
"Phase index as a float",
false},
116 short_desc_map.insert(std::pair<int, std::string>(el->key, el->short_desc));
117 IO_map.insert(std::pair<int, std::string>(el->key, el->IO));
118 units_map.insert(std::pair<int, std::string>(el->key, el->units));
119 description_map.insert(std::pair<int, std::string>(el->key, el->description));
120 index_map_insert(el->short_desc, el->key);
121 trivial_map.insert(std::pair<int, bool>(el->key, el->trivial));
124 index_map_insert(
"D",
iDmass);
125 index_map_insert(
"H",
iHmass);
127 index_map_insert(
"S",
iSmass);
128 index_map_insert(
"U",
iUmass);
129 index_map_insert(
"C",
iCpmass);
130 index_map_insert(
"O",
iCvmass);
131 index_map_insert(
"G",
iGmass);
140 index_map_insert(
"Tmin",
iT_min);
141 index_map_insert(
"Tmax",
iT_max);
142 index_map_insert(
"pmax",
iP_max);
143 index_map_insert(
"pmin",
iP_min);
151 void index_map_insert(
const std::string& desc,
int key) {
152 index_map.insert(std::pair<std::string, int>(desc, key));
169 auto it = parameter_information.trivial_map.find(key);
170 if (it != parameter_information.trivial_map.end()) {
177 const std::map<int, std::string>* M;
180 if (!info.compare(
"IO")) {
181 M = &(parameter_information.IO_map);
182 }
else if (!info.compare(
"short")) {
183 M = &(parameter_information.short_desc_map);
184 }
else if (!info.compare(
"long")) {
185 M = &(parameter_information.description_map);
186 }
else if (!info.compare(
"units")) {
187 M = &(parameter_information.units_map);
189 throw ValueError(
format(
"Bad info string [%s] to get_parameter_information", info.c_str()));
192 auto it = M->find(key);
193 if (it != M->end()) {
196 throw ValueError(
format(
"Unable to match the key [%d] in get_parameter_information for info [%s]", key, info.c_str()));
202 std::vector<std::string> strings;
203 for (std::map<std::string, int>::const_iterator it = parameter_information.index_map.begin(); it != parameter_information.index_map.end(); ++it) {
204 strings.push_back(it->first);
211 std::map<std::string, int>::const_iterator it = parameter_information.index_map.find(param_name);
213 if (it != parameter_information.index_map.end()) {
215 iOutput =
static_cast<parameters>(it->second);
224 std::cout <<
format(
"is_valid_first_derivative(%s)", name.c_str());
230 std::vector<std::string> split_at_bar =
strsplit(name,
'|');
231 if (split_at_bar.size() != 2) {
235 std::vector<std::string> split_at_slash =
strsplit(split_at_bar[0],
'/');
236 if (split_at_slash.size() != 2) {
240 std::size_t i0 = split_at_slash[0].find(
"(");
241 std::size_t
i1 = split_at_slash[0].find(
")", i0);
242 if (!((i0 > 0) && (i0 != std::string::npos) && (
i1 > (i0 + 1)) && (
i1 != std::string::npos))) {
245 std::string num = split_at_slash[0].substr(i0 + 1,
i1 - i0 - 1);
247 i0 = split_at_slash[1].find(
"(");
248 i1 = split_at_slash[1].find(
")", i0);
249 if (!((i0 > 0) && (i0 != std::string::npos) && (
i1 > (i0 + 1)) && (
i1 != std::string::npos))) {
252 std::string den = split_at_slash[1].substr(i0 + 1,
i1 - i0 - 1);
258 iConstant = Constant;
267 std::cout <<
format(
"is_valid_first_saturation_derivative(%s)", name.c_str());
273 std::vector<std::string> split_at_bar =
strsplit(name,
'|');
274 if (split_at_bar.size() != 2) {
278 std::vector<std::string> split_at_slash =
strsplit(split_at_bar[0],
'/');
279 if (split_at_slash.size() != 2) {
283 std::size_t i0 = split_at_slash[0].find(
"(");
284 std::size_t
i1 = split_at_slash[0].find(
")", i0);
285 if (!((i0 > 0) && (i0 != std::string::npos) && (
i1 > (i0 + 1)) && (
i1 != std::string::npos))) {
288 std::string num = split_at_slash[0].substr(i0 + 1,
i1 - i0 - 1);
290 i0 = split_at_slash[1].find(
"(");
291 i1 = split_at_slash[1].find(
")", i0);
292 if (!((i0 > 0) && (i0 != std::string::npos) && (
i1 > (i0 + 1)) && (
i1 != std::string::npos))) {
295 std::string den = split_at_slash[1].substr(i0 + 1,
i1 - i0 - 1);
310 std::cout <<
format(
"is_valid_second_derivative(%s)", name.c_str());
314 std::size_t i = name.rfind(
'|');
315 if ((i == 0) || (i == std::string::npos)) {
318 std::string constant2 = name.substr(i + 1);
322 std::string left_of_bar = name.substr(0, i);
324 i = left_of_bar.rfind(
'/');
325 if ((i == 0) || (i == std::string::npos)) {
328 std::string left_of_slash = left_of_bar.substr(0, i);
329 std::string right_of_slash = left_of_bar.substr(i + 1);
331 i = left_of_slash.find(
"(");
332 std::size_t
i1 = left_of_slash.rfind(
")");
333 if (!((i > 0) && (i != std::string::npos) && (
i1 > (i + 1)) && (
i1 != std::string::npos))) {
336 std::string num = left_of_slash.substr(i + 1,
i1 - i - 1);
341 i = right_of_slash.find(
"(");
342 i1 = right_of_slash.rfind(
")");
343 if (!((i > 0) && (i != std::string::npos) && (
i1 > (i + 1)) && (
i1 != std::string::npos))) {
346 std::string den = right_of_slash.substr(i + 1,
i1 - i - 1);
381 short_desc_map.insert(std::pair<phases, std::string>(el->key, el->short_desc));
382 long_desc_map.insert(std::pair<phases, std::string>(el->key, el->long_desc));
383 index_map.insert(std::pair<std::string, phases>(el->short_desc, el->key));
400 auto iter = coolprop_information.short_desc_map.find(phase);
401 if (iter != coolprop_information.short_desc_map.end()) {
404 throw ValueError(
"Cannot find the short phase description.");
409 std::map<std::string, phases>::const_iterator it = phase_information.index_map.find(phase_name);
411 if (it != phase_information.index_map.end()) {
413 iOutput =
static_cast<phases>(it->second);
425 throw ValueError(
format(
"Your input name [%s] is not valid in get_phase_index (names are case sensitive)", param_name.c_str()));
455 short_desc_map.insert(std::pair<schemes, std::string>(el->key, el->short_desc));
456 index_map.insert(std::pair<std::string, schemes>(el->short_desc, el->key));
473 auto it = coolprop_information.short_desc_map.find(scheme);
474 if (it != coolprop_information.short_desc_map.end()) {
477 throw ValueError(
"Cannot find the short scheme description.");
482 auto it = scheme_information.index_map.find(scheme_name);
484 if (it != scheme_information.index_map.end()){
486 iOutput =
static_cast<schemes>(it->second);
500 throw ValueError(
format(
"Your input name [%s] is not valid in get_scheme_index (names are case sensitive)",param_name.c_str()));
509 throw ValueError(
format(
"Your input name [%s] is not valid in get_parameter_index (names are case sensitive)", param_name.c_str()));
520 {
QT_INPUTS,
"QT_INPUTS",
"Molar quality, Temperature in K"},
521 {
QSmolar_INPUTS,
"QS_INPUTS",
"Molar quality, Entropy in J/mol/K"},
522 {
QSmass_INPUTS,
"QS_INPUTS",
"Molar quality, Entropy in J/kg/K"},
523 {
HmolarQ_INPUTS,
"HQ_INPUTS",
"Enthalpy in J/mol, Molar quality"},
524 {
HmassQ_INPUTS,
"HQ_INPUTS",
"Enthalpy in J/kg, Molar quality"},
525 {
DmassQ_INPUTS,
"DmassQ_INPUTS",
"Molar density kg/m^3, Molar quality"},
526 {
DmolarQ_INPUTS,
"DmolarQ_INPUTS",
"Molar density in mol/m^3, Molar quality"},
528 {
PQ_INPUTS,
"PQ_INPUTS",
"Pressure in Pa, Molar quality"},
530 {
PT_INPUTS,
"PT_INPUTS",
"Pressure in Pa, Temperature in K"},
532 {
DmassT_INPUTS,
"DmassT_INPUTS",
"Mass density in kg/m^3, Temperature in K"},
533 {
DmolarT_INPUTS,
"DmolarT_INPUTS",
"Molar density in mol/m^3, Temperature in K"},
534 {
HmassT_INPUTS,
"HmassT_INPUTS",
"Enthalpy in J/kg, Temperature in K"},
535 {
HmolarT_INPUTS,
"HmolarT_INPUTS",
"Enthalpy in J/mol, Temperature in K"},
536 {
SmassT_INPUTS,
"SmassT_INPUTS",
"Entropy in J/kg/K, Temperature in K"},
537 {
SmolarT_INPUTS,
"SmolarT_INPUTS",
"Entropy in J/mol/K, Temperature in K"},
538 {
TUmass_INPUTS,
"TUmass_INPUTS",
"Temperature in K, Internal energy in J/kg"},
539 {
TUmolar_INPUTS,
"TUmolar_INPUTS",
"Temperature in K, Internal energy in J/mol"},
541 {
DmassP_INPUTS,
"DmassP_INPUTS",
"Mass density in kg/m^3, Pressure in Pa"},
542 {
DmolarP_INPUTS,
"DmolarP_INPUTS",
"Molar density in mol/m^3, Pressure in Pa"},
543 {
HmassP_INPUTS,
"HmassP_INPUTS",
"Enthalpy in J/kg, Pressure in Pa"},
544 {
HmolarP_INPUTS,
"HmolarP_INPUTS",
"Enthalpy in J/mol, Pressure in Pa"},
545 {
PSmass_INPUTS,
"PSmass_INPUTS",
"Pressure in Pa, Entropy in J/kg/K"},
546 {
PSmolar_INPUTS,
"PSmolar_INPUTS",
"Pressure in Pa, Entropy in J/mol/K "},
547 {
PUmass_INPUTS,
"PUmass_INPUTS",
"Pressure in Pa, Internal energy in J/kg"},
548 {
PUmolar_INPUTS,
"PUmolar_INPUTS",
"Pressure in Pa, Internal energy in J/mol"},
550 {
DmassHmass_INPUTS,
"DmassHmass_INPUTS",
"Mass density in kg/m^3, Enthalpy in J/kg"},
551 {
DmolarHmolar_INPUTS,
"DmolarHmolar_INPUTS",
"Molar density in mol/m^3, Enthalpy in J/mol"},
552 {
DmassSmass_INPUTS,
"DmassSmass_INPUTS",
"Mass density in kg/m^3, Entropy in J/kg/K"},
553 {
DmolarSmolar_INPUTS,
"DmolarSmolar_INPUTS",
"Molar density in mol/m^3, Entropy in J/mol/K"},
554 {
DmassUmass_INPUTS,
"DmassUmass_INPUTS",
"Mass density in kg/m^3, Internal energy in J/kg"},
555 {
DmolarUmolar_INPUTS,
"DmolarUmolar_INPUTS",
"Molar density in mol/m^3, Internal energy in J/mol"},
559 {
SmassUmass_INPUTS,
"SmassUmass_INPUTS",
"Entropy in J/kg/K, Internal energy in J/kg"},
560 {
SmolarUmolar_INPUTS,
"SmolarUmolar_INPUTS",
"Entropy in J/mol/K, Internal energy in J/mol"},
571 short_desc_map.insert(std::pair<input_pairs, std::string>(el->key, el->short_desc));
572 long_desc_map.insert(std::pair<input_pairs, std::string>(el->key, el->long_desc));
573 index_map.insert(std::pair<std::string, input_pairs>(el->short_desc, el->key));
590 auto it = coolprop_information.index_map.find(input_pair_name);
591 if (it != coolprop_information.index_map.end()) {
594 throw ValueError(
format(
"Your input name [%s] is not valid in get_input_pair_index (names are case sensitive)", input_pair_name.c_str()));
599 auto it = coolprop_information.short_desc_map.find(pair);
600 if (it != coolprop_information.short_desc_map.end()) {
603 throw ValueError(
"Cannot find the short input pair description.");
607 auto it = coolprop_information.long_desc_map.find(pair);
608 if (it != coolprop_information.long_desc_map.end()) {
611 throw ValueError(
"Cannot find the long input pair description.");
805 family_name_map.insert(std::pair<backend_families, std::string>(el->family, el->name));
806 family_name_map_r.insert(std::pair<std::string, backend_families>(el->name, el->family));
810 backend_family_map.insert(std::pair<backends, backend_families>(el->backend, el->family));
811 backend_name_map.insert(std::pair<backends, std::string>(el->backend, el->name));
813 family_name_map_r.insert(std::pair<std::string, backend_families>(el->name, el->family));
833 std::size_t i = backend_string.find(
"&");
834 std::map<std::string, backend_families>::const_iterator it;
835 if (i != std::string::npos) {
836 it = backend_information.family_name_map_r.find(backend_string.substr(0, i));
837 if (it != backend_information.family_name_map_r.end()) f1 = it->second;
838 it = backend_information.family_name_map_r.find(backend_string.substr(i + 1));
839 if (it != backend_information.family_name_map_r.end()) f2 = it->second;
841 it = backend_information.family_name_map_r.find(backend_string);
842 if (it != backend_information.family_name_map_r.end()) f1 = it->second;
850 std::map<backend_families, std::string>::const_iterator it;
851 it = backend_information.family_name_map.find(f2_enum);
852 if (it != backend_information.family_name_map.end())
860 std::map<backends, std::string>::const_iterator it;
861 it = backend_information.backend_name_map.find(backend);
862 if (it != backend_information.backend_name_map.end())
865 return std::string(
"");
871 # include <catch2/catch_all.hpp>
874 TEST_CASE(
"Check that all parameters are described",
"") {
876 std::ostringstream ss;
878 SECTION(ss.str(),
"") {
889 TEST_CASE(
"Check that all phases are described",
"[phase_index]") {
891 std::ostringstream ss;
893 SECTION(ss.str(),
"") {
894 std::string stringrepr;