From 62d902435a3bb7fa320cd5b2fd1e35a0bf3fb95c Mon Sep 17 00:00:00 2001 From: Tor Harald Sandve Date: Fri, 23 Apr 2021 08:40:14 +0200 Subject: [PATCH] move solveWellEquation inside prepareTimeStep --- .../wells/BlackoilWellModel_impl.hpp | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/opm/simulators/wells/BlackoilWellModel_impl.hpp b/opm/simulators/wells/BlackoilWellModel_impl.hpp index 55d268503..623a5ed87 100644 --- a/opm/simulators/wells/BlackoilWellModel_impl.hpp +++ b/opm/simulators/wells/BlackoilWellModel_impl.hpp @@ -1055,13 +1055,6 @@ namespace Opm { // Set the well primary variables based on the value of well solutions initPrimaryVariablesEvaluation(); - if (param_.solve_welleq_initially_ && iterationIdx == 0) { - for (auto& well : well_container_) { - well->solveWellEquation(ebosSimulator_, this->wellState(), this->groupState(), local_deferredLogger); - } - updateWellControls(local_deferredLogger, /* check group controls */ false); - } - maybeDoGasLiftOptimize(local_deferredLogger); assembleWellEq(dt, local_deferredLogger); } catch (const std::runtime_error& e) { @@ -1681,10 +1674,7 @@ namespace Opm { try { for (const auto& well : well_container_) { well->checkWellOperability(ebosSimulator_, this->wellState(), deferred_logger); - } - // since the controls are all updated, we should update well_state accordingly - for (const auto& well : well_container_) { - const int w = well->indexOfWell(); + if (!well->isOperable() ) continue; auto& events = this->wellState().events(); @@ -1694,7 +1684,13 @@ namespace Opm { // so next time step, the well does not consider to have effective events anymore. events.clearEvent(well->name(), WellStateFullyImplicitBlackoil::event_mask); } - } + + // solve the well equation initially to improve the initial solution of the well model + if (param_.solve_welleq_initially_) { + well->solveWellEquation(ebosSimulator_, this->wellState(), this->groupState(), deferred_logger); + } + + } // end of for (const auto& well : well_container_) updatePrimaryVariables(deferred_logger); } catch (const std::runtime_error& e) { exc_type = ExceptionType::RUNTIME_ERROR;