24 #ifndef OPM_BLACKOILWELLMODEL_GENERIC_HEADER_INCLUDED
25 #define OPM_BLACKOILWELLMODEL_GENERIC_HEADER_INCLUDED
31 #include <unordered_map>
32 #include <unordered_set>
35 #include <dune/common/version.hh>
36 #include <opm/output/data/GuideRateValue.hpp>
37 #include <opm/parser/eclipse/EclipseState/Schedule/Well/WellTestState.hpp>
38 #include <opm/parser/eclipse/EclipseState/Schedule/Group/GuideRate.hpp>
40 #include <opm/simulators/utils/DeferredLoggingErrorHelpers.hpp>
41 #include <opm/simulators/wells/ParallelWellInfo.hpp>
42 #include <opm/simulators/wells/PerforationData.hpp>
43 #include <opm/simulators/wells/WellInterfaceGeneric.hpp>
44 #include <opm/simulators/wells/WellProdIndexCalculator.hpp>
45 #include <opm/simulators/wells/WGState.hpp>
51 struct GroupGuideRates;
52 class GroupAndNetworkValues;
58 class GasLiftSingleWellGeneric;
59 class GasLiftWellState;
72 using GLiftOptWells = std::map<std::string,std::unique_ptr<GasLiftSingleWellGeneric>>;
73 using GLiftProdWells = std::map<std::string,const WellInterfaceGeneric*>;
74 using GLiftWellStateMap = std::map<std::string,std::unique_ptr<GasLiftWellState>>;
77 const SummaryState& summaryState,
78 const EclipseState& eclState,
80 const Parallel::Communication& comm);
84 int numLocalWells()
const;
85 int numPhases()
const;
89 bool hasWell(
const std::string& wname);
93 bool anyMSWellOpenLocal()
const;
95 const Well& getWellEcl(
const std::string& well_name)
const;
96 std::vector<Well> getLocalWells(
const int timeStepIdx)
const;
97 const Schedule& schedule()
const {
return schedule_; }
98 const PhaseUsage& phaseUsage()
const {
return phase_usage_; }
99 const GroupState& groupState()
const {
return this->active_wgstate_.group_state; }
106 return this->active_wgstate_.well_state;
114 return this->active_wgstate_.well_state;
117 GroupState& groupState() {
return this->active_wgstate_.group_state; }
119 WellTestState& wellTestState() {
return this->active_wgstate_.well_test_state; }
121 const WellTestState& wellTestState()
const {
return this->active_wgstate_.well_test_state; }
124 double wellPI(
const int well_index)
const;
125 double wellPI(
const std::string& well_name)
const;
127 void updateEclWells(
const int timeStepIdx,
128 const std::unordered_set<std::string>& wells);
131 void loadRestartData(
const data::Wells& rst_wells,
132 const data::GroupAndNetworkValues& grpNwrkValues,
134 const bool handle_ms_well,
137 void initFromRestartFile(
const RestartValue& restartValues,
138 WellTestState wtestState,
139 const size_t numCells,
140 bool handle_ms_well);
142 void setWellsActive(
const bool wells_active);
152 this->last_valid_wgstate_ = this->active_wgstate_;
155 data::GroupAndNetworkValues groupAndNetworkData(
const int reportStepIdx)
const;
163 const double simulation_time);
197 return this->last_valid_wgstate_.well_state;
200 const WGState& prevWGState()
const
202 return this->last_valid_wgstate_;
210 return this->nupcol_wgstate_.well_state;
218 void commitWGState(
WGState wgstate)
220 this->last_valid_wgstate_ = std::move(wgstate);
230 this->active_wgstate_ = this->last_valid_wgstate_;
238 void updateNupcolWGState()
240 this->nupcol_wgstate_ = this->active_wgstate_;
247 void initializeWellProdIndCalculators();
248 void initializeWellPerfData();
250 bool wasDynamicallyShutThisTimeStep(
const int well_index)
const;
252 void updateNetworkPressures(
const int reportStepIdx);
254 void updateWsolvent(
const Group& group,
255 const int reportStepIdx,
257 void setWsolvent(
const Group& group,
258 const int reportStepIdx,
260 virtual void calcRates(
const int fipnum,
262 std::vector<double>& resv_coeff) = 0;
263 virtual void calcInjRates(
const int fipnum,
265 std::vector<double>& resv_coeff) = 0;
267 data::GuideRateValue getGuideRateValues(
const Group& group)
const;
268 data::GuideRateValue getGuideRateValues(
const Well& well)
const;
269 data::GuideRateValue getGuideRateInjectionGroupValues(
const Group& group)
const;
270 void getGuideRateValues(
const GuideRate::RateVector& qs,
272 const std::string& wgname,
273 data::GuideRateValue& grval)
const;
275 void assignWellGuideRates(data::Wells& wsrpt)
const;
276 void assignShutConnections(data::Wells& wsrpt,
277 const int reportStepIndex)
const;
278 void assignGroupControl(
const Group& group,
279 data::GroupData& gdata)
const;
280 void assignGroupGuideRates(
const Group& group,
281 const std::unordered_map<std::string, data::GroupGuideRates>& groupGuideRates,
282 data::GroupData& gdata)
const;
283 void assignGroupValues(
const int reportStepIdx,
284 std::map<std::string, data::GroupData>& gvalues)
const;
285 void assignNodeValues(std::map<std::string, data::NodeData>& nodevalues)
const;
287 std::unordered_map<std::string, data::GroupGuideRates>
288 calculateAllGroupGuiderates(
const int reportStepIdx)
const;
290 void calculateEfficiencyFactors(
const int reportStepIdx);
292 bool checkGroupConstraints(
const Group& group,
293 const int reportStepIdx,
296 std::pair<Group::InjectionCMode, double> checkGroupInjectionConstraints(
const Group& group,
297 const int reportStepIdx,
298 const Phase& phase)
const;
299 std::pair<Group::ProductionCMode, double> checkGroupProductionConstraints(
const Group& group,
300 const int reportStepIdx,
303 void checkGconsaleLimits(
const Group& group,
305 const int reportStepIdx,
308 bool checkGroupHigherConstraints(
const Group& group,
310 const int reportStepIdx,
311 std::set<std::string>& switched_groups);
313 bool updateGroupIndividualControl(
const Group& group,
315 const int reportStepIdx,
316 std::set<std::string>& switched_groups);
318 bool updateGroupIndividualControls(
DeferredLogger& deferred_logger,
319 std::set<std::string>& switched_groups,
320 const int reportStepIdx,
321 const int iterationIdx);
324 const int reportStepIdx,
325 std::set<std::string>& switched_groups);
327 void actionOnBrokenConstraints(
const Group& group,
328 const Group::ExceedAction& exceed_action,
329 const Group::ProductionCMode& newControl,
331 void actionOnBrokenConstraints(
const Group& group,
332 const Group::InjectionCMode& newControl,
333 const Phase& controlPhase,
336 void updateAndCommunicateGroupData(
const int reportStepIdx,
337 const int iterationIdx);
339 void inferLocalShutWells();
341 void setRepRadiusPerfLength();
343 void gliftDebug(
const std::string& msg,
349 GLiftProdWells& prod_wells,
350 GLiftOptWells& glift_wells,
351 GLiftWellStateMap& map,
352 const int episodeIndex);
354 virtual void computePotentials(
const std::size_t widx,
356 std::string& exc_msg,
357 ExceptionType::ExcEnum& exc_type,
361 void updateWellPotentials(
const int reportStepIdx,
362 const bool onlyAfterEvent,
363 const SummaryConfig& summaryConfig,
367 virtual void createWellContainer(
const int time_step) = 0;
368 virtual void initWellContainer() = 0;
370 virtual void calculateProductivityIndexValuesShutWells(
const int reportStepIdx,
372 virtual void calculateProductivityIndexValues(
DeferredLogger& deferred_logger) = 0;
374 void runWellPIScaling(
const int timeStepIdx,
378 const SummaryState& summaryState_;
379 const EclipseState& eclState_;
380 const Parallel::Communication& comm_;
383 bool terminal_output_{
false};
384 bool wells_active_{
false};
385 bool initial_step_{};
386 bool report_step_starts_{};
388 std::optional<int> last_run_wellpi_{};
390 std::vector<Well> wells_ecl_;
391 std::vector<std::vector<PerforationData>> well_perf_data_;
392 std::function<bool(
const Well&)> not_on_process_{};
395 std::vector<WellInterfaceGeneric*> well_container_generic_{};
397 std::vector<int> local_shut_wells_{};
399 std::vector<ParallelWellInfo> parallel_well_info_;
400 std::vector<std::reference_wrapper<ParallelWellInfo>> local_parallel_well_info_;
402 std::vector<WellProdIndexCalculator> prod_index_calc_;
407 std::vector<int> cartesian_to_compressed_;
409 std::vector<int> pvt_region_idx_;
411 mutable std::unordered_set<std::string> closed_this_step_;
413 GuideRate guideRate_;
414 std::unique_ptr<VFPProperties> vfp_properties_{};
415 std::map<std::string, double> node_pressures_;
427 bool glift_debug =
false;
Class for handling the blackoil well model.
Definition: BlackoilWellModelGeneric.hpp:69
std::vector< std::reference_wrapper< ParallelWellInfo > > createLocalParallelWellInfo(const std::vector< Well > &wells)
Create the parallel well information.
Definition: BlackoilWellModelGeneric.cpp:305
bool forceShutWellByNameIfPredictionMode(const std::string &wellname, const double simulation_time)
Shut down any single well, but only if it is in prediction mode.
Definition: BlackoilWellModelGeneric.cpp:1589
bool wellsActive() const
return true if wells are available in the reservoir
Definition: BlackoilWellModelGeneric.cpp:105
bool hasTHPConstraints() const
Return true if any well has a THP constraint.
Definition: BlackoilWellModelGeneric.cpp:1576
bool localWellsActive() const
return true if wells are available on this process
Definition: BlackoilWellModelGeneric.cpp:112
Definition: DeferredLogger.hpp:57
Definition: GroupState.hpp:34
Definition: WellInterfaceGeneric.hpp:51
The state of a set of wells, tailored for use by the fully implicit blackoil simulator.
Definition: WellState.hpp:56
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition: BlackoilPhases.hpp:26
Definition: BlackoilPhases.hpp:45
Definition: WGState.hpp:35