My Project
Loading...
Searching...
No Matches
GasLiftGroupInfo.hpp
1/*
2 Copyright 2021 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_GASLIFT_GROUP_INFO_HEADER_INCLUDED
21#define OPM_GASLIFT_GROUP_INFO_HEADER_INCLUDED
22
23#include <opm/core/props/BlackoilPhases.hpp>
24#include <opm/simulators/wells/GasLiftCommon.hpp>
25
26#include <map>
27#include <optional>
28#include <string>
29#include <tuple>
30#include <vector>
31
32namespace Opm
33{
34
35class DeferredLogger;
36class GasLiftOpt;
37class Group;
38class GroupState;
39class Schedule;
40class SummaryState;
41class Well;
42class WellState;
43
45{
46protected:
47 class GroupRates;
48 // NOTE: In the Well2GroupMap below, in the std::vector value we store
49 // pairs of group names and efficiency factors. The efficiency factors
50 // are the product of the wells efficiency factor and all the efficiency
51 // factors of the child groups of the group all the way down
52 // to the well group.
53 using Well2GroupMap =
54 std::map<std::string, std::vector<std::pair<std::string,double>>>;
55 using GroupRateMap =
56 std::map<std::string, GroupRates>;
57 using GroupIdxMap = std::map<std::string, int>;
58 using Communication = Dune::Communication<Dune::MPIHelper::MPICommunicator>;
59
60 // TODO: same definition with WellInterface, and
61 // WellState eventually they should go to a common header file.
62 static const int Water = BlackoilPhases::Aqua;
63 static const int Oil = BlackoilPhases::Liquid;
64 static const int Gas = BlackoilPhases::Vapour;
65public:
66 enum class Rate {oil, gas, water, liquid};
67
68 using GLiftEclWells = std::map<std::string,std::pair<const Well *,int>>;
70 GLiftEclWells& ecl_wells,
71 const Schedule& schedule,
72 const SummaryState& summary_state,
73 const int report_step_idx,
74 const int iteration_idx,
75 const PhaseUsage& phase_usage,
76 DeferredLogger& deferred_logger,
77 WellState& well_state,
78 const GroupState& group_state,
79 const Parallel::Communication& comm,
80 bool glift_debug
81 );
82 std::vector<std::pair<std::string,double>>& getWellGroups(
83 const std::string& well_name);
84
85 double alqRate(const std::string& group_name);
86 double gasRate(const std::string& group_name) const;
87 double gasPotential(const std::string& group_name) const;
88 double waterPotential(const std::string& group_name) const;
89 double oilPotential(const std::string& group_name) const;
90 int getGroupIdx(const std::string& group_name);
91 double getRate(Rate rate_type, const std::string& group_name) const;
92 double getPotential(Rate rate_type, const std::string& group_name) const;
93 std::tuple<double,double,double,double> getRates(const int group_idx) const;
94 std::optional<double> gasTarget(const std::string& group_name) const;
95 std::optional<double> getTarget(
96 Rate rate_type, const std::string& group_name) const;
97 const std::string& groupIdxToName(int group_idx) const;
98 bool hasAnyTarget(const std::string& group_name) const;
99 bool hasWell(const std::string& well_name);
100 void initialize();
101 std::optional<double> liquidTarget(const std::string& group_name) const;
102 std::optional<double> maxAlq(const std::string& group_name);
103 std::optional<double> maxTotalGasRate(const std::string& group_name);
104 double oilRate(const std::string& group_name) const;
105 std::optional<double> oilTarget(const std::string& group_name) const;
106 static const std::string rateToString(Rate rate);
107 double waterRate(const std::string& group_name) const;
108 std::optional<double> waterTarget(const std::string& group_name) const;
109 void update(const std::string& well_name,
110 double delta_oil, double delta_gas, double delta_water, double delta_alq);
111 void updateRate(int idx, double oil_rate, double gas_rate, double water_rate, double alq);
112 const Well2GroupMap& wellGroupMap() { return well_group_map_; }
113protected:
114 bool checkDoGasLiftOptimization_(const std::string& well_name);
115 bool checkNewtonIterationIdxOk_(const std::string& well_name);
116 void debugDisplayWellContribution_(
117 const std::string& gr_name, const std::string& well_name,
118 double eff_factor,
119 double well_oil_rate, double well_gas_rate, double well_water_rate,
120 double well_alq,
121 double oil_rate, double gas_rate, double water_rate,
122 double alq
123 ) const;
124 void debugDisplayUpdatedGroupRates(const std::string& name,
125 double oil_rate, double gas_rate, double water_rate, double alq) const;
126 void debugEndInitializeGroup(const std::string& name) const;
127 void debugStartInitializeGroup(const std::string& name) const;
128 void displayDebugMessage_(const std::string& msg) const override;
129 void displayDebugMessage_(const std::string& msg, const std::string& well_name);
130 std::tuple<double, double, double, double, double, double>
131 getProducerWellRates_(const Well* well, const int index);
132 std::tuple<double, double, double, double, double, double, double>
133 initializeGroupRatesRecursive_(const Group &group);
134 void initializeWell2GroupMapRecursive_(
135 const Group& group, std::vector<std::string>& group_names,
136 std::vector<double>& group_efficiency, double cur_efficiency);
137 void updateGroupIdxMap_(const std::string& group_name);
138
139
141 public:
142 GroupRates( double oil_rate, double gas_rate, double water_rate, double alq,
143 double oil_potential, double gas_potential, double water_potential,
144 std::optional<double> oil_target,
145 std::optional<double> gas_target,
146 std::optional<double> water_target,
147 std::optional<double> liquid_target,
148 std::optional<double> total_gas,
149 std::optional<double> max_alq
150 ) :
151 oil_rate_{oil_rate},
152 gas_rate_{gas_rate},
153 water_rate_{water_rate},
154 alq_{alq},
155 oil_potential_{oil_potential},
156 gas_potential_{gas_potential},
157 water_potential_{water_potential},
158 oil_target_{oil_target},
159 gas_target_{gas_target},
160 water_target_{water_target},
161 liquid_target_{liquid_target},
162 total_gas_{total_gas},
163 max_alq_{max_alq}
164 {}
165 double alq() const { return alq_; }
166 void assign(double oil_rate, double gas_rate, double water_rate, double alq)
167 {
168 oil_rate_ = oil_rate;
169 gas_rate_ = gas_rate;
170 water_rate_ = water_rate;
171 alq_ = alq;
172 }
173 double gasRate() const { return gas_rate_; }
174 double waterRate() const { return water_rate_; }
175 std::optional<double> gasTarget() const { return gas_target_; }
176 std::optional<double> waterTarget() const { return water_target_; }
177 std::optional<double> maxAlq() const { return max_alq_; }
178 std::optional<double> maxTotalGasRate() const { return total_gas_; }
179 double oilRate() const { return oil_rate_; }
180 std::optional<double> oilTarget() const { return oil_target_; }
181 std::optional<double> liquidTarget() const { return liquid_target_; }
182 double oilPotential() const { return oil_potential_; }
183 double gasPotential() const { return gas_potential_; }
184 double waterPotential() const { return water_potential_; }
185
186 void update(double delta_oil, double delta_gas, double delta_water, double delta_alq)
187 {
188 oil_rate_ += delta_oil;
189 gas_rate_ += delta_gas;
190 water_rate_ += delta_water;
191 alq_ += delta_alq;
192 // Note. We don't updata the potentials at this point. They
193 // are only needed initially.
194 }
195 private:
196 double oil_rate_;
197 double gas_rate_;
198 double water_rate_;
199 double alq_;
200 double oil_potential_;
201 double gas_potential_;
202 double water_potential_;
203 std::optional<double> oil_target_;
204 std::optional<double> gas_target_;
205 std::optional<double> water_target_;
206 std::optional<double> liquid_target_;
207 std::optional<double> total_gas_;
208 std::optional<double> max_alq_;
209 };
210
211 GLiftEclWells &ecl_wells_;
212 const Schedule &schedule_;
213 const SummaryState &summary_state_;
214 const int report_step_idx_;
215 const int iteration_idx_;
216 const PhaseUsage &phase_usage_;
217 const GasLiftOpt& glo_;
218 GroupRateMap group_rate_map_;
219 Well2GroupMap well_group_map_;
220 GroupIdxMap group_idx_;
221 int next_group_idx_ = 0;
222 // Optimize only wells under THP control
223 bool optimize_only_thp_wells_ = false;
224
225};
226
227} // namespace Opm
228
229#endif // OPM_GASLIFT_GROUP_INFO_INCLUDED
Definition DeferredLogger.hpp:57
Definition GasLiftCommon.hpp:35
Definition GasLiftGroupInfo.hpp:140
Definition GasLiftGroupInfo.hpp:45
Definition GroupState.hpp:34
The state of a set of wells, tailored for use by the fully implicit blackoil simulator.
Definition WellState.hpp:61
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition BlackoilPhases.hpp:27
Definition BlackoilPhases.hpp:46