diff --git a/opm/core/WellsGroup.cpp b/opm/core/WellsGroup.cpp index 70d7203b3..510b65052 100644 --- a/opm/core/WellsGroup.cpp +++ b/opm/core/WellsGroup.cpp @@ -113,7 +113,7 @@ namespace Opm } } } - + bool WellsGroup::conditionsMet(const std::vector& well_bhp, const std::vector& well_rate, const UnstructuredGrid& grid, const std::vector& saturations, @@ -127,6 +127,38 @@ namespace Opm return false; } } + + int number_of_leaf_nodes = 1;//numberOfLeafNodes(); + + double bhp_target = 1e100; + double rate_target = 1e100; + switch(wells->type[index_of_well]) { + case INJECTOR: + { + const InjectionSpecification& inje_spec = injSpec(); + bhp_target = inje_spec.BHP_limit_ / number_of_leaf_nodes; + rate_target = inje_spec.fluid_volume_max_rate_ / number_of_leaf_nodes; + break; + } + case PRODUCER: + { + const ProductionSpecification& prod_spec = prodSpec(); + bhp_target = prod_spec.BHP_limit_ / number_of_leaf_nodes; + rate_target = prod_spec.fluid_volume_max_rate_ / number_of_leaf_nodes; + break; + } + } + + if (well_bhp[index_of_well] - bhp_target > epsilon) { + std::cout << "BHP not met" << std::endl; + return false; + } + if(well_rate[index_of_well] - rate_target > epsilon) { + std::cout << wells->type[index_of_well] << std::endl; + std::cout << "well_rate not met" << std::endl; + std::cout << "target = " << rate_target << ", well_rate[index_of_well] = " << well_rate[index_of_well] << std::endl; + return false; + } return true; } @@ -135,6 +167,19 @@ namespace Opm children_.push_back(child); } + + int WellsGroup::numberOfLeafNodes() { + // This could probably use some caching, but seeing as how the number of + // wells is relatively small, we'll do without for now. + int sum = 0; + + for(size_t i = 0; i < children_.size(); i++) { + sum += children_[i]->numberOfLeafNodes(); + } + + return sum; + } + WellNode::WellNode(const std::string& myname, ProductionSpecification prod_spec, InjectionSpecification inj_spec) @@ -214,6 +259,11 @@ namespace Opm { // Empty } + + int WellNode::numberOfLeafNodes() + { + return 1; + } namespace { diff --git a/opm/core/WellsGroup.hpp b/opm/core/WellsGroup.hpp index abf1dcfed..cc2b67f80 100644 --- a/opm/core/WellsGroup.hpp +++ b/opm/core/WellsGroup.hpp @@ -45,7 +45,13 @@ namespace Opm void setParent(WellsGroupInterface* parent); const WellsGroupInterface* getParent() const; + /// Recursively calculate the guide rate for each member of the well group. + /// This should be called after the guide rates are set to the non-normalized values. virtual void calculateGuideRates() = 0; + + /// Calculates the number of leaf nodes in the given group. + /// A leaf node is defined to have one leaf node in its group. + virtual int numberOfLeafNodes() = 0; protected: WellsGroupInterface* parent_; @@ -73,6 +79,9 @@ namespace Opm int index_of_well, double epsilon = 1e-8); virtual void calculateGuideRates(); + + + virtual int numberOfLeafNodes(); private: std::vector > children_; }; @@ -94,6 +103,7 @@ namespace Opm void setWellsPointer(const struct Wells* wells, int self_index); virtual void calculateGuideRates(); + virtual int numberOfLeafNodes(); private: const struct Wells* wells_; int self_index_; diff --git a/opm/core/WellsManager.cpp b/opm/core/WellsManager.cpp index 911f27438..d0d409729 100644 --- a/opm/core/WellsManager.cpp +++ b/opm/core/WellsManager.cpp @@ -517,9 +517,7 @@ namespace Opm // 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;