diff --git a/include/AbstractState.h b/include/AbstractState.h index 7cd6457f..f36637db 100644 --- a/include/AbstractState.h +++ b/include/AbstractState.h @@ -42,8 +42,12 @@ protected: long _phase; ///< The key for the phase from CoolProp::phases enum bool _forceSinglePhase, _forceTwoPhase; + bool isSupercriticalPhase(void){ + return (this->_phase == iphase_supercritical || this->_phase == iphase_supercritical_liquid || this->_phase == iphase_supercritical_gas); + } + bool isHomogeneousPhase(void){ - return (this->_phase==iphase_liquid || this->_phase==iphase_gas || this->_phase == iphase_supercritical); + return (this->_phase==iphase_liquid || this->_phase==iphase_gas || isSupercriticalPhase()); } bool isTwoPhase(void){ diff --git a/include/DataStructures.h b/include/DataStructures.h index 3f71b8fa..e9299352 100644 --- a/include/DataStructures.h +++ b/include/DataStructures.h @@ -73,17 +73,26 @@ enum parameters{ /// @param key The key, one of iT, iP, etc. /// @param info The thing you want, one of "IO" ("IO" if input/output, "O" if output only), "short" (very short description), "long" (a longer description), "units" std::string get_parameter_information(int key, std::string info); + /// Return the integer key corresponding to the parameter name ("Dmolar" for instance) int get_parameter_index(const std::string ¶m_name); + /// Returns true if the input is trivial (constants, critical parameters, etc.) bool is_trivial_parameter(int key); + std::string get_csv_parameter_list(); /// These are constants for the compositions enum composition_types{IFRAC_MASS, IFRAC_MOLE, IFRAC_VOLUME, IFRAC_UNDEFINED, IFRAC_PURE}; /// These are constants for the phases of the fluid -enum phases{iphase_liquid, iphase_supercritical, iphase_gas, iphase_twophase, iphase_unknown}; +enum phases{iphase_liquid, ///< Subcritical liquid + iphase_supercritical, ///< Supercritical (p > pc, T > Tc) + iphase_supercritical_gas, ///< Supercritical gas (p < pc, T > Tc) + iphase_supercritical_liquid, ///< Supercritical liquid (p > pc, T < Tc) + iphase_gas, ///< Subcritical gas + iphase_twophase, ///< Twophase + iphase_unknown}; /// These are unit types for the fluid enum fluid_types{FLUID_TYPE_PURE, FLUID_TYPE_PSEUDOPURE, FLUID_TYPE_REFPROP, FLUID_TYPE_INCOMPRESSIBLE_LIQUID, FLUID_TYPE_INCOMPRESSIBLE_SOLUTION, FLUID_TYPE_UNDEFINED}; @@ -238,10 +247,9 @@ template long generate_update_pair(long key1, T value1, long key2, T va /// Return the short description of an input pair key ("DmolarT_INPUTS" for instance) std::string get_input_pair_short_desc(int pair); + /// Return the long description of an input pair key ("Molar density in mol/m^3, Temperature in K" for instance) std::string get_input_pair_long_desc(int pair); - - } /* namespace CoolProp */ #endif /* DATASTRUCTURES_H_ */ diff --git a/src/Backends/Helmholtz/FlashRoutines.cpp b/src/Backends/Helmholtz/FlashRoutines.cpp index f5c6fa35..77845df6 100644 --- a/src/Backends/Helmholtz/FlashRoutines.cpp +++ b/src/Backends/Helmholtz/FlashRoutines.cpp @@ -590,10 +590,17 @@ void FlashRoutines::HSU_P_flash(HelmholtzEOSMixtureBackend &HEOS, int other) } break; } + case iphase_supercritical_liquid: + case iphase_supercritical_gas: case iphase_supercritical: { Tmax = HEOS.Tmax(); - Tmin = HEOS.Tmin(); + if (HEOS.has_melting_curve()){ + Tmin = HEOS.calc_melting_line(iT, iP, HEOS._p); + } + else{ + Tmin = HEOS.Tmin() + 1; + } break; } default: diff --git a/src/Backends/Helmholtz/HelmholtzEOSMixtureBackend.cpp b/src/Backends/Helmholtz/HelmholtzEOSMixtureBackend.cpp index 8f643733..43bffd30 100644 --- a/src/Backends/Helmholtz/HelmholtzEOSMixtureBackend.cpp +++ b/src/Backends/Helmholtz/HelmholtzEOSMixtureBackend.cpp @@ -664,43 +664,43 @@ void HelmholtzEOSMixtureBackend::p_phase_determination_pure_or_pseudopure(int ot this->_phase = iphase_supercritical; return; } else{ - this->_phase = iphase_liquid; return; + this->_phase = iphase_supercritical_liquid; return; } } case iDmolar: { if (_rhomolar < _crit.rhomolar){ - this->_phase = iphase_supercritical; return; + this->_phase = iphase_supercritical_gas; return; } else{ - this->_phase = iphase_liquid; return; + this->_phase = iphase_supercritical_liquid; return; } } case iSmolar: { if (_smolar.pt() > _crit.smolar){ - this->_phase = iphase_supercritical; return; + this->_phase = iphase_supercritical_gas; return; } else{ - this->_phase = iphase_liquid; return; + this->_phase = iphase_supercritical_liquid; return; } } case iHmolar: { if (_hmolar.pt() > _crit.hmolar){ - this->_phase = iphase_supercritical; return; + this->_phase = iphase_supercritical_gas; return; } else{ - this->_phase = iphase_liquid; return; + this->_phase = iphase_supercritical_liquid; return; } } case iUmolar: { if (_umolar.pt() > _crit.umolar){ - this->_phase = iphase_supercritical; return; + this->_phase = iphase_supercritical_gas; return; } else{ - this->_phase = iphase_liquid; return; + this->_phase = iphase_supercritical_liquid; return; } } default: @@ -1044,43 +1044,43 @@ void HelmholtzEOSMixtureBackend::T_phase_determination_pure_or_pseudopure(int ot this->_phase = iphase_supercritical; return; } else{ - this->_phase = iphase_gas; return; + this->_phase = iphase_supercritical_gas; return; } } case iDmolar: { if (_rhomolar > _crit.rhomolar){ - this->_phase = iphase_supercritical; return; + this->_phase = iphase_supercritical_liquid; return; } else{ - this->_phase = iphase_gas; return; + this->_phase = iphase_supercritical_gas; return; } } case iSmolar: { if (_smolar.pt() > _crit.smolar){ - this->_phase = iphase_supercritical; return; + this->_phase = iphase_supercritical_gas; return; } else{ - this->_phase = iphase_gas; return; + this->_phase = iphase_supercritical_liquid; return; } } case iHmolar: { if (_hmolar.pt() > _crit.hmolar){ - this->_phase = iphase_supercritical; return; + this->_phase = iphase_supercritical_gas; return; } else{ - this->_phase = iphase_gas; return; + this->_phase = iphase_supercritical_liquid; return; } } case iUmolar: { if (_umolar.pt() > _crit.umolar){ - this->_phase = iphase_supercritical; return; + this->_phase = iphase_supercritical_gas; return; } else{ - this->_phase = iphase_gas; return; + this->_phase = iphase_supercritical_liquid; return; } } default: diff --git a/src/Tests/CoolProp-Tests.cpp b/src/Tests/CoolProp-Tests.cpp index 0395fef6..45347806 100644 --- a/src/Tests/CoolProp-Tests.cpp +++ b/src/Tests/CoolProp-Tests.cpp @@ -733,7 +733,7 @@ TEST_CASE("Tests for solvers in P,Y flash using Water", "[flash],[PH],[PS],[PU]" CHECK(ValidNumber(T2)); } std::ostringstream ss5; - ss5 << "Supercritical \"gas\" P," << ykey; + ss5 << "Supercritical P," << ykey; SECTION(ss5.str(), "") { double Tc = Props1SI("Water","Tcrit"); @@ -744,7 +744,47 @@ TEST_CASE("Tests for solvers in P,Y flash using Water", "[flash],[PH],[PS],[PU]" CAPTURE(p); CHECK(ValidNumber(T)); CHECK(ValidNumber(p)); - CHECK_NOTHROW(y=PropsSI("H","P",p,"T",T,"Water")); + CHECK_NOTHROW(y=PropsSI(ykey,"P",p,"T",T,"Water")); + CAPTURE(y); + CHECK(ValidNumber(y)); + CHECK_NOTHROW(T2=PropsSI("T",ykey,y,"P",p,"Water")); + CAPTURE(CoolProp::get_global_param_string("errstring")); + CAPTURE(T2); + CHECK(ValidNumber(T2)); + } + std::ostringstream ss6; + ss6 << "Supercritical \"gas\" P," << ykey; + SECTION(ss6.str(), "") + { + double Tc = Props1SI("Water","Tcrit"); + double pc = Props1SI("Water","pcrit"); + double p = pc*0.7; + double T = Tc*1.3; + CAPTURE(T); + CAPTURE(p); + CHECK(ValidNumber(T)); + CHECK(ValidNumber(p)); + CHECK_NOTHROW(y=PropsSI(ykey,"P",p,"T",T,"Water")); + CAPTURE(y); + CHECK(ValidNumber(y)); + CHECK_NOTHROW(T2=PropsSI("T",ykey,y,"P",p,"Water")); + CAPTURE(CoolProp::get_global_param_string("errstring")); + CAPTURE(T2); + CHECK(ValidNumber(T2)); + } + std::ostringstream ss7; + ss7 << "Supercritical \"liquid\" P," << ykey; + SECTION(ss7.str(), "") + { + double Tc = Props1SI("Water","Tcrit"); + double pc = Props1SI("Water","pcrit"); + double p = pc*1.3; + double T = Tc*0.7; + CAPTURE(T); + CAPTURE(p); + CHECK(ValidNumber(T)); + CHECK(ValidNumber(p)); + CHECK_NOTHROW(y=PropsSI(ykey,"P",p,"T",T,"Water")); CAPTURE(y); CHECK(ValidNumber(y)); CHECK_NOTHROW(T2=PropsSI("T",ykey,y,"P",p,"Water")); @@ -752,7 +792,6 @@ TEST_CASE("Tests for solvers in P,Y flash using Water", "[flash],[PH],[PS],[PU]" CAPTURE(T2); CHECK(ValidNumber(T2)); } - }