Let reported pressures (GPR) respect the NETBALAN configuration

This commit is contained in:
Vegard Kippe 2023-10-06 15:14:59 +02:00
parent 389db91839
commit 77bb7aa9cf
4 changed files with 10 additions and 18 deletions

View File

@ -214,7 +214,6 @@ namespace Opm {
void endTimeStep() void endTimeStep()
{ {
updateNetworkPressures(ebosSimulator_.episodeIndex(), true);
OPM_TIMEBLOCK(endTimeStep); OPM_TIMEBLOCK(endTimeStep);
timeStepSucceeded(ebosSimulator_.time(), ebosSimulator_.timeStepSize()); timeStepSucceeded(ebosSimulator_.time(), ebosSimulator_.timeStepSize());
} }

View File

@ -1010,8 +1010,6 @@ bool
BlackoilWellModelGeneric:: BlackoilWellModelGeneric::
needPreStepNetworkRebalance(const int report_step) const needPreStepNetworkRebalance(const int report_step) const
{ {
assert(this->networkActive());
const auto& network = schedule()[report_step].network(); const auto& network = schedule()[report_step].network();
bool network_rebalance_necessary = false; bool network_rebalance_necessary = false;
for (const auto& well : well_container_generic_) { for (const auto& well : well_container_generic_) {
@ -1082,9 +1080,9 @@ inferLocalShutWells()
double double
BlackoilWellModelGeneric:: BlackoilWellModelGeneric::
updateNetworkPressures(const int reportStepIdx, const bool compute_only) updateNetworkPressures(const int reportStepIdx)
{ {
// Get the network and return if inactive. // Get the network and return if inactive (no wells in network at this time)
const auto& network = schedule()[reportStepIdx].network(); const auto& network = schedule()[reportStepIdx].network();
if (!network.active()) { if (!network.active()) {
return 0.0; return 0.0;
@ -1101,7 +1099,7 @@ updateNetworkPressures(const int reportStepIdx, const bool compute_only)
// here, the network imbalance is the difference between the previous nodal pressure and the new nodal pressure // here, the network imbalance is the difference between the previous nodal pressure and the new nodal pressure
double network_imbalance = 0.; double network_imbalance = 0.;
if (compute_only) if (!this->networkActive())
return network_imbalance; return network_imbalance;
if (!previous_node_pressures.empty()) { if (!previous_node_pressures.empty()) {
@ -1138,7 +1136,7 @@ updateNetworkPressures(const int reportStepIdx, const bool compute_only)
// Producers only, since we so far only support the // Producers only, since we so far only support the
// "extended" network model (properties defined by // "extended" network model (properties defined by
// BRANPROP and NODEPROP) which only applies to producers. // BRANPROP and NODEPROP) which only applies to producers.
if (well->isProducer()) { if (well->isProducer() && well->wellEcl().predictionMode()) {
const auto it = node_pressures_.find(well->wellEcl().groupName()); const auto it = node_pressures_.find(well->wellEcl().groupName());
if (it != node_pressures_.end()) { if (it != node_pressures_.end()) {
// The well belongs to a group with has a network pressure constraint, // The well belongs to a group with has a network pressure constraint,
@ -1394,10 +1392,6 @@ bool
BlackoilWellModelGeneric:: BlackoilWellModelGeneric::
shouldBalanceNetwork(const int reportStepIdx, const int iterationIdx) const shouldBalanceNetwork(const int reportStepIdx, const int iterationIdx) const
{ {
// If the network is not active now, we do not need to balance it.
if (!this->networkActive())
return false;
const auto& balance = schedule()[reportStepIdx].network_balance(); const auto& balance = schedule()[reportStepIdx].network_balance();
if (balance.mode() == Network::Balance::CalcMode::TimeStepStart) { if (balance.mode() == Network::Balance::CalcMode::TimeStepStart) {
return iterationIdx == 0; return iterationIdx == 0;

View File

@ -328,7 +328,7 @@ protected:
bool wasDynamicallyShutThisTimeStep(const int well_index) const; bool wasDynamicallyShutThisTimeStep(const int well_index) const;
double updateNetworkPressures(const int reportStepIdx, const bool compute_only = false); double updateNetworkPressures(const int reportStepIdx);
void updateWsolvent(const Group& group, void updateWsolvent(const Group& group,
const int reportStepIdx, const int reportStepIdx,

View File

@ -1010,7 +1010,7 @@ namespace Opm {
const double dt = this->ebosSimulator_.timeStepSize(); const double dt = this->ebosSimulator_.timeStepSize();
// TODO: should we also have the group and network backed-up here in case the solution did not get converged? // TODO: should we also have the group and network backed-up here in case the solution did not get converged?
auto& well_state = this->wellState(); auto& well_state = this->wellState();
constexpr std::size_t max_iter = 100; const std::size_t max_iter = param_.network_max_iterations_;
bool converged = false; bool converged = false;
std::size_t iter = 0; std::size_t iter = 0;
bool changed_well_group = false; bool changed_well_group = false;
@ -1030,11 +1030,11 @@ namespace Opm {
} while (iter < max_iter); } while (iter < max_iter);
if (!converged) { if (!converged) {
const std::string msg = fmt::format("balanceNetwork did not get converged with {} iterations, and unconverged " const std::string msg = fmt::format("Initial (pre-step) network balance did not get converged with {} iterations, "
"network balance result will be used", max_iter); "unconverged network balance result will be used", max_iter);
deferred_logger.warning(msg); deferred_logger.warning(msg);
} else { } else {
const std::string msg = fmt::format("balanceNetwork get converged with {} iterations", iter); const std::string msg = fmt::format("Initial (pre-step) network balance converged with {} iterations", iter);
deferred_logger.debug(msg); deferred_logger.debug(msg);
} }
} }
@ -2245,8 +2245,7 @@ namespace Opm {
// Rebalance the network initially if any wells in the network have status changes // Rebalance the network initially if any wells in the network have status changes
// (Need to check this before clearing events) // (Need to check this before clearing events)
bool do_prestep_network_rebalance{false}; const bool do_prestep_network_rebalance = this->needPreStepNetworkRebalance(episodeIdx);
if (this->networkActive()) do_prestep_network_rebalance = this->needPreStepNetworkRebalance(episodeIdx);
for (const auto& well : well_container_) { for (const auto& well : well_container_) {
auto& events = this->wellState().well(well->indexOfWell()).events; auto& events = this->wellState().well(well->indexOfWell()).events;