WellsGroup.hpp
Go to the documentation of this file.
1 /*
2  Copyright 2012 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 
20 #ifndef OPM_WELLSGROUP_HPP
21 #define OPM_WELLSGROUP_HPP
22 
25 #include <opm/core/grid.h>
27 
28 #include <opm/parser/eclipse/EclipseState/Schedule/Well.hpp>
29 #include <opm/parser/eclipse/EclipseState/Schedule/Group.hpp>
30 
31 #include <string>
32 #include <memory>
33 
34 namespace Opm
35 {
36  // Need to forward declare this one, some of the methods in the base
37  // class returns pointers to it.
38  class WellNode;
39 
43  {
45  double res_inj_rates[3];
46  double res_prod_rates[3];
47  double surf_inj_rates[3];
48  double surf_prod_rates[3];
49 
51  void operator+=(const WellPhasesSummed& other);
52  };
53 
55  {
56  public:
57  WellsGroupInterface(const std::string& name,
58  const ProductionSpecification& prod_spec,
59  const InjectionSpecification& inj_spec,
60  const PhaseUsage& phase_usage);
61  virtual ~WellsGroupInterface();
62 
64  const std::string& name() const;
65 
67  const ProductionSpecification& prodSpec() const;
68 
70  const InjectionSpecification& injSpec() const;
71 
74 
77 
79  const PhaseUsage& phaseUsage() const;
80 
82  virtual bool isLeafNode() const;
83 
86  virtual WellsGroupInterface* findGroup(const std::string& name_of_node) = 0;
87 
90  void setParent(WellsGroupInterface* parent);
91 
93  const WellsGroupInterface* getParent() const;
94 
97  virtual int numberOfLeafNodes() = 0;
98 
123  virtual bool conditionsMet(const std::vector<double>& well_bhp,
124  const std::vector<double>& well_reservoirrates_phase,
125  const std::vector<double>& well_surfacerates_phase,
126  WellPhasesSummed& summed_phases) = 0;
127 
133  virtual void applyInjGroupControl(const InjectionSpecification::ControlMode control_mode,
134  const double target,
135  const bool forced) = 0;
141  virtual void applyProdGroupControl(const ProductionSpecification::ControlMode control_mode,
142  const double target,
143  const bool forced) = 0;
144 
157  virtual std::pair<WellNode*, double> getWorstOffending(const std::vector<double>& well_reservoirrates_phase,
158  const std::vector<double>& well_surfacerates_phase,
160 
163 
166 
169  virtual void applyProdGroupControls() = 0;
170 
173  virtual void applyInjGroupControls() = 0;
174 
178  virtual double productionGuideRate(bool only_group) = 0;
179 
183  virtual double injectionGuideRate(bool only_group) = 0;
184 
190  virtual double getTotalProductionFlow(const std::vector<double>& phase_flows,
191  const BlackoilPhases::PhaseIndex phase) = 0;
192 
202  virtual void applyExplicitReinjectionControls(const std::vector<double>& well_reservoirrates_phase,
203  const std::vector<double>& well_surfacerates_phase) = 0;
204 
205 
206  protected:
208  double rateByMode(const double* res_rates,
209  const double* surf_rates,
211 
213  double rateByMode(const double* res_rates,
214  const double* surf_rates,
216 
218 
219  private:
220  std::string name_;
221  ProductionSpecification production_specification_;
222  InjectionSpecification injection_specification_;
223  PhaseUsage phase_usage_;
224  };
225 
226 
227 
229  {
230  public:
231  WellsGroup(const std::string& name,
232  const ProductionSpecification& prod_spec,
233  const InjectionSpecification& inj_spec,
234  const PhaseUsage& phase_usage);
235 
236  virtual WellsGroupInterface* findGroup(const std::string& name_of_node);
237 
238  void addChild(std::shared_ptr<WellsGroupInterface> child);
239 
240  virtual bool conditionsMet(const std::vector<double>& well_bhp,
241  const std::vector<double>& well_reservoirrates_phase,
242  const std::vector<double>& well_surfacerates_phase,
243  WellPhasesSummed& summed_phases);
244 
245  virtual int numberOfLeafNodes();
246  virtual std::pair<WellNode*, double> getWorstOffending(const std::vector<double>& well_reservoirrates_phase,
247  const std::vector<double>& well_surfacerates_phase,
249 
255  virtual void applyInjGroupControl(const InjectionSpecification::ControlMode control_mode,
256  const double target,
257  bool forced);
258 
264  virtual void applyProdGroupControl(const ProductionSpecification::ControlMode control_mode,
265  const double target,
266  bool forced);
267 
270  virtual void applyProdGroupControls();
271 
274  virtual void applyInjGroupControls();
275 
279  virtual double productionGuideRate(bool only_group);
280 
284  virtual double injectionGuideRate(bool only_group);
285 
291  virtual double getTotalProductionFlow(const std::vector<double>& phase_flows,
292  const BlackoilPhases::PhaseIndex phase);
293 
303  virtual void applyExplicitReinjectionControls(const std::vector<double>& well_reservoirrates_phase,
304  const std::vector<double>& well_surfacerates_phase);
305 
306  private:
307  std::vector<std::shared_ptr<WellsGroupInterface> > children_;
308  };
309 
310 
311 
313  {
314  public:
315  WellNode(const std::string& name,
316  const ProductionSpecification& prod_spec,
317  const InjectionSpecification& inj_spec,
318  const PhaseUsage& phase_usage);
319 
320  virtual WellsGroupInterface* findGroup(const std::string& name_of_node);
321  virtual bool conditionsMet(const std::vector<double>& well_bhp,
322  const std::vector<double>& well_reservoirrates_phase,
323  const std::vector<double>& well_surfacerates_phase,
324  WellPhasesSummed& summed_phases);
325 
326  virtual bool isLeafNode() const;
327 
328  void setWellsPointer(Wells* wells, int self_index);
329 
330  virtual int numberOfLeafNodes();
331 
332  // Shuts the well (in the well struct)
333  void shutWell();
334 
335  virtual std::pair<WellNode*, double> getWorstOffending(const std::vector<double>& well_reservoirrates_phase,
336  const std::vector<double>& well_surfacerates_phase,
338 
344  virtual void applyInjGroupControl(const InjectionSpecification::ControlMode control_mode,
345  const double target,
346  bool forced);
347 
353  virtual void applyProdGroupControl(const ProductionSpecification::ControlMode control_mode,
354  const double target,
355  bool forced);
356 
359  virtual void applyProdGroupControls();
360 
363  virtual void applyInjGroupControls();
364 
368  virtual double productionGuideRate(bool only_group);
369 
373  virtual double injectionGuideRate(bool only_group);
374 
380  virtual double getTotalProductionFlow(const std::vector<double>& phase_flows,
381  const BlackoilPhases::PhaseIndex phase);
382 
384  WellType type() const;
385 
395  virtual void applyExplicitReinjectionControls(const std::vector<double>& well_reservoirrates_phase,
396  const std::vector<double>& well_surfacerates_phase);
397 
398  private:
399  Wells* wells_;
400  int self_index_;
401  int group_control_index_;
402  bool shut_well_;
403  };
404 
409  std::shared_ptr<WellsGroupInterface> createWellWellsGroup(WellConstPtr well, size_t timeStep,
410  const PhaseUsage& phase_usage );
411 
416  std::shared_ptr<WellsGroupInterface> createGroupWellsGroup(GroupConstPtr group, size_t timeStep,
417  const PhaseUsage& phase_usage );
418 }
419 #endif /* OPM_WELLSGROUP_HPP */
420 
void operator+=(const WellPhasesSummed &other)
Sums each component.
double surf_inj_rates[3]
Definition: WellsGroup.hpp:47
virtual bool conditionsMet(const std::vector< double > &well_bhp, const std::vector< double > &well_reservoirrates_phase, const std::vector< double > &well_surfacerates_phase, WellPhasesSummed &summed_phases)
Definition: wells.h:50
virtual bool conditionsMet(const std::vector< double > &well_bhp, const std::vector< double > &well_reservoirrates_phase, const std::vector< double > &well_surfacerates_phase, WellPhasesSummed &summed_phases)=0
virtual void applyInjGroupControls()
void setParent(WellsGroupInterface *parent)
Definition: WellsGroup.hpp:54
WellType type() const
Returns the type of the well.
virtual double injectionGuideRate(bool only_group)=0
virtual void applyInjGroupControls()
std::shared_ptr< WellsGroupInterface > createGroupWellsGroup(GroupConstPtr group, size_t timeStep, const PhaseUsage &phase_usage)
const WellsGroupInterface * getParent() const
Gets the parent of the group, NULL if no parent.
virtual int numberOfLeafNodes()=0
virtual void applyProdGroupControl(const ProductionSpecification::ControlMode control_mode, const double target, bool forced)
Definition: AnisotropicEikonal.hpp:43
virtual void applyProdGroupControls()
Definition: WellsGroup.hpp:312
const InjectionSpecification & injSpec() const
Injection specifications for the well or well group.
virtual void applyProdGroupControl(const ProductionSpecification::ControlMode control_mode, const double target, bool forced)
virtual void applyInjGroupControls()=0
const std::string & name() const
The unique identifier for the well or well group.
void setWellsPointer(Wells *wells, int self_index)
virtual int numberOfLeafNodes()
const ProductionSpecification & prodSpec() const
Production specifications for the well or well group.
Definition: WellsGroup.hpp:228
virtual WellsGroupInterface * findGroup(const std::string &name_of_node)=0
double res_inj_rates[3]
Definition: WellsGroup.hpp:45
virtual double getTotalProductionFlow(const std::vector< double > &phase_flows, const BlackoilPhases::PhaseIndex phase)
virtual void applyInjGroupControl(const InjectionSpecification::ControlMode control_mode, const double target, bool forced)
only children that are under group control will be changed.
Definition: WellsGroup.hpp:42
virtual void applyExplicitReinjectionControls(const std::vector< double > &well_reservoirrates_phase, const std::vector< double > &well_surfacerates_phase)
WellsGroup(const std::string &name, const ProductionSpecification &prod_spec, const InjectionSpecification &inj_spec, const PhaseUsage &phase_usage)
virtual void applyProdGroupControls()
WellsGroupInterface * parent_
Definition: WellsGroup.hpp:217
virtual int numberOfLeafNodes()
double res_prod_rates[3]
Definition: WellsGroup.hpp:46
const PhaseUsage & phaseUsage() const
Phase usage information.
virtual std::pair< WellNode *, double > getWorstOffending(const std::vector< double > &well_reservoirrates_phase, const std::vector< double > &well_surfacerates_phase, ProductionSpecification::ControlMode mode)
virtual void applyExplicitReinjectionControls(const std::vector< double > &well_reservoirrates_phase, const std::vector< double > &well_surfacerates_phase)=0
void addChild(std::shared_ptr< WellsGroupInterface > child)
virtual double injectionGuideRate(bool only_group)
Definition: ProductionSpecification.hpp:9
virtual bool isLeafNode() const
double surf_prod_rates[3]
Definition: WellsGroup.hpp:48
virtual std::pair< WellNode *, double > getWorstOffending(const std::vector< double > &well_reservoirrates_phase, const std::vector< double > &well_surfacerates_phase, ProductionSpecification::ControlMode mode)
virtual double getTotalProductionFlow(const std::vector< double > &phase_flows, const BlackoilPhases::PhaseIndex phase)
WellNode(const std::string &name, const ProductionSpecification &prod_spec, const InjectionSpecification &inj_spec, const PhaseUsage &phase_usage)
virtual double productionGuideRate(bool only_group)=0
WellType
Definition: wells.h:41
PhaseIndex
Definition: BlackoilPhases.hpp:32
virtual bool conditionsMet(const std::vector< double > &well_bhp, const std::vector< double > &well_reservoirrates_phase, const std::vector< double > &well_surfacerates_phase, WellPhasesSummed &summed_phases)
ControlMode
Definition: InjectionSpecification.hpp:12
virtual void applyInjGroupControl(const InjectionSpecification::ControlMode control_mode, const double target, const bool forced)=0
virtual void applyProdGroupControls()=0
virtual void applyInjGroupControl(const InjectionSpecification::ControlMode control_mode, const double target, bool forced)
virtual WellsGroupInterface * findGroup(const std::string &name_of_node)
virtual double injectionGuideRate(bool only_group)
virtual void applyProdGroupControl(const ProductionSpecification::ControlMode control_mode, const double target, const bool forced)=0
virtual double getTotalProductionFlow(const std::vector< double > &phase_flows, const BlackoilPhases::PhaseIndex phase)=0
virtual double productionGuideRate(bool only_group)
virtual void applyExplicitReinjectionControls(const std::vector< double > &well_reservoirrates_phase, const std::vector< double > &well_surfacerates_phase)
virtual bool isLeafNode() const
virtual WellsGroupInterface * findGroup(const std::string &name_of_node)
double rateByMode(const double *res_rates, const double *surf_rates, const ProductionSpecification::ControlMode mode)
Calculates the correct rate for the given ProductionSpecification::ControlMode.
WellsGroupInterface(const std::string &name, const ProductionSpecification &prod_spec, const InjectionSpecification &inj_spec, const PhaseUsage &phase_usage)
ControlMode
Definition: ProductionSpecification.hpp:12
Definition: InjectionSpecification.hpp:9
std::shared_ptr< WellsGroupInterface > createWellWellsGroup(WellConstPtr well, size_t timeStep, const PhaseUsage &phase_usage)
double getTarget(ProductionSpecification::ControlMode mode)
Gets the target rate for the given mode.
virtual double productionGuideRate(bool only_group)
Definition: BlackoilPhases.hpp:36
Mode mode(const std::string &control)
virtual std::pair< WellNode *, double > getWorstOffending(const std::vector< double > &well_reservoirrates_phase, const std::vector< double > &well_surfacerates_phase, ProductionSpecification::ControlMode mode)=0