From 6042f2a4ebe66d2dbc7fd070b19e3784033e2dc5 Mon Sep 17 00:00:00 2001 From: Ian Bell Date: Thu, 14 Dec 2017 15:38:12 -0700 Subject: [PATCH] Add ability to retrieve the list of cubic fluids that are loaded --- src/Backends/Cubics/CubicsLibrary.cpp | 15 ++++++++++++++- src/Backends/Cubics/CubicsLibrary.h | 5 ++++- src/CoolProp.cpp | 3 +++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/Backends/Cubics/CubicsLibrary.cpp b/src/Backends/Cubics/CubicsLibrary.cpp index e94e552c..659b7fbc 100644 --- a/src/Backends/Cubics/CubicsLibrary.cpp +++ b/src/Backends/Cubics/CubicsLibrary.cpp @@ -56,6 +56,9 @@ public: // Already there, see http://www.cplusplus.com/reference/map/map/insert/ fluid_map.erase(ret.first); ret = fluid_map.insert(std::pair(val.name, val)); + if (get_debug_level() > 0){ + std::cout << "added the cubic fluid: "+val.name << std::endl; + } assert(ret.second == true); } @@ -87,6 +90,13 @@ public: } } }; + std::string get_fluids_list(){ + std::vector out; + for (std::map::const_iterator it = fluid_map.begin(); it != fluid_map.end(); ++it){ + out.push_back(it->first); + } + return strjoin(out, ","); + } }; static CubicsLibraryClass library; @@ -120,6 +130,9 @@ CubicLibrary::CubicsValues get_cubic_values(const std::string &identifier){ std::string get_cubic_fluids_schema(){ return cubic_fluids_schema_JSON; } +std::string get_cubic_fluids_list(){ + return library.get_fluids_list(); +} -} /* namepace CriticalLibrary */ +} /* namepace CubicsLibrary */ } /* namepace CoolProp */ diff --git a/src/Backends/Cubics/CubicsLibrary.h b/src/Backends/Cubics/CubicsLibrary.h index c62e4860..1e3ce483 100644 --- a/src/Backends/Cubics/CubicsLibrary.h +++ b/src/Backends/Cubics/CubicsLibrary.h @@ -41,8 +41,11 @@ namespace CoolProp{ /// Get the schema used to validate the cubic fluids std::string get_cubic_fluids_schema(); + /// Get a csv separated list of fluid names that are loaded + std::string get_cubic_fluids_list(); + } /* namespace CubicLibrary */ } /* namespace CoolProp */ -#endif \ No newline at end of file +#endif diff --git a/src/CoolProp.cpp b/src/CoolProp.cpp index bd3526f8..9ae4cd91 100644 --- a/src/CoolProp.cpp +++ b/src/CoolProp.cpp @@ -921,6 +921,9 @@ std::string get_global_param_string(const std::string &ParamName) else if (ParamName == "cubic_fluids_schema"){ return CoolProp::CubicLibrary::get_cubic_fluids_schema(); } + else if (ParamName == "cubic_fluids_list"){ + return CoolProp::CubicLibrary::get_cubic_fluids_list(); + } else{ throw ValueError(format("Input parameter [%s] is invalid",ParamName.c_str())); }