From f2b31faffc8539baf6080283c1ca50e3a2a21415 Mon Sep 17 00:00:00 2001 From: Ian Bell Date: Tue, 10 Feb 2015 18:55:24 -0700 Subject: [PATCH] Fail appropriately when two-phase inputs are given for pseudo-pure; Closes #459 Fix is_pure() function Signed-off-by: Ian Bell --- src/Backends/Helmholtz/HelmholtzEOSMixtureBackend.cpp | 6 ++++-- src/Backends/Helmholtz/HelmholtzEOSMixtureBackend.h | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Backends/Helmholtz/HelmholtzEOSMixtureBackend.cpp b/src/Backends/Helmholtz/HelmholtzEOSMixtureBackend.cpp index 51768f8f..2a9ce891 100644 --- a/src/Backends/Helmholtz/HelmholtzEOSMixtureBackend.cpp +++ b/src/Backends/Helmholtz/HelmholtzEOSMixtureBackend.cpp @@ -1365,6 +1365,9 @@ void HelmholtzEOSMixtureBackend::T_phase_determination_pure_or_pseudopure(int ot else if (value > p_liq){ this->_phase = iphase_liquid; _Q = 1000; return; } + else if (!is_pure() && value < static_cast(_pLanc) && value > static_cast(_pVanc)){ + throw ValueError("Two-phase inputs not supported for pseudo-pure for now"); + } break; } default: @@ -1432,8 +1435,7 @@ void HelmholtzEOSMixtureBackend::T_phase_determination_pure_or_pseudopure(int ot } } - // Determine Q based on the input provided - if (!is_pure_or_pseudopure){throw ValueError("possibly two-phase inputs not supported for pseudo-pure for now");} + // Actually have to use saturation information sadly // For the given temperature, find the saturation state diff --git a/src/Backends/Helmholtz/HelmholtzEOSMixtureBackend.h b/src/Backends/Helmholtz/HelmholtzEOSMixtureBackend.h index f3ebe5f7..e65df652 100644 --- a/src/Backends/Helmholtz/HelmholtzEOSMixtureBackend.h +++ b/src/Backends/Helmholtz/HelmholtzEOSMixtureBackend.h @@ -54,7 +54,7 @@ public: bool using_mole_fractions(){return true;} bool using_mass_fractions(){return false;} bool using_volu_fractions(){return false;} - bool is_pure(){ return is_pure_or_pseudopure; } + bool is_pure(){ return components.size() == 1 && !components[0]->EOSVector[0].pseudo_pure; } bool has_melting_line(){ return is_pure_or_pseudopure && components[0]->ancillaries.melting_line.enabled();}; long double calc_melting_line(int param, int given, long double value); phases calc_phase(void){return _phase;};