diff --git a/Web/fluid_properties/Mixtures.rst b/Web/fluid_properties/Mixtures.rst index d34847b4..f2235f21 100644 --- a/Web/fluid_properties/Mixtures.rst +++ b/Web/fluid_properties/Mixtures.rst @@ -34,8 +34,6 @@ The two schemes available are * ``linear`` - :math:`T_r` and :math:`v_r` are a linear function of molar composition between the two pure fluid values * ``Lorentz-Berthelot`` - all interaction parameters are 1.0 -Note that if ``apply_simple_mixing_rule`` is called first in a programme before any property calculation function, the interaction parameter library is initialized with just the binary mixture that was specified, and other binary mixtures will raise an error. To augment the built-in database, call a property calculation function before calling ``apply_simple_mixing_rule``. - Here is a sample of using this in python: .. ipython:: diff --git a/include/DataStructures.h b/include/DataStructures.h index 2c51d2b4..30ce0fed 100644 --- a/include/DataStructures.h +++ b/include/DataStructures.h @@ -428,6 +428,9 @@ const std::string& get_input_pair_long_desc(input_pairs pair); /// Split an input pair into parameters for the two parts that form the pair void split_input_pair(input_pairs pair, parameters& p1, parameters& p2); +extern void apply_simple_mixing_rule(const std::string& identifier1, const std::string& identifier2, const std::string& rule); +extern void set_interaction_parameters(const std::string& string_data); + extern std::string get_mixture_binary_pair_data(const std::string& CAS1, const std::string& CAS2, const std::string& param); extern void set_mixture_binary_pair_data(const std::string& CAS1, const std::string& CAS2, const std::string& param, const double val); extern std::string get_mixture_binary_pair_pcsaft(const std::string& CAS1, const std::string& CAS2, const std::string& param); diff --git a/src/Backends/Helmholtz/MixtureParameters.cpp b/src/Backends/Helmholtz/MixtureParameters.cpp index 3e8fe8ae..6a5467ff 100644 --- a/src/Backends/Helmholtz/MixtureParameters.cpp +++ b/src/Backends/Helmholtz/MixtureParameters.cpp @@ -88,10 +88,7 @@ class MixtureBinaryPairLibrary public: std::map, std::vector>& binary_pair_map() { - // Set the default departure functions if none have been provided yet - if (m_binary_pair_map.size() == 0) { - load_defaults(); - } + load_defaults_if_needed(); return m_binary_pair_map; }; @@ -105,6 +102,12 @@ class MixtureBinaryPairLibrary load_from_JSON(doc); } + void load_defaults_if_needed() { + if (m_binary_pair_map.size() == 0) { + load_defaults(); + } + } + // Load the defaults that come from the JSON-encoded string compiled into library // as the variable mixture_departure_functions_JSON void load_defaults() { @@ -284,11 +287,10 @@ class MixtureBinaryPairLibrary }; // The modifiable parameter library static MixtureBinaryPairLibrary mixturebinarypairlibrary; -// A fixed parameter library containing the default values -static MixtureBinaryPairLibrary mixturebinarypairlibrary_default; /// Add a simple mixing rule void apply_simple_mixing_rule(const std::string& identifier1, const std::string& identifier2, const std::string& rule) { + mixturebinarypairlibrary.load_defaults_if_needed(); mixturebinarypairlibrary.add_simple_mixing_rule(identifier1, identifier2, rule); } @@ -410,10 +412,7 @@ class MixtureDepartureFunctionsLibrary public: std::map& departure_function_map() { - // Set the default departure functions if none have been provided yet - if (m_departure_function_map.size() == 0) { - load_defaults(); - } + load_defaults_if_needed(); return m_departure_function_map; }; @@ -507,6 +506,11 @@ class MixtureDepartureFunctionsLibrary } } } + void load_defaults_if_needed() { + if (m_departure_function_map.size() == 0) { + load_defaults(); + } + } // Load the defaults that come from the JSON-encoded string compiled into library // as the variable mixture_departure_functions_JSON void load_defaults() {