diff --git a/include/CoolProp.h b/include/CoolProp.h index 2289b899..787bee10 100644 --- a/include/CoolProp.h +++ b/include/CoolProp.h @@ -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. diff --git a/include/CoolPropLib.h b/include/CoolPropLib.h index 310fd748..3402e084 100644 --- a/include/CoolPropLib.h +++ b/include/CoolPropLib.h @@ -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&) diff --git a/src/CoolProp.cpp b/src/CoolProp.cpp index f3f2ab0a..c880a27c 100644 --- a/src/CoolProp.cpp +++ b/src/CoolProp.cpp @@ -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 _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"); } diff --git a/src/CoolPropLib.cpp b/src/CoolPropLib.cpp index 830018c4..431d659e 100644 --- a/src/CoolPropLib.cpp +++ b/src/CoolPropLib.cpp @@ -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()); }