WellInterfaceGeneric.hpp
Go to the documentation of this file.
1/*
2 Copyright 2017 SINTEF Digital, Mathematics and Cybernetics.
3 Copyright 2017 Statoil ASA.
4 Copyright 2017 IRIS
5 Copyright 2019 Norce
6
7 This file is part of the Open Porous Media project (OPM).
8
9 OPM is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13
14 OPM is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with OPM. If not, see <http://www.gnu.org/licenses/>.
21*/
22
23
24#ifndef OPM_WELLINTERFACE_GENERIC_HEADER_INCLUDED
25#define OPM_WELLINTERFACE_GENERIC_HEADER_INCLUDED
26
27#include <opm/input/eclipse/Schedule/Well/Well.hpp>
28
29#include <map>
30#include <optional>
31#include <string>
32#include <vector>
33
34namespace Opm
35{
36
37class DeferredLogger;
38class GuideRate;
39class ParallelWellInfo;
40struct PerforationData;
41struct PhaseUsage;
42class SummaryState;
43class VFPProperties;
44class WellTestState;
45template<class Scalar> class WellState;
46template<class Scalar> class SingleWellState;
47class Group;
48class Schedule;
49
51public:
52 WellInterfaceGeneric(const Well& well,
53 const ParallelWellInfo& parallel_well_info,
54 const int time_step,
55 const int pvtRegionIdx,
56 const int num_components,
57 const int num_phases,
58 const int index_of_well,
59 const std::vector<PerforationData>& perf_data);
60
62 const std::vector<PerforationData>& perforationData() const;
63
65 const std::string& name() const;
66
68 bool isInjector() const;
69
71 bool isProducer() const;
72
74 const std::vector<int>& cells() const { return well_cells_; }
75
77 int indexOfWell() const;
78
79 void adaptRatesForVFP(std::vector<double>& rates) const;
80
81 const Well& wellEcl() const;
82 Well& wellEcl();
83 const PhaseUsage& phaseUsage() const;
84
86 bool underPredictionMode() const;
87
88 // whether the well is operable
90 bool useVfpExplicit () const;
92
94 void closeCompletions(const WellTestState& wellTestState);
95
96 void setVFPProperties(const VFPProperties* vfp_properties_arg);
98 const WellState<double>& prev_well_state) const;
99 void setGuideRate(const GuideRate* guide_rate_arg);
100 void setWellEfficiencyFactor(const double efficiency_factor);
102 void setWsolvent(const double wsolvent);
103 void setDynamicThpLimit(const double thp_limit);
104 std::optional<double> getDynamicThpLimit() const;
105 void updatePerforatedCell(std::vector<bool>& is_cell_perforated);
106
108 bool wellHasTHPConstraints(const SummaryState& summaryState) const;
109
110 void stopWell() {
111 this->wellStatus_ = Well::Status::STOP;
112 }
113
114 void openWell() {
115 this->wellStatus_ = Well::Status::OPEN;
116 }
117
118 bool wellIsStopped() const {
119 return this->wellStatus_ == Well::Status::STOP;
120 }
121
122 int currentStep() const {
123 return this->current_step_;
124 }
125
126 int pvtRegionIdx() const {
127 return pvtRegionIdx_;
128 }
129
130 const GuideRate* guideRate() const {
131 return guide_rate_;
132 }
133
134 int numComponents() const {
135 return num_components_;
136 }
137
138 int numPhases() const {
139 return number_of_phases_;
140 }
141
142 int numPerfs() const {
144 }
145
146 double refDepth() const {
147 return ref_depth_;
148 }
149
150 double gravity() const {
151 return gravity_;
152 }
153
155 return vfp_properties_;
156 }
157
159 return parallel_well_info_;
160 }
161
162 const std::vector<double>& perfDepth() const {
163 return perf_depth_;
164 }
165
166 std::vector<double>& perfDepth() {
167 return perf_depth_;
168 }
169
170 const std::vector<double>& wellIndex() const {
171 return well_index_;
172 }
173
174 const std::map<int,std::vector<int>>& getCompletions() const {
175 return completions_;
176 }
177
178 double getTHPConstraint(const SummaryState& summaryState) const;
179 double getALQ(const WellState<double>& well_state) const;
180 double wsolvent() const;
181 double rsRvInj() const;
182
183 // at the beginning of the time step, we check what inj_multiplier from the previous running
184 void initInjMult(const std::vector<double>& max_inj_mult);
185
186 // update the InjMult information at the end of the time step, so it can be used for later.
187 void updateInjMult(std::vector<double>& inj_multipliers, DeferredLogger& deferred_logger) const;
188
189 // Note:: for multisegment wells, bhp is actually segment pressure in practice based on observation
190 // it might change in the future
191 double getInjMult(const int perf, const double bhp, const double perf_pres) const;
192
193 // whether a well is specified with a non-zero and valid VFP table number
194 bool isVFPActive(DeferredLogger& deferred_logger) const;
195
196 void reportWellSwitching(const SingleWellState<double>& ws, DeferredLogger& deferred_logger) const;
197
199 return this->changed_to_open_this_step_;
200 }
201
203 const double& simulationTime,
204 const bool& writeMessageToOPMLog,
205 WellTestState& wellTestState,
206 DeferredLogger& deferred_logger) const;
207
208 bool isPressureControlled(const WellState<double>& well_state) const;
209
210 bool stopppedOrZeroRateTarget(const SummaryState& summary_state,
211 const WellState<double>& well_state) const;
212
213 double wellEfficiencyFactor() const
214 { return well_efficiency_factor_; }
215
217 void updateFilterCakeMultipliers(const std::vector<double>& inj_fc_multiplier)
218 {
219 inj_fc_multiplier_ = inj_fc_multiplier;
220 }
221
223
224protected:
225 bool getAllowCrossFlow() const;
226
227 double wmicrobes_() const;
228 double wfoam_() const;
229 double woxygen_() const;
230 double wpolymer_() const;
231 double wsalt_() const;
232 double wurea_() const;
233
234 int polymerTable_() const;
235 int polymerInjTable_() const;
237
238 bool wellUnderZeroRateTarget(const SummaryState& summary_state,
239 const WellState<double>& well_state) const;
240
241 std::pair<bool,bool>
242 computeWellPotentials(std::vector<double>& well_potentials,
243 const WellState<double>& well_state);
244
245 void checkNegativeWellPotentials(std::vector<double>& well_potentials,
246 const bool checkOperability,
247 DeferredLogger& deferred_logger);
248
249 void prepareForPotentialCalculations(const SummaryState& summary_state,
250 WellState<double>& well_state,
251 Well::InjectionControls& inj_controls,
252 Well::ProductionControls& prod_controls) const;
253
254 // definition of the struct OperabilityStatus
258 return false;
259 } else {
261 }
262 }
263
266 }
267
270 }
271
277 }
278
279 // whether the well can be operated under bhp limit
280 // without considering other limits.
281 // if it is false, then the well is not operable for sure.
283 // if the well can be operated under bhp limit, will it obey(not violate)
284 // the thp limit when operated under bhp limit
286 // whether the well operate under the thp limit only
288 // whether the well obey bhp limit when operated under thp limit
290 // the well is solveable
291 bool solvable = true;
292 // the well have non positive potentials
294 //thp limit violated but not switched
296
297 bool use_vfpexplicit = false;
298 };
299
301
303
305 const int current_step_;
306
307 // The pvt region of the well. We assume
308 // We assume a well to not penetrate more than one pvt region.
309 const int pvtRegionIdx_;
310
312
313 // number of phases
315
316 // the index of well in Wells struct
318
319 const std::vector<PerforationData>* perf_data_;
320
321 // the vectors used to describe the inflow performance relationship (IPR)
322 // Q = IPR_A - BHP * IPR_B
323 // TODO: it minght need to go to WellInterface, let us implement it in StandardWell first
324 // it is only updated and used for producers for now
325 mutable std::vector<double> ipr_a_;
326 mutable std::vector<double> ipr_b_;
327
328 // cell index for each well perforation
329 std::vector<int> well_cells_;
330
331 // well index for each perforation
332 std::vector<double> well_index_;
333
334 // number of the perforations for this well
336
337 // depth for each perforation
338 std::vector<double> perf_depth_;
339
340 // representative radius of the perforations, used in shear calculation
341 std::vector<double> perf_rep_radius_;
342
343 // length of the perforations, use in shear calculation
344 std::vector<double> perf_length_;
345
346 // well bore diameter
347 std::vector<double> bore_diameters_;
348
349 /*
350 * completions_ contains the mapping from completion id to connection indices
351 * {
352 * 2 : [ConnectionIndex, ConnectionIndex],
353 * 1 : [ConnectionIndex, ConnectionIndex, ConnectionIndex],
354 * 5 : [ConnectionIndex],
355 * 7 : [ConnectionIndex]
356 * ...
357 * }
358 * The integer IDs correspond to the COMPLETION id given by the COMPLUMP keyword.
359 * When there is no COMPLUMP keyword used, a default completion number will be assigned
360 * based on the order of the declaration of the connections.
361 * Since the connections not OPEN is not included in the Wells, so they will not be considered
362 * in this mapping relation.
363 */
364 std::map<int, std::vector<int>> completions_;
365
366 // reference depth for the BHP
368
369 // saturation table nubmer for each well perforation
370 std::vector<int> saturation_table_number_;
371
372 Well::Status wellStatus_;
373
375
376 double gravity_;
377 double wsolvent_;
378 std::optional<double> dynamic_thp_limit_;
379
380 // recording the multiplier calculate from the keyword WINJMULT during the time step
381 mutable std::vector<double> inj_multiplier_;
382
383 // the injection multiplier from the previous running, it is mostly used for CIRR mode
384 // which intends to keep the fracturing open
385 std::vector<double> prev_inj_multiplier_;
386
387 // the multiplier due to injection filtration cake
388 std::vector<double> inj_fc_multiplier_;
389
392 const GuideRate* guide_rate_;
393
394 std::vector< std::string> well_control_log_;
395
397};
398
399}
400
401#endif // OPM_WELLINTERFACE_HEADER_INCLUDED
Definition: DeferredLogger.hpp:57
Class encapsulating some information about parallel wells.
Definition: ParallelWellInfo.hpp:184
Definition: VFPProperties.hpp:40
Definition: WellInterfaceGeneric.hpp:50
bool wellHasTHPConstraints(const SummaryState &summaryState) const
Returns true if the well has one or more THP limits/constraints.
bool stopppedOrZeroRateTarget(const SummaryState &summary_state, const WellState< double > &well_state) const
void setWellEfficiencyFactor(const double efficiency_factor)
const int current_step_
Definition: WellInterfaceGeneric.hpp:305
const GuideRate * guide_rate_
Definition: WellInterfaceGeneric.hpp:392
const PhaseUsage * phase_usage_
Definition: WellInterfaceGeneric.hpp:374
int numPerfs() const
Definition: WellInterfaceGeneric.hpp:142
std::vector< double > inj_fc_multiplier_
Definition: WellInterfaceGeneric.hpp:388
void updateWellTestState(const SingleWellState< double > &ws, const double &simulationTime, const bool &writeMessageToOPMLog, WellTestState &wellTestState, DeferredLogger &deferred_logger) const
void updateInjMult(std::vector< double > &inj_multipliers, DeferredLogger &deferred_logger) const
const int pvtRegionIdx_
Definition: WellInterfaceGeneric.hpp:309
void checkNegativeWellPotentials(std::vector< double > &well_potentials, const bool checkOperability, DeferredLogger &deferred_logger)
std::vector< double > perf_depth_
Definition: WellInterfaceGeneric.hpp:338
bool changedToOpenThisStep() const
Definition: WellInterfaceGeneric.hpp:198
const std::vector< int > & cells() const
Well cells.
Definition: WellInterfaceGeneric.hpp:74
void updatePerforatedCell(std::vector< bool > &is_cell_perforated)
double wellEfficiencyFactor() const
Definition: WellInterfaceGeneric.hpp:213
int number_of_phases_
Definition: WellInterfaceGeneric.hpp:314
int pvtRegionIdx() const
Definition: WellInterfaceGeneric.hpp:126
std::pair< bool, bool > computeWellPotentials(std::vector< double > &well_potentials, const WellState< double > &well_state)
void prepareForPotentialCalculations(const SummaryState &summary_state, WellState< double > &well_state, Well::InjectionControls &inj_controls, Well::ProductionControls &prod_controls) const
std::vector< double > ipr_a_
Definition: WellInterfaceGeneric.hpp:325
const int num_components_
Definition: WellInterfaceGeneric.hpp:311
const PhaseUsage & phaseUsage() const
const ParallelWellInfo & parallelWellInfo() const
Definition: WellInterfaceGeneric.hpp:158
std::vector< double > perf_rep_radius_
Definition: WellInterfaceGeneric.hpp:341
void adaptRatesForVFP(std::vector< double > &rates) const
void setPrevSurfaceRates(WellState< double > &well_state, const WellState< double > &prev_well_state) const
int indexOfWell() const
Index of well in the wells struct and wellState.
void setDynamicThpLimit(const double thp_limit)
double wsolvent_
Definition: WellInterfaceGeneric.hpp:377
bool thpLimitViolatedButNotSwitched() const
std::optional< double > dynamic_thp_limit_
Definition: WellInterfaceGeneric.hpp:378
double refDepth() const
Definition: WellInterfaceGeneric.hpp:146
OperabilityStatus operability_status_
Definition: WellInterfaceGeneric.hpp:300
std::vector< double > ipr_b_
Definition: WellInterfaceGeneric.hpp:326
WellInterfaceGeneric(const Well &well, const ParallelWellInfo &parallel_well_info, const int time_step, const int pvtRegionIdx, const int num_components, const int num_phases, const int index_of_well, const std::vector< PerforationData > &perf_data)
void setVFPProperties(const VFPProperties *vfp_properties_arg)
std::vector< double > bore_diameters_
Definition: WellInterfaceGeneric.hpp:347
bool isOperableAndSolvable() const
const std::vector< double > & perfDepth() const
Definition: WellInterfaceGeneric.hpp:162
std::optional< double > getDynamicThpLimit() const
int index_of_well_
Definition: WellInterfaceGeneric.hpp:317
std::vector< double > prev_inj_multiplier_
Definition: WellInterfaceGeneric.hpp:385
bool changed_to_open_this_step_
Definition: WellInterfaceGeneric.hpp:396
std::vector< double > well_index_
Definition: WellInterfaceGeneric.hpp:332
const std::string & name() const
Well name.
double well_efficiency_factor_
Definition: WellInterfaceGeneric.hpp:390
std::vector< double > & perfDepth()
Definition: WellInterfaceGeneric.hpp:166
const std::map< int, std::vector< int > > & getCompletions() const
Definition: WellInterfaceGeneric.hpp:174
const std::vector< PerforationData > * perf_data_
Definition: WellInterfaceGeneric.hpp:319
double gravity_
Definition: WellInterfaceGeneric.hpp:376
void setGuideRate(const GuideRate *guide_rate_arg)
bool isVFPActive(DeferredLogger &deferred_logger) const
std::vector< double > perf_length_
Definition: WellInterfaceGeneric.hpp:344
Well::Status wellStatus_
Definition: WellInterfaceGeneric.hpp:372
int polymerWaterTable_() const
std::map< int, std::vector< int > > completions_
Definition: WellInterfaceGeneric.hpp:364
bool wellUnderZeroRateTarget(const SummaryState &summary_state, const WellState< double > &well_state) const
int number_of_perforations_
Definition: WellInterfaceGeneric.hpp:335
void setWsolvent(const double wsolvent)
double getALQ(const WellState< double > &well_state) const
int currentStep() const
Definition: WellInterfaceGeneric.hpp:122
int numPhases() const
Definition: WellInterfaceGeneric.hpp:138
void updateFilterCakeMultipliers(const std::vector< double > &inj_fc_multiplier)
Update filter cake multipliers.
Definition: WellInterfaceGeneric.hpp:217
void reportWellSwitching(const SingleWellState< double > &ws, DeferredLogger &deferred_logger) const
std::vector< std::string > well_control_log_
Definition: WellInterfaceGeneric.hpp:394
bool underPredictionMode() const
Returns true if the well is currently in prediction mode (i.e. not history mode).
void stopWell()
Definition: WellInterfaceGeneric.hpp:110
bool isProducer() const
True if the well is a producer.
void initInjMult(const std::vector< double > &max_inj_mult)
void closeCompletions(const WellTestState &wellTestState)
const Well & wellEcl() const
const std::vector< double > & wellIndex() const
Definition: WellInterfaceGeneric.hpp:170
bool wellIsStopped() const
Definition: WellInterfaceGeneric.hpp:118
double ref_depth_
Definition: WellInterfaceGeneric.hpp:367
double wpolymer_() const
bool isPressureControlled(const WellState< double > &well_state) const
bool isInjector() const
True if the well is an injector.
bool getAllowCrossFlow() const
double getInjMult(const int perf, const double bhp, const double perf_pres) const
std::vector< int > well_cells_
Definition: WellInterfaceGeneric.hpp:329
const VFPProperties * vfpProperties() const
Definition: WellInterfaceGeneric.hpp:154
Well well_ecl_
Definition: WellInterfaceGeneric.hpp:302
double getTHPConstraint(const SummaryState &summaryState) const
double gravity() const
Definition: WellInterfaceGeneric.hpp:150
const VFPProperties * vfp_properties_
Definition: WellInterfaceGeneric.hpp:391
const GuideRate * guideRate() const
Definition: WellInterfaceGeneric.hpp:130
std::vector< int > saturation_table_number_
Definition: WellInterfaceGeneric.hpp:370
const ParallelWellInfo & parallel_well_info_
Definition: WellInterfaceGeneric.hpp:304
const std::vector< PerforationData > & perforationData() const
Get the perforations of the well.
double wmicrobes_() const
void openWell()
Definition: WellInterfaceGeneric.hpp:114
std::vector< double > inj_multiplier_
Definition: WellInterfaceGeneric.hpp:381
int numComponents() const
Definition: WellInterfaceGeneric.hpp:134
VFPEvaluation bhp(const VFPProdTable &table, const double aqua, const double liquid, const double vapour, const double thp, const double alq, const double explicit_wfr, const double explicit_gfr, const bool use_vfpexplicit)
Definition: BlackoilPhases.hpp:27
Definition: BlackoilPhases.hpp:46
Definition: WellInterfaceGeneric.hpp:255
bool solvable
Definition: WellInterfaceGeneric.hpp:291
bool has_negative_potentials
Definition: WellInterfaceGeneric.hpp:293
bool obey_bhp_limit_with_thp_limit
Definition: WellInterfaceGeneric.hpp:289
bool obey_thp_limit_under_bhp_limit
Definition: WellInterfaceGeneric.hpp:285
void resetOperability()
Definition: WellInterfaceGeneric.hpp:272
bool isOperableAndSolvable() const
Definition: WellInterfaceGeneric.hpp:256
bool isOperableUnderBHPLimit() const
Definition: WellInterfaceGeneric.hpp:264
bool can_obtain_bhp_with_thp_limit
Definition: WellInterfaceGeneric.hpp:287
bool use_vfpexplicit
Definition: WellInterfaceGeneric.hpp:297
bool operable_under_only_bhp_limit
Definition: WellInterfaceGeneric.hpp:282
bool thp_limit_violated_but_not_switched
Definition: WellInterfaceGeneric.hpp:295
bool isOperableUnderTHPLimit() const
Definition: WellInterfaceGeneric.hpp:268