From e0573e99b11327febf87dcd62beb4b684d157e17 Mon Sep 17 00:00:00 2001 From: Tor Harald Sandve Date: Wed, 9 Feb 2022 10:59:24 +0100 Subject: [PATCH] iterate in computeBhpAtThpLimitProdWithAlq if no solution or potentials are negative --- opm/simulators/wells/StandardWell_impl.hpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/opm/simulators/wells/StandardWell_impl.hpp b/opm/simulators/wells/StandardWell_impl.hpp index 888257d71..f66e5b2a6 100644 --- a/opm/simulators/wells/StandardWell_impl.hpp +++ b/opm/simulators/wells/StandardWell_impl.hpp @@ -2328,11 +2328,30 @@ namespace Opm double pressure_cell = this->getPerfCellPressure(fs).value(); max_pressure = std::max(max_pressure, pressure_cell); } - return this->StandardWellGeneric::computeBhpAtThpLimitProdWithAlq(frates, + auto bhpAtLimit = this->StandardWellGeneric::computeBhpAtThpLimitProdWithAlq(frates, summary_state, deferred_logger, max_pressure, alq_value); + auto v = frates(*bhpAtLimit); + if(bhpAtLimit && std::all_of(v.cbegin(), v.cend(), [](double i){ return i <= 0; })) + return bhpAtLimit; + + auto fratesIter = [this, &ebos_simulator, &deferred_logger](const double bhp) { + // Solver the well iterations to see if we are + // able to get a solution with an update + // solution + std::vector rates(3); + computeWellRatesWithBhpIterations(ebos_simulator, bhp, rates, deferred_logger); + return rates; + }; + + return this->StandardWellGeneric::computeBhpAtThpLimitProdWithAlq(fratesIter, + summary_state, + deferred_logger, + max_pressure, + alq_value); + }