diff --git a/include/AbstractState.h b/include/AbstractState.h index d4e4f8af..d2393c35 100644 --- a/include/AbstractState.h +++ b/include/AbstractState.h @@ -47,7 +47,7 @@ protected: } bool isHomogeneousPhase(void){ - return (this->_phase==iphase_liquid || this->_phase==iphase_gas || isSupercriticalPhase()); + return (this->_phase==iphase_liquid || this->_phase==iphase_gas || isSupercriticalPhase() || this->_phase == iphase_critical_point); } bool isTwoPhase(void){ diff --git a/include/DataStructures.h b/include/DataStructures.h index f59dcb31..d5486936 100644 --- a/include/DataStructures.h +++ b/include/DataStructures.h @@ -109,6 +109,7 @@ 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_critical_point, ///< At the critical point iphase_gas, ///< Subcritical gas iphase_twophase, ///< Twophase iphase_unknown, ///< Unknown phase diff --git a/src/Backends/Helmholtz/HelmholtzEOSMixtureBackend.cpp b/src/Backends/Helmholtz/HelmholtzEOSMixtureBackend.cpp index 7bf828d8..8aaaf86c 100644 --- a/src/Backends/Helmholtz/HelmholtzEOSMixtureBackend.cpp +++ b/src/Backends/Helmholtz/HelmholtzEOSMixtureBackend.cpp @@ -1086,10 +1086,30 @@ void HelmholtzEOSMixtureBackend::T_phase_determination_pure_or_pseudopure(int ot { if (!ValidNumber(value)){ throw ValueError(format("value to T_phase_determination_pure_or_pseudopure is invalid"));}; + + // T is known, another input P, T, H, S, U is given (all molar) if (_T < _crit.T && _p > _crit.p){ _phase = iphase_supercritical_liquid; } + else if (std::abs(_T - _crit.T) < 10*DBL_EPSILON) + { + switch (other) + { + case iDmolar: + if (std::abs(_rhomolar - _crit.rhomolar) < 10*DBL_EPSILON){ + _phase = iphase_critical_point; break; + } + else if (_rhomolar > _crit.rhomolar){ + _phase = iphase_supercritical_liquid; break; + } + else{ + _phase = iphase_supercritical_gas; break; + } + default: + throw ValueError(format("T=Tcrit; invalid input for other to T_phase_determination_pure_or_pseudopure")); + } + } else if (_T < _crit.T) { // Start to think about the saturation stuff diff --git a/src/CoolProp.cpp b/src/CoolProp.cpp index 984c266b..f62dbc8f 100644 --- a/src/CoolProp.cpp +++ b/src/CoolProp.cpp @@ -964,6 +964,8 @@ std::string phase_lookup_string(phases Phase) return "supercritical_gas"; case iphase_supercritical_liquid: ///< Supercritical liquid (p > pc, T < Tc) return "supercritical_liquid"; + case iphase_critical_point: ///< At the critical point + return "critical_point"; case iphase_gas: ///< Subcritical gas return "gas"; case iphase_twophase: ///< Twophase