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