My Project
Loading...
Searching...
No Matches
Group.hpp
1/*
2 Copyright 2019 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
20#ifndef OPM_GROUP_HPP
21#define OPM_GROUP_HPP
22
23#include <opm/input/eclipse/EclipseState/Phase.hpp>
24#include <opm/input/eclipse/EclipseState/Util/IOrderSet.hpp>
25
26#include <opm/input/eclipse/Schedule/Group/GPMaint.hpp>
27
28#include <opm/input/eclipse/Deck/UDAValue.hpp>
29
30#include <opm/input/eclipse/Units/UnitSystem.hpp>
31
32#include <cstddef>
33#include <map>
34#include <optional>
35#include <string>
36
37namespace Opm {
38
39namespace RestartIO {
40struct RstGroup;
41}
42
43class SummaryState;
44class UDQConfig;
45class UDQActive;
46
47class Group {
48public:
49 // A group can have both injection controls and production controls set at
50 // the same time, i.e. this enum is used as a bitmask.
51 enum class GroupType : unsigned {
52 NONE = 0,
53 PRODUCTION = 1,
54 INJECTION = 2,
55 MIXED = 3
56 };
57
58 enum class ExceedAction {
59 NONE = 0,
60 CON = 1,
61 CON_PLUS = 2, // String: "+CON"
62 WELL = 3,
63 PLUG = 4,
64 RATE = 5
65 };
66 static const std::string ExceedAction2String( ExceedAction enumValue );
67 static ExceedAction ExceedActionFromString( const std::string& stringValue );
68 static ExceedAction ExceedActionFromInt(const int value);
69
70 enum class InjectionCMode : int {
71 NONE = 0,
72 RATE = 1,
73 RESV = 2,
74 REIN = 4,
75 VREP = 8,
76 FLD = 16,
77 SALE = 32
78 };
79 static const std::string InjectionCMode2String( InjectionCMode enumValue );
80 static InjectionCMode InjectionCModeFromString( const std::string& stringValue );
81 static InjectionCMode InjectionCModeFromInt(int ecl_int);
82 static int InjectionCMode2Int(InjectionCMode enumValue);
83
84 enum class ProductionCMode : int {
85 NONE = 0,
86 ORAT = 1,
87 WRAT = 2,
88 GRAT = 4,
89 LRAT = 8,
90 CRAT = 16,
91 RESV = 32,
92 PRBL = 64,
93 FLD = 128
94 };
95 static const std::string ProductionCMode2String( ProductionCMode enumValue );
96 static ProductionCMode ProductionCModeFromString( const std::string& stringValue );
97 static ProductionCMode ProductionCModeFromInt(int ecl_int);
98 static int ProductionCMode2Int(Group::ProductionCMode cmode);
99
100 enum class GuideRateProdTarget {
101 OIL = 0,
102 WAT = 1,
103 GAS = 2,
104 LIQ = 3,
105 RES = 4,
106 COMB = 5,
107 WGA = 6,
108 CVAL = 7,
109 INJV = 8,
110 POTN = 9,
111 FORM = 10,
112 NO_GUIDE_RATE = 11
113 };
114 static GuideRateProdTarget GuideRateProdTargetFromString( const std::string& stringValue );
115 static GuideRateProdTarget GuideRateProdTargetFromInt(int ecl_id);
116
117 enum class GuideRateInjTarget {
118 RATE = 1,
119 VOID = 2,
120 NETV = 3,
121 RESV = 4,
122 NO_GUIDE_RATE = 5
123 };
124 static GuideRateInjTarget GuideRateInjTargetFromString( const std::string& stringValue );
125 static GuideRateInjTarget GuideRateInjTargetFromInt(int ecl_id);
126 static int GuideRateInjTargetToInt(GuideRateInjTarget target);
127
129 {
130 GroupInjectionProperties() = default;
131 explicit GroupInjectionProperties(std::string group_name_arg);
132 GroupInjectionProperties(std::string group_name_arg, Phase phase, const UnitSystem& unit_system);
133
134 std::string name{};
135 Phase phase = Phase::WATER;
136 InjectionCMode cmode = InjectionCMode::NONE;
137 UDAValue surface_max_rate;
138 UDAValue resv_max_rate;
139 UDAValue target_reinj_fraction;
140 UDAValue target_void_fraction;
141 std::optional<std::string> reinj_group;
142 std::optional<std::string> voidage_group;
143 bool available_group_control = true;
144 double guide_rate = 0;
145 GuideRateInjTarget guide_rate_def = GuideRateInjTarget::NO_GUIDE_RATE;
146
147 static GroupInjectionProperties serializationTestObject();
148
149 int injection_controls = 0;
150 bool operator==(const GroupInjectionProperties& other) const;
151 bool operator!=(const GroupInjectionProperties& other) const;
152 bool updateUDQActive(const UDQConfig& udq_config, UDQActive& active) const;
153 bool uda_phase() const;
154 void update_uda(const UDQConfig& udq_config, UDQActive& udq_active, UDAControl control, const UDAValue& value);
155
156 template<class Serializer>
157 void serializeOp(Serializer& serializer)
158 {
159 serializer(this->name);
160 serializer(phase);
161 serializer(cmode);
162 serializer(surface_max_rate);
163 serializer(resv_max_rate);
164 serializer(target_reinj_fraction);
165 serializer(target_void_fraction);
166 serializer(reinj_group);
167 serializer(voidage_group);
168 serializer(injection_controls);
169 serializer(available_group_control);
170 serializer(guide_rate);
171 serializer(guide_rate_def);
172 }
173 };
174
176 {
177 ExceedAction allRates{ExceedAction::NONE};
178 ExceedAction water{ExceedAction::NONE};
179 ExceedAction gas{ExceedAction::NONE};
180 ExceedAction liquid{ExceedAction::NONE};
181
182 template<class Serializer>
183 void serializeOp(Serializer& serializer)
184 {
185 serializer(allRates);
186 serializer(water);
187 serializer(gas);
188 serializer(liquid);
189 }
190
191 bool operator==(const GroupLimitAction& other) const
192 {
193 return (this->allRates == other.allRates)
194 && (this->water == other.water)
195 && (this->gas == other.gas)
196 && (this->liquid == other.liquid);
197 }
198 };
199
201 {
202 Phase phase;
203 InjectionCMode cmode;
204 double surface_max_rate;
205 double resv_max_rate;
206 double target_reinj_fraction;
207 double target_void_fraction;
208 int injection_controls = 0;
209 std::string reinj_group;
210 std::string voidage_group;
211 double guide_rate;
212 GuideRateInjTarget guide_rate_def = GuideRateInjTarget::NO_GUIDE_RATE;
213 };
214
216 {
218 GroupProductionProperties(const UnitSystem& unit_system, const std::string& gname);
219
220 std::string name;
221 ProductionCMode cmode = ProductionCMode::NONE;
222 GroupLimitAction group_limit_action;
223 UDAValue oil_target;
224 UDAValue water_target;
225 UDAValue gas_target;
226 UDAValue liquid_target;
227 double guide_rate = 0;
228 GuideRateProdTarget guide_rate_def = GuideRateProdTarget::NO_GUIDE_RATE;
229 double resv_target = 0;
230 bool available_group_control = true;
231 static GroupProductionProperties serializationTestObject();
232
233 int production_controls = 0;
234 bool operator==(const GroupProductionProperties& other) const;
235 bool operator!=(const GroupProductionProperties& other) const;
236 bool updateUDQActive(const UDQConfig& udq_config, UDQActive& active) const;
237 void update_uda(const UDQConfig& udq_config, UDQActive& udq_active, UDAControl control, const UDAValue& value);
238
239 template<class Serializer>
240 void serializeOp(Serializer& serializer)
241 {
242 serializer(name);
243 serializer(cmode);
244 serializer(group_limit_action);
245 serializer(oil_target);
246 serializer(water_target);
247 serializer(gas_target);
248 serializer(liquid_target);
249 serializer(guide_rate);
250 serializer(guide_rate_def);
251 serializer(resv_target);
252 serializer(available_group_control);
253 serializer(production_controls);
254 }
255 };
256
258 {
259 ProductionCMode cmode;
260 GroupLimitAction group_limit_action;
261 double oil_target;
262 double water_target;
263 double gas_target;
264 double liquid_target;
265 double guide_rate;
266 GuideRateProdTarget guide_rate_def = GuideRateProdTarget::NO_GUIDE_RATE;
267 double resv_target = 0;
268 int production_controls = 0;
269 };
270
271 Group();
272 Group(const std::string& group_name, std::size_t insert_index_arg, double udq_undefined_arg, const UnitSystem& unit_system);
273 Group(const RestartIO::RstGroup& rst_group, std::size_t insert_index_arg, double udq_undefined_arg, const UnitSystem& unit_system);
274
275 static Group serializationTestObject();
276
277 std::size_t insert_index() const;
278 const std::string& name() const;
279 bool is_field() const;
280
281 bool update_gefac(double gefac, bool use_efficiency_in_network);
282
283 // [[deprecated("use Group::control_group() or Group::flow_group()")]]
284 const std::string& parent() const;
285 std::optional<std::string> control_group() const;
286 std::optional<std::string> flow_group() const;
287
288 bool updateParent(const std::string& parent);
289 bool updateInjection(const GroupInjectionProperties& injection);
290 bool updateProduction(const GroupProductionProperties& production);
291 bool isProductionGroup() const;
292 bool isInjectionGroup() const;
293 void setProductionGroup();
294 void setInjectionGroup();
295 double getGroupEfficiencyFactor(bool network = false) const;
296 bool useEfficiencyInNetwork() const;
297
298 std::size_t numWells() const;
299 bool addGroup(const std::string& group_name);
300 bool hasGroup(const std::string& group_name) const;
301 void delGroup(const std::string& group_name);
302 bool addWell(const std::string& well_name);
303 bool hasWell(const std::string& well_name) const;
304 void delWell(const std::string& well_name);
305
306 const std::vector<std::string>& wells() const;
307 const std::vector<std::string>& groups() const;
308 bool wellgroup() const;
309 ProductionControls productionControls(const SummaryState& st) const;
310 InjectionControls injectionControls(Phase phase, const SummaryState& st) const;
311 bool hasInjectionControl(Phase phase) const;
312 const GroupProductionProperties& productionProperties() const;
313 const std::map<Phase , GroupInjectionProperties>& injectionProperties() const;
314 const GroupInjectionProperties& injectionProperties(Phase phase) const;
315 const GroupType& getGroupType() const;
316 ProductionCMode prod_cmode() const;
317 InjectionCMode injection_cmode() const;
318 Phase injection_phase() const;
319 bool has_control(ProductionCMode control) const;
320 bool has_control(Phase phase, InjectionCMode control) const;
321 bool productionGroupControlAvailable() const;
322 bool injectionGroupControlAvailable(const Phase phase) const;
323 const std::optional<GPMaint>& gpmaint() const;
324 void set_gpmaint(GPMaint gpmaint);
325 void set_gpmaint();
326 bool has_gpmaint_control(Phase phase, InjectionCMode cmode) const;
327 bool has_gpmaint_control(ProductionCMode cmode) const;
328 bool as_choke() const;
329 void as_choke(const std::string& group);
330
331 bool operator==(const Group& data) const;
332 const std::optional<Phase>& topup_phase() const;
333
334 template<class Serializer>
335 void serializeOp(Serializer& serializer)
336 {
337 serializer(m_name);
338 serializer(m_insert_index);
339 serializer(udq_undefined);
340 serializer(unit_system);
341 serializer(group_type);
342 serializer(gefac);
343 serializer(use_efficiency_in_network);
344 serializer(parent_group);
345 serializer(m_wells);
346 serializer(m_groups);
347 serializer(injection_properties);
348 serializer(production_properties);
349 serializer(m_topup_phase);
350 serializer(m_gpmaint);
351 }
352
353private:
354 bool hasType(GroupType gtype) const;
355 void addType(GroupType new_gtype);
356
357 std::string m_name;
358 std::size_t m_insert_index;
359 double udq_undefined;
360 UnitSystem unit_system;
361 GroupType group_type;
362 double gefac;
363 bool use_efficiency_in_network;
364
365 std::string parent_group;
367 IOrderSet<std::string> m_groups;
368
369 std::map<Phase, GroupInjectionProperties> injection_properties;
370 GroupProductionProperties production_properties;
371 std::optional<Phase> m_topup_phase;
372 std::optional<GPMaint> m_gpmaint;
373 std::optional<std::string> m_choke_group;
374};
375
376Group::GroupType operator |(Group::GroupType lhs, Group::GroupType rhs);
377Group::GroupType operator &(Group::GroupType lhs, Group::GroupType rhs);
378
379}
380
381#endif // OPM_GROUP_HPP
Definition GPMaint.hpp:32
Definition Group.hpp:47
Definition IOrderSet.hpp:48
Class for (de-)serializing.
Definition Serializer.hpp:94
Definition SummaryState.hpp:72
Definition UDAValue.hpp:31
Internalised representation of all UDAs in a simulation run.
Definition UDQActive.hpp:50
Collection of all user-defined quantities in the current simulation run.
Definition UDQConfig.hpp:69
Definition UnitSystem.hpp:34
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30
Definition Group.hpp:129
Definition Group.hpp:176
Definition Group.hpp:201
Definition Group.hpp:258
Definition group.hpp:38