From 61ed8037400c08278ba2447952bc86444dcaf935 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20H=C3=A6gland?= Date: Sun, 9 Oct 2022 17:47:48 +0200 Subject: [PATCH] Do stage2 even if GLIFTOPT is not defined --- .../wells/GasLiftSingleWellGeneric.cpp | 2 +- opm/simulators/wells/GasLiftStage2.cpp | 39 ++++++++++++------- opm/simulators/wells/GasLiftStage2.hpp | 2 + 3 files changed, 27 insertions(+), 16 deletions(-) diff --git a/opm/simulators/wells/GasLiftSingleWellGeneric.cpp b/opm/simulators/wells/GasLiftSingleWellGeneric.cpp index 65a6607f7..bced1e3a8 100644 --- a/opm/simulators/wells/GasLiftSingleWellGeneric.cpp +++ b/opm/simulators/wells/GasLiftSingleWellGeneric.cpp @@ -765,7 +765,7 @@ getRateWithGroupLimit_( const double delta_rate = new_rate - old_rate; if (delta_rate > 0) { // It is required that the production rate for a given group is - // is less than or equal to its target rate, see assert() below. + // is less than or equal to its target rate. // Then it only makes sense to check if the group target is exceeded // if delta_rate > 0 const auto &pairs = diff --git a/opm/simulators/wells/GasLiftStage2.cpp b/opm/simulators/wells/GasLiftStage2.cpp index 422f7e134..627f7fbb5 100644 --- a/opm/simulators/wells/GasLiftStage2.cpp +++ b/opm/simulators/wells/GasLiftStage2.cpp @@ -403,6 +403,26 @@ getCurrentWellRates_(const std::string &well_name, const std::string &group_name return std::make_tuple(oil_rate, gas_rate, alq); } +std::optional +GasLiftStage2::getGroupMaxALQ_(const Group &group) +{ + if (this->glo_.has_group(group.name())) { + const auto &gl_group = this->glo_.group(group.name()); + return gl_group.max_lift_gas(); + } + return std::nullopt; // If GLIFTOPT is missing from schedule, assume unlimited alq +} + +std::optional +GasLiftStage2::getGroupMaxTotalGas_(const Group &group) +{ + if (this->glo_.has_group(group.name())) { + const auto &gl_group = this->glo_.group(group.name()); + return gl_group.max_total_gas(); + } + return std::nullopt; // If GLIFTOPT is missing from schedule, assume unlimited alq +} + std::pair GasLiftStage2:: getWellRates_(const WellInterfaceGeneric &well) @@ -517,9 +537,8 @@ void GasLiftStage2:: optimizeGroup_(const Group &group) { - const auto &gl_group = this->glo_.group(group.name()); - const auto &max_glift = gl_group.max_lift_gas(); - const auto &max_total_gas = gl_group.max_total_gas(); + const auto max_glift = getGroupMaxALQ_(group); + const auto max_total_gas = getGroupMaxTotalGas_(group); if (group.has_control(Group::ProductionCMode::ORAT) || max_glift || max_total_gas) { @@ -546,16 +565,7 @@ optimizeGroupsRecursive_(const Group &group) group_name, this->report_step_idx_); optimizeGroupsRecursive_(sub_group); } - // TODO: should we also optimize groups that do not have GLIFTOPT defined? - // (i.e. glo_.has_group(name) returns false) - // IF GLIFTOPT is not specified for the group or if item 2 of GLIFTOPT - // is defaulted, there is no maximum lift gas supply for the group. - // But even if there is no limit on the liftgas supply it can still - // be desireable to use as little ALQ as possible to achieve a - // group oil rate limit or gas rate limit. - if (this->glo_.has_group(group.name())) // only optimize if GLIFTOPT is given - optimizeGroup_(group); - + optimizeGroup_(group); } void @@ -718,8 +728,7 @@ removeSurplusALQ_(const Group &group, return; } assert(!dec_grads.empty()); - const auto &gl_group = this->glo_.group(group.name()); - const auto &max_glift = gl_group.max_lift_gas(); + const auto max_glift = getGroupMaxALQ_(group); const auto controls = group.productionControls(this->summary_state_); //const auto &max_total_gas = gl_group.max_total_gas(); auto [oil_rate, gas_rate, alq] = getCurrentGroupRates_(group); diff --git a/opm/simulators/wells/GasLiftStage2.hpp b/opm/simulators/wells/GasLiftStage2.hpp index e2ce7bcbb..660af32b7 100644 --- a/opm/simulators/wells/GasLiftStage2.hpp +++ b/opm/simulators/wells/GasLiftStage2.hpp @@ -92,6 +92,8 @@ protected: const Group& group); std::tuple getCurrentWellRates_( const std::string& well_name, const std::string& group_name); + std::optional getGroupMaxALQ_(const Group &group); + std::optional getGroupMaxTotalGas_(const Group &group); std::vector getGroupGliftWells_( const Group& group); void getGroupGliftWellsRecursive_(