From b6eecf5c55ef3a77eb7c40ec28ad901eeb1bf1ad Mon Sep 17 00:00:00 2001 From: Kai Bao Date: Tue, 28 Mar 2023 15:22:50 +0200 Subject: [PATCH] not updating the THP for zero rate controlled wells --- opm/simulators/wells/MultisegmentWellPrimaryVariables.cpp | 3 ++- opm/simulators/wells/MultisegmentWellPrimaryVariables.hpp | 1 + opm/simulators/wells/MultisegmentWell_impl.hpp | 2 +- opm/simulators/wells/StandardWell.hpp | 4 +++- opm/simulators/wells/StandardWellEval.cpp | 4 +++- opm/simulators/wells/StandardWellEval.hpp | 3 ++- opm/simulators/wells/StandardWell_impl.hpp | 8 +++++--- opm/simulators/wells/WellBhpThpCalculator.cpp | 3 ++- opm/simulators/wells/WellBhpThpCalculator.hpp | 1 + opm/simulators/wells/WellInterface_impl.hpp | 3 ++- 10 files changed, 22 insertions(+), 10 deletions(-) diff --git a/opm/simulators/wells/MultisegmentWellPrimaryVariables.cpp b/opm/simulators/wells/MultisegmentWellPrimaryVariables.cpp index e1fd2c003..368101606 100644 --- a/opm/simulators/wells/MultisegmentWellPrimaryVariables.cpp +++ b/opm/simulators/wells/MultisegmentWellPrimaryVariables.cpp @@ -207,6 +207,7 @@ template void MultisegmentWellPrimaryVariables:: copyToWellState(const MultisegmentWellGeneric& mswell, const double rho, + const bool zero_rate_target, WellState& well_state, DeferredLogger& deferred_logger) const { @@ -393,7 +394,7 @@ copyToWellState(const MultisegmentWellGeneric& mswell, } WellBhpThpCalculator(well_) - .updateThp(rho, [this]() { return well_.wellEcl().alq_value(); }, + .updateThp(rho, zero_rate_target, [this]() { return well_.wellEcl().alq_value(); }, {FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx), FluidSystem::phaseIsActive(FluidSystem::oilPhaseIdx), FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx)}, diff --git a/opm/simulators/wells/MultisegmentWellPrimaryVariables.hpp b/opm/simulators/wells/MultisegmentWellPrimaryVariables.hpp index 5dce2d536..4d5630617 100644 --- a/opm/simulators/wells/MultisegmentWellPrimaryVariables.hpp +++ b/opm/simulators/wells/MultisegmentWellPrimaryVariables.hpp @@ -100,6 +100,7 @@ public: //! \brief Copy values to well state. void copyToWellState(const MultisegmentWellGeneric& mswell, const double rho, + const bool zero_rate_target, WellState& well_state, DeferredLogger& deferred_logger) const; diff --git a/opm/simulators/wells/MultisegmentWell_impl.hpp b/opm/simulators/wells/MultisegmentWell_impl.hpp index e2ea225ab..9491bff20 100644 --- a/opm/simulators/wells/MultisegmentWell_impl.hpp +++ b/opm/simulators/wells/MultisegmentWell_impl.hpp @@ -622,7 +622,7 @@ namespace Opm zero_rate_target, max_pressure_change); - this->primary_variables_.copyToWellState(*this, getRefDensity(), + this->primary_variables_.copyToWellState(*this, getRefDensity(), zero_rate_target, well_state, deferred_logger); Base::calculateReservoirRates(well_state.well(this->index_of_well_)); } diff --git a/opm/simulators/wells/StandardWell.hpp b/opm/simulators/wells/StandardWell.hpp index ca0629a30..ba7d3829d 100644 --- a/opm/simulators/wells/StandardWell.hpp +++ b/opm/simulators/wells/StandardWell.hpp @@ -368,7 +368,9 @@ namespace Opm const bool zero_rate_target, DeferredLogger& deferred_logger); - void updateWellStateFromPrimaryVariables(WellState& well_state, DeferredLogger& deferred_logger) const; + void updateWellStateFromPrimaryVariables(const bool zero_rate_target, + WellState& well_state, + DeferredLogger& deferred_logger) const; virtual void assembleWellEqWithoutIteration(const Simulator& ebosSimulator, const double dt, diff --git a/opm/simulators/wells/StandardWellEval.cpp b/opm/simulators/wells/StandardWellEval.cpp index fb496728a..da13a574a 100644 --- a/opm/simulators/wells/StandardWellEval.cpp +++ b/opm/simulators/wells/StandardWellEval.cpp @@ -71,13 +71,15 @@ extendEval(const Eval& in) const template void StandardWellEval:: -updateWellStateFromPrimaryVariables(WellState& well_state, +updateWellStateFromPrimaryVariables(const bool zero_rate_target, + WellState& well_state, DeferredLogger& deferred_logger) const { this->primary_variables_.copyToWellState(well_state, deferred_logger); WellBhpThpCalculator(baseif_). updateThp(connections_.rho(), + zero_rate_target, [this,&well_state]() { return this->baseif_.getALQ(well_state); }, {FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx), FluidSystem::phaseIsActive(FluidSystem::oilPhaseIdx), diff --git a/opm/simulators/wells/StandardWellEval.hpp b/opm/simulators/wells/StandardWellEval.hpp index adc39275b..ff0c960de 100644 --- a/opm/simulators/wells/StandardWellEval.hpp +++ b/opm/simulators/wells/StandardWellEval.hpp @@ -92,7 +92,8 @@ protected: const int num_cells, const bool has_polymermw); - void updateWellStateFromPrimaryVariables(WellState& well_state, + void updateWellStateFromPrimaryVariables(const bool zero_rate_target, + WellState& well_state, DeferredLogger& deferred_logger) const; PrimaryVariables primary_variables_; //!< Primary variables for well diff --git a/opm/simulators/wells/StandardWell_impl.hpp b/opm/simulators/wells/StandardWell_impl.hpp index aff6dd886..aaef3656a 100644 --- a/opm/simulators/wells/StandardWell_impl.hpp +++ b/opm/simulators/wells/StandardWell_impl.hpp @@ -1003,7 +1003,7 @@ namespace Opm const bool zero_rate_target = this->wellUnderZeroRateControl(summary_state, well_state); updatePrimaryVariablesNewton(dwells, zero_rate_target, deferred_logger); - updateWellStateFromPrimaryVariables(well_state, deferred_logger); + updateWellStateFromPrimaryVariables(zero_rate_target, well_state, deferred_logger); Base::calculateReservoirRates(well_state.well(this->index_of_well_)); } @@ -1037,9 +1037,11 @@ namespace Opm template void StandardWell:: - updateWellStateFromPrimaryVariables(WellState& well_state, DeferredLogger& deferred_logger) const + updateWellStateFromPrimaryVariables(const bool zero_rate_target, + WellState& well_state, + DeferredLogger& deferred_logger) const { - this->StdWellEval::updateWellStateFromPrimaryVariables(well_state, deferred_logger); + this->StdWellEval::updateWellStateFromPrimaryVariables(zero_rate_target, well_state, deferred_logger); // other primary variables related to polymer injectivity study if constexpr (Base::has_polymermw) { diff --git a/opm/simulators/wells/WellBhpThpCalculator.cpp b/opm/simulators/wells/WellBhpThpCalculator.cpp index 00a6c5a87..7cc184eeb 100644 --- a/opm/simulators/wells/WellBhpThpCalculator.cpp +++ b/opm/simulators/wells/WellBhpThpCalculator.cpp @@ -224,6 +224,7 @@ computeBhpAtThpLimitInj(const std::function(const double)>& } void WellBhpThpCalculator::updateThp(const double rho, + const bool zero_rate_target, const std::function& alq_value, const std::array& active, WellState& well_state, @@ -235,7 +236,7 @@ void WellBhpThpCalculator::updateThp(const double rho, auto& ws = well_state.well(well_.indexOfWell()); // When there is no vaild VFP table provided, we set the thp to be zero. - if (!well_.isVFPActive(deferred_logger) || well_.wellIsStopped()) { + if (!well_.isVFPActive(deferred_logger) || well_.wellIsStopped() || zero_rate_target) { ws.thp = 0; return; } diff --git a/opm/simulators/wells/WellBhpThpCalculator.hpp b/opm/simulators/wells/WellBhpThpCalculator.hpp index b401ed06b..651ab2f55 100644 --- a/opm/simulators/wells/WellBhpThpCalculator.hpp +++ b/opm/simulators/wells/WellBhpThpCalculator.hpp @@ -82,6 +82,7 @@ public: //! \brief Update THP. void updateThp(const double rho, + const bool zero_rate_target, const std::function& alq_value, const std::array& active, WellState& well_state, diff --git a/opm/simulators/wells/WellInterface_impl.hpp b/opm/simulators/wells/WellInterface_impl.hpp index 248f46e38..53fb8d96f 100644 --- a/opm/simulators/wells/WellInterface_impl.hpp +++ b/opm/simulators/wells/WellInterface_impl.hpp @@ -184,7 +184,8 @@ namespace Opm const GroupState& group_state, DeferredLogger& deferred_logger) /* const */ { - if (this->wellIsStopped()) { + const auto& summary_state = ebos_simulator.vanguard().summaryState(); + if (this->wellUnderZeroRateControl(summary_state, well_state)) { return false; }