From bafa408be152d7c4bef82d4f31dbbd2630c6de30 Mon Sep 17 00:00:00 2001 From: Vegard Kippe Date: Fri, 17 Jan 2025 13:01:24 +0100 Subject: [PATCH 1/2] Ensure setting GRUP control mode in WCONPROD is allowed for wells belonging to auto-choke groups. --- .../Schedule/Well/WellKeywordHandlers.cpp | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/opm/input/eclipse/Schedule/Well/WellKeywordHandlers.cpp b/opm/input/eclipse/Schedule/Well/WellKeywordHandlers.cpp index f881c11d5ec..0bdc49906d6 100644 --- a/opm/input/eclipse/Schedule/Well/WellKeywordHandlers.cpp +++ b/opm/input/eclipse/Schedule/Well/WellKeywordHandlers.cpp @@ -29,6 +29,7 @@ #include #include +#include #include #include #include @@ -332,6 +333,25 @@ void handleWCONINJH(HandlerContext& handlerContext) } } +bool belongsToAutoChokeGroup(const Well& well, const ScheduleState& state) { + const auto& network = state.network.get(); + auto group_name = well.groupName(); + while (group_name != "FIELD") { + if (network.has_node(group_name)) { + auto node_name = group_name; + if (network.node(node_name).as_choke()) + return true; + while (network.uptree_branch(node_name)) { + node_name = network.uptree_branch(node_name)->uptree_node(); + if (network.node(node_name).as_choke()) + return true; + } + } + group_name = state.groups.get(group_name).parent(); + } + return false; +} + void handleWCONPROD(HandlerContext& handlerContext) { for (const auto& record : handlerContext.keyword) { @@ -348,7 +368,7 @@ void handleWCONPROD(HandlerContext& handlerContext) const bool switching_from_injector = !well2.isProducer(); auto properties = std::make_shared(well2.getProductionProperties()); properties->clearControls(); - if (well2.isAvailableForGroupControl()) { + if (well2.isAvailableForGroupControl() || belongsToAutoChokeGroup(well2, handlerContext.state())) { properties->addProductionControl(Well::ProducerCMode::GRUP); } From 2189f4d320ab54ee521d8560169455dc847175fe Mon Sep 17 00:00:00 2001 From: Vegard Kippe Date: Fri, 24 Jan 2025 15:44:29 +0100 Subject: [PATCH 2/2] Early return if network is not active --- opm/input/eclipse/Schedule/Well/WellKeywordHandlers.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/opm/input/eclipse/Schedule/Well/WellKeywordHandlers.cpp b/opm/input/eclipse/Schedule/Well/WellKeywordHandlers.cpp index 0bdc49906d6..db03674a6cb 100644 --- a/opm/input/eclipse/Schedule/Well/WellKeywordHandlers.cpp +++ b/opm/input/eclipse/Schedule/Well/WellKeywordHandlers.cpp @@ -335,6 +335,8 @@ void handleWCONINJH(HandlerContext& handlerContext) bool belongsToAutoChokeGroup(const Well& well, const ScheduleState& state) { const auto& network = state.network.get(); + if (!network.active()) + return false; auto group_name = well.groupName(); while (group_name != "FIELD") { if (network.has_node(group_name)) {