diff --git a/opm/core/wells/WellCollection.cpp b/opm/core/wells/WellCollection.cpp index 618042b1b..88de6ba3a 100644 --- a/opm/core/wells/WellCollection.cpp +++ b/opm/core/wells/WellCollection.cpp @@ -194,12 +194,19 @@ namespace Opm //TODO: later, it should be extended to update group targets bool WellCollection::needUpdateWellTargets() const { + bool any_group_control_node = false; + bool any_should_update_node = false; for (size_t i = 0; i < leaf_nodes_.size(); ++i) { - if (leaf_nodes_[i]->shouldUpdateWellTargets() && !leaf_nodes_[i]->individualControl()) { - return true; + std::cout << " well " << leaf_nodes_[i]->name() << " under group control ? " << !leaf_nodes_[i]->individualControl() << " should update well target? " << leaf_nodes_[i]->shouldUpdateWellTargets() << std::endl; + if (leaf_nodes_[i]->shouldUpdateWellTargets()) { + any_should_update_node = true; + } + if (!leaf_nodes_[i]->individualControl()) { + any_group_control_node = true; } } - return false; + std::cout << " any_group_control_node " << any_group_control_node << " any_should_update_node " << any_should_update_node << std::endl; + return (any_group_control_node && any_should_update_node); } @@ -215,4 +222,12 @@ namespace Opm return leaf_nodes_[i]; } + bool WellCollection::justUpdateWellTargets() const { + return just_update_well_targets_; + } + + void WellCollection::setJustUpdateWellTargets(const bool flag) { + just_update_well_targets_ = flag; + } + } diff --git a/opm/core/wells/WellCollection.hpp b/opm/core/wells/WellCollection.hpp index ee51313a0..4822a7229 100644 --- a/opm/core/wells/WellCollection.hpp +++ b/opm/core/wells/WellCollection.hpp @@ -124,6 +124,10 @@ namespace Opm template void updateWellTargets(const WellState& well_state); + bool justUpdateWellTargets() const; + + void setJustUpdateWellTargets(const bool flag); + private: // To account for the possibility of a forest std::vector > roots_; @@ -131,6 +135,8 @@ namespace Opm // This will be used to traverse the bottom nodes. std::vector leaf_nodes_; + bool just_update_well_targets_; + }; diff --git a/opm/core/wells/WellsGroup.cpp b/opm/core/wells/WellsGroup.cpp index 4e9ebaa59..5e759a953 100644 --- a/opm/core/wells/WellsGroup.cpp +++ b/opm/core/wells/WellsGroup.cpp @@ -308,6 +308,9 @@ namespace Opm const double target, const bool forced) { + if (prodSpec().control_mode_ == ProductionSpecification::NONE) { + return; + } if (forced || (prodSpec().control_mode_ == ProductionSpecification::FLD || prodSpec().control_mode_ == ProductionSpecification::NONE)) { const double my_guide_rate = productionGuideRate(false); @@ -483,7 +486,7 @@ namespace Opm // Apply for all children. // Note, we do _not_ want to call the applyProdGroupControl in this object, // as that would check if we're under group control, something we're not. - const double children_guide_rate = children_[i]->productionGuideRate(true); + const double children_guide_rate = children_[i]->productionGuideRate(false); children_[i]->applyProdGroupControl(prod_mode, (children_guide_rate / my_guide_rate) * getTarget(prod_mode), false); @@ -930,13 +933,13 @@ namespace Opm const bool forced) { // Not changing if we're not forced to change - if (!forced && (prodSpec().control_mode_ != ProductionSpecification::GRUP + /* if (!forced && (prodSpec().control_mode_ != ProductionSpecification::GRUP && prodSpec().control_mode_ != ProductionSpecification::NONE)) { std::cout << "Returning" << std::endl; return; - } + } */ if (wells_->type[self_index_] != PRODUCER) { - assert(target == 0.0); + // assert(target == 0.0); return; } // We're a producer, so we need to negate the input @@ -988,6 +991,9 @@ namespace Opm OPM_THROW(std::runtime_error, "Group production control mode not handled: " << control_mode); } + std::cout << " well name " << name() << " group_control_index_ " << group_control_index_ << " ntarget " << ntarget + << std::endl; + if (group_control_index_ < 0) { // The well only had its own controls, no group controls. append_well_controls(wct, ntarget, invalid_alq, invalid_vfp, distr, self_index_, wells_); diff --git a/opm/core/wells/WellsManager_impl.hpp b/opm/core/wells/WellsManager_impl.hpp index b6fd9e2c0..7bae00e82 100644 --- a/opm/core/wells/WellsManager_impl.hpp +++ b/opm/core/wells/WellsManager_impl.hpp @@ -411,6 +411,7 @@ WellsManager::init(const Opm::EclipseState& eclipseState, well_collection_.addField(fieldGroup, timeStep, pu); addChildGroups(*fieldNode, schedule, timeStep, pu); + well_collection_.setJustUpdateWellTargets(false); } for (auto w = wells.begin(), e = wells.end(); w != e; ++w) {