From de455acf10e0199a4ac75efeebc6bf6f8a282236 Mon Sep 17 00:00:00 2001 From: Ian Bell Date: Mon, 22 Aug 2016 22:18:49 -0600 Subject: [PATCH] Add some logic for mixtures to use "normal" TP solver when phase is imposed (not the global search) --- src/Backends/Helmholtz/FlashRoutines.cpp | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/Backends/Helmholtz/FlashRoutines.cpp b/src/Backends/Helmholtz/FlashRoutines.cpp index 4a578872..1e09131b 100644 --- a/src/Backends/Helmholtz/FlashRoutines.cpp +++ b/src/Backends/Helmholtz/FlashRoutines.cpp @@ -55,17 +55,27 @@ void FlashRoutines::PT_flash_mixtures(HelmholtzEOSMixtureBackend &HEOS) } } else{ - // Following the strategy of Gernert, 2014 - StabilityRoutines::StabilityEvaluationClass stability_tester(HEOS); - if (!stability_tester.is_stable()){ - throw CoolProp::ValueError("PT_INPUTS are two-phase, not yet supported"); + if (HEOS.imposed_phase_index == iphase_not_imposed){ + // Blind flash call + // Following the strategy of Gernert, 2014 + StabilityRoutines::StabilityEvaluationClass stability_tester(HEOS); + if (!stability_tester.is_stable()){ + throw CoolProp::ValueError("PT_INPUTS are two-phase, not yet supported"); + } + else{ + // It's single-phase + double rho = HEOS.solver_rho_Tp_global(HEOS.T(), HEOS.p(), 20000); + HEOS.update_DmolarT_direct(rho, HEOS.T()); + HEOS._Q = -1; + HEOS._phase = iphase_liquid; + } } else{ - // It's single-phase - double rho = HEOS.solver_rho_Tp_global(HEOS.T(), HEOS.p(), 20000); + // It's single-phase, and phase is imposed + double rho = HEOS.solver_rho_Tp(HEOS.T(), HEOS.p()); HEOS.update_DmolarT_direct(rho, HEOS.T()); HEOS._Q = -1; - HEOS._phase = iphase_liquid; + HEOS._phase = HEOS.imposed_phase_index; } } }