From fe48c7e403fcd86b1984593c0ef361f5b50b982d Mon Sep 17 00:00:00 2001 From: Ian Bell Date: Wed, 7 Jan 2015 13:05:39 -0700 Subject: [PATCH] Fixed bugs with bad departure function names and better error message; Closes #396 Signed-off-by: Ian Bell --- include/CoolPropTools.h | 1 + src/Backends/Helmholtz/MixtureParameters.cpp | 2 ++ src/CoolProp.cpp | 9 ++++----- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/include/CoolPropTools.h b/include/CoolPropTools.h index d69beedd..7d0827ac 100644 --- a/include/CoolPropTools.h +++ b/include/CoolPropTools.h @@ -254,6 +254,7 @@ std::map > string_vectors; public: Dictionary(){}; + bool is_empty(void){return numbers.empty() && strings.empty() && double_vectors.empty() && string_vectors.empty();} void add_string(std::string s1, std::string s2){ strings.insert(std::pair(s1, s2));} void add_number(std::string s1, double d){ numbers.insert(std::pair(s1, d));} void add_double_vector(std::string s1, std::vector d){ double_vectors.insert(std::pair >(s1, d));} diff --git a/src/Backends/Helmholtz/MixtureParameters.cpp b/src/Backends/Helmholtz/MixtureParameters.cpp index 1aa735ad..7bcea918 100644 --- a/src/Backends/Helmholtz/MixtureParameters.cpp +++ b/src/Backends/Helmholtz/MixtureParameters.cpp @@ -365,6 +365,8 @@ void MixtureParameters::set_mixture_parameters(HelmholtzEOSMixtureBackend &HEOS) // Get the dictionary itself Dictionary &dict_dep = mixturedeparturefunctionslibrary.departure_function_map[Name]; + if (dict_dep.is_empty()){throw ValueError(format("Departure function name [%s] seems to be invalid",Name.c_str()));} + // These terms are common std::vector n = dict_dep.get_double_vector("n"); std::vector d = dict_dep.get_double_vector("d"); diff --git a/src/CoolProp.cpp b/src/CoolProp.cpp index 570648da..dcb8133f 100644 --- a/src/CoolProp.cpp +++ b/src/CoolProp.cpp @@ -422,14 +422,13 @@ double PropsSI(const std::string &Output, const std::string &Name1, double Prop1 // BEGIN OF TRY // Here is the real code that is inside the try block - - extract_backend(Ref, backend, fluid); - if (has_fractions_in_string(fluid)){ - extract_fractions(fluid, fractions); + std::string fluid_string = fluid; + if (has_fractions_in_string(fluid) || has_solution_concentration(fluid)){ + fluid_string = extract_fractions(fluid, fractions); } std::vector > IO; - _PropsSImulti(strsplit(Output,'&'), Name1, std::vector(1, Prop1), Name2, std::vector(1, Prop2), backend, std::vector(1, fluid), fractions, IO); + _PropsSImulti(strsplit(Output,'&'), Name1, std::vector(1, Prop1), Name2, std::vector(1, Prop2), backend, strsplit(fluid_string, '&'), fractions, IO); if (IO.empty()){ throw ValueError(get_global_param_string("errstring").c_str()); } if (IO.size()!= 1 || IO[0].size() != 1){ throw ValueError(format("output should be 1x1; error was %s", get_global_param_string("errstring").c_str())); }