From b2eccfdba84dbcf05b6503fbffb51a90b17c86d6 Mon Sep 17 00:00:00 2001 From: Ian Bell Date: Mon, 15 Sep 2014 18:02:12 +0200 Subject: [PATCH] Find Tmax and pmax indices right at the end - much simpler Signed-off-by: Ian Bell --- .../Helmholtz/PhaseEnvelopeRoutines.cpp | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/src/Backends/Helmholtz/PhaseEnvelopeRoutines.cpp b/src/Backends/Helmholtz/PhaseEnvelopeRoutines.cpp index f9a82963..baa38d7e 100644 --- a/src/Backends/Helmholtz/PhaseEnvelopeRoutines.cpp +++ b/src/Backends/Helmholtz/PhaseEnvelopeRoutines.cpp @@ -204,7 +204,6 @@ void PhaseEnvelopeRoutines::build(HelmholtzEOSMixtureBackend &HEOS) std::cout << format("envelope built.\n"); // Now we refine the phase envelope to add some points in places that are still pretty rough - // Can be re-enabled by just uncommenting the following line refine(HEOS); return; @@ -376,20 +375,14 @@ void PhaseEnvelopeRoutines::finalize(HelmholtzEOSMixtureBackend &HEOS) env.insert_variables(resid.IO.T, resid.IO.p, resid.IO.rhomolar_liq, resid.IO.rhomolar_vap, resid.IO.hmolar_liq, resid.IO.hmolar_vap, resid.IO.smolar_liq, resid.IO.smolar_vap, resid.IO.x, resid.IO.y, imax); - - if (maxima == TMAX_SAT){ - env.iTsat_max = imax; - if (imax <= env.ipsat_max){ - // Psat_max goes first; an insertion at a smaller index bumps up the index - // for ipsat_max, so we bump the index to keep pace - env.ipsat_max++; - } - } - else{ - env.ipsat_max = imax; - } } } + + // Find the index of the point with the highest temperature + env.iTsat_max = std::distance(env.T.begin(), std::max_element(env.T.begin(), env.T.end())); + + // Find the index of the point with the highest pressure + env.ipsat_max = std::distance(env.p.begin(), std::max_element(env.p.begin(), env.p.end())); } std::vector > PhaseEnvelopeRoutines::find_intersections(HelmholtzEOSMixtureBackend &HEOS, parameters iInput, long double value)