diff --git a/opm/simulators/wells/BlackoilWellModel_impl.hpp b/opm/simulators/wells/BlackoilWellModel_impl.hpp index 3b1b7168b..729758dcf 100644 --- a/opm/simulators/wells/BlackoilWellModel_impl.hpp +++ b/opm/simulators/wells/BlackoilWellModel_impl.hpp @@ -297,17 +297,6 @@ namespace Opm { well->closeCompletions(wellTestState()); } - // calculate the well potentials - try { - updateWellPotentials(reportStepIdx, - /*onlyAfterEvent*/true, - ebosSimulator_.vanguard().summaryConfig(), - local_deferredLogger); - } catch ( std::runtime_error& e ) { - const std::string msg = "A zero well potential is returned for output purposes. "; - local_deferredLogger.warning("WELL_POTENTIAL_CALCULATION_FAILED", msg); - } - if (alternative_well_rate_init_) { // Update the well rates of well_state_, if only single-phase rates, to // have proper multi-phase rates proportional to rates at bhp zero. @@ -320,6 +309,17 @@ namespace Opm { } } + // calculate the well potentials + try { + updateWellPotentials(reportStepIdx, + /*onlyAfterEvent*/true, + ebosSimulator_.vanguard().summaryConfig(), + local_deferredLogger); + } catch ( std::runtime_error& e ) { + const std::string msg = "A zero well potential is returned for output purposes. "; + local_deferredLogger.warning("WELL_POTENTIAL_CALCULATION_FAILED", msg); + } + //update guide rates const auto& comm = ebosSimulator_.vanguard().grid().comm(); const auto& summaryState = ebosSimulator_.vanguard().summaryState(); diff --git a/opm/simulators/wells/MultisegmentWell_impl.hpp b/opm/simulators/wells/MultisegmentWell_impl.hpp index 893385b50..6603427bb 100644 --- a/opm/simulators/wells/MultisegmentWell_impl.hpp +++ b/opm/simulators/wells/MultisegmentWell_impl.hpp @@ -422,9 +422,15 @@ namespace Opm // initialized the well rates with the potentials i.e. the well rates based on bhp const int np = this->number_of_phases_; - const double sign = well_copy.well_ecl_.isInjector() ? 1.0 : -1.0; + bool trivial = true; for (int phase = 0; phase < np; ++phase){ - ws.surface_rates[phase] = sign * ws.well_potentials[phase]; + trivial = trivial && (ws.well_potentials[phase] == 0.0) ; + } + if (!trivial) { + const double sign = well_copy.well_ecl_.isInjector() ? 1.0 : -1.0; + for (int phase = 0; phase < np; ++phase) { + ws.surface_rates[phase] = sign * ws.well_potentials[phase]; + } } well_copy.scaleSegmentRatesWithWellRates(well_state_copy); diff --git a/opm/simulators/wells/WellInterface_impl.hpp b/opm/simulators/wells/WellInterface_impl.hpp index 36233d048..93b18212a 100644 --- a/opm/simulators/wells/WellInterface_impl.hpp +++ b/opm/simulators/wells/WellInterface_impl.hpp @@ -1013,14 +1013,19 @@ namespace Opm } } } - if (nonzero_rate_index == -1) { - // No nonzero rates. - return; - } // Calculate the rates that follow from the current primary variables. std::vector well_q_s = computeCurrentWellRates(ebosSimulator, deferred_logger); + if (nonzero_rate_index == -1) { + // No nonzero rates. + // Use the computed rate directly + for (int p = 0; p < this->number_of_phases_; ++p) { + ws.surface_rates[p] = well_q_s[this->flowPhaseToEbosCompIdx(p)]; + } + return; + } + // Set the currently-zero phase flows to be nonzero in proportion to well_q_s. const double initial_nonzero_rate = ws.surface_rates[nonzero_rate_index]; const int comp_idx_nz = this->flowPhaseToEbosCompIdx(nonzero_rate_index);