From 246af80ee80b26a3c5c1f855905da97bb1b6a0e3 Mon Sep 17 00:00:00 2001 From: Kjetil Olsen Lye Date: Fri, 13 Apr 2012 11:37:50 +0200 Subject: [PATCH] Fixed a small bug in reading of WCONPROD --- opm/core/WellsGroup.cpp | 6 ++- opm/core/WellsGroup.hpp | 1 + opm/core/WellsManager.cpp | 96 ++++++++++++++++++++++++++------------- 3 files changed, 70 insertions(+), 33 deletions(-) diff --git a/opm/core/WellsGroup.cpp b/opm/core/WellsGroup.cpp index 797779458..379356dbc 100644 --- a/opm/core/WellsGroup.cpp +++ b/opm/core/WellsGroup.cpp @@ -24,6 +24,10 @@ namespace Opm { } + const WellsGroupInterface* WellsGroupInterface::getParent() const + { + return parent_; + } const std::string& WellsGroupInterface::name() { return name_; @@ -305,6 +309,7 @@ namespace Opm ProductionSpecification production_specification; if (deck.hasField("WCONPROD")) { WCONPROD wconprod = deck.getWCONPROD(); + std::cout << wconprod.wconprod.size() << std::endl; for (size_t i = 0; i < wconprod.wconprod.size(); i++) { if (wconprod.wconprod[i].well_ == name) { WconprodLine line = wconprod.wconprod[i]; @@ -316,7 +321,6 @@ namespace Opm } } } - return_value.reset(new WellNode(name, production_specification, injection_specification)); } else { InjectionSpecification injection_specification; diff --git a/opm/core/WellsGroup.hpp b/opm/core/WellsGroup.hpp index a8d5ab486..5eff617e9 100644 --- a/opm/core/WellsGroup.hpp +++ b/opm/core/WellsGroup.hpp @@ -42,6 +42,7 @@ namespace Opm virtual WellsGroupInterface* findGroup(std::string name_of_node) = 0; void setParent(WellsGroupInterface* parent); + const WellsGroupInterface* getParent() const; virtual void calculateGuideRates() = 0; protected: diff --git a/opm/core/WellsManager.cpp b/opm/core/WellsManager.cpp index 7c64fe74f..f093624d9 100644 --- a/opm/core/WellsManager.cpp +++ b/opm/core/WellsManager.cpp @@ -479,6 +479,69 @@ namespace Opm } #endif + + if (deck.hasField("GRUPTREE")) { + std::cout << "Found gruptree" << std::endl; + const GRUPTREE& gruptree = deck.getGRUPTREE(); + + std::map::const_iterator it = gruptree.tree.begin(); + for( ; it != gruptree.tree.end(); ++it) { + well_collection_.addChild(it->first, it->second, deck); + } + } + + for (size_t i = 0; i < welspecs.welspecs.size(); ++i) { + WelspecsLine line = welspecs.welspecs[i]; + well_collection_.addChild(line.name_, line.group_, deck); + } + + + + // Set the guide rates: + 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++) { + 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_ + = 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(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; + } + } + 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; + } + } + + } + // Set up the Wells struct. w_ = wells_create(num_wells, num_perfs); if (!w_) { @@ -509,21 +572,6 @@ namespace Opm } } - if (deck.hasField("GRUPTREE")) { - std::cout << "Found gruptree" << std::endl; - const GRUPTREE& gruptree = deck.getGRUPTREE(); - - std::map::const_iterator it = gruptree.tree.begin(); - for( ; it != gruptree.tree.end(); ++it) { - well_collection_.addChild(it->first, it->second, deck); - } - } - - for (size_t i = 0; i < welspecs.welspecs.size(); ++i) { - WelspecsLine line = welspecs.welspecs[i]; - well_collection_.addChild(line.name_, line.group_, deck); - } - for(size_t i = 0; i < well_collection_.getLeafNodes().size(); i++) { WellNode* node = static_cast(well_collection_.getLeafNodes()[i].get()); @@ -531,23 +579,7 @@ namespace Opm node->setWellsPointer(w_, i); } - // Set the guide rates: - 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++) { - 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_ - = lines[i].phase_ == "OIL" ? ProductionSpecification::OIL : ProductionSpecification::RAT; - } - - well_collection_.calculateGuideRates(); - } + }