diff --git a/opm/core/wells/InjectionSpecification.cpp b/opm/core/wells/InjectionSpecification.cpp index 09d11f60..b16e1b7b 100644 --- a/opm/core/wells/InjectionSpecification.cpp +++ b/opm/core/wells/InjectionSpecification.cpp @@ -34,7 +34,7 @@ namespace Opm BHP_limit_(-1e100), reinjection_fraction_target_(1), voidage_replacment_fraction_(1), - guide_rate_(1.0), + guide_rate_(-1.0), guide_rate_type_(NONE_GRT) { diff --git a/opm/core/wells/ProductionSpecification.cpp b/opm/core/wells/ProductionSpecification.cpp index 1bdaac30..b7b9e823 100644 --- a/opm/core/wells/ProductionSpecification.cpp +++ b/opm/core/wells/ProductionSpecification.cpp @@ -36,7 +36,7 @@ namespace Opm liquid_max_rate_(-1e100), reservoir_flow_max_rate_(-1e100), BHP_limit_(-1e100), - guide_rate_(1.0), + guide_rate_(-1.0), guide_rate_type_(NONE_GRT) { } diff --git a/opm/core/wells/WellCollection.cpp b/opm/core/wells/WellCollection.cpp index 6325fab4..fad447ae 100644 --- a/opm/core/wells/WellCollection.cpp +++ b/opm/core/wells/WellCollection.cpp @@ -482,4 +482,15 @@ namespace Opm } // end of for (int w = 0; w < nw; ++w) } + + bool WellCollection::requireWellPotentials() const + { + for (const auto& well_node : leaf_nodes_) { + if (well_node->isGuideRateWellPotential()) { + return true; + } + } + return false; + } + } diff --git a/opm/core/wells/WellCollection.hpp b/opm/core/wells/WellCollection.hpp index 846b1747..419e0f9c 100644 --- a/opm/core/wells/WellCollection.hpp +++ b/opm/core/wells/WellCollection.hpp @@ -155,6 +155,9 @@ namespace Opm const PhaseUsage& phase_usage, const std::vector& well_potentials) const; + + bool requireWellPotentials() const; + private: // To account for the possibility of a forest std::vector > roots_; diff --git a/opm/core/wells/WellsGroup.cpp b/opm/core/wells/WellsGroup.cpp index a57c7ed0..a166ca77 100644 --- a/opm/core/wells/WellsGroup.cpp +++ b/opm/core/wells/WellsGroup.cpp @@ -921,7 +921,8 @@ namespace Opm self_index_(-1), group_control_index_(-1), shut_well_(true), // This is default for now - target_updated_(false) // This is default for now, not sure whether to use the default value + target_updated_(false), // This is default for now, not sure whether to use the default value + is_guiderate_wellpotential_(false) { } @@ -1651,6 +1652,18 @@ namespace Opm } + bool WellNode::isGuideRateWellPotential() const + { + return is_guiderate_wellpotential_; + } + + + void WellNode::setIsGuideRateWellPotential(const bool flag) + { + is_guiderate_wellpotential_ = flag; + } + + bool WellNode::canProduceMore() const { return (isProducer() && !individualControl()); diff --git a/opm/core/wells/WellsGroup.hpp b/opm/core/wells/WellsGroup.hpp index 966dc971..e18f62de 100644 --- a/opm/core/wells/WellsGroup.hpp +++ b/opm/core/wells/WellsGroup.hpp @@ -514,6 +514,10 @@ namespace Opm bool targetUpdated() const; + bool isGuideRateWellPotential() const; + + void setIsGuideRateWellPotential(const bool flag); + virtual void setTargetUpdated(const bool flag); virtual bool canProduceMore() const; @@ -527,6 +531,10 @@ namespace Opm bool shut_well_; // TODO: used when updating well targets bool target_updated_; + // whether the guide rate is specified with well potential + // TODO: we have never handle the guide rates for groups, maybe this + // is something will go to WellsGroupInterface later + bool is_guiderate_wellpotential_; }; /// Creates the WellsGroupInterface for the given well diff --git a/opm/core/wells/WellsManager.cpp b/opm/core/wells/WellsManager.cpp index 0c7960b5..5b67cc15 100644 --- a/opm/core/wells/WellsManager.cpp +++ b/opm/core/wells/WellsManager.cpp @@ -748,7 +748,7 @@ namespace Opm WellNode& wellnode = *well_collection_.getLeafNodes()[wix]; // TODO: looks like only handling OIL phase guide rate for producers - if (well->getGuideRatePhase(timeStep) != GuideRate::UNDEFINED) { + if (well->getGuideRatePhase(timeStep) != GuideRate::UNDEFINED && well->getGuideRate(timeStep) >= 0.) { if (well_data[wix].type == PRODUCER) { wellnode.prodSpec().guide_rate_ = well->getGuideRate(timeStep); if (well->getGuideRatePhase(timeStep) == GuideRate::OIL) { @@ -768,6 +768,8 @@ namespace Opm } else { OPM_THROW(std::runtime_error, "Unknown well type " << well_data[wix].type << " for well " << well->name()); } + } else { + wellnode.setIsGuideRateWellPotential(true); } } }