From affbb08795369ebaf9b3e927f77bf29d320c3266 Mon Sep 17 00:00:00 2001 From: Kjetil Olsen Lye Date: Fri, 13 Apr 2012 12:57:47 +0200 Subject: [PATCH] Added checks for BHP and fluid_volume_rate for group control. Also added error tolerance for group control --- examples/wells_example.cpp | 2 +- opm/core/InjectionSpecification.cpp | 4 +- opm/core/ProductionSpecification.cpp | 10 ++--- opm/core/WellCollection.cpp | 5 ++- opm/core/WellCollection.hpp | 3 +- opm/core/WellsGroup.cpp | 26 ++++++++--- opm/core/WellsGroup.hpp | 8 ++-- opm/core/WellsManager.cpp | 55 ++++++++++++----------- opm/core/eclipse/SpecialEclipseFields.hpp | 2 +- 9 files changed, 67 insertions(+), 48 deletions(-) diff --git a/examples/wells_example.cpp b/examples/wells_example.cpp index 11132ae0..09329be4 100644 --- a/examples/wells_example.cpp +++ b/examples/wells_example.cpp @@ -76,7 +76,7 @@ int main(int argc, char** argv) { std::vector well_rate; pressure_solver.solve(totmob, omega, src, wdp, bcs.c_bcs(), pressure, face_flux, well_bhp, well_rate); std::cout << "Solved" << std::endl; - if(wells.wellCollection().conditionsMet(well_bhp, well_rate)) { + if(wells.wellCollection().conditionsMet(well_bhp, well_rate, *grid.c_grid(), state.saturation() )) { std::cout << "Conditions met for wells!" << std::endl; } else diff --git a/opm/core/InjectionSpecification.cpp b/opm/core/InjectionSpecification.cpp index 641526d6..2cd8fec1 100644 --- a/opm/core/InjectionSpecification.cpp +++ b/opm/core/InjectionSpecification.cpp @@ -3,8 +3,8 @@ namespace Opm { InjectionSpecification::InjectionSpecification() - : injector_type_(WATER), control_mode_(NONE), surface_flow_max_rate_(0.0), - reinjection_fraction_target_(0.0), BHP_limit_(0.0) + : injector_type_(WATER), control_mode_(NONE), surface_flow_max_rate_(1e100), + reinjection_fraction_target_(0.0), BHP_limit_(1e100) { } diff --git a/opm/core/ProductionSpecification.cpp b/opm/core/ProductionSpecification.cpp index 1c23b2ff..b1a46dac 100644 --- a/opm/core/ProductionSpecification.cpp +++ b/opm/core/ProductionSpecification.cpp @@ -7,11 +7,11 @@ namespace Opm : control_mode_(NONE_CM), procedure_(NONE_P), - oil_max_rate_(-1.0), - water_production_target_(-1.0), - fluid_volume_max_rate_(-1.0), - BHP_limit_(-1.0), - guide_rate_(-1.0) + oil_max_rate_(1e100), + water_production_target_(1e100), + fluid_volume_max_rate_(1e100), + BHP_limit_(1e100), + guide_rate_(1e100) { } diff --git a/opm/core/WellCollection.cpp b/opm/core/WellCollection.cpp index 10a32c65..f38e05d4 100644 --- a/opm/core/WellCollection.cpp +++ b/opm/core/WellCollection.cpp @@ -88,9 +88,10 @@ namespace Opm return NULL; } - bool WellCollection::conditionsMet(const std::vector& well_bhp, const std::vector& well_rate) const { + bool WellCollection::conditionsMet(const std::vector& well_bhp, const std::vector& well_rate, + const UnstructuredGrid& grid, const std::vector& saturations, double epsilon) const { for(size_t i = 0; i < leaf_nodes_.size(); i++) { - if(! static_cast(leaf_nodes_[i].get())->conditionsMet(well_bhp, well_rate) ) { + if(! static_cast(leaf_nodes_[i].get())->conditionsMet(well_bhp, well_rate, grid, saturations, epsilon) ) { return false; } } diff --git a/opm/core/WellCollection.hpp b/opm/core/WellCollection.hpp index 58412265..92ccccfa 100644 --- a/opm/core/WellCollection.hpp +++ b/opm/core/WellCollection.hpp @@ -40,7 +40,8 @@ namespace Opm const EclipseGridParser& deck); - bool conditionsMet(const std::vector& well_bhp, const std::vector& well_rate) const; + bool conditionsMet(const std::vector& well_bhp, const std::vector& well_rate, + const UnstructuredGrid& grid, const std::vector& saturations, double epsilon=1e-8) const; const std::vector >& getLeafNodes() const; diff --git a/opm/core/WellsGroup.cpp b/opm/core/WellsGroup.cpp index 379356db..77d6399e 100644 --- a/opm/core/WellsGroup.cpp +++ b/opm/core/WellsGroup.cpp @@ -114,11 +114,14 @@ namespace Opm } - bool WellsGroup::conditionsMet(const std::vector& well_bhp, const std::vector& well_rate, - const struct Wells* wells, int index_of_well) + bool WellsGroup::conditionsMet(const std::vector& well_bhp, const std::vector& well_rate, + const UnstructuredGrid& grid, const std::vector& saturations, + const struct Wells* wells, int index_of_well, double epsilon) { if (parent_ != NULL) { - bool parent_ok = (static_cast (parent_))->conditionsMet(well_bhp, well_rate, wells, index_of_well); + bool parent_ok = + (static_cast (parent_))->conditionsMet(well_bhp, + well_rate,grid, saturations, wells, index_of_well, epsilon); if (!parent_ok) { return false; } @@ -138,15 +141,26 @@ namespace Opm { } - bool WellNode::conditionsMet(const std::vector& well_bhp, const std::vector& well_rate) + bool WellNode::conditionsMet(const std::vector& well_bhp, const std::vector& well_rate, + const UnstructuredGrid& grid, const std::vector& saturations, double epsilon) { + if (parent_ != NULL) { - bool parent_ok = (static_cast (parent_))->conditionsMet(well_bhp, well_rate, wells_, self_index_); + bool parent_ok = (static_cast (parent_))->conditionsMet(well_bhp, well_rate, grid, saturations, wells_, self_index_, epsilon); if (!parent_ok) { return false; } } - + + std::cout << "checking here" << std::endl; + // Check for self: + if(well_rate[self_index_] - prodSpec().BHP_limit_ > epsilon) { + return false; + } + + if(well_rate[self_index_] - prodSpec().fluid_volume_max_rate_ > epsilon) { + return false; + } return true; } diff --git a/opm/core/WellsGroup.hpp b/opm/core/WellsGroup.hpp index 5eff617e..46819ed0 100644 --- a/opm/core/WellsGroup.hpp +++ b/opm/core/WellsGroup.hpp @@ -67,8 +67,9 @@ namespace Opm void addChild(std::tr1::shared_ptr child); - bool conditionsMet(const std::vector& well_bhp, const std::vector& well_rate, const struct Wells* wells, - int index_of_well); + bool conditionsMet(const std::vector& well_bhp, const std::vector& well_rate, + const UnstructuredGrid& grid, const std::vector& saturations, const struct Wells* wells, + int index_of_well, double epsilon = 1e-8); virtual void calculateGuideRates(); private: @@ -85,7 +86,8 @@ namespace Opm InjectionSpecification inj_spec); virtual WellsGroupInterface* findGroup(std::string name_of_node); - virtual bool conditionsMet(const std::vector& well_bhp, const std::vector& well_rate); + virtual bool conditionsMet(const std::vector& well_bhp, const std::vector& well_rate, + const UnstructuredGrid& grid, const std::vector& saturations, double epsilon=1e-8); virtual bool isLeafNode() const; void setWellsPointer(const struct Wells* wells, int self_index); diff --git a/opm/core/WellsManager.cpp b/opm/core/WellsManager.cpp index f093624d..4f73b304 100644 --- a/opm/core/WellsManager.cpp +++ b/opm/core/WellsManager.cpp @@ -496,49 +496,50 @@ namespace Opm } - + // Set the guide rates: - if(deck.hasField("WGRUPCON")) { + if (deck.hasField("WGRUPCON")) { std::cout << "Found Wgrupcon" << std::endl; WGRUPCON wgrupcon = deck.getWGRUPCON(); const std::vector& lines = wgrupcon.wgrupcon; std::cout << well_collection_.getLeafNodes().size() << std::endl; - for(size_t i = 0; i < lines.size(); i++) { + for (size_t i = 0; i < lines.size(); i++) { std::string name = lines[i].well_; int index = well_names_to_index[name]; ASSERT(well_collection_.getLeafNodes()[index]->name() == name); well_collection_.getLeafNodes()[index]->prodSpec().guide_rate_ = lines[i].guide_rate_; - well_collection_.getLeafNodes()[index]->prodSpec().guide_rate_type_ + well_collection_.getLeafNodes()[index]->prodSpec().guide_rate_type_ = lines[i].phase_ == "OIL" ? ProductionSpecification::OIL : ProductionSpecification::RAT; } - + well_collection_.calculateGuideRates(); - } - - // Apply guide rates: - for(size_t i = 0; i < well_data.size(); i++) { - if(well_collection_.getLeafNodes()[i]->prodSpec().control_mode_ == ProductionSpecification::GRUP) - { + +#if 0 + // Apply guide rates: + for (size_t i = 0; i < well_data.size(); i++) { + std::cout << "hello" << std::endl; + if (well_collection_.getLeafNodes()[i]->prodSpec().control_mode_ == ProductionSpecification::GRUP) { + std::cout << "hello" << std::endl; + if (well_collection_.getLeafNodes()[i]->prodSpec().guide_rate_type_ == ProductionSpecification::OIL) { + well_data[i].control = RATE; - if(well_collection_.getLeafNodes()[i]->prodSpec().guide_rate_type_ == ProductionSpecification::OIL) { - well_data[i].control = RATE; + double parent_oil_rate = well_collection_.getLeafNodes()[i]->getParent()->prodSpec().oil_max_rate_; + double guide_rate = well_collection_.getLeafNodes()[i]->prodSpec().guide_rate_; + well_data[i].target = guide_rate * parent_oil_rate; + } + } - double parent_oil_rate = well_collection_.getLeafNodes()[i]->getParent()->prodSpec().oil_max_rate_; - double guide_rate = well_collection_.getLeafNodes()[i]->prodSpec().guide_rate_; - well_data[i].target = guide_rate * parent_oil_rate; - } - } - else if(well_collection_.getLeafNodes()[i]->injSpec().control_mode_ == InjectionSpecification::GRUP) - { - if(well_collection_.getLeafNodes()[i]->prodSpec().guide_rate_type_ == ProductionSpecification::RAT) { - - well_data[i].control = RATE; - well_data[i].type = INJECTOR; - double parent_surface_rate = well_collection_.getLeafNodes()[i]->getParent()->injSpec().surface_flow_max_rate_; - double guide_rate = well_collection_.getLeafNodes()[i]->prodSpec().guide_rate_; - well_data[i].target = guide_rate * parent_surface_rate; + if (well_collection_.getLeafNodes()[i]->injSpec().control_mode_ == InjectionSpecification::GRUP) { + if (well_collection_.getLeafNodes()[i]->prodSpec().guide_rate_type_ == ProductionSpecification::RAT) { + well_data[i].control = RATE; + well_data[i].type = INJECTOR; + double parent_surface_rate = well_collection_.getLeafNodes()[i]->getParent()->injSpec().surface_flow_max_rate_; + double guide_rate = well_collection_.getLeafNodes()[i]->prodSpec().guide_rate_; + well_data[i].target = guide_rate * parent_surface_rate; + } } } +#endif } diff --git a/opm/core/eclipse/SpecialEclipseFields.hpp b/opm/core/eclipse/SpecialEclipseFields.hpp index fb7069f9..8567c712 100644 --- a/opm/core/eclipse/SpecialEclipseFields.hpp +++ b/opm/core/eclipse/SpecialEclipseFields.hpp @@ -1424,7 +1424,7 @@ struct WconprodLine WconprodLine() : open_shut_flag_("OPEN"), oil_max_rate_(1.0E20), water_max_rate_(1.0E20), gas_max_rate_(1.0E20), liquid_max_rate_(1.0E20), - fluid_volume_max_rate_(1.0E20), BHP_limit_(-1.0), THP_limit_(0.0), + fluid_volume_max_rate_(1.0E20), BHP_limit_(1e100), THP_limit_(0.0), VFP_table_number_(0), artif_lift_quantity_(0.0) { }