My Project
GasLiftOpt.hpp
1 /*
2  Copyright 2020 Equinor ASA.
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 GAS_LIFT_OPT_HPP
20 #define GAS_LIFT_OPT_HPP
21 
22 #include <optional>
23 #include <string>
24 #include <map>
25 
26 namespace Opm {
27 
28 class GasLiftOpt {
29 public:
30 
31  class Group {
32  public:
33  Group() = default;
34 
35  Group(const std::string& name) :
36  m_name(name)
37  {}
38 
39  const std::optional<double>& max_lift_gas() const {
40  return this->m_max_lift_gas;
41  }
42 
43  void max_lift_gas(double value) {
44  if (value >= 0)
45  this->m_max_lift_gas = value;
46  }
47 
48  const std::optional<double>& max_total_gas() const {
49  return this->m_max_total_gas;
50  }
51 
52  void max_total_gas(double value) {
53  if (value >= 0)
54  this->m_max_total_gas = value;
55  }
56 
57  const std::string& name() const {
58  return this->m_name;
59  }
60 
61  template<class Serializer>
62  void serializeOp(Serializer& serializer)
63  {
64  serializer(m_name);
65  serializer(m_max_lift_gas);
66  serializer(m_max_total_gas);
67  }
68 
69 
70  static Group serializeObject() {
71  Group group;
72  group.m_name = "GR";
73  group.m_max_lift_gas = 100;
74  group.m_max_total_gas = 200;
75  return group;
76  }
77 
78 
79  bool operator==(const Group& other) const {
80  return this->m_name == other.m_name &&
81  this->m_max_lift_gas == other.m_max_lift_gas &&
82  this->m_max_total_gas == other.m_max_total_gas;
83  }
84 
85  private:
86  std::string m_name;
87  std::optional<double> m_max_lift_gas;
88  std::optional<double> m_max_total_gas;
89  };
90 
91 
92  class Well {
93  public:
94  Well() = default;
95  Well(const std::string& name, bool use_glo) :
96  m_name(name),
97  m_use_glo(use_glo)
98  {}
99 
100  const std::string& name() const {
101  return this->m_name;
102  }
103 
104  bool use_glo() const {
105  return this->m_use_glo;
106  }
107 
108  void max_rate(double value) {
109  this->m_max_rate = value;
110  }
111 
112 
113  /*
114  The semantics of the max_rate is quite complicated:
115 
116  1. If the std::optional<double> has a value that value should be
117  used as the maximum rate and all is fine.
118 
119  2. If the std::optional<double> does not a have well we must check
120  the value of Well::use_glo():
121 
122  False: The maximum gas lift should have been set with WCONPROD /
123  WELTARG - this code does not provide a value in that case.
124 
125  True: If the well should be controlled with gas lift optimization
126  the value to use should be the largest ALQ value in the wells
127  VFP table.
128  */
129  const std::optional<double>& max_rate() const {
130  return this->m_max_rate;
131  }
132 
133  void weight_factor(double value) {
134  if (this->m_use_glo)
135  this->m_weight = value;
136  }
137 
138  double weight_factor() const {
139  return this->m_weight;
140  }
141 
142  void inc_weight_factor(double value) {
143  if (this->m_use_glo)
144  this->m_inc_weight = value;
145  }
146 
147  double inc_weight_factor() const {
148  return this->m_inc_weight;
149  }
150 
151  void min_rate(double value) {
152  if (this->m_use_glo)
153  this->m_min_rate = value;
154  }
155 
156  double min_rate() const {
157  return this->m_min_rate;
158  }
159 
160  void alloc_extra_gas(bool value) {
161  if (this->m_use_glo)
162  this->m_alloc_extra_gas = value;
163  }
164 
165  bool alloc_extra_gas() const {
166  return this->m_alloc_extra_gas;
167  }
168 
169  template<class Serializer>
170  void serializeOp(Serializer& serializer)
171  {
172  serializer(m_name);
173  serializer(m_use_glo);
174  serializer(m_max_rate);
175  serializer(m_min_rate);
176  serializer(m_weight);
177  serializer(m_inc_weight);
178  serializer(m_alloc_extra_gas);
179  }
180 
181  static Well serializeObject() {
182  Well well;
183  well.m_name = "WELL";
184  well.m_max_rate = 2000;
185  well.m_min_rate = 56;
186  well.m_use_glo = true;
187  well.m_weight = 1.25;
188  well.m_inc_weight = 0.25;
189  well.m_alloc_extra_gas = false;
190  return well;
191  }
192 
193  bool operator==(const Well& other) const {
194  return this->m_name == other.m_name &&
195  this->m_max_rate == other.m_max_rate &&
196  this->m_min_rate == other.m_min_rate &&
197  this->m_use_glo == other.m_use_glo &&
198  this->m_weight == other.m_weight &&
199  this->m_inc_weight == other.m_inc_weight &&
200  this->m_alloc_extra_gas == other.m_alloc_extra_gas;
201  }
202 
203  private:
204  std::string m_name;
205  std::optional<double> m_max_rate;
206  double m_min_rate = 0;
207  bool m_use_glo = false;
208  double m_weight = 1;
209  double m_inc_weight = 0;
210  bool m_alloc_extra_gas = false;
211  };
212 
213  GasLiftOpt() = default;
214 
215  const Group& group(const std::string& gname) const;
216  const Well& well(const std::string& wname) const;
217 
218  double gaslift_increment() const;
219  void gaslift_increment(double gaslift_increment);
220  double min_eco_gradient() const;
221  void min_eco_gradient(double min_eco_gradient);
222  double min_wait() const;
223  void min_wait(double min_wait);
224  void all_newton(double all_newton);
225  bool all_newton() const;
226  void add_group(const Group& group);
227  void add_well(const Well& well);
228  bool active() const;
229  bool has_well(const std::string& well) const;
230  bool has_group(const std::string& group) const;
231 
232  static GasLiftOpt serializeObject();
233  bool operator==(const GasLiftOpt& other) const;
234 
235  template<class Serializer>
236  void serializeOp(Serializer& serializer)
237  {
238  serializer(m_increment);
239  serializer(m_min_eco_gradient);
240  serializer(m_min_wait);
241  serializer(m_all_newton);
242  serializer.map(m_groups);
243  serializer.map(m_wells);
244  }
245 private:
246  double m_increment = 0;
247  double m_min_eco_gradient;
248  double m_min_wait;
249  bool m_all_newton = true;
250 
251  std::map<std::string, GasLiftOpt::Group> m_groups;
252  std::map<std::string, GasLiftOpt::Well> m_wells;
253 };
254 
255 }
256 
257 #endif
Definition: GasLiftOpt.hpp:31
Definition: GasLiftOpt.hpp:92
Definition: GasLiftOpt.hpp:28
Definition: Serializer.hpp:38
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:29