24 #ifndef OPM_WELLINTERFACE_GENERIC_HEADER_INCLUDED
25 #define OPM_WELLINTERFACE_GENERIC_HEADER_INCLUDED
27 #include <opm/input/eclipse/Schedule/Well/Well.hpp>
39 class ParallelWellInfo;
40 struct PerforationData;
46 class SingleWellState;
57 const int pvtRegionIdx,
58 const int num_components,
60 const int index_of_well,
61 const std::vector<PerforationData>& perf_data);
67 const std::string&
name()
const;
76 const std::vector<int>&
cells()
const {
return well_cells_; }
81 void adaptRatesForVFP(std::vector<double>& rates)
const;
83 const Well& wellEcl()
const;
90 bool isOperableAndSolvable()
const;
92 void initCompletions();
93 void closeCompletions(
const WellTestState& wellTestState);
95 void setVFPProperties(
const VFPProperties* vfp_properties_arg);
96 void setGuideRate(
const GuideRate* guide_rate_arg);
97 void setWellEfficiencyFactor(
const double efficiency_factor);
98 void setRepRadiusPerfLength();
99 void setWsolvent(
const double wsolvent);
100 void setDynamicThpLimit(
const double thp_limit);
101 void updatePerforatedCell(std::vector<bool>& is_cell_perforated);
107 this->wellStatus_ = Well::Status::STOP;
111 this->wellStatus_ = Well::Status::OPEN;
114 bool wellIsStopped()
const {
115 return this->wellStatus_ == Well::Status::STOP;
118 int currentStep()
const {
119 return this->current_step_;
122 int pvtRegionIdx()
const {
123 return pvtRegionIdx_;
126 const GuideRate* guideRate()
const {
130 int numComponents()
const {
131 return num_components_;
134 int numPhases()
const {
135 return number_of_phases_;
138 int numPerfs()
const {
139 return number_of_perforations_;
142 double refDepth()
const {
146 double gravity()
const {
150 const VFPProperties* vfpProperties()
const {
151 return vfp_properties_;
154 const ParallelWellInfo& parallelWellInfo()
const {
155 return parallel_well_info_;
158 const std::vector<double>& perfDepth()
const {
162 std::vector<double>& perfDepth() {
166 const std::vector<double>& wellIndex()
const {
170 double getTHPConstraint(
const SummaryState& summaryState)
const;
171 double getALQ(
const WellState& well_state)
const;
172 double wsolvent()
const;
175 bool isVFPActive(DeferredLogger& deferred_logger)
const;
177 void reportWellSwitching(
const SingleWellState& ws, DeferredLogger& deferred_logger)
const;
179 bool changedToOpenThisStep()
const {
180 return this->changed_to_open_this_step_;
182 std::optional<double> computeBhpAtThpLimitProdCommon(
const std::function<std::vector<double>(
const double)>& frates,
183 const SummaryState& summary_state,
184 const double maxPerfPress,
186 const double alq_value,
187 DeferredLogger& deferred_logger
193 bool getAllowCrossFlow()
const;
194 double mostStrictBhpFromBhpLimits(
const SummaryState& summaryState)
const;
195 void updateWellTestStatePhysical(
const double simulation_time,
196 const bool write_message_to_opmlog,
197 WellTestState& well_test_state,
198 DeferredLogger& deferred_logger)
const;
200 std::optional<double> bhpMax(
const std::function<
double(
const double)>& fflo,
201 const double bhp_limit,
202 const double maxPerfPress,
203 const double vfp_flo_front,
204 DeferredLogger& deferred_logger)
const;
206 std::optional<double> computeBhpAtThpLimitCommon(
207 const std::function<std::vector<double>(
const double)>& frates,
208 const std::function<
double(
const std::vector<double>)>& fbhp,
209 const std::array<double, 2>& range,
210 DeferredLogger& deferred_logger)
const;
213 bool bruteForceBracket(
const std::function<
double(
const double)>& eq,
214 const std::array<double, 2>& range,
215 double& low,
double& high,
216 DeferredLogger& deferred_logger)
const;
218 bool bisectBracket(
const std::function<
double(
const double)>& eq,
219 const std::array<double, 2>& range,
220 double& low,
double& high,
221 std::optional<double>& approximate_solution,
222 DeferredLogger& deferred_logger)
const;
227 bool isOperableAndSolvable()
const {
228 if (!operable_under_only_bhp_limit || !solvable || has_negative_potentials) {
231 return ( (isOperableUnderBHPLimit() || isOperableUnderTHPLimit()) );
235 bool isOperableUnderBHPLimit()
const {
236 return operable_under_only_bhp_limit && obey_thp_limit_under_bhp_limit;
239 bool isOperableUnderTHPLimit()
const {
240 return can_obtain_bhp_with_thp_limit && obey_bhp_limit_with_thp_limit;
243 void resetOperability() {
244 operable_under_only_bhp_limit =
true;
245 obey_thp_limit_under_bhp_limit =
true;
246 can_obtain_bhp_with_thp_limit =
true;
247 obey_bhp_limit_with_thp_limit =
true;
253 bool operable_under_only_bhp_limit =
true;
256 bool obey_thp_limit_under_bhp_limit =
true;
258 bool can_obtain_bhp_with_thp_limit =
true;
260 bool obey_bhp_limit_with_thp_limit =
true;
262 bool solvable =
true;
264 bool has_negative_potentials =
false;
266 mutable bool thp_limit_violated_but_not_switched =
false;
274 const int current_step_;
278 const int pvtRegionIdx_;
280 const int num_components_;
283 int number_of_phases_;
288 const std::vector<PerforationData>* perf_data_;
294 mutable std::vector<double> ipr_a_;
295 mutable std::vector<double> ipr_b_;
298 std::vector<int> well_cells_;
301 std::vector<double> well_index_;
304 int number_of_perforations_;
307 std::vector<double> perf_depth_;
310 std::vector<double> perf_rep_radius_;
313 std::vector<double> perf_length_;
316 std::vector<double> bore_diameters_;
333 std::map<int, std::vector<int>> completions_;
339 std::vector<int> saturation_table_number_;
341 Well::Status wellStatus_;
347 std::optional<double> dynamic_thp_limit_;
349 double well_efficiency_factor_;
351 const GuideRate* guide_rate_;
353 std::vector< std::string> well_control_log_;
355 bool changed_to_open_this_step_ =
false;
Class encapsulating some information about parallel wells.
Definition: ParallelWellInfo.hpp:252
A thin wrapper class that holds one VFPProdProperties and one VFPInjProperties object.
Definition: VFPProperties.hpp:37
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:176
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
const std::vector< int > & cells() const
Well cells.
Definition: WellInterfaceGeneric.hpp:76
bool underPredictionMode() const
Returns true if the well is currently in prediction mode (i.e. not history mode).
Definition: WellInterfaceGeneric.cpp:231
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:226