diff --git a/opm/simulators/wells/BlackoilWellModelGeneric.cpp b/opm/simulators/wells/BlackoilWellModelGeneric.cpp index 14d6116cb..cfbbe8759 100644 --- a/opm/simulators/wells/BlackoilWellModelGeneric.cpp +++ b/opm/simulators/wells/BlackoilWellModelGeneric.cpp @@ -1238,6 +1238,12 @@ bool BlackoilWellModelGeneric:: shouldBalanceNetwork(const int reportStepIdx, const int iterationIdx) const { + // if network is not active, we do not need to balance the network + const auto& network = schedule()[reportStepIdx].network(); + if (!network.active()) { + return false; + } + const auto& balance = schedule()[reportStepIdx].network_balance(); if (balance.mode() == Network::Balance::CalcMode::TimeStepStart) { return iterationIdx == 0; diff --git a/opm/simulators/wells/BlackoilWellModel_impl.hpp b/opm/simulators/wells/BlackoilWellModel_impl.hpp index 0b5e6b16f..41389eebe 100644 --- a/opm/simulators/wells/BlackoilWellModel_impl.hpp +++ b/opm/simulators/wells/BlackoilWellModel_impl.hpp @@ -25,12 +25,13 @@ #include #include +#include +#include #include #include #include #include -#include #if HAVE_MPI #include @@ -746,7 +747,25 @@ namespace Opm { well_container_generic_.clear(); for (auto& w : well_container_) - well_container_generic_.push_back(w.get()); + well_container_generic_.push_back(w.get()); + + const auto& network = schedule()[time_step].network(); + if (network.active() && !this->node_pressures_.empty()) { + for (auto& well: well_container_generic_) { + // Producers only, since we so far only support the + // "extended" network model (properties defined by + // BRANPROP and NODEPROP) which only applies to producers. + if (well->isProducer()) { + const auto it = node_pressures_.find(well->wellEcl().groupName()); + if (it != node_pressures_.end()) { + // The well belongs to a group which has a network nodal pressure, + // set the dynamic THP constraint based on the network nodal pressure + const double nodal_pressure = it->second; + well->setDynamicThpLimit(nodal_pressure); + } + } + } + } }