86 using GLiftOptWells = std::map<std::string, std::unique_ptr<GasLiftSingleWellGeneric>>;
87 using GLiftProdWells = std::map<std::string, const WellInterfaceGeneric*>;
88 using GLiftWellStateMap = std::map<std::string, std::unique_ptr<GasLiftWellState>>;
91 const SummaryState& summaryState,
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& groupState()
const {
return this->active_wgstate_.group_state; }
118 std::vector<const WellInterfaceGeneric*> 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;
145 GroupState& groupState() {
return this->active_wgstate_.group_state; }
147 WellTestState& wellTestState() {
return this->active_wgstate_.well_test_state; }
149 const WellTestState& wellTestState()
const {
return this->active_wgstate_.well_test_state; }
152 double wellPI(
const int well_index)
const;
153 double wellPI(
const std::string& well_name)
const;
155 void updateEclWells(
const int timeStepIdx,
156 const SimulatorUpdate& sim_update,
157 const SummaryState& st);
159 void initFromRestartFile(
const RestartValue& restartValues,
160 WellTestState wtestState,
161 const std::size_t numCells,
162 bool handle_ms_well);
164 void prepareDeserialize(
int report_step,
165 const std::size_t numCells,
166 bool handle_ms_well);
176 this->last_valid_wgstate_ = this->active_wgstate_;
179 data::GroupAndNetworkValues groupAndNetworkData(
const int reportStepIdx)
const;
195 const double simulation_time);
197 const std::vector<PerforationData>& perfData(
const int well_idx)
const
198 {
return well_perf_data_[well_idx]; }
200 const Parallel::Communication& comm()
const {
return comm_; }
202 const EclipseState& eclipseState()
const {
return eclState_; }
204 const SummaryState& summaryState()
const {
return summaryState_; }
206 const GuideRate& guideRate()
const {
return guideRate_; }
208 bool reportStepStarts()
const {
return report_step_starts_; }
210 bool shouldBalanceNetwork(
const int reportStepIndex,
211 const int iterationIdx)
const;
213 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>
219 void serializeOp(Serializer& serializer)
221 serializer(initial_step_);
222 serializer(report_step_starts_);
223 serializer(last_run_wellpi_);
224 serializer(local_shut_wells_);
225 serializer(closed_this_step_);
226 serializer(guideRate_);
227 serializer(node_pressures_);
228 serializer(prev_inj_multipliers_);
229 serializer(active_wgstate_);
230 serializer(last_valid_wgstate_);
231 serializer(nupcol_wgstate_);
232 serializer(last_glift_opt_time_);
233 serializer(switched_prod_groups_);
234 serializer(switched_inj_groups_);
235 serializer(closed_offending_wells_);
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_;
288 return this->last_valid_wgstate_.well_state;
292 const WGState& prevWGState()
const
294 return this->last_valid_wgstate_;
304 void commitWGState(
WGState wgstate)
306 this->last_valid_wgstate_ = std::move(wgstate);
316 this->active_wgstate_ = this->last_valid_wgstate_;
324 void updateNupcolWGState()
326 this->nupcol_wgstate_ = this->active_wgstate_;
333 void initializeWellProdIndCalculators();
334 void initializeWellPerfData();
336 bool wasDynamicallyShutThisTimeStep(
const int well_index)
const;
338 double updateNetworkPressures(
const int reportStepIdx);
340 void updateWsolvent(
const Group& group,
341 const int reportStepIdx,
343 void setWsolvent(
const Group& group,
344 const int reportStepIdx,
346 virtual void calcRates(
const int fipnum,
348 const std::vector<double>& production_rates,
349 std::vector<double>& resv_coeff) = 0;
350 virtual void calcInjRates(
const int fipnum,
352 std::vector<double>& resv_coeff) = 0;
354 void assignShutConnections(data::Wells& wsrpt,
355 const int reportStepIndex)
const;
356 void assignGroupControl(
const Group& group,
357 data::GroupData& gdata)
const;
358 void assignGroupValues(
const int reportStepIdx,
359 std::map<std::string, data::GroupData>& gvalues)
const;
360 void assignNodeValues(std::map<std::string, data::NodeData>& nodevalues,
const int reportStepIdx)
const;
362 void calculateEfficiencyFactors(
const int reportStepIdx);
364 void checkGconsaleLimits(
const Group& group,
366 const int reportStepIdx,
369 void checkGEconLimits(
const Group& group,
370 const double simulation_time,
371 const int report_step_idx,
374 bool checkGroupHigherConstraints(
const Group& group,
376 const int reportStepIdx);
378 void updateAndCommunicateGroupData(
const int reportStepIdx,
379 const int iterationIdx);
381 void inferLocalShutWells();
383 void setRepRadiusPerfLength();
385 void gliftDebug(
const std::string& msg,
391 GLiftProdWells& prod_wells,
392 GLiftOptWells& glift_wells,
394 GLiftWellStateMap& map,
395 const int episodeIndex);
397 virtual void computePotentials(
const std::size_t widx,
399 std::string& exc_msg,
400 ExceptionType::ExcEnum& exc_type,
404 void updateWellPotentials(
const int reportStepIdx,
405 const bool onlyAfterEvent,
406 const SummaryConfig& summaryConfig,
415 void updateFiltrationParticleVolume(
const double dt,
const std::size_t water_index);
418 virtual void createWellContainer(
const int time_step) = 0;
419 virtual void initWellContainer(
const int reportStepIdx) = 0;
421 virtual void calculateProductivityIndexValuesShutWells(
const int reportStepIdx,
423 virtual void calculateProductivityIndexValues(
DeferredLogger& deferred_logger) = 0;
425 void runWellPIScaling(
const int reportStepIdx,
431 std::vector<int> getCellsForConnections(
const Well& well)
const;
432 std::vector<std::vector<int>> getMaxWellConnections()
const;
434 std::vector<std::string> getWellsForTesting(
const int timeStepIdx,
435 const double simulationTime);
437 using WellTracerRates = std::map<std::pair<std::string, std::string>,
double>;
438 void assignWellTracerRates(data::Wells& wsrpt,
439 const WellTracerRates& wellTracerRates)
const;
442 const SummaryState& summaryState_;
443 const EclipseState& eclState_;
444 const Parallel::Communication& comm_;
447 bool terminal_output_{
false};
448 bool wells_active_{
false};
449 bool network_active_{
false};
450 bool initial_step_{};
451 bool report_step_starts_{};
453 std::optional<int> last_run_wellpi_{};
455 std::vector<Well> wells_ecl_;
456 std::vector<std::vector<PerforationData>> well_perf_data_;
467 : local_(numConns, -1)
469 this->global_.reserve(numConns);
470 this->open_.reserve(numConns);
481 const bool connIsOpen)
483 this->local_[connIdx] =
484 static_cast<int>(this->global_.size());
486 this->global_.push_back(connIdx);
488 const auto open_conn_idx = connIsOpen
489 ? this->num_open_conns_++
492 this->open_.push_back(open_conn_idx);
500 const std::vector<int>&
local()
const
512 return this->global_[connIdx];
522 int open(
const int connIdx)
const
524 return this->open_[connIdx];
531 std::vector<int> local_{};
535 std::vector<int> global_{};
538 std::vector<int> open_{};
541 int num_open_conns_{0};
544 std::vector<ConnectionIndexMap> conn_idx_map_{};
545 std::function<bool(
const Well&)> not_on_process_{};
548 std::vector<WellInterfaceGeneric*> well_container_generic_{};
550 std::vector<int> local_shut_wells_{};
552 std::vector<ParallelWellInfo> parallel_well_info_;
553 std::vector<std::reference_wrapper<ParallelWellInfo>> local_parallel_well_info_;
555 std::vector<WellProdIndexCalculator> prod_index_calc_;
556 mutable ParallelWBPCalculation wbpCalculationService_;
558 std::vector<int> pvt_region_idx_;
560 mutable std::unordered_set<std::string> closed_this_step_;
562 GuideRate guideRate_;
563 std::unique_ptr<VFPProperties> vfp_properties_{};
564 std::map<std::string, double> node_pressures_;
567 std::unordered_map<std::string, std::vector<double>> prev_inj_multipliers_;
570 std::unordered_map<std::string, WellFilterCake> filter_cake_;
578 WGState active_wgstate_;
579 WGState last_valid_wgstate_;
580 WGState nupcol_wgstate_;
582 bool glift_debug =
false;
584 double last_glift_opt_time_ = -1.0;
586 bool wellStructureChangedDynamically_{
false};
589 std::map<std::string, std::string> switched_prod_groups_;
590 std::map<std::pair<std::string, Opm::Phase>, std::string> switched_inj_groups_;
592 std::map<std::string, std::pair<std::string, std::string>> closed_offending_wells_;
596 WellInterfaceGeneric* getGenWell(
const std::string& well_name);