24#ifndef OPM_WELLINTERFACE_GENERIC_HEADER_INCLUDED
25#define OPM_WELLINTERFACE_GENERIC_HEADER_INCLUDED
27#include <opm/input/eclipse/Schedule/Well/Well.hpp>
39class ParallelWellInfo;
40struct PerforationData;
54 static constexpr bool extraBhpAtThpLimitProdOutput =
false;
59 const int pvtRegionIdx,
60 const int num_components,
62 const int index_of_well,
63 const std::vector<PerforationData>& perf_data);
69 const std::string&
name()
const;
78 const std::vector<int>&
cells()
const {
return well_cells_; }
83 void adaptRatesForVFP(std::vector<double>& rates)
const;
85 const Well& wellEcl()
const;
92 bool isOperableAndSolvable()
const;
93 bool useVfpExplicit ()
const;
94 bool thpLimitViolatedButNotSwitched()
const;
96 void initCompletions();
97 void closeCompletions(
const WellTestState& wellTestState);
99 void setVFPProperties(
const VFPProperties* vfp_properties_arg);
100 void setGuideRate(
const GuideRate* guide_rate_arg);
101 void setWellEfficiencyFactor(
const double efficiency_factor);
102 void setRepRadiusPerfLength();
103 void setWsolvent(
const double wsolvent);
104 void setDynamicThpLimit(
const double thp_limit);
105 std::optional<double> getDynamicThpLimit()
const;
106 void updatePerforatedCell(std::vector<bool>& is_cell_perforated);
112 this->wellStatus_ = Well::Status::STOP;
116 this->wellStatus_ = Well::Status::OPEN;
119 bool wellIsStopped()
const {
120 return this->wellStatus_ == Well::Status::STOP;
123 int currentStep()
const {
124 return this->current_step_;
127 int pvtRegionIdx()
const {
128 return pvtRegionIdx_;
131 const GuideRate* guideRate()
const {
135 int numComponents()
const {
136 return num_components_;
139 int numPhases()
const {
140 return number_of_phases_;
143 int numPerfs()
const {
144 return number_of_perforations_;
147 double refDepth()
const {
151 double gravity()
const {
155 const VFPProperties* vfpProperties()
const {
156 return vfp_properties_;
159 const ParallelWellInfo& parallelWellInfo()
const {
160 return parallel_well_info_;
163 const std::vector<double>& perfDepth()
const {
167 std::vector<double>& perfDepth() {
171 const std::vector<double>& wellIndex()
const {
175 double getTHPConstraint(
const SummaryState& summaryState)
const;
176 double getALQ(
const WellState& well_state)
const;
177 double wsolvent()
const;
178 double rsRvInj()
const;
181 bool isVFPActive(DeferredLogger& deferred_logger)
const;
183 void reportWellSwitching(
const SingleWellState& ws, DeferredLogger& deferred_logger)
const;
185 bool changedToOpenThisStep()
const {
186 return this->changed_to_open_this_step_;
188 std::optional<double> computeBhpAtThpLimitProdCommon(
const std::function<std::vector<double>(
const double)>& frates,
189 const SummaryState& summary_state,
190 const double maxPerfPress,
192 const double alq_value,
193 DeferredLogger& deferred_logger
199 bool getAllowCrossFlow()
const;
200 double mostStrictBhpFromBhpLimits(
const SummaryState& summaryState)
const;
201 void updateWellTestStatePhysical(
const double simulation_time,
202 const bool write_message_to_opmlog,
203 WellTestState& well_test_state,
204 DeferredLogger& deferred_logger)
const;
206 std::optional<double> bhpMax(
const std::function<
double(
const double)>& fflo,
207 const double bhp_limit,
208 const double maxPerfPress,
209 const double vfp_flo_front,
210 DeferredLogger& deferred_logger)
const;
212 std::optional<double> computeBhpAtThpLimitCommon(
213 const std::function<std::vector<double>(
const double)>& frates,
214 const std::function<
double(
const std::vector<double>)>& fbhp,
215 const std::array<double, 2>& range,
216 DeferredLogger& deferred_logger)
const;
219 bool bruteForceBracket(
const std::function<
double(
const double)>& eq,
220 const std::array<double, 2>& range,
221 double& low,
double& high,
222 DeferredLogger& deferred_logger)
const;
224 bool bisectBracket(
const std::function<
double(
const double)>& eq,
225 const std::array<double, 2>& range,
226 double& low,
double& high,
227 std::optional<double>& approximate_solution,
228 DeferredLogger& deferred_logger)
const;
233 bool isOperableAndSolvable()
const {
234 if (!operable_under_only_bhp_limit || !solvable || has_negative_potentials) {
237 return ( (isOperableUnderBHPLimit() || isOperableUnderTHPLimit()) );
241 bool isOperableUnderBHPLimit()
const {
242 return operable_under_only_bhp_limit && obey_thp_limit_under_bhp_limit;
245 bool isOperableUnderTHPLimit()
const {
246 return can_obtain_bhp_with_thp_limit && obey_bhp_limit_with_thp_limit;
249 void resetOperability() {
250 operable_under_only_bhp_limit =
true;
251 obey_thp_limit_under_bhp_limit =
true;
252 can_obtain_bhp_with_thp_limit =
true;
253 obey_bhp_limit_with_thp_limit =
true;
259 bool operable_under_only_bhp_limit =
true;
262 bool obey_thp_limit_under_bhp_limit =
true;
264 bool can_obtain_bhp_with_thp_limit =
true;
266 bool obey_bhp_limit_with_thp_limit =
true;
268 bool solvable =
true;
270 bool has_negative_potentials =
false;
272 mutable bool thp_limit_violated_but_not_switched =
false;
274 bool use_vfpexplicit =
false;
282 const int current_step_;
286 const int pvtRegionIdx_;
288 const int num_components_;
291 int number_of_phases_;
296 const std::vector<PerforationData>* perf_data_;
302 mutable std::vector<double> ipr_a_;
303 mutable std::vector<double> ipr_b_;
306 std::vector<int> well_cells_;
309 std::vector<double> well_index_;
312 int number_of_perforations_;
315 std::vector<double> perf_depth_;
318 std::vector<double> perf_rep_radius_;
321 std::vector<double> perf_length_;
324 std::vector<double> bore_diameters_;
341 std::map<int, std::vector<int>> completions_;
347 std::vector<int> saturation_table_number_;
349 Well::Status wellStatus_;
355 std::optional<double> dynamic_thp_limit_;
357 double well_efficiency_factor_;
359 const GuideRate* guide_rate_;
361 std::vector< std::string> well_control_log_;
363 bool changed_to_open_this_step_ =
true;
Class encapsulating some information about parallel wells.
Definition: ParallelWellInfo.hpp:243
A thin wrapper class that holds one VFPProdProperties and one VFPInjProperties object.
Definition: VFPProperties.hpp:39
Definition: WellInterfaceGeneric.hpp:51
bool wellHasTHPConstraints(const SummaryState &summaryState) const
Returns true if the well has one or more THP limits/constraints.
Definition: WellInterfaceGeneric.cpp:181
const std::vector< int > & cells() const
Well cells.
Definition: WellInterfaceGeneric.hpp:78
int indexOfWell() const
Index of well in the wells struct and wellState.
Definition: WellInterfaceGeneric.cpp:149
const std::string & name() const
Well name.
Definition: WellInterfaceGeneric.cpp:134
bool underPredictionMode() const
Returns true if the well is currently in prediction mode (i.e. not history mode).
Definition: WellInterfaceGeneric.cpp:236
bool isProducer() const
True if the well is a producer.
Definition: WellInterfaceGeneric.cpp:144
bool isInjector() const
True if the well is an injector.
Definition: WellInterfaceGeneric.cpp:139
const std::vector< PerforationData > & perforationData() const
Get the perforations of the well.
Definition: WellInterfaceGeneric.cpp:129
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition: BlackoilPhases.hpp:27
Definition: BlackoilPhases.hpp:46
Definition: WellInterfaceGeneric.hpp:232