diff --git a/opm/simulators/wells/BlackoilWellModel_impl.hpp b/opm/simulators/wells/BlackoilWellModel_impl.hpp index 1d151ebba..c3908f4c3 100644 --- a/opm/simulators/wells/BlackoilWellModel_impl.hpp +++ b/opm/simulators/wells/BlackoilWellModel_impl.hpp @@ -669,7 +669,6 @@ namespace Opm { case Well::ProducerCMode::RESV: zero_rate_control = is_zero(prod_controls.resv_rate); break; - default: // Might still have zero rate controls, but is pressure controlled. zero_rate_control = false; diff --git a/opm/simulators/wells/SingleWellState.cpp b/opm/simulators/wells/SingleWellState.cpp index 6e8388b7c..fb0ca8bd9 100644 --- a/opm/simulators/wells/SingleWellState.cpp +++ b/opm/simulators/wells/SingleWellState.cpp @@ -39,6 +39,7 @@ SingleWellState::SingleWellState(const std::string& name_, , surface_rates(pu_.num_phases) , reservoir_rates(pu_.num_phases) , perf_data(perf_input.size(), pressure_first_connection, !is_producer, pu_.num_phases) + , trivial_target(false) { for (std::size_t perf = 0; perf < perf_input.size(); perf++) { this->perf_data.cell_index[perf] = perf_input[perf].cell_index; diff --git a/opm/simulators/wells/SingleWellState.hpp b/opm/simulators/wells/SingleWellState.hpp index 3fd99aa77..b0d1c5605 100644 --- a/opm/simulators/wells/SingleWellState.hpp +++ b/opm/simulators/wells/SingleWellState.hpp @@ -61,6 +61,7 @@ public: std::vector surface_rates; std::vector reservoir_rates; PerfData perf_data; + bool trivial_target; SegmentState segments; Events events; Well::InjectorCMode injection_cmode{Well::InjectorCMode::CMODE_UNDEFINED}; diff --git a/opm/simulators/wells/WellInterfaceFluidSystem.cpp b/opm/simulators/wells/WellInterfaceFluidSystem.cpp index 13743c496..56f65945b 100644 --- a/opm/simulators/wells/WellInterfaceFluidSystem.cpp +++ b/opm/simulators/wells/WellInterfaceFluidSystem.cpp @@ -163,7 +163,7 @@ activeProductionConstraint(const SingleWellState& ws, if (controls.hasControl(Well::ProducerCMode::THP) && currentControl != Well::ProducerCMode::THP) { const auto& thp = getTHPConstraint(summaryState); double current_thp = ws.thp; - if (thp > current_thp) { + if (thp > current_thp && !ws.trivial_target) { // If WVFPEXP item 4 is set to YES1 or YES2 // switching to THP is prevented if the well will // produce at a higher rate with THP control @@ -1120,6 +1120,10 @@ getGroupProductionTargetRate(const Group& group, const auto& rates = ws.surface_rates; const auto current_rate = -tcalc.calcModeRateFromRates(rates); // Switch sign since 'rates' are negative for producers. double scale = 1.0; + if (target_rate == 0.0) { + return 0.0; + } + if (current_rate > 1e-14) scale = target_rate/current_rate; return scale; diff --git a/opm/simulators/wells/WellInterface_impl.hpp b/opm/simulators/wells/WellInterface_impl.hpp index 4b0013ce3..07bab78a2 100644 --- a/opm/simulators/wells/WellInterface_impl.hpp +++ b/opm/simulators/wells/WellInterface_impl.hpp @@ -982,6 +982,9 @@ namespace Opm for (int p = 0; p