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()
249 std::ranges::fill(this->inj_multiplier_damp_factor_, 1.0);
255 bool isOperableAndSolvable()
const
257 if (!operable_under_only_bhp_limit || !solvable || has_negative_potentials) {
261 return isOperableUnderBHPLimit() || isOperableUnderTHPLimit();
264 bool isOperableUnderBHPLimit()
const
266 return operable_under_only_bhp_limit && obey_thp_limit_under_bhp_limit;
269 bool isOperableUnderTHPLimit()
const
271 return can_obtain_bhp_with_thp_limit && obey_bhp_limit_with_thp_limit;
274 void resetOperability()
276 operable_under_only_bhp_limit =
true;
277 obey_thp_limit_under_bhp_limit =
true;
278 can_obtain_bhp_with_thp_limit =
true;
279 obey_bhp_limit_with_thp_limit =
true;
285 bool operable_under_only_bhp_limit =
true;
288 bool obey_thp_limit_under_bhp_limit =
true;
290 bool can_obtain_bhp_with_thp_limit =
true;
292 bool obey_bhp_limit_with_thp_limit =
true;
294 bool solvable =
true;
296 bool has_negative_potentials =
false;
298 mutable bool thp_limit_violated_but_not_switched =
false;
300 bool use_vfpexplicit =
false;
308 const int current_step_;
309 const ModelParameters& param_;
313 const int pvtRegionIdx_;
315 const int num_conservation_quantities_;
318 int number_of_phases_;
325 const std::vector<PerforationData<Scalar>>* perf_data_;
331 mutable std::vector<Scalar> ipr_a_;
332 mutable std::vector<Scalar> ipr_b_;
335 std::vector<int> well_cells_;
338 std::vector<Scalar> well_index_;
341 int number_of_local_perforations_;
344 std::vector<Scalar> perf_depth_;
347 std::vector<Scalar> perf_rep_radius_;
350 std::vector<Scalar> perf_length_;
353 std::vector<Scalar> bore_diameters_;
370 std::map<int, std::vector<int>> completions_;
376 std::vector<int> saturation_table_number_;
378 Well::Status wellStatus_;
382 std::optional<Scalar> dynamic_thp_limit_;
385 mutable std::vector<Scalar> inj_multiplier_;
389 std::vector<Scalar> prev_inj_multiplier_;
392 mutable std::vector<Scalar> inj_multiplier_previter_;
394 mutable std::vector<Scalar> inj_multiplier_damp_factor_;
397 std::vector<Scalar> inj_fc_multiplier_;
399 Scalar well_efficiency_factor_;
401 const GuideRate* guide_rate_;
403 std::vector<std::string> well_control_log_;
405 bool changed_to_open_this_step_ =
true;