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;
39template<class Scalar> class ParallelWellInfo;
40template<class Scalar> struct PerforationData;
41struct PhaseUsage;
42class SummaryState;
43template<class Scalar> class VFPProperties;
44class WellTestState;
45template<class Scalar> class WellState;
46template<class Scalar> class SingleWellState;
47class Group;
48class Schedule;
49
50template<class Scalar>
52public:
53 WellInterfaceGeneric(const Well& well,
54 const ParallelWellInfo<Scalar>& parallel_well_info,
55 const int time_step,
56 const int pvtRegionIdx,
57 const int num_components,
58 const int num_phases,
59 const int index_of_well,
60 const std::vector<PerforationData<Scalar>>& perf_data);
61
63 const std::vector<PerforationData<Scalar>>& perforationData() const;
64
66 const std::string& name() const;
67
69 bool isInjector() const;
70
72 bool isProducer() const;
73
75 const std::vector<int>& cells() const { return well_cells_; }
76
78 int indexOfWell() const;
79
80 void adaptRatesForVFP(std::vector<Scalar>& rates) const;
81
82 const Well& wellEcl() const;
83 Well& wellEcl();
84 const PhaseUsage& phaseUsage() const;
85
87 bool underPredictionMode() const;
88
89 // whether the well is operable
91 bool useVfpExplicit () const;
93
95 void closeCompletions(const WellTestState& wellTestState);
96
97 void setVFPProperties(const VFPProperties<Scalar>* vfp_properties_arg);
99 const WellState<Scalar>& prev_well_state) const;
100 void setGuideRate(const GuideRate* guide_rate_arg);
101 void setWellEfficiencyFactor(const Scalar efficiency_factor);
103 void setWsolvent(const Scalar wsolvent);
104 void setDynamicThpLimit(const Scalar thp_limit);
105 std::optional<Scalar> getDynamicThpLimit() const;
106 void setDynamicThpLimit(const std::optional<Scalar> thp_limit);
107 void updatePerforatedCell(std::vector<bool>& is_cell_perforated);
108
110 bool wellHasTHPConstraints(const SummaryState& summaryState) const;
111
112 void stopWell() { this->wellStatus_ = Well::Status::STOP; }
113 void openWell() { this->wellStatus_ = Well::Status::OPEN; }
114
115 bool wellIsStopped() const { return this->wellStatus_ == Well::Status::STOP; }
116
117 int currentStep() const { return this->current_step_; }
118
119 int pvtRegionIdx() const { return pvtRegionIdx_; }
120
121 const GuideRate* guideRate() const { return guide_rate_; }
122
123 int numComponents() const { return num_components_; }
124
125 int numPhases() const { return number_of_phases_; }
126
127 int numPerfs() const { return number_of_perforations_; }
128
129 Scalar refDepth() const { return ref_depth_; }
130
131 Scalar gravity() const { return gravity_; }
132
134
136
137 const std::vector<Scalar>& perfDepth() const { return perf_depth_; }
138
139 std::vector<Scalar>& perfDepth() { return perf_depth_; }
140
141 const std::vector<Scalar>& wellIndex() const { return well_index_; }
142
143 const std::map<int,std::vector<int>>& getCompletions() const { return completions_; }
144
145 Scalar getTHPConstraint(const SummaryState& summaryState) const;
146 Scalar getALQ(const WellState<Scalar>& well_state) const;
147 Scalar wsolvent() const;
148 Scalar rsRvInj() const;
149
150 // at the beginning of the time step, we check what inj_multiplier from the previous running
151 void initInjMult(const std::vector<Scalar>& max_inj_mult);
152
153 // update the InjMult information at the end of the time step, so it can be used for later.
154 void updateInjMult(std::vector<Scalar>& inj_multipliers,
155 DeferredLogger& deferred_logger) const;
156
157 // Note:: for multisegment wells, bhp is actually segment pressure in practice based on observation
158 // it might change in the future
159 Scalar getInjMult(const int perf, const Scalar bhp, const Scalar perf_pres) const;
160
161 // whether a well is specified with a non-zero and valid VFP table number
162 bool isVFPActive(DeferredLogger& deferred_logger) const;
163
165 DeferredLogger& deferred_logger) const;
166
168
170 const double& simulationTime,
171 const bool& writeMessageToOPMLog,
172 const bool zero_group_target,
173 WellTestState& wellTestState,
174 DeferredLogger& deferred_logger) const;
175
176 bool isPressureControlled(const WellState<Scalar>& well_state) const;
177
179
181 void updateFilterCakeMultipliers(const std::vector<Scalar>& inj_fc_multiplier)
182 {
183 inj_fc_multiplier_ = inj_fc_multiplier;
184 }
185
187
188protected:
189 bool getAllowCrossFlow() const;
190
191 Scalar wmicrobes_() const;
192 Scalar wfoam_() const;
193 Scalar woxygen_() const;
194 Scalar wpolymer_() const;
195 Scalar wsalt_() const;
196 Scalar wurea_() const;
197
198 int polymerTable_() const;
199 int polymerInjTable_() const;
201
202 bool wellUnderZeroRateTargetIndividual(const SummaryState& summary_state,
203 const WellState<Scalar>& well_state) const;
204
206
207 std::pair<bool,bool>
208 computeWellPotentials(std::vector<Scalar>& well_potentials,
209 const WellState<Scalar>& well_state);
210
211 void checkNegativeWellPotentials(std::vector<Scalar>& well_potentials,
212 const bool checkOperability,
213 DeferredLogger& deferred_logger);
214
215 void prepareForPotentialCalculations(const SummaryState& summary_state,
216 WellState<Scalar>& well_state,
217 Well::InjectionControls& inj_controls,
218 Well::ProductionControls& prod_controls) const;
219
220 // definition of the struct OperabilityStatus
222 {
224 {
226 return false;
227 } else {
229 }
230 }
231
233 {
235 }
236
238 {
240 }
241
243 {
248 }
249
250 // whether the well can be operated under bhp limit
251 // without considering other limits.
252 // if it is false, then the well is not operable for sure.
254 // if the well can be operated under bhp limit, will it obey(not violate)
255 // the thp limit when operated under bhp limit
257 // whether the well operate under the thp limit only
259 // whether the well obey bhp limit when operated under thp limit
261 // the well is solveable
262 bool solvable = true;
263 // the well have non positive potentials
265 //thp limit violated but not switched
267
268 bool use_vfpexplicit = false;
269 };
270
272
274
276 const int current_step_;
277
278 // The pvt region of the well. We assume
279 // We assume a well to not penetrate more than one pvt region.
280 const int pvtRegionIdx_;
281
283
284 // number of phases
286
287 // the index of well in Wells struct
289
290 const std::vector<PerforationData<Scalar>>* perf_data_;
291
292 // the vectors used to describe the inflow performance relationship (IPR)
293 // Q = IPR_A - BHP * IPR_B
294 // TODO: it minght need to go to WellInterface, let us implement it in StandardWell first
295 // it is only updated and used for producers for now
296 mutable std::vector<Scalar> ipr_a_;
297 mutable std::vector<Scalar> ipr_b_;
298
299 // cell index for each well perforation
300 std::vector<int> well_cells_;
301
302 // well index for each perforation
303 std::vector<Scalar> well_index_;
304
305 // number of the perforations for this well
307
308 // depth for each perforation
309 std::vector<Scalar> perf_depth_;
310
311 // representative radius of the perforations, used in shear calculation
312 std::vector<Scalar> perf_rep_radius_;
313
314 // length of the perforations, use in shear calculation
315 std::vector<Scalar> perf_length_;
316
317 // well bore diameter
318 std::vector<Scalar> bore_diameters_;
319
320 /*
321 * completions_ contains the mapping from completion id to connection indices
322 * {
323 * 2 : [ConnectionIndex, ConnectionIndex],
324 * 1 : [ConnectionIndex, ConnectionIndex, ConnectionIndex],
325 * 5 : [ConnectionIndex],
326 * 7 : [ConnectionIndex]
327 * ...
328 * }
329 * The integer IDs correspond to the COMPLETION id given by the COMPLUMP keyword.
330 * When there is no COMPLUMP keyword used, a default completion number will be assigned
331 * based on the order of the declaration of the connections.
332 * Since the connections not OPEN is not included in the Wells, so they will not be considered
333 * in this mapping relation.
334 */
335 std::map<int, std::vector<int>> completions_;
336
337 // reference depth for the BHP
339
340 // saturation table nubmer for each well perforation
341 std::vector<int> saturation_table_number_;
342
343 Well::Status wellStatus_;
344
346
347 Scalar gravity_;
348 Scalar wsolvent_;
349 std::optional<Scalar> dynamic_thp_limit_;
350
351 // recording the multiplier calculate from the keyword WINJMULT during the time step
352 mutable std::vector<Scalar> inj_multiplier_;
353
354 // the injection multiplier from the previous running, it is mostly used for CIRR mode
355 // which intends to keep the fracturing open
356 std::vector<Scalar> prev_inj_multiplier_;
357
358 // the multiplier due to injection filtration cake
359 std::vector<Scalar> inj_fc_multiplier_;
360
363 const GuideRate* guide_rate_;
364
365 std::vector<std::string> well_control_log_;
366
368};
369
370}
371
372#endif // OPM_WELLINTERFACE_HEADER_INCLUDED
Definition: DeferredLogger.hpp:57
Class encapsulating some information about parallel wells.
Definition: ParallelWellInfo.hpp:186
Definition: SingleWellState.hpp:42
Definition: VFPProperties.hpp:40
Definition: WellInterfaceGeneric.hpp:51
bool wellIsStopped() const
Definition: WellInterfaceGeneric.hpp:115
int number_of_phases_
Definition: WellInterfaceGeneric.hpp:285
const PhaseUsage * phase_usage_
Definition: WellInterfaceGeneric.hpp:345
void updatePerforatedCell(std::vector< bool > &is_cell_perforated)
void setGuideRate(const GuideRate *guide_rate_arg)
const std::string & name() const
Well name.
std::vector< Scalar > inj_multiplier_
Definition: WellInterfaceGeneric.hpp:352
bool isOperableAndSolvable() const
Scalar wellEfficiencyFactor() const
Definition: WellInterfaceGeneric.hpp:178
OperabilityStatus operability_status_
Definition: WellInterfaceGeneric.hpp:271
void updateInjMult(std::vector< Scalar > &inj_multipliers, DeferredLogger &deferred_logger) const
void stopWell()
Definition: WellInterfaceGeneric.hpp:112
int currentStep() const
Definition: WellInterfaceGeneric.hpp:117
void setPrevSurfaceRates(WellState< Scalar > &well_state, const WellState< Scalar > &prev_well_state) const
bool changedToOpenThisStep() const
Definition: WellInterfaceGeneric.hpp:167
int numPhases() const
Definition: WellInterfaceGeneric.hpp:125
const GuideRate * guideRate() const
Definition: WellInterfaceGeneric.hpp:121
Scalar getALQ(const WellState< Scalar > &well_state) const
std::vector< Scalar > bore_diameters_
Definition: WellInterfaceGeneric.hpp:318
int pvtRegionIdx() const
Definition: WellInterfaceGeneric.hpp:119
const ParallelWellInfo< Scalar > & parallel_well_info_
Definition: WellInterfaceGeneric.hpp:275
void updateFilterCakeMultipliers(const std::vector< Scalar > &inj_fc_multiplier)
Update filter cake multipliers.
Definition: WellInterfaceGeneric.hpp:181
std::vector< Scalar > ipr_a_
Definition: WellInterfaceGeneric.hpp:296
const GuideRate * guide_rate_
Definition: WellInterfaceGeneric.hpp:363
const Well & wellEcl() const
void checkNegativeWellPotentials(std::vector< Scalar > &well_potentials, const bool checkOperability, DeferredLogger &deferred_logger)
int index_of_well_
Definition: WellInterfaceGeneric.hpp:288
Well::Status wellStatus_
Definition: WellInterfaceGeneric.hpp:343
bool getAllowCrossFlow() const
void prepareForPotentialCalculations(const SummaryState &summary_state, WellState< Scalar > &well_state, Well::InjectionControls &inj_controls, Well::ProductionControls &prod_controls) const
const VFPProperties< Scalar > * vfpProperties() const
Definition: WellInterfaceGeneric.hpp:133
std::pair< bool, bool > computeWellPotentials(std::vector< Scalar > &well_potentials, const WellState< Scalar > &well_state)
Scalar getTHPConstraint(const SummaryState &summaryState) const
std::vector< Scalar > well_index_
Definition: WellInterfaceGeneric.hpp:303
std::map< int, std::vector< int > > completions_
Definition: WellInterfaceGeneric.hpp:335
const int num_components_
Definition: WellInterfaceGeneric.hpp:282
void openWell()
Definition: WellInterfaceGeneric.hpp:113
void setDynamicThpLimit(const std::optional< Scalar > thp_limit)
Scalar gravity_
Definition: WellInterfaceGeneric.hpp:347
const int pvtRegionIdx_
Definition: WellInterfaceGeneric.hpp:280
std::optional< Scalar > dynamic_thp_limit_
Definition: WellInterfaceGeneric.hpp:349
const VFPProperties< Scalar > * vfp_properties_
Definition: WellInterfaceGeneric.hpp:362
void adaptRatesForVFP(std::vector< Scalar > &rates) const
int number_of_perforations_
Definition: WellInterfaceGeneric.hpp:306
const std::vector< PerforationData< Scalar > > * perf_data_
Definition: WellInterfaceGeneric.hpp:290
int numPerfs() const
Definition: WellInterfaceGeneric.hpp:127
bool isInjector() const
True if the well is an injector.
std::vector< Scalar > perf_depth_
Definition: WellInterfaceGeneric.hpp:309
bool thpLimitViolatedButNotSwitched() const
bool wellHasTHPConstraints(const SummaryState &summaryState) const
Returns true if the well has one or more THP limits/constraints.
Scalar wmicrobes_() const
void setVFPProperties(const VFPProperties< Scalar > *vfp_properties_arg)
void setDynamicThpLimit(const Scalar thp_limit)
std::optional< Scalar > getDynamicThpLimit() const
Scalar gravity() const
Definition: WellInterfaceGeneric.hpp:131
bool isVFPActive(DeferredLogger &deferred_logger) const
Scalar well_efficiency_factor_
Definition: WellInterfaceGeneric.hpp:361
const PhaseUsage & phaseUsage() const
const std::vector< int > & cells() const
Well cells.
Definition: WellInterfaceGeneric.hpp:75
const ParallelWellInfo< Scalar > & parallelWellInfo() const
Definition: WellInterfaceGeneric.hpp:135
std::vector< Scalar > perf_length_
Definition: WellInterfaceGeneric.hpp:315
bool isProducer() const
True if the well is a producer.
int polymerWaterTable_() const
std::vector< Scalar > & perfDepth()
Definition: WellInterfaceGeneric.hpp:139
std::vector< int > well_cells_
Definition: WellInterfaceGeneric.hpp:300
std::vector< std::string > well_control_log_
Definition: WellInterfaceGeneric.hpp:365
void closeCompletions(const WellTestState &wellTestState)
Scalar wpolymer_() const
std::vector< Scalar > inj_fc_multiplier_
Definition: WellInterfaceGeneric.hpp:359
const std::vector< Scalar > & perfDepth() const
Definition: WellInterfaceGeneric.hpp:137
WellInterfaceGeneric(const Well &well, const ParallelWellInfo< Scalar > &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< Scalar > > &perf_data)
void setWellEfficiencyFactor(const Scalar efficiency_factor)
Scalar refDepth() const
Definition: WellInterfaceGeneric.hpp:129
Well well_ecl_
Definition: WellInterfaceGeneric.hpp:273
std::vector< Scalar > prev_inj_multiplier_
Definition: WellInterfaceGeneric.hpp:356
void reportWellSwitching(const SingleWellState< Scalar > &ws, DeferredLogger &deferred_logger) const
bool wellUnderGroupControl(const SingleWellState< Scalar > &ws) const
const std::vector< PerforationData< Scalar > > & perforationData() const
Get the perforations of the well.
void setWsolvent(const Scalar wsolvent)
bool wellUnderZeroRateTargetIndividual(const SummaryState &summary_state, const WellState< Scalar > &well_state) const
void initInjMult(const std::vector< Scalar > &max_inj_mult)
int numComponents() const
Definition: WellInterfaceGeneric.hpp:123
std::vector< Scalar > perf_rep_radius_
Definition: WellInterfaceGeneric.hpp:312
const std::vector< Scalar > & wellIndex() const
Definition: WellInterfaceGeneric.hpp:141
int indexOfWell() const
Index of well in the wells struct and wellState.
Scalar getInjMult(const int perf, const Scalar bhp, const Scalar perf_pres) const
bool changed_to_open_this_step_
Definition: WellInterfaceGeneric.hpp:367
void updateWellTestState(const SingleWellState< Scalar > &ws, const double &simulationTime, const bool &writeMessageToOPMLog, const bool zero_group_target, WellTestState &wellTestState, DeferredLogger &deferred_logger) const
bool underPredictionMode() const
Returns true if the well is currently in prediction mode (i.e. not history mode).
Scalar ref_depth_
Definition: WellInterfaceGeneric.hpp:338
Scalar wsolvent_
Definition: WellInterfaceGeneric.hpp:348
std::vector< Scalar > ipr_b_
Definition: WellInterfaceGeneric.hpp:297
const std::map< int, std::vector< int > > & getCompletions() const
Definition: WellInterfaceGeneric.hpp:143
const int current_step_
Definition: WellInterfaceGeneric.hpp:276
std::vector< int > saturation_table_number_
Definition: WellInterfaceGeneric.hpp:341
bool isPressureControlled(const WellState< Scalar > &well_state) const
Definition: WellState.hpp:62
Definition: blackoilboundaryratevector.hh:37
Static data associated with a well perforation.
Definition: PerforationData.hpp:30
Definition: BlackoilPhases.hpp:46
Definition: WellInterfaceGeneric.hpp:222
bool obey_thp_limit_under_bhp_limit
Definition: WellInterfaceGeneric.hpp:256
void resetOperability()
Definition: WellInterfaceGeneric.hpp:242
bool obey_bhp_limit_with_thp_limit
Definition: WellInterfaceGeneric.hpp:260
bool operable_under_only_bhp_limit
Definition: WellInterfaceGeneric.hpp:253
bool use_vfpexplicit
Definition: WellInterfaceGeneric.hpp:268
bool isOperableUnderTHPLimit() const
Definition: WellInterfaceGeneric.hpp:237
bool isOperableUnderBHPLimit() const
Definition: WellInterfaceGeneric.hpp:232
bool thp_limit_violated_but_not_switched
Definition: WellInterfaceGeneric.hpp:266
bool has_negative_potentials
Definition: WellInterfaceGeneric.hpp:264
bool isOperableAndSolvable() const
Definition: WellInterfaceGeneric.hpp:223
bool can_obtain_bhp_with_thp_limit
Definition: WellInterfaceGeneric.hpp:258
bool solvable
Definition: WellInterfaceGeneric.hpp:262