Skip to content

Commit

Permalink
Merge pull request #4435 from vkip/allow_wconprod_grup_after_autochoke
Browse files Browse the repository at this point in the history
Ensure setting GRUP control in WCONPROD works for wells in auto-choke groups
  • Loading branch information
GitPaean authored Jan 24, 2025
2 parents 2275e4d + 2189f4d commit 4e5ce97
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion opm/input/eclipse/Schedule/Well/WellKeywordHandlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <opm/input/eclipse/Parser/ParserKeywords/F.hpp>
#include <opm/input/eclipse/Parser/ParserKeywords/W.hpp>

#include <opm/input/eclipse/Schedule/Network/ExtNetwork.hpp>
#include <opm/input/eclipse/Schedule/ScheduleState.hpp>
#include <opm/input/eclipse/Schedule/ScheduleStatic.hpp>
#include <opm/input/eclipse/Schedule/UDQ/UDQActive.hpp>
Expand Down Expand Up @@ -332,6 +333,27 @@ 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)) {
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) {
Expand All @@ -348,7 +370,7 @@ void handleWCONPROD(HandlerContext& handlerContext)
const bool switching_from_injector = !well2.isProducer();
auto properties = std::make_shared<Well::WellProductionProperties>(well2.getProductionProperties());
properties->clearControls();
if (well2.isAvailableForGroupControl()) {
if (well2.isAvailableForGroupControl() || belongsToAutoChokeGroup(well2, handlerContext.state())) {
properties->addProductionControl(Well::ProducerCMode::GRUP);
}

Expand Down

0 comments on commit 4e5ce97

Please sign in to comment.