53class WellInterfaceGeneric {
59 WellInterfaceGeneric(
const Well& well,
62 const ModelParameters& param,
63 const int pvtRegionIdx,
64 const int num_conservation_quantities,
66 const int index_of_well,
70 virtual ~WellInterfaceGeneric() =
default;
76 const std::string&
name()
const;
85 const std::vector<int>&
cells()
const {
return well_cells_; }
90 void adaptRatesForVFP(std::vector<Scalar>& rates)
const;
92 const Well& wellEcl()
const;
100 bool isOperableAndSolvable()
const;
101 bool useVfpExplicit ()
const;
102 bool thpLimitViolatedButNotSwitched()
const;
104 void initCompletions();
105 void closeCompletions(
const WellTestState& wellTestState);
108 void setPrevSurfaceRates(WellStateType& well_state,
109 const WellStateType& prev_well_state)
const;
110 void setGuideRate(
const GuideRate* guide_rate_arg);
111 void setWellEfficiencyFactor(
const Scalar efficiency_factor);
112 void setRepRadiusPerfLength();
113 void setWsolvent(
const Scalar wsolvent);
114 void setDynamicThpLimit(
const Scalar thp_limit);
115 std::optional<Scalar> getDynamicThpLimit()
const;
116 void setDynamicThpLimit(
const std::optional<Scalar> thp_limit);
117 void updatePerforatedCell(std::vector<bool>& is_cell_perforated);
122 void stopWell() { this->wellStatus_ = Well::Status::STOP; }
123 void openWell() { this->wellStatus_ = Well::Status::OPEN; }
124 Well::Status wellStatus() {
return this->wellStatus_;}
126 bool wellIsStopped()
const {
return this->wellStatus_ == Well::Status::STOP; }
128 int currentStep()
const {
return this->current_step_; }
130 int pvtRegionIdx()
const {
return pvtRegionIdx_; }
132 const GuideRate* guideRate()
const {
return guide_rate_; }
134 int numConservationQuantities()
const {
return num_conservation_quantities_; }
136 int numPhases()
const {
return number_of_phases_; }
138 int numLocalPerfs()
const {
return number_of_local_perforations_; }
140 Scalar refDepth()
const {
return ref_depth_; }
142 Scalar gravity()
const {
return gravity_; }
144 const VFPProperties<Scalar, IndexTraits>* vfpProperties()
const {
return vfp_properties_; }
146 const ParallelWellInfo<Scalar>& parallelWellInfo()
const {
return parallel_well_info_; }
148 const std::vector<Scalar>& perfDepth()
const {
return perf_depth_; }
150 std::vector<Scalar>& perfDepth() {
return perf_depth_; }
152 const std::vector<Scalar>& wellIndex()
const {
return well_index_; }
154 const std::map<int,std::vector<int>>& getCompletions()
const {
return completions_; }
156 Scalar getTHPConstraint(
const SummaryState& summaryState)
const;
157 Scalar getALQ(
const WellStateType& well_state)
const;
158 Scalar wsolvent()
const;
159 Scalar rsRvInj()
const;
162 void initInjMult(
const std::vector<Scalar>& max_inj_mult);
165 void updateInjMult(std::vector<Scalar>& inj_multipliers,
166 DeferredLogger& deferred_logger)
const;
170 Scalar getInjMult(
const int local_perf_index,
const Scalar bhp,
const Scalar perf_pres, DeferredLogger& dlogger)
const;
173 bool isVFPActive(DeferredLogger& deferred_logger)
const;
175 void reportWellSwitching(
const SingleWellState<Scalar, IndexTraits>& ws,
176 DeferredLogger& deferred_logger)
const;
178 bool changedToOpenThisStep()
const {
return this->changed_to_open_this_step_; }
180 void updateWellTestState(
const SingleWellState<Scalar, IndexTraits>& ws,
181 const double& simulationTime,
182 const bool& writeMessageToOPMLog,
183 const bool zero_group_target,
184 WellTestState& wellTestState,
185 DeferredLogger& deferred_logger)
const;
187 bool isPressureControlled(
const WellStateType& well_state)
const;
189 Scalar wellEfficiencyFactor()
const {
return well_efficiency_factor_; }
194 inj_fc_multiplier_ = inj_fc_multiplier;
197 void resetWellOperability();
199 virtual std::vector<Scalar> getPrimaryVars()
const
204 virtual int setPrimaryVars(
typename std::vector<Scalar>::const_iterator)
209 virtual Scalar connectionDensity(
const int globalConnIdx,
210 const int openConnIdx)
const = 0;
212 void addPerforations(
const std::vector<RuntimePerforation>& perfs);
215 bool getAllowCrossFlow()
const;
217 Scalar wmicrobes_()
const;
218 Scalar wfoam_()
const;
219 Scalar woxygen_()
const;
220 Scalar wpolymer_()
const;
221 Scalar wsalt_()
const;
222 Scalar wurea_()
const;
224 int polymerTable_()
const;
225 int polymerInjTable_()
const;
226 int polymerWaterTable_()
const;
228 bool wellUnderZeroRateTargetIndividual(
const SummaryState& summary_state,
229 const WellState<Scalar, IndexTraits>& well_state)
const;
231 bool wellUnderGroupControl(
const SingleWellState<Scalar, IndexTraits>& ws)
const;
234 computeWellPotentials(std::vector<Scalar>& well_potentials,
235 const WellStateType& well_state);
237 void checkNegativeWellPotentials(std::vector<Scalar>& well_potentials,
238 const bool checkOperability,
239 DeferredLogger& deferred_logger);
242 void onlyKeepBHPandTHPcontrols(
const SummaryState& summary_state,
243 WellStateType& well_state,
244 Well::InjectionControls& inj_controls,
245 Well::ProductionControls& prod_controls)
const;
247 void resetDampening() {
248 std::fill(this->inj_multiplier_damp_factor_.begin(), this->inj_multiplier_damp_factor_.end(), 1.0);
254 bool isOperableAndSolvable()
const
256 if (!operable_under_only_bhp_limit || !solvable || has_negative_potentials) {
260 return isOperableUnderBHPLimit() || isOperableUnderTHPLimit();
263 bool isOperableUnderBHPLimit()
const
265 return operable_under_only_bhp_limit && obey_thp_limit_under_bhp_limit;
268 bool isOperableUnderTHPLimit()
const
270 return can_obtain_bhp_with_thp_limit && obey_bhp_limit_with_thp_limit;
273 void resetOperability()
275 operable_under_only_bhp_limit =
true;
276 obey_thp_limit_under_bhp_limit =
true;
277 can_obtain_bhp_with_thp_limit =
true;
278 obey_bhp_limit_with_thp_limit =
true;
284 bool operable_under_only_bhp_limit =
true;
287 bool obey_thp_limit_under_bhp_limit =
true;
289 bool can_obtain_bhp_with_thp_limit =
true;
291 bool obey_bhp_limit_with_thp_limit =
true;
293 bool solvable =
true;
295 bool has_negative_potentials =
false;
297 mutable bool thp_limit_violated_but_not_switched =
false;
299 bool use_vfpexplicit =
false;
307 const int current_step_;
308 const ModelParameters& param_;
312 const int pvtRegionIdx_;
314 const int num_conservation_quantities_;
317 int number_of_phases_;
324 const std::vector<PerforationData<Scalar>>* perf_data_;
330 mutable std::vector<Scalar> ipr_a_;
331 mutable std::vector<Scalar> ipr_b_;
334 std::vector<int> well_cells_;
337 std::vector<Scalar> well_index_;
340 int number_of_local_perforations_;
343 std::vector<Scalar> perf_depth_;
346 std::vector<Scalar> perf_rep_radius_;
349 std::vector<Scalar> perf_length_;
352 std::vector<Scalar> bore_diameters_;
369 std::map<int, std::vector<int>> completions_;
375 std::vector<int> saturation_table_number_;
377 Well::Status wellStatus_;
381 std::optional<Scalar> dynamic_thp_limit_;
384 mutable std::vector<Scalar> inj_multiplier_;
388 std::vector<Scalar> prev_inj_multiplier_;
391 mutable std::vector<Scalar> inj_multiplier_previter_;
393 mutable std::vector<Scalar> inj_multiplier_damp_factor_;
396 std::vector<Scalar> inj_fc_multiplier_;
398 Scalar well_efficiency_factor_;
400 const GuideRate* guide_rate_;
402 std::vector<std::string> well_control_log_;
404 bool changed_to_open_this_step_ =
true;