Implemented psat_max and Tsat_max for pseudo-pure fluids to close https://github.com/CoolProp/CoolProp/issues/89

This commit is contained in:
Ian Bell
2014-08-09 12:17:44 +02:00
parent 56dbf62619
commit 801aa61485
5 changed files with 46 additions and 4 deletions

View File

@@ -265,7 +265,9 @@ public:
SimpleState reduce, ///< Reducing state used for the EOS (usually, but not always, the critical point)
sat_min_liquid, ///< The saturated liquid state at the minimum saturation temperature
sat_min_vapor, ///< The saturated vapor state at the minimum saturation temperature
hs_anchor; ///< A fixed anchor state at Tc*1.1 and rhoc*0.9 used as a reference state for enthalpy and entropy ancillary curves
hs_anchor, ///< A fixed anchor state at Tc*1.1 and rhoc*0.9 used as a reference state for enthalpy and entropy ancillary curves
max_sat_T, ///< The state at the maximum saturation temperature for pseudo-pure
max_sat_p; ///< The state at the maximum saturation pressure for pseudo-pure
EOSLimits limits; ///< Limits on the EOS
double R_u, ///< The universal gas constant used for this EOS (usually, but not always, 8.314472 J/mol/K)
molar_mass, ///< The molar mass in kg/mol (note NOT kg/kmol)
@@ -328,7 +330,6 @@ public:
return alphar.dTau3(tau, delta);
};
long double base0(const long double &tau, const long double &delta) throw()
{
return alpha0.base(tau, delta);

View File

@@ -131,6 +131,18 @@ void FlashRoutines::PQ_flash(HelmholtzEOSMixtureBackend &HEOS)
throw NotImplementedError("PQ_flash not implemented for pseudo-pure fluids yet");
}
else{
// Critical point for pure fluids, slightly different for pseudo-pure, very different for mixtures
long double pmax_sat = HEOS.calc_pmax_sat();
// Check what the minimum limits for the equation of state are
long double pmin_satL, pmin_satV, pmin_sat;
HEOS.calc_pmin_sat(pmin_satL, pmin_satV);
pmin_sat = std::max(pmin_satL, pmin_satV);
// Check limits
if (!is_in_closed_range(pmin_sat, pmax_sat, static_cast<long double>(HEOS._p))){
throw ValueError(format("Temperature to PQ_flash [%6g Pa] must be in range [%8g Pa, %8g Pa]",HEOS._p, pmin_sat, pmax_sat));
}
// ------------------
// It is a pure fluid
// ------------------

View File

@@ -337,6 +337,21 @@ protected:
EOS.hs_anchor.hmolar = cpjson::get_double(hs_anchor, "hmolar");
EOS.hs_anchor.smolar = cpjson::get_double(hs_anchor, "smolar");
}
if (EOS_json["STATES"].HasMember("pressure_max_sat")){
rapidjson::Value &s = EOS_json["STATES"]["pressure_max_sat"];
EOS.max_sat_T.T = cpjson::get_double(s, "T");
EOS.max_sat_T.p = cpjson::get_double(s, "p");
EOS.max_sat_T.rhomolar = cpjson::get_double(s, "rhomolar");
}
if (EOS_json["STATES"].HasMember("temperature_max_sat")){
rapidjson::Value &s = EOS_json["STATES"]["temperature_max_sat"];
EOS.max_sat_p.T = cpjson::get_double(s, "T");
EOS.max_sat_p.p = cpjson::get_double(s, "p");
EOS.max_sat_p.rhomolar = cpjson::get_double(s, "rhomolar");
}
// Validate the equation of state that was just created
EOS.validate();

View File

@@ -419,7 +419,7 @@ long double HelmholtzEOSMixtureBackend::calc_pmax_sat(void)
{
if (components[0]->pEOS->pseudo_pure)
{
throw ValueError("calc_pmax_sat not yet defined for pseudo-pure");
return components[0]->pEOS->max_sat_p.p;
}
else{
return p_critical();
@@ -435,7 +435,7 @@ long double HelmholtzEOSMixtureBackend::calc_Tmax_sat(void)
{
if (components[0]->pEOS->pseudo_pure)
{
throw ValueError("calc_Tmax_sat not yet defined for pseudo-pure");
return components[0]->pEOS->max_sat_T.T;
}
else{
return T_critical();
@@ -459,6 +459,19 @@ void HelmholtzEOSMixtureBackend::calc_Tmin_sat(long double &Tmin_satL, long doub
}
}
void HelmholtzEOSMixtureBackend::calc_pmin_sat(long double &pmin_satL, long double &pmin_satV)
{
if (is_pure_or_pseudopure)
{
pmin_satL = components[0]->pEOS->sat_min_liquid.p;
pmin_satV = components[0]->pEOS->sat_min_vapor.p;
return;
}
else{
throw ValueError("calc_pmin_sat not yet defined for mixtures");
}
}
// Minimum allowed saturation temperature the maximum of the saturation temperatures of liquid and vapor
// For pure fluids, both values are the same, for pseudo-pure they are probably the same, for mixtures they are definitely not the same

View File

@@ -144,6 +144,7 @@ public:
long double calc_pmax_sat(void);
long double calc_Tmax_sat(void);
void calc_Tmin_sat(long double &Tmin_satL, long double &Tmin_satV);
void calc_pmin_sat(long double &pmin_satL, long double &pmin_satV);
long double calc_T_critical(void);
long double calc_p_critical(void);