WellCollection.hpp
1 /*
2  Copyright 2011 SINTEF ICT, Applied Mathematics.
3 
4  This file is part of the Open Porous Media project (OPM).
5 
6  OPM is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  OPM is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with OPM. If not, see <http://www.gnu.org/licenses/>.
18 */
19 #ifndef OPM_WELLCOLLECTION_HPP
20 #define OPM_WELLCOLLECTION_HPP
21 
22 #include <vector>
23 #include <memory>
24 
25 #include <opm/core/wells/WellsGroup.hpp>
26 #include <opm/core/grid.h>
27 #include <opm/core/props/phaseUsageFromDeck.hpp>
28 
29 #include <opm/parser/eclipse/EclipseState/Schedule/Well.hpp>
30 #include <opm/parser/eclipse/EclipseState/Schedule/Group.hpp>
31 
32 namespace Opm
33 {
34 
36  {
37  public:
38 
39  void addField(const Group& fieldGroup, size_t timeStep, const PhaseUsage& phaseUsage);
40 
41  void addWell(const Well* wellChild, size_t timeStep, const PhaseUsage& phaseUsage);
42 
43  void addGroup(const Group& groupChild, std::string parent_name,
44  size_t timeStep, const PhaseUsage& phaseUsage);
45 
50  void addChild(std::shared_ptr<WellsGroupInterface>& child_node,
51  const std::string& parent);
52 
54  void addChild(std::shared_ptr<WellsGroupInterface>& child_node);
55 
78  bool conditionsMet(const std::vector<double>& well_bhp,
79  const std::vector<double>& well_reservoirrates_phase,
80  const std::vector<double>& well_surfacerates_phase);
81 
83  void setWellsPointer(Wells* wells);
84 
86  const std::vector<WellNode*>& getLeafNodes() const;
87 
91  WellsGroupInterface* findNode(const std::string& name);
92 
96  const WellsGroupInterface* findNode(const std::string& name) const;
97 
98 
99  WellNode& findWellNode(const std::string& name) const;
100 
101 
103  void applyGroupControls();
104 
114  void applyExplicitReinjectionControls(const std::vector<double>& well_reservoirrates_phase,
115  const std::vector<double>& well_surfacerates_phase);
116 
117 
119  void applyVREPGroupControls(const std::vector<double>& well_voidage_rates,
120  const std::vector<double>& conversion_coeffs);
121 
125  bool needUpdateWellTargets() const;
126 
128  bool needUpdateInjectionTargets() const;
129 
131  bool needUpdateProductionTargets() const;
132 
134  void updateWellTargets(const std::vector<double>& well_rates);
135 
137  bool havingVREPGroups() const;
138 
140  bool groupControlActive() const;
141 
143  bool groupControlApplied() const;
144 
146  // It is considered converged if eitehr the group targets are matched or the group targets are not matched while the wells are
147  // running under their own limits so that they can not produce more
148  // It is considered not converged if the group targets are not matched while some of the wells are still running under group control
149  // The strategy may need to be adjusted when more complicated multi-layered group control situation applied, not sure about thatyet.
150  bool groupTargetConverged(const std::vector<double>& well_rates) const;
151 
152 
154  void setGuideRatesWithPotentials(const Wells* wells,
155  const PhaseUsage& phase_usage,
156  const std::vector<double>& well_potentials) const;
157 
158 
159  bool requireWellPotentials() const;
160 
161  private:
162  // To account for the possibility of a forest
163  std::vector<std::shared_ptr<WellsGroupInterface> > roots_;
164 
165  // This will be used to traverse the bottom nodes.
166  std::vector<WellNode*> leaf_nodes_;
167 
168  bool having_vrep_groups_ = false;
169 
170  bool group_control_active_ = false;
171 
172  // This is used to mark whether apply or update the group control
173  bool group_control_applied_ = false;
174  };
175 
176 } // namespace Opm
177 
178 #endif /* OPM_WELLCOLLECTION_HPP */
179 
bool havingVREPGroups() const
When we have VREP group, we need to update the targets based on the updated production voidage rates ...
Definition: WellCollection.cpp:321
void setGuideRatesWithPotentials(const Wells *wells, const PhaseUsage &phase_usage, const std::vector< double > &well_potentials) const
Setting the guide rates with well potentials.
Definition: WellCollection.cpp:355
bool groupTargetConverged(const std::vector< double > &well_rates) const
Whether the group target is converged.
Definition: WellCollection.cpp:340
Definition: WellsGroup.hpp:396
void applyExplicitReinjectionControls(const std::vector< double > &well_reservoirrates_phase, const std::vector< double > &well_surfacerates_phase)
Applies explicit reinjection controls.
Definition: WellCollection.cpp:211
WellsGroupInterface * findNode(const std::string &name)
Finds the group with the given name.
Definition: WellCollection.cpp:99
Definition: AnisotropicEikonal.cpp:446
Data structure aggregating static information about all wells in a scenario.
Definition: wells.h:50
Definition: WellsGroup.hpp:54
bool conditionsMet(const std::vector< double > &well_bhp, const std::vector< double > &well_reservoirrates_phase, const std::vector< double > &well_surfacerates_phase)
Checks if each condition is met, applies well controls where needed (that is, it either changes the a...
Definition: WellCollection.cpp:169
bool groupControlActive() const
Whether we have active group control.
Definition: WellCollection.cpp:327
void addChild(std::shared_ptr< WellsGroupInterface > &child_node, const std::string &parent)
Adds the child to the collection and appends it to parent&#39;s children.
Definition: WellCollection.cpp:144
void applyGroupControls()
Applies all group controls (injection and production)
Definition: WellCollection.cpp:191
Definition: BlackoilPhases.hpp:36
bool needUpdateWellTargets() const
Checking whether need to update the targets of the wells / or the groups later True need to update we...
Definition: WellCollection.cpp:230
Definition: WellCollection.hpp:35
void applyVREPGroupControls(const std::vector< double > &well_voidage_rates, const std::vector< double > &conversion_coeffs)
applying VREP group control based on calculated voidage rates
Definition: WellCollection.cpp:220
bool groupControlApplied() const
Whether we have applied the group control.
Definition: WellCollection.cpp:334
const std::vector< WellNode * > & getLeafNodes() const
Definition: WellCollection.cpp:95
bool needUpdateProductionTargets() const
Checking whehter need to update the targets for the production wells.
Definition: WellCollection.cpp:261
void setWellsPointer(Wells *wells)
Adds the well pointer to each leaf node (does not take ownership).
Definition: WellCollection.cpp:185
void updateWellTargets(const std::vector< double > &well_rates)
Updating the well targets based on the well rates.
Definition: WellCollection.cpp:285
bool needUpdateInjectionTargets() const
Checking whether need to update the targets for the injection wells.
Definition: WellCollection.cpp:236