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