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
34namespace 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 double efficiency_factor,
59 const ProductionSpecification& prod_spec,
60 const InjectionSpecification& inj_spec,
61 const PhaseUsage& phase_usage);
63
65 const std::string& name() const;
66
69
72
75
78
80 const PhaseUsage& phaseUsage() const;
81
83 virtual bool isLeafNode() const;
84
87 virtual WellsGroupInterface* findGroup(const std::string& name_of_node) = 0;
88
92
95
97
100 virtual int numberOfLeafNodes() = 0;
101
126 virtual bool conditionsMet(const std::vector<double>& well_bhp,
127 const std::vector<double>& well_reservoirrates_phase,
128 const std::vector<double>& well_surfacerates_phase,
129 WellPhasesSummed& summed_phases) = 0;
130
135 // otherwise, all children will be set under group control
137 const InjectionSpecification::InjectorType injector_type,
138 const double target,
139 const bool only_group) = 0;
144 // otherwise, all children will be set under group control
146 const double target,
147 const bool only_group) = 0;
148
161 virtual std::pair<WellNode*, double> getWorstOffending(const std::vector<double>& well_reservoirrates_phase,
162 const std::vector<double>& well_surfacerates_phase,
164
167
170
173 virtual void applyProdGroupControls() = 0;
174
177 virtual void applyInjGroupControls() = 0;
178
182 virtual double productionGuideRate(bool only_group) = 0;
183
187 virtual double injectionGuideRate(bool only_group) = 0;
188
194 virtual double getTotalProductionFlow(const std::vector<double>& phase_flows,
195 const BlackoilPhases::PhaseIndex phase) const = 0;
196
206 virtual void applyExplicitReinjectionControls(const std::vector<double>& well_reservoirrates_phase,
207 const std::vector<double>& well_surfacerates_phase) = 0;
208
210 virtual void applyVREPGroupControls(const std::vector<double>& well_voidage_rates,
211 const std::vector<double>& conversion_coeffs) = 0;
212
213 virtual void applyVREPGroupControl(const double target,
214 const InjectionSpecification::InjectorType injector_type,
215 const std::vector<double>& well_voidage_rates,
216 const std::vector<double>& conversion_coeffs,
217 const bool only_group) = 0;
218
219 virtual double getTotalVoidageRate(const std::vector<double>& well_voidage_rates) = 0;
220
225 bool individualControl() const;
226
228 void setIndividualControl(const bool);
229
230 virtual double getProductionRate(const std::vector<double>& well_rates,
231 const ProductionSpecification::ControlMode prod_mode) const = 0;
232
233 virtual void updateWellProductionTargets(const std::vector<double>& well_rates) = 0;
234
235 virtual void updateWellInjectionTargets(const std::vector<double>& well_rates) = 0;
236
237 virtual void setTargetUpdated(const bool flag) = 0;
238
239 // bascially, for the group or wells under group control
240 // they have the potential to adjust their targets to produce more to match the higher level target
241 virtual bool canProduceMore() const = 0;
242
243 // checking wether group production target converged
244 // if the group is producing following the target, then it should be considered okay
245 // if the group is not producing following the target, then we should check wether the group
246 // should be able to produce more to match the target.
247 // if the group can not produce more, we also consider the effort to match the group target is
248 // also done and the group target converged while we should give a message
249 virtual bool groupProdTargetConverged(const std::vector<double>& well_rates) const = 0;
250
251 double efficiencyFactor() const;
252
253 void setEfficiencyFactor(const double efficiency_factor);
254
255 protected:
257 double rateByMode(const double* res_rates,
258 const double* surf_rates,
260
262 double rateByMode(const double* res_rates,
263 const double* surf_rates,
265
267
268 // Whether well is running under the group control target.
269 // Current only consider one level of control.
270 // So not putting it in the WellsGroupInterface yet.
272
273 // Efficiency factor
275
276 private:
277 std::string name_;
278 ProductionSpecification production_specification_;
279 InjectionSpecification injection_specification_;
280 PhaseUsage phase_usage_;
281 };
282
283
284
286 {
287 public:
288 WellsGroup(const std::string& name,
289 const double efficiency_factor,
290 const ProductionSpecification& prod_spec,
291 const InjectionSpecification& inj_spec,
292 const PhaseUsage& phase_usage);
293
294 virtual WellsGroupInterface* findGroup(const std::string& name_of_node);
295
296 void addChild(std::shared_ptr<WellsGroupInterface> child);
297
298 virtual bool conditionsMet(const std::vector<double>& well_bhp,
299 const std::vector<double>& well_reservoirrates_phase,
300 const std::vector<double>& well_surfacerates_phase,
301 WellPhasesSummed& summed_phases);
302
303 virtual int numberOfLeafNodes();
304 virtual std::pair<WellNode*, double> getWorstOffending(const std::vector<double>& well_reservoirrates_phase,
305 const std::vector<double>& well_surfacerates_phase,
307
312 // otherwise, all children will be set under group control
314 const InjectionSpecification::InjectorType injector_type,
315 const double target,
316 bool only_group);
317
322 // otherwise, all children will be set under group control
324 const double target,
325 bool only_group);
326
330
333 virtual void applyInjGroupControls();
334
338 virtual double productionGuideRate(bool only_group);
339
343 virtual double injectionGuideRate(bool only_group);
344
350 virtual double getTotalProductionFlow(const std::vector<double>& phase_flows,
351 const BlackoilPhases::PhaseIndex phase) const;
352
362 virtual void applyExplicitReinjectionControls(const std::vector<double>& well_reservoirrates_phase,
363 const std::vector<double>& well_surfacerates_phase);
364
366 virtual void applyVREPGroupControls(const std::vector<double>& well_voidage_rates,
367 const std::vector<double>& conversion_coeffs);
368
369 virtual void applyVREPGroupControl(const double target,
370 const InjectionSpecification::InjectorType injector_type,
371 const std::vector<double>& well_voidage_rates,
372 const std::vector<double>& conversion_coeffs,
373 const bool only_group);
374
375 virtual double getTotalVoidageRate(const std::vector<double>& well_voidage_rates);
376
377 virtual void updateWellProductionTargets(const std::vector<double>& well_rates);
378
379 virtual void updateWellInjectionTargets(const std::vector<double>& well_rates);
380
381 virtual void setTargetUpdated(const bool flag);
382
383 virtual double getProductionRate(const std::vector<double>& well_rates,
384 const ProductionSpecification::ControlMode prod_mode) const;
385
386 virtual bool canProduceMore() const;
387
388 virtual bool groupProdTargetConverged(const std::vector<double>& well_rates) const;
389
390 private:
391 std::vector<std::shared_ptr<WellsGroupInterface> > children_;
392 };
393
394
395
397 {
398 public:
399 WellNode(const std::string& name,
400 const double efficiency_factor,
401 const ProductionSpecification& prod_spec,
402 const InjectionSpecification& inj_spec,
403 const PhaseUsage& phase_usage);
404
405 virtual WellsGroupInterface* findGroup(const std::string& name_of_node);
406 virtual bool conditionsMet(const std::vector<double>& well_bhp,
407 const std::vector<double>& well_reservoirrates_phase,
408 const std::vector<double>& well_surfacerates_phase,
409 WellPhasesSummed& summed_phases);
410
411 virtual bool isLeafNode() const;
412
413 void setWellsPointer(Wells* wells, int self_index);
414
415 virtual int numberOfLeafNodes();
416
417 // Shuts the well (in the well struct)
418 void shutWell();
419
420 virtual std::pair<WellNode*, double> getWorstOffending(const std::vector<double>& well_reservoirrates_phase,
421 const std::vector<double>& well_surfacerates_phase,
423
430 const InjectionSpecification::InjectorType injector_type,
431 const double target,
432 bool only_group);
433
440 const double target,
441 bool only_group);
442
446
449 virtual void applyInjGroupControls();
450
454 virtual double productionGuideRate(bool only_group);
455
459 virtual double injectionGuideRate(bool only_group);
460
466 virtual double getTotalProductionFlow(const std::vector<double>& phase_flows,
467 const BlackoilPhases::PhaseIndex phase) const;
468
470 WellType type() const;
471
481 virtual void applyExplicitReinjectionControls(const std::vector<double>& well_reservoirrates_phase,
482 const std::vector<double>& well_surfacerates_phase);
483
485 virtual void applyVREPGroupControls(const std::vector<double>& well_voidage_rates,
486 const std::vector<double>& conversion_coeffs);
487
488 virtual void applyVREPGroupControl(const double target,
489 const InjectionSpecification::InjectorType injector_type,
490 const std::vector<double>& well_voidage_rates,
491 const std::vector<double>& conversion_coeffs,
492 const bool only_group);
493
494 virtual double getTotalVoidageRate(const std::vector<double>& well_voidage_rates);
495
496 int groupControlIndex() const;
497
498 virtual double getProductionRate(const std::vector<double>& well_rates,
499 const ProductionSpecification::ControlMode prod_mode) const;
500
501 virtual void updateWellProductionTargets(const std::vector<double>& well_rates);
502
503 virtual void updateWellInjectionTargets(const std::vector<double>& well_rates);
504
508
509 bool isProducer() const;
510
511 bool isInjector() const;
512
513 int selfIndex() const;
514
515 bool targetUpdated() const;
516
518
519 void setIsGuideRateWellPotential(const bool flag);
520
521 virtual void setTargetUpdated(const bool flag);
522
523 virtual bool canProduceMore() const;
524
525 virtual bool groupProdTargetConverged(const std::vector<double>& well_rates) const;
526
527 private:
528 Wells* wells_;
529 int self_index_;
530 int group_control_index_;
531 bool shut_well_;
532 // TODO: used when updating well targets
533 bool target_updated_;
534 // whether the guide rate is specified with well potential
535 // TODO: we have never handle the guide rates for groups, maybe this
536 // is something will go to WellsGroupInterface later
537 bool is_guiderate_wellpotential_;
538 };
539
544 std::shared_ptr<WellsGroupInterface> createWellWellsGroup(const Well* well, size_t timeStep,
545 const PhaseUsage& phase_usage );
546
551 std::shared_ptr<WellsGroupInterface> createGroupWellsGroup(const Group& group, size_t timeStep,
552 const PhaseUsage& phase_usage );
553}
554
555#endif /* OPM_WELLSGROUP_HPP */
556
PhaseIndex
Definition: BlackoilPhases.hpp:40
Definition: WellsGroup.hpp:397
bool targetUpdated() const
WellNode(const std::string &name, const double efficiency_factor, const ProductionSpecification &prod_spec, const InjectionSpecification &inj_spec, const PhaseUsage &phase_usage)
bool isProducer() const
virtual bool groupProdTargetConverged(const std::vector< double > &well_rates) const
bool isInjector() const
virtual int numberOfLeafNodes()
virtual bool isLeafNode() const
virtual std::pair< WellNode *, double > getWorstOffending(const std::vector< double > &well_reservoirrates_phase, const std::vector< double > &well_surfacerates_phase, ProductionSpecification::ControlMode mode)
bool isGuideRateWellPotential() const
virtual void setTargetUpdated(const bool flag)
virtual WellsGroupInterface * findGroup(const std::string &name_of_node)
double getAccumulativeEfficiencyFactor() const
virtual double getProductionRate(const std::vector< double > &well_rates, const ProductionSpecification::ControlMode prod_mode) const
void setWellsPointer(Wells *wells, int self_index)
virtual void applyExplicitReinjectionControls(const std::vector< double > &well_reservoirrates_phase, const std::vector< double > &well_surfacerates_phase)
void setIsGuideRateWellPotential(const bool flag)
int selfIndex() const
int groupControlIndex() const
virtual void applyVREPGroupControl(const double target, const InjectionSpecification::InjectorType injector_type, const std::vector< double > &well_voidage_rates, const std::vector< double > &conversion_coeffs, const bool only_group)
virtual void applyInjGroupControls()
virtual void applyProdGroupControl(const ProductionSpecification::ControlMode control_mode, const double target, bool only_group)
virtual double injectionGuideRate(bool only_group)
WellType type() const
Returns the type of the well.
virtual double productionGuideRate(bool only_group)
virtual double getTotalVoidageRate(const std::vector< double > &well_voidage_rates)
virtual void updateWellProductionTargets(const std::vector< double > &well_rates)
virtual void updateWellInjectionTargets(const std::vector< double > &well_rates)
virtual bool canProduceMore() const
virtual double getTotalProductionFlow(const std::vector< double > &phase_flows, const BlackoilPhases::PhaseIndex phase) const
virtual void applyProdGroupControls()
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)
virtual void applyVREPGroupControls(const std::vector< double > &well_voidage_rates, const std::vector< double > &conversion_coeffs)
TODO: prototyping a VREP enforcement function.
virtual void applyInjGroupControl(const InjectionSpecification::ControlMode control_mode, const InjectionSpecification::InjectorType injector_type, const double target, bool only_group)
Definition: WellsGroup.hpp:55
double rateByMode(const double *res_rates, const double *surf_rates, const ProductionSpecification::ControlMode mode)
Calculates the correct rate for the given ProductionSpecification::ControlMode.
virtual void updateWellInjectionTargets(const std::vector< double > &well_rates)=0
const ProductionSpecification & prodSpec() const
Production specifications for the well or well group.
double getTarget(ProductionSpecification::ControlMode mode) const
Gets the target rate for the given mode.
void setEfficiencyFactor(const double efficiency_factor)
const WellsGroupInterface * getParent() const
Gets the parent of the group, NULL if no parent.
double efficiency_factor_
Definition: WellsGroup.hpp:274
virtual double injectionGuideRate(bool only_group)=0
virtual void updateWellProductionTargets(const std::vector< double > &well_rates)=0
virtual void applyInjGroupControl(const InjectionSpecification::ControlMode control_mode, const InjectionSpecification::InjectorType injector_type, const double target, const bool only_group)=0
virtual bool groupProdTargetConverged(const std::vector< double > &well_rates) const =0
virtual double getProductionRate(const std::vector< double > &well_rates, const ProductionSpecification::ControlMode prod_mode) const =0
virtual double getTotalProductionFlow(const std::vector< double > &phase_flows, const BlackoilPhases::PhaseIndex phase) const =0
double rateByMode(const double *res_rates, const double *surf_rates, const InjectionSpecification::ControlMode mode)
Calculates the correct rate for the given InjectionSpecification::ControlMode.
WellsGroupInterface * parent_
Definition: WellsGroup.hpp:266
virtual void setTargetUpdated(const bool flag)=0
double getTarget(InjectionSpecification::ControlMode mode) const
Gets the target rate for the given mode.
virtual void applyVREPGroupControl(const double target, const InjectionSpecification::InjectorType injector_type, const std::vector< double > &well_voidage_rates, const std::vector< double > &conversion_coeffs, const bool only_group)=0
virtual int numberOfLeafNodes()=0
const InjectionSpecification & injSpec() const
Injection specifications for the well or well group.
virtual bool isLeafNode() const
virtual void applyProdGroupControls()=0
double efficiencyFactor() const
virtual bool canProduceMore() const =0
virtual double productionGuideRate(bool only_group)=0
virtual double getTotalVoidageRate(const std::vector< double > &well_voidage_rates)=0
WellsGroupInterface(const std::string &name, const double efficiency_factor, const ProductionSpecification &prod_spec, const InjectionSpecification &inj_spec, const PhaseUsage &phase_usage)
virtual std::pair< WellNode *, double > getWorstOffending(const std::vector< double > &well_reservoirrates_phase, const std::vector< double > &well_surfacerates_phase, ProductionSpecification::ControlMode mode)=0
void setIndividualControl(const bool)
Update the status for individual contrl.
virtual void applyExplicitReinjectionControls(const std::vector< double > &well_reservoirrates_phase, const std::vector< double > &well_surfacerates_phase)=0
virtual void applyVREPGroupControls(const std::vector< double > &well_voidage_rates, const std::vector< double > &conversion_coeffs)=0
TODO: prototyping a VREP enforcement function.
InjectionSpecification & injSpec()
Injection specifications for the well or well group.
WellsGroupInterface * getParent()
virtual void applyInjGroupControls()=0
ProductionSpecification & prodSpec()
Production specifications for the well or well group.
void setParent(WellsGroupInterface *parent)
const std::string & name() const
The unique identifier for the well or well group.
const PhaseUsage & phaseUsage() const
Phase usage information.
bool individual_control_
Definition: WellsGroup.hpp:271
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 WellsGroupInterface * findGroup(const std::string &name_of_node)=0
bool individualControl() const
virtual void applyProdGroupControl(const ProductionSpecification::ControlMode control_mode, const double target, const bool only_group)=0
Definition: WellsGroup.hpp:286
virtual void updateWellInjectionTargets(const std::vector< double > &well_rates)
void addChild(std::shared_ptr< WellsGroupInterface > child)
virtual void updateWellProductionTargets(const std::vector< double > &well_rates)
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)
virtual void applyVREPGroupControls(const std::vector< double > &well_voidage_rates, const std::vector< double > &conversion_coeffs)
TODO: prototyping a VREP enforcement function.
virtual double getTotalVoidageRate(const std::vector< double > &well_voidage_rates)
virtual void setTargetUpdated(const bool flag)
virtual WellsGroupInterface * findGroup(const std::string &name_of_node)
WellsGroup(const std::string &name, const double efficiency_factor, const ProductionSpecification &prod_spec, const InjectionSpecification &inj_spec, const PhaseUsage &phase_usage)
virtual double productionGuideRate(bool only_group)
virtual bool canProduceMore() const
virtual void applyProdGroupControl(const ProductionSpecification::ControlMode control_mode, const double target, bool only_group)
virtual double getProductionRate(const std::vector< double > &well_rates, const ProductionSpecification::ControlMode prod_mode) const
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 applyInjGroupControls()
virtual double injectionGuideRate(bool only_group)
virtual bool groupProdTargetConverged(const std::vector< double > &well_rates) const
virtual int numberOfLeafNodes()
virtual double getTotalProductionFlow(const std::vector< double > &phase_flows, const BlackoilPhases::PhaseIndex phase) const
virtual void applyVREPGroupControl(const double target, const InjectionSpecification::InjectorType injector_type, const std::vector< double > &well_voidage_rates, const std::vector< double > &conversion_coeffs, const bool only_group)
virtual void applyInjGroupControl(const InjectionSpecification::ControlMode control_mode, const InjectionSpecification::InjectorType injector_type, const double target, bool only_group)
virtual void applyProdGroupControls()
virtual void applyExplicitReinjectionControls(const std::vector< double > &well_reservoirrates_phase, const std::vector< double > &well_surfacerates_phase)
Definition: AnisotropicEikonal.hpp:44
std::shared_ptr< WellsGroupInterface > createGroupWellsGroup(const Group &group, size_t timeStep, const PhaseUsage &phase_usage)
std::shared_ptr< WellsGroupInterface > createWellWellsGroup(const Well *well, size_t timeStep, const PhaseUsage &phase_usage)
Mode mode(const std::string &control)
Definition: InjectionSpecification.hpp:11
InjectorType
Definition: InjectionSpecification.hpp:19
ControlMode
Definition: InjectionSpecification.hpp:14
Definition: BlackoilPhases.hpp:44
Definition: ProductionSpecification.hpp:11
ControlMode
Definition: ProductionSpecification.hpp:14
Definition: WellsGroup.hpp:43
double surf_prod_rates[3]
Definition: WellsGroup.hpp:48
double surf_inj_rates[3]
Definition: WellsGroup.hpp:47
void operator+=(const WellPhasesSummed &other)
Sums each component.
double res_inj_rates[3]
Definition: WellsGroup.hpp:45
double res_prod_rates[3]
Definition: WellsGroup.hpp:46
Definition: wells.h:51
WellType
Definition: wells.h:41