Fix set_reference_stateD(); closes #1091

Now all inputs are molar, and the function actually works!
This commit is contained in:
Ian Bell
2016-06-05 15:16:02 -06:00
parent f7ef611f50
commit 154de451fe
4 changed files with 13 additions and 14 deletions

View File

@@ -150,10 +150,10 @@ You might want to start by looking at CoolProp.h
/// Set the reference state based on a thermodynamic state point specified by temperature and molar density
/// @param FluidName The name of the fluid
/// @param T Temperature at reference state [K]
/// @param rhomolar Density at reference state [mol/m^3]
/// @param h0 Enthalpy at reference state [J/mol]
/// @param s0 Entropy at references state [J/mol/K]
void set_reference_stateD(const std::string &FluidName, double T, double rhomolar, double h0, double s0);
/// @param rhomolar Molar density at reference state [mol/m^3]
/// @param hmolar0 Molar enthalpy at reference state [J/mol]
/// @param smolar0 Molar entropy at reference state [J/mol/K]
void set_reference_stateD(const std::string &FluidName, double T, double rhomolar, double hmolar0, double smolar0);
/// Return a string representation of the phase
/// @param Name1 The first state variable name, one of "T","D","H",etc.

View File

@@ -138,7 +138,7 @@
* \sa \ref CoolProp::set_reference_stateD
* @returns error_code 1 = Ok 0 = error
*/
EXPORT_CODE int CONVENTION set_reference_stateD(const char *Ref, double T, double rho, double h0, double s0);
EXPORT_CODE int CONVENTION set_reference_stateD(const char *Ref, double T, double rhomolar, double hmolar0, double smolar0);
/** \brief FORTRAN 77 style wrapper of the PropsSI function
* \overload
* \sa \ref CoolProp::PropsSI(const std::string &, const std::string &, double, const std::string &, double, const std::string&)

View File

@@ -828,7 +828,7 @@ void set_reference_stateS(const std::string &fluid_string, const std::string &re
}
}
}
void set_reference_stateD(const std::string &Ref, double T, double rhomolar, double h0, double s0)
void set_reference_stateD(const std::string &Ref, double T, double rhomolar, double hmass0, double smass0)
{
std::vector<std::string> _comps(1, Ref);
CoolProp::HelmholtzEOSMixtureBackend HEOS(_comps);
@@ -836,12 +836,11 @@ void set_reference_stateD(const std::string &Ref, double T, double rhomolar, dou
HEOS.update(DmolarT_INPUTS, rhomolar, T);
// Get current values for the enthalpy and entropy
double deltah = HEOS.hmass() - h0; // offset from specified enthalpy in J/mol
double deltas = HEOS.smass() - s0; // offset from specified entropy in J/mol/K
double delta_a1 = deltas/(8.314472/HEOS.molar_mass());
double delta_a2 = -deltah/(8.314472/HEOS.molar_mass()*HEOS.get_reducing_state().T);
HEOS.get_components()[0].EOS().alpha0.EnthalpyEntropyOffset.set(delta_a1, delta_a2, "custom");
HEOS.update_states();
double deltah = HEOS.hmass() - hmass0; // offset from specified enthalpy in J/kg
double deltas = HEOS.smass() - smass0; // offset from specified entropy in J/kg/K
double delta_a1 = deltas/(HEOS.gas_constant()/HEOS.molar_mass());
double delta_a2 = -deltah/(HEOS.gas_constant()/HEOS.molar_mass()*HEOS.get_reducing_state().T);
set_fluid_enthalpy_entropy_offset(Ref, delta_a1, delta_a2, "custom");
}

View File

@@ -115,11 +115,11 @@ EXPORT_CODE int CONVENTION set_reference_stateS(const char *Ref, const char *ref
catch (...){ CoolProp::set_error_string("Undefined error"); }
return false;
}
EXPORT_CODE int CONVENTION set_reference_stateD(const char *Ref, double T, double rho, double h0, double s0)
EXPORT_CODE int CONVENTION set_reference_stateD(const char *Ref, double T, double rhomolar, double hmolar0, double smolar0)
{
fpu_reset_guard guard;
try{
CoolProp::set_reference_stateD(std::string(Ref), T, rho, h0, s0);
CoolProp::set_reference_stateD(std::string(Ref), T, rhomolar, hmolar0, smolar0);
return true;
}
catch (std::exception &e){ CoolProp::set_error_string(e.what()); }