check also the validity of the iterated solution

This commit is contained in:
Tor Harald Sandve 2022-02-11 09:34:00 +01:00
parent 650416c647
commit cb99a2fc74

View File

@ -2333,25 +2333,30 @@ namespace Opm
deferred_logger, deferred_logger,
max_pressure, max_pressure,
alq_value); alq_value);
auto v = frates(*bhpAtLimit); auto v = frates(*bhpAtLimit);
if(bhpAtLimit && std::all_of(v.cbegin(), v.cend(), [](double i){ return i <= 0; })) if(bhpAtLimit && std::all_of(v.cbegin(), v.cend(), [](double i){ return i <= 0; }))
return bhpAtLimit; return bhpAtLimit;
auto fratesIter = [this, &ebos_simulator, &deferred_logger](const double bhp) { auto fratesIter = [this, &ebos_simulator, &deferred_logger](const double bhp) {
// Solver the well iterations to see if we are // Solver the well iterations to see if we are
// able to get a solution with an update // able to get a solution with an update
// solution // solution
std::vector<double> rates(3); std::vector<double> rates(3);
computeWellRatesWithBhpIterations(ebos_simulator, bhp, rates, deferred_logger); computeWellRatesWithBhpIterations(ebos_simulator, bhp, rates, deferred_logger);
return rates; return rates;
}; };
return this->StandardWellGeneric<Scalar>::computeBhpAtThpLimitProdWithAlq(fratesIter, bhpAtLimit = this->StandardWellGeneric<Scalar>::computeBhpAtThpLimitProdWithAlq(fratesIter,
summary_state, summary_state,
deferred_logger, deferred_logger,
max_pressure, max_pressure,
alq_value); alq_value);
v = frates(*bhpAtLimit);
if(bhpAtLimit && std::all_of(v.cbegin(), v.cend(), [](double i){ return i <= 0; }))
return bhpAtLimit;
// we still don't get a valied solution.
return std::nullopt;
} }