From 4a9dbe9c1ab6b960767e9d5ccad2cca470ec9fd5 Mon Sep 17 00:00:00 2001 From: Paul Date: Tue, 7 Nov 2023 22:15:52 +0100 Subject: [PATCH] disable guiderates and set control mode to THP for wells with autochoke --- opm/input/eclipse/Schedule/Well/Well.hpp | 1 + .../eclipse/Schedule/KeywordHandlers.cpp | 26 ++++++++++++++++++- src/opm/input/eclipse/Schedule/Well/Well.cpp | 10 +++++++ 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/opm/input/eclipse/Schedule/Well/Well.hpp b/opm/input/eclipse/Schedule/Well/Well.hpp index 76bde9442..37ab2fb92 100644 --- a/opm/input/eclipse/Schedule/Well/Well.hpp +++ b/opm/input/eclipse/Schedule/Well/Well.hpp @@ -457,6 +457,7 @@ public: bool updateGroup(const std::string& group); bool updateWellGuideRate(bool available, double guide_rate, GuideRateTarget guide_phase, double scale_factor); bool updateWellGuideRate(double guide_rate); + bool updateWellGuideRate(bool available); bool updateEfficiencyFactor(double efficiency_factor); bool updateSolventFraction(double solvent_fraction); bool updateTracer(std::shared_ptr tracer_properties); diff --git a/src/opm/input/eclipse/Schedule/KeywordHandlers.cpp b/src/opm/input/eclipse/Schedule/KeywordHandlers.cpp index f57358d54..06d51a37c 100644 --- a/src/opm/input/eclipse/Schedule/KeywordHandlers.cpp +++ b/src/opm/input/eclipse/Schedule/KeywordHandlers.cpp @@ -987,6 +987,31 @@ File {} line {}.)", wname, location.keyword, location.filename, location.lineno) node.terminal_pressure(pressure_item.getSIDouble(0)); if (as_choke) { + //Wells belong to a group with autochoke enabled are to be run on a common THP and guide rate should be ignored + + const auto& group = this->getGroup(name, handlerContext.currentStep); + for (const std::string& wellName : group.wells()) { + auto well = this->snapshots.back().wells.get(wellName); + + //Let the wells be operating on a THP Constraint + auto properties = std::make_shared(well.getProductionProperties()); + properties->clearControls(); + properties->addProductionControl(Well::ProducerCMode::THP); + properties->controlMode = Well::ProducerCMode::THP; + well.updateProduction(properties); + // this->snapshots.back().events().addEvent( ScheduleEvents::PRODUCTION_UPDATE ); + // this->snapshots.back().wellgroup_events().addEvent( well2.name(), ScheduleEvents::PRODUCTION_UPDATE); + + // Guide rate availablity should be set to false + const bool availableForGroupControl = false; + well.updateWellGuideRate(availableForGroupControl); + auto new_config = this->snapshots.back().guide_rate(); + new_config.update_well(well); + this->snapshots.back().guide_rate.update( std::move(new_config) ); + + this->snapshots.back().wells.update( std::move(well) ); + } + std::string target_group = name; const auto& target_item = record.getItem(); @@ -995,7 +1020,6 @@ File {} line {}.)", wname, location.keyword, location.filename, location.lineno) if (target_group != name) { if (this->snapshots.back().groups.has(name)) { - const auto& group = this->getGroup(name, handlerContext.currentStep); if (group.numWells() > 0) throw std::invalid_argument("A manifold group must respond to its own target"); } diff --git a/src/opm/input/eclipse/Schedule/Well/Well.cpp b/src/opm/input/eclipse/Schedule/Well/Well.cpp index 6ce34f26d..20bc90eb1 100644 --- a/src/opm/input/eclipse/Schedule/Well/Well.cpp +++ b/src/opm/input/eclipse/Schedule/Well/Well.cpp @@ -757,6 +757,16 @@ bool Well::updateWellGuideRate(bool available, double guide_rate_arg, GuideRateT return update; } +bool Well::updateWellGuideRate(bool available) { + bool update = false; + if (this->guide_rate.available != available) { + this->guide_rate.available = available; + update = true; + } + + return update; +} +