From 7295f26f541172d3336f6b040e62db9fb6d3a731 Mon Sep 17 00:00:00 2001 From: Kai Bao Date: Fri, 7 Oct 2016 16:18:09 +0200 Subject: [PATCH] adding updateWellInjectionTargets updateWellProductionTargets For WellsGroup. At least for the current moment, the updation of the well targets for injectors and producers should be handled in a seprate way. --- opm/core/wells/WellCollection.cpp | 4 +-- opm/core/wells/WellCollection_impl.hpp | 8 ++++- opm/core/wells/WellsGroup.hpp | 5 ++- opm/core/wells/WellsGroup_impl.hpp | 44 +++++++++++--------------- 4 files changed, 32 insertions(+), 29 deletions(-) diff --git a/opm/core/wells/WellCollection.cpp b/opm/core/wells/WellCollection.cpp index 9bcaf140..9fa9909f 100644 --- a/opm/core/wells/WellCollection.cpp +++ b/opm/core/wells/WellCollection.cpp @@ -209,7 +209,7 @@ namespace Opm any_should_update_node = true; } - if (leaf_nodes_[i]->individualControl()) { + if (!leaf_nodes_[i]->individualControl()) { any_group_control_node = true; } } @@ -228,7 +228,7 @@ namespace Opm any_should_update_node = true; } - if (leaf_nodes_[i]->individualControl()) { + if (!leaf_nodes_[i]->individualControl()) { any_group_control_node = true; } } diff --git a/opm/core/wells/WellCollection_impl.hpp b/opm/core/wells/WellCollection_impl.hpp index 14454a4d..5f8085b7 100644 --- a/opm/core/wells/WellCollection_impl.hpp +++ b/opm/core/wells/WellCollection_impl.hpp @@ -38,7 +38,13 @@ namespace Opm // TODO: will remove dynamic_cast with interface revision. WellsGroup* parent_node = dynamic_cast(leaf_nodes_[i]->getParent()); // update the target within this group. - parent_node->updateWellTargets(well_state); + if (leaf_nodes_[i]->isProducer()) { + parent_node->updateWellProductionTargets(well_state); + } + + if (leaf_nodes_[i]->isInjector()) { + parent_node->updateWellInjectionTargets(well_state); + } } } diff --git a/opm/core/wells/WellsGroup.hpp b/opm/core/wells/WellsGroup.hpp index 309e770e..92ce8147 100644 --- a/opm/core/wells/WellsGroup.hpp +++ b/opm/core/wells/WellsGroup.hpp @@ -325,7 +325,10 @@ namespace Opm const std::vector& well_surfacerates_phase); template - void updateWellTargets(const WellState& well_state); + void updateWellProductionTargets(const WellState& well_state); + + template + void updateWellInjectionTargets(const WellState& well_state); private: std::vector > children_; diff --git a/opm/core/wells/WellsGroup_impl.hpp b/opm/core/wells/WellsGroup_impl.hpp index eba7d9a7..dba8f266 100644 --- a/opm/core/wells/WellsGroup_impl.hpp +++ b/opm/core/wells/WellsGroup_impl.hpp @@ -27,38 +27,28 @@ namespace Opm template - void WellsGroup::updateWellTargets(const WellState& well_state) + void WellsGroup::updateWellProductionTargets(const WellState& well_state) { // TODO: currently, we only handle the level of the well groups for the moment, i.e. the level just above wells // We believe the relations between groups are similar to the relations between different wells inside the same group. // While there will be somre more complication invloved for sure. // Basically, we need to update the target rates for the wells still under group control. - // What facility need to be put in? - // update the production control - // What we need there? 1. The target. 2. The control mode. 3. The share produced by the wells under individual control - // 4. The guide rate. - // control mode ProductionSpecification::ControlMode control_mode = prodSpec().control_mode_; double target_rate = prodSpec().liquid_max_rate_; - std::cout << " control mode is " << ProductionSpecification::toString(control_mode); - std::cout << " rate is " << target_rate << std::endl; if (ProductionSpecification::toString(control_mode) == "FLD") { auto* parent_node = getParent(); control_mode = parent_node->prodSpec().control_mode_; target_rate = parent_node->prodSpec().liquid_max_rate_; - std::cout << " control mode is " << ProductionSpecification::toString(control_mode); - std::cout << " rate is " << target_rate << std::endl; } double rate_individual_control = 0; for (size_t i = 0; i < children_.size(); ++i) { - if (children_[i]->individualControl()) { + if (children_[i]->individualControl() && std::dynamic_pointer_cast(children_[i])->isProducer()) { // get the rate here. const std::string well_name = children_[i]->name(); - std::cout << "well_name " << well_name; typedef typename WellState::WellMapType::const_iterator const_iterator; const_iterator it = well_state.wellMap().find(well_name); const int well_index = (*it).second[0]; @@ -66,36 +56,40 @@ namespace Opm const double oil_rate = well_state.wellRates()[np * well_index + 1]; const double water_rate = well_state.wellRates()[np * well_index]; - std::cout << " oil_rate is " << oil_rate << " water_rate is " << water_rate << " liquid rate is " << oil_rate + water_rate << std::endl; rate_individual_control += std::abs(oil_rate + water_rate); } } const double rate_for_group_control = target_rate - rate_individual_control; - std::cout << " rate_for_group_control " << rate_for_group_control << std::endl; const double my_guide_rate = productionGuideRate(true); - std::cout << " my_guide_rate is " << my_guide_rate << " when updateWellTargets " << std::endl; - if (my_guide_rate == 0) { - std::cout << " something wrong with the my_guide_rate, need to check, it should have come here " << std::endl; - std::cin.ignore(); - } for (size_t i = 0; i < children_.size(); ++i) { // if (children_[i]->shouldUpdateWellTargets() && !children_[i]->individualControl()) { - if (!children_[i]->individualControl()) { + if (!children_[i]->individualControl() && std::dynamic_pointer_cast(children_[i])->isProducer()) { const double children_guide_rate = children_[i]->productionGuideRate(true); - std::cout << " well_name " << children_[i]->name() << " children_guide_rate " << children_guide_rate << " my_guide_rate " << my_guide_rate << std::endl; - std::cout << " new target rate is " << (children_guide_rate/my_guide_rate) * rate_for_group_control * 86400/0.1590 << std::endl; // children_[i]->applyProdGroupControl(control_mode, (children_guide_rate/my_guide_rate) * rate_for_group_control, false); children_[i]->applyProdGroupControl(control_mode, (children_guide_rate/my_guide_rate) * rate_for_group_control, true); children_[i]->setShouldUpdateWellTargets(false); } } - std::cin.ignore(); - // liquid_max_rate + } + + + + + + + template + void WellsGroup::updateWellInjectionTargets(const WellState&) { + // NOT doing anything yet. + // Will finish it when having an examples with more than one injection wells within same injection group. + for (size_t i = 0; i < children_.size(); ++i) { + if (!children_[i]->individualControl() && std::dynamic_pointer_cast(children_[i])->isInjector()) { + children_[i]->setShouldUpdateWellTargets(false); + } + } - // update the injectioin control } }