diff --git a/opm/core/WellsGroup.cpp b/opm/core/WellsGroup.cpp index b145793d4..a23fbcbe1 100644 --- a/opm/core/WellsGroup.cpp +++ b/opm/core/WellsGroup.cpp @@ -544,6 +544,45 @@ namespace Opm return sum; } + /// Applies explicit reinjection controls. This must be called at each timestep to be correct. + /// \param[in] well_reservoirrates_phase + /// A vector containing reservoir rates by phase for each well. + /// Is assumed to be ordered the same way as the related Wells-struct, + /// with all phase rates of a single well adjacent in the array. + /// \param[in] well_surfacerates_phase + /// A vector containing surface rates by phase for each well. + /// Is assumed to be ordered the same way as the related Wells-struct, + /// with all phase rates of a single well adjacent in the array. + void WellsGroup::applyExplicitReinjectionControls(const std::vector&, + const std::vector& well_surfacerates_phase) + { + if (injSpec().control_mode_ == InjectionSpecification::REIN) { + BlackoilPhases::PhaseIndex phase; + switch (injSpec().injector_type_) { + case InjectionSpecification::WATER: + phase = BlackoilPhases::Aqua; + break; + case InjectionSpecification::GAS: + phase = BlackoilPhases::Vapour; + break; + case InjectionSpecification::OIL: + phase = BlackoilPhases::Liquid; + break; + } + const double total_produced = getTotalProductionFlow(well_surfacerates_phase, phase); + const double my_guide_rate = injectionGuideRate(true); + for (size_t i = 0; i < children_.size(); ++i) { + // 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]->injectionGuideRate(true); + children_[i]->applyInjGroupControl(InjectionSpecification::RATE, + (children_guide_rate / my_guide_rate) * total_produced, + false); + } + } + } + // ============== WellNode members ============ @@ -761,6 +800,20 @@ namespace Opm return wells_->type[self_index_]; } + /// Applies explicit reinjection controls. This must be called at each timestep to be correct. + /// \param[in] well_reservoirrates_phase + /// A vector containing reservoir rates by phase for each well. + /// Is assumed to be ordered the same way as the related Wells-struct, + /// with all phase rates of a single well adjacent in the array. + /// \param[in] well_surfacerates_phase + /// A vector containing surface rates by phase for each well. + /// Is assumed to be ordered the same way as the related Wells-struct, + /// with all phase rates of a single well adjacent in the array. + void WellNode::applyExplicitReinjectionControls(const std::vector&, + const std::vector&) + { + // Do nothing at well level. + } void WellNode::applyProdGroupControl(const ProductionSpecification::ControlMode control_mode, const double target, const bool forced) diff --git a/opm/core/WellsGroup.hpp b/opm/core/WellsGroup.hpp index d1b98aeda..3c14950dd 100644 --- a/opm/core/WellsGroup.hpp +++ b/opm/core/WellsGroup.hpp @@ -187,6 +187,18 @@ namespace Opm virtual double getTotalProductionFlow(const std::vector& phase_flows, const BlackoilPhases::PhaseIndex phase) = 0; + /// Applies explicit reinjection controls. This must be called at each timestep to be correct. + /// \param[in] well_reservoirrates_phase + /// A vector containing reservoir rates by phase for each well. + /// Is assumed to be ordered the same way as the related Wells-struct, + /// with all phase rates of a single well adjacent in the array. + /// \param[in] well_surfacerates_phase + /// A vector containing surface rates by phase for each well. + /// Is assumed to be ordered the same way as the related Wells-struct, + /// with all phase rates of a single well adjacent in the array. + virtual void applyExplicitReinjectionControls(const std::vector& well_reservoirrates_phase, + const std::vector& well_surfacerates_phase) = 0; + protected: /// Calculates the correct rate for the given ProductionSpecification::ControlMode @@ -275,6 +287,18 @@ namespace Opm /// \param[in] phase The phase for which to sum up. virtual double getTotalProductionFlow(const std::vector& phase_flows, const BlackoilPhases::PhaseIndex phase); + + /// Applies explicit reinjection controls. This must be called at each timestep to be correct. + /// \param[in] well_reservoirrates_phase + /// A vector containing reservoir rates by phase for each well. + /// Is assumed to be ordered the same way as the related Wells-struct, + /// with all phase rates of a single well adjacent in the array. + /// \param[in] well_surfacerates_phase + /// A vector containing surface rates by phase for each well. + /// Is assumed to be ordered the same way as the related Wells-struct, + /// with all phase rates of a single well adjacent in the array. + virtual void applyExplicitReinjectionControls(const std::vector& well_reservoirrates_phase, + const std::vector& well_surfacerates_phase); private: std::vector > children_; @@ -355,6 +379,18 @@ namespace Opm /// Returns the type of the well. WellType type() const; + + /// Applies explicit reinjection controls. This must be called at each timestep to be correct. + /// \param[in] well_reservoirrates_phase + /// A vector containing reservoir rates by phase for each well. + /// Is assumed to be ordered the same way as the related Wells-struct, + /// with all phase rates of a single well adjacent in the array. + /// \param[in] well_surfacerates_phase + /// A vector containing surface rates by phase for each well. + /// Is assumed to be ordered the same way as the related Wells-struct, + /// with all phase rates of a single well adjacent in the array. + virtual void applyExplicitReinjectionControls(const std::vector& well_reservoirrates_phase, + const std::vector& well_surfacerates_phase); private: Wells* wells_;