Add T_freeze as an output for incompressibles

Signed-off-by: Ian Bell <ian.h.bell@gmail.com>
This commit is contained in:
Ian Bell
2014-11-23 20:43:50 -05:00
parent 383b045bb1
commit cf6f2f0c22
6 changed files with 19 additions and 9 deletions

View File

@@ -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(){};

View File

@@ -120,6 +120,7 @@ enum parameters{
// Accessors for incompressibles
ifraction_min,
ifraction_max,
iT_freeze,
// Environmental parameters
iGWP20, ///< The 20-year global warming potential

View File

@@ -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()));
}

View File

@@ -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 */

View File

@@ -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);

View File

@@ -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),