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