From cf6f2f0c2204e574a93eb7882f6ee4dc4d9efb38 Mon Sep 17 00:00:00 2001 From: Ian Bell Date: Sun, 23 Nov 2014 20:43:50 -0500 Subject: [PATCH] Add T_freeze as an output for incompressibles Signed-off-by: Ian Bell --- include/AbstractState.h | 1 + include/DataStructures.h | 1 + src/AbstractState.cpp | 2 ++ .../Incompressible/IncompressibleBackend.h | 2 ++ src/CoolProp.cpp | 21 +++++++++++-------- src/DataStructures.cpp | 1 + 6 files changed, 19 insertions(+), 9 deletions(-) diff --git a/include/AbstractState.h b/include/AbstractState.h index fed09f24..01f50b52 100644 --- a/include/AbstractState.h +++ b/include/AbstractState.h @@ -271,6 +271,7 @@ protected: virtual long double calc_fraction_min(void){throw NotImplementedError("calc_fraction_min is not implemented for this backend");}; /// Get the maximum fraction (mole, mass, volume) for incompressible fluid virtual long double calc_fraction_max(void){throw NotImplementedError("calc_fraction_max is not implemented for this backend");}; + virtual long double calc_T_freeze(void){throw NotImplementedError("calc_T_freeze is not implemented for this backend");}; public: AbstractState(){}; diff --git a/include/DataStructures.h b/include/DataStructures.h index 61285228..206e54de 100644 --- a/include/DataStructures.h +++ b/include/DataStructures.h @@ -120,6 +120,7 @@ enum parameters{ // Accessors for incompressibles ifraction_min, ifraction_max, + iT_freeze, // Environmental parameters iGWP20, ///< The 20-year global warming potential diff --git a/src/AbstractState.cpp b/src/AbstractState.cpp index 8cc16efa..cd95d1b2 100644 --- a/src/AbstractState.cpp +++ b/src/AbstractState.cpp @@ -199,6 +199,8 @@ double AbstractState::trivial_keyed_output(int key) return this->calc_fraction_min(); case ifraction_max: return this->calc_fraction_max(); + case iT_freeze: + return this->calc_T_freeze(); default: throw ValueError(format("This input [%d: \"%s\"] is not valid for trivial_keyed_output",key,get_parameter_information(key,"short").c_str())); } diff --git a/src/Backends/Incompressible/IncompressibleBackend.h b/src/Backends/Incompressible/IncompressibleBackend.h index aa16d358..8604d539 100644 --- a/src/Backends/Incompressible/IncompressibleBackend.h +++ b/src/Backends/Incompressible/IncompressibleBackend.h @@ -122,6 +122,8 @@ public: long double calc_fraction_min(void){return fluid->getxmin();}; long double calc_fraction_max(void){return fluid->getxmax();}; + long double calc_T_freeze(void){ + return fluid->Tfreeze(_p, _fractions[0]);}; }; } /* namespace CoolProp */ diff --git a/src/CoolProp.cpp b/src/CoolProp.cpp index 29c82b66..e95c464d 100644 --- a/src/CoolProp.cpp +++ b/src/CoolProp.cpp @@ -377,6 +377,17 @@ double _PropsSI(const std::string &Output, const std::string &Name1, double Prop // We are going to let the factory function load the state State.reset(AbstractState::factory(backend, fluid_string)); + // Set the fraction for the state + if (State->using_mole_fractions()){ + State->set_mole_fractions(fractions); + } else if (State->using_mass_fractions()){ + State->set_mass_fractions(fractions); + } else if (State->using_volu_fractions()){ + State->set_volu_fractions(fractions); + } else { + if (get_debug_level()>50) std::cout << format("%s:%d: _PropsSI, could not set composition to %s, defaulting to mole fraction.\n",__FILE__,__LINE__, vec_to_string(z).c_str()).c_str(); + } + // First check if it is a trivial input (critical/max parameters for instance) if (is_valid_parameter(Output, iOutput)) { @@ -392,15 +403,7 @@ double _PropsSI(const std::string &Output, const std::string &Name1, double Prop parameters iName1 = get_parameter_index(Name1); parameters iName2 = get_parameter_index(Name2); - if (State->using_mole_fractions()){ - State->set_mole_fractions(fractions); - } else if (State->using_mass_fractions()){ - State->set_mass_fractions(fractions); - } else if (State->using_volu_fractions()){ - State->set_volu_fractions(fractions); - } else { - if (get_debug_level()>50) std::cout << format("%s:%d: _PropsSI, could not set composition to %s, defaulting to mole fraction.\n",__FILE__,__LINE__, vec_to_string(z).c_str()).c_str(); - } + // Obtain the input pair CoolProp::input_pairs pair = generate_update_pair(iName1, Prop1, iName2, Prop2, x1, x2); diff --git a/src/DataStructures.cpp b/src/DataStructures.cpp index 6cc37e58..a79ff5b4 100644 --- a/src/DataStructures.cpp +++ b/src/DataStructures.cpp @@ -67,6 +67,7 @@ parameter_info parameter_info_list[] = { parameter_info(iP_triple, "p_triple","O","Pa","Pressure at the triple point (pure only)",true), parameter_info(ifraction_min, "fraction_min","O","-","Fraction (mole, mass, volume) minimum value for incompressible solutions",true), parameter_info(ifraction_max, "fraction_max","O","-","Fraction (mole, mass, volume) maximum value for incompressible solutions",true), + parameter_info(iT_freeze, "T_freeze","O","-","Freezing temperature incompressible solutions",true), parameter_info(ispeed_sound, "speed_of_sound","O","m/s","Speed of sound",false), parameter_info(iviscosity, "viscosity","O","Pa-s","Viscosity",false),