mirror of
https://github.com/CoolProp/CoolProp.git
synced 2026-01-23 12:58:03 -05:00
introduced backend enumerations, I hope this fixes #1120 reliably
This commit is contained in:
@@ -410,7 +410,7 @@ const input_pair_info input_pair_list[] = {
|
||||
{ QSmass_INPUTS, "QS_INPUTS", "Molar quality, Entropy in J/kg/K" },
|
||||
{ HmolarQ_INPUTS, "HQ_INPUTS", "Enthalpy in J/mol, Molar quality" },
|
||||
{ HmassQ_INPUTS, "HQ_INPUTS", "Enthalpy in J/kg, Molar quality" },
|
||||
{ DmassQ_INPUTS, "DmassQ_INPUTS", "Molar density kg/m^3, Molar quality" },
|
||||
{ DmassQ_INPUTS, "DmassQ_INPUTS", "Molar density kg/m^3, Molar quality" },
|
||||
{ DmolarQ_INPUTS, "DmolarQ_INPUTS", "Molar density in mol/m^3, Molar quality" },
|
||||
|
||||
{ PQ_INPUTS, "PQ_INPUTS", "Pressure in Pa, Molar quality" },
|
||||
@@ -529,6 +529,82 @@ void split_input_pair(input_pairs pair, parameters &p1, parameters &p2)
|
||||
}
|
||||
}
|
||||
|
||||
const std::map<std::string, backend_families> backend_mapping = {
|
||||
{ "", HEOS_BACKEND_FAMILY },
|
||||
{ "?", HEOS_BACKEND_FAMILY },
|
||||
{ "HEOS", HEOS_BACKEND_FAMILY },
|
||||
{ "HelmholtzEOSBackend", HEOS_BACKEND_FAMILY },
|
||||
{ "HelmholtzEOSMixtureBackend", HEOS_BACKEND_FAMILY },
|
||||
{ "REFPROP", REFPROP_BACKEND_FAMILY },
|
||||
{ "REFPROPBackend", REFPROP_BACKEND_FAMILY },
|
||||
{ "REFPROPMixtureBackend", REFPROP_BACKEND_FAMILY },
|
||||
{ "INCOMP", INCOMP_BACKEND_FAMILY },
|
||||
{ "IncompressibleBackend", INCOMP_BACKEND_FAMILY },
|
||||
{ "IF97", IF97_BACKEND_FAMILY },
|
||||
{ "IF97Backend", IF97_BACKEND_FAMILY },
|
||||
{ "TREND", TREND_BACKEND_FAMILY },
|
||||
{ "TRENDBackend", TREND_BACKEND_FAMILY },
|
||||
{ "TTSE", TTSE_BACKEND_FAMILY },
|
||||
{ "TTSEBackend", TTSE_BACKEND_FAMILY },
|
||||
{ "BICUBIC", BICUBIC_BACKEND_FAMILY },
|
||||
{ "BicubicBackend", BICUBIC_BACKEND_FAMILY },
|
||||
{ "SRK", SRK_BACKEND_FAMILY },
|
||||
{ "SRKBackend", SRK_BACKEND_FAMILY },
|
||||
{ "PR", PR_BACKEND_FAMILY },
|
||||
{ "Peng-Robinson", PR_BACKEND_FAMILY },
|
||||
{ "PengRobinsonBackend", PR_BACKEND_FAMILY },
|
||||
};
|
||||
const std::map<backends, std::string> backend_mapping_reversed = {
|
||||
{ HEOS_BACKEND_PURE,"HelmholtzEOSBackend" },
|
||||
{ HEOS_BACKEND_MIX,"HelmholtzEOSMixtureBackend" },
|
||||
{ REFPROP_BACKEND_PURE,"REFPROPBackend" },
|
||||
{ REFPROP_BACKEND_MIX,"REFPROPMixtureBackend" },
|
||||
{ INCOMP_BACKEND,"IncompressibleBackend" },
|
||||
{ IF97_BACKEND,"IF97Backend" },
|
||||
{ TREND_BACKEND,"TRENDBackend" },
|
||||
{ TTSE_BACKEND,"TTSEBackend" },
|
||||
{ BICUBIC_BACKEND,"BicubicBackend" },
|
||||
{ SRK_BACKEND,"SRKBackend" },
|
||||
{ PR_BACKEND, "PengRobinsonBackend" } ,
|
||||
};
|
||||
const std::map<backend_families, std::string> backend_alias_mapping = {
|
||||
{ HEOS_BACKEND_FAMILY, "HEOS" },
|
||||
{ REFPROP_BACKEND_FAMILY, "REFPROP" },
|
||||
};
|
||||
|
||||
/// Convert a string into the enum values
|
||||
void extract_backend_enums(std::string backend_string, backend_families &f1, backend_families &f2) {
|
||||
f1 = INVALID_BACKEND_FAMILY;
|
||||
f2 = INVALID_BACKEND_FAMILY;
|
||||
std::size_t i = backend_string.find("&");
|
||||
std::map<std::string, backend_families>::const_iterator it;
|
||||
if (i != std::string::npos) {
|
||||
it = backend_mapping.find(backend_string.substr(0, i));// Before "&"
|
||||
if (it != backend_mapping.end()) f1 = it->second;
|
||||
it = backend_mapping.find(backend_string.substr(i + 1)); // After "&"
|
||||
if (it != backend_mapping.end()) f2 = it->second;
|
||||
} else {
|
||||
it = backend_mapping.find(backend_string);
|
||||
if (it != backend_mapping.end()) f1 = it->second;
|
||||
}
|
||||
}
|
||||
|
||||
void extract_backend_enums_string(std::string backend_string, backend_families &f1, std::string &f2) {
|
||||
backend_families f2_enum;
|
||||
extract_backend_enums(backend_string, f1, f2_enum);
|
||||
std::map<backend_families, std::string>::const_iterator it;
|
||||
it = backend_alias_mapping.find(f2_enum);
|
||||
if (it != backend_alias_mapping.end()) f2 = it->second;
|
||||
else f2.clear();
|
||||
}
|
||||
|
||||
std::string get_backend_string(backends backend) {
|
||||
std::map<backends, std::string>::const_iterator it;
|
||||
it = backend_mapping_reversed.find(backend);
|
||||
if (it != backend_mapping_reversed.end()) return it->second;
|
||||
else return std::string("");
|
||||
}
|
||||
|
||||
} /* namespace CoolProp */
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user