From 0d5a86cc71c4627e7e75b2e5fdf5fbbf0167a0c2 Mon Sep 17 00:00:00 2001 From: Kai Bao Date: Wed, 5 Oct 2016 17:03:47 +0200 Subject: [PATCH] keeping adding group control related in. --- opm/core/wells/ProductionSpecification.hpp | 1 - opm/core/wells/WellsGroup.cpp | 18 ++++++-- opm/core/wells/WellsGroup_impl.hpp | 52 ++++++++++++++++++++++ 3 files changed, 67 insertions(+), 4 deletions(-) diff --git a/opm/core/wells/ProductionSpecification.hpp b/opm/core/wells/ProductionSpecification.hpp index 104b3a32..ef64c4c0 100644 --- a/opm/core/wells/ProductionSpecification.hpp +++ b/opm/core/wells/ProductionSpecification.hpp @@ -46,4 +46,3 @@ namespace Opm } #endif /* OPM_PRODUCTIONSPECIFICATION_HPP */ - diff --git a/opm/core/wells/WellsGroup.cpp b/opm/core/wells/WellsGroup.cpp index c5cda8d3..4e9ebaa5 100644 --- a/opm/core/wells/WellsGroup.cpp +++ b/opm/core/wells/WellsGroup.cpp @@ -310,7 +310,10 @@ namespace Opm { if (forced || (prodSpec().control_mode_ == ProductionSpecification::FLD || prodSpec().control_mode_ == ProductionSpecification::NONE)) { - const double my_guide_rate = productionGuideRate(!forced); + const double my_guide_rate = productionGuideRate(false); + std::cout << " forced " << forced << std::endl; + std::cout << " name " << name () << std::endl; + std::cout << " my_guide_rate is " << my_guide_rate << std::endl; if (my_guide_rate == 0.0) { // Nothing to do here std::cout << "returning" << std::endl; @@ -470,7 +473,9 @@ namespace Opm case ProductionSpecification::LRAT: case ProductionSpecification::RESV: { - const double my_guide_rate = productionGuideRate(true); + // const double my_guide_rate = productionGuideRate(true); + const double my_guide_rate = productionGuideRate(false); + std::cout << "my_guide_rate of group " << name() << " is " << my_guide_rate << std::endl; if (my_guide_rate == 0) { OPM_THROW(std::runtime_error, "Can't apply group control for group " << name() << " as the sum of guide rates for all group controlled wells is zero."); } @@ -549,7 +554,13 @@ namespace Opm { double sum = 0.0; for (size_t i = 0; i < children_.size(); ++i) { - sum += children_[i]->productionGuideRate(only_group); + if (only_group) { + if (!children_[i]->individualControl()) { + sum += children_[i]->productionGuideRate(only_group); + } + } else { + sum += children_[i]->productionGuideRate(only_group); + } } return sum; } @@ -1013,6 +1024,7 @@ namespace Opm // 2. the well violating some limits and working under limits. We do not have strategy // to handle this situation yet. // if (!only_group || prodSpec().control_mode_ == ProductionSpecification::GRUP) { + std::cout << "guide_rate for well " << name() << " is " << prodSpec().guide_rate_ << std::endl; return prodSpec().guide_rate_; // } // return 0.0; diff --git a/opm/core/wells/WellsGroup_impl.hpp b/opm/core/wells/WellsGroup_impl.hpp index 567e99bd..c3414296 100644 --- a/opm/core/wells/WellsGroup_impl.hpp +++ b/opm/core/wells/WellsGroup_impl.hpp @@ -19,6 +19,7 @@ */ #include +#include namespace Opm @@ -35,6 +36,57 @@ namespace Opm // 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()) { + // 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]; + const int np = well_state.numPhases(); + + 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; + + const double my_guide_rate = productionGuideRate(true); + 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) { + const double children_guide_rate = children_[i]->productionGuideRate(true); + children_[i]->applyProdGroupControl(control_mode, (children_guide_rate/my_guide_rate) * rate_for_group_control, false); + children_[i]->setShouldUpdateWellTargets(false); + } + std::cin.ignore(); + // liquid_max_rate + // update the injectioin control }