86 using GLiftOptWells = std::map<std::string, std::unique_ptr<GasLiftSingleWellGeneric<Scalar>>>;
87 using GLiftProdWells = std::map<std::string, const WellInterfaceGeneric<Scalar>*>;
88 using GLiftWellStateMap = std::map<std::string, std::unique_ptr<GasLiftWellState<Scalar>>>;
92 const EclipseState& eclState,
94 const Parallel::Communication& comm);
98 int numLocalWells()
const;
99 int numLocalWellsEnd()
const;
100 int numLocalNonshutWells()
const;
101 int numPhases()
const;
105 bool hasWell(
const std::string&
wname)
const;
111 bool anyMSWellOpenLocal()
const;
113 const Well& getWellEcl(
const std::string& well_name)
const;
114 std::vector<Well> getLocalWells(
const int timeStepIdx)
const;
115 const Schedule& schedule()
const {
return schedule_; }
116 const PhaseUsage& phaseUsage()
const {
return phase_usage_; }
117 const GroupState<Scalar>& groupState()
const {
return this->active_wgstate_.group_state; }
118 std::vector<const WellInterfaceGeneric<Scalar>*> genericWells()
const
119 {
return {well_container_generic_.begin(), well_container_generic_.end()}; }
126 return this->active_wgstate_.well_state;
134 return this->active_wgstate_.well_state;
143 return this->nupcol_wgstate_.well_state;
147 WellTestState& wellTestState() {
return this->active_wgstate_.well_test_state; }
149 const WellTestState& wellTestState()
const {
return this->active_wgstate_.well_test_state; }
151 Scalar wellPI(
const int well_index)
const;
152 Scalar wellPI(
const std::string& well_name)
const;
160 const std::size_t numCells,
163 void prepareDeserialize(
int report_step,
164 const std::size_t numCells,
175 this->last_valid_wgstate_ = this->active_wgstate_;
178 data::GroupAndNetworkValues groupAndNetworkData(
const int reportStepIdx)
const;
196 const std::vector<PerforationData<Scalar>>& perfData(
const int well_idx)
const
197 {
return well_perf_data_[
well_idx]; }
199 const Parallel::Communication& comm()
const {
return comm_; }
201 const EclipseState& eclipseState()
const {
return eclState_; }
203 const SummaryState& summaryState()
const {
return summaryState_; }
205 const GuideRate& guideRate()
const {
return guideRate_; }
207 bool reportStepStarts()
const {
return report_step_starts_; }
209 bool shouldBalanceNetwork(
const int reportStepIndex,
212 void updateClosedWellsThisStep(
const std::string& well_name)
const
214 this->closed_this_step_.insert(well_name);
216 bool wasDynamicallyShutThisTimeStep(
const std::string& well_name)
const;
218 template<
class Serializer>
240 return this->initial_step_ == rhs.initial_step_ &&
241 this->report_step_starts_ == rhs.report_step_starts_ &&
242 this->last_run_wellpi_ == rhs.last_run_wellpi_ &&
243 this->local_shut_wells_ == rhs.local_shut_wells_ &&
244 this->closed_this_step_ == rhs.closed_this_step_ &&
245 this->node_pressures_ == rhs.node_pressures_ &&
246 this->prev_inj_multipliers_ == rhs.prev_inj_multipliers_ &&
247 this->active_wgstate_ == rhs.active_wgstate_ &&
248 this->last_valid_wgstate_ == rhs.last_valid_wgstate_ &&
249 this->nupcol_wgstate_ == rhs.nupcol_wgstate_ &&
250 this->last_glift_opt_time_ == rhs.last_glift_opt_time_ &&
251 this->switched_prod_groups_ == rhs.switched_prod_groups_ &&
252 this->switched_inj_groups_ == rhs.switched_inj_groups_ &&
253 this->closed_offending_wells_ == rhs.closed_offending_wells_;
286 return this->last_valid_wgstate_.well_state;
291 return this->last_valid_wgstate_;
301 this->last_valid_wgstate_ = std::move(
wgstate);
311 this->active_wgstate_ = this->last_valid_wgstate_;
319 void updateNupcolWGState()
321 this->nupcol_wgstate_ = this->active_wgstate_;
326 std::vector<std::reference_wrapper<ParallelWellInfo<Scalar>>>
329 void initializeWellProdIndCalculators();
330 void initializeWellPerfData();
332 bool wasDynamicallyShutThisTimeStep(
const int well_index)
const;
336 void updateWsolvent(
const Group& group,
339 void setWsolvent(
const Group& group,
342 virtual void calcResvCoeff(
const int fipnum,
344 const std::vector<Scalar>& production_rates,
346 virtual void calcInjResvCoeff(
const int fipnum,
350 void assignShutConnections(data::Wells&
wsrpt,
351 const int reportStepIndex)
const;
352 void assignWellTargets(data::Wells&
wsrpt)
const;
353 void assignProductionWellTargets(
const Well& well, data::WellControlLimits&
limits)
const;
354 void assignInjectionWellTargets(
const Well& well, data::WellControlLimits&
limits)
const;
355 void assignGroupControl(
const Group& group,
356 data::GroupData&
gdata)
const;
358 std::map<std::string, data::GroupData>&
gvalues)
const;
359 void assignNodeValues(std::map<std::string, data::NodeData>&
nodevalues,
364 void checkGconsaleLimits(
const Group& group,
369 void checkGEconLimits(
const Group& group,
374 bool checkGroupHigherConstraints(
const Group& group,
381 void inferLocalShutWells();
383 void setRepRadiusPerfLength();
385 void gliftDebug(
const std::string&
msg,
394 GLiftWellStateMap&
map,
395 const int episodeIndex);
397 virtual void computePotentials(
const std::size_t
widx,
414 void updateFiltrationModelsPostStep(
const double dt,
421 virtual void createWellContainer(
const int time_step) = 0;
424 virtual void calculateProductivityIndexValuesShutWells(
const int reportStepIdx,
434 std::vector<int> getCellsForConnections(
const Well& well)
const;
435 std::vector<std::vector<int>> getMaxWellConnections()
const;
437 std::vector<std::string> getWellsForTesting(
const int timeStepIdx,
440 using WellTracerRates = std::map<std::pair<std::string, std::string>, Scalar>;
441 void assignWellTracerRates(data::Wells&
wsrpt,
443 using MswTracerRates = std::map<std::tuple<std::string, std::string, std::size_t>, Scalar>;
444 void assignMswTracerRates(data::Wells&
wsrpt,
446 void assignMassGasRate(data::Wells&
wsrpt,
451 const EclipseState& eclState_;
452 const Parallel::Communication& comm_;
455 bool terminal_output_{
false};
456 bool wells_active_{
false};
457 bool network_active_{
false};
458 bool initial_step_{};
459 bool report_step_starts_{};
461 std::optional<int> last_run_wellpi_{};
463 std::vector<Well> wells_ecl_;
464 std::vector<std::vector<PerforationData<Scalar>>> well_perf_data_;
492 static_cast<int>(this->global_.size());
494 this->global_.push_back(
connIdx);
497 ? this->num_open_conns_++
508 const std::vector<int>&
local()
const
539 std::vector<int> local_{};
543 std::vector<int> global_{};
546 std::vector<int> open_{};
549 int num_open_conns_{0};
552 std::vector<ConnectionIndexMap> conn_idx_map_{};
553 std::function<
bool(
const Well&)> not_on_process_{};
556 std::vector<WellInterfaceGeneric<Scalar>*> well_container_generic_{};
558 std::vector<int> local_shut_wells_{};
560 std::vector<ParallelWellInfo<Scalar>> parallel_well_info_;
561 std::vector<std::reference_wrapper<ParallelWellInfo<Scalar>>> local_parallel_well_info_;
563 std::vector<WellProdIndexCalculator<Scalar>> prod_index_calc_;
566 std::vector<int> pvt_region_idx_;
568 mutable std::unordered_set<std::string> closed_this_step_;
571 std::unique_ptr<VFPProperties<Scalar>> vfp_properties_{};
572 std::map<std::string, Scalar> node_pressures_;
575 std::unordered_map<std::string, std::vector<Scalar>> prev_inj_multipliers_;
578 std::unordered_map<std::string, WellFilterCake<Scalar>> filter_cake_;
590 bool glift_debug =
false;
592 double last_glift_opt_time_ = -1.0;
594 bool wellStructureChangedDynamically_{
false};
597 std::map<std::string, std::string> switched_prod_groups_;
598 std::map<std::pair<std::string, Phase>, std::string> switched_inj_groups_;
600 std::map<std::string, std::pair<std::string, std::string>> closed_offending_wells_;
605 template <
typename Iter,
typename Body>
608 void updateEclWellsConstraints(
const int timeStepIdx,
612 void updateEclWellsCTFFromAction(
const int timeStepIdx,