22 #include <opm/input/eclipse/Schedule/Action/ActionResult.hpp> 23 #include <opm/input/eclipse/Schedule/Action/SimulatorUpdate.hpp> 24 #include <opm/input/eclipse/Schedule/Action/WGNames.hpp> 25 #include <opm/input/eclipse/Schedule/CompletedCells.hpp> 26 #include <opm/input/eclipse/Schedule/Group/Group.hpp> 27 #include <opm/input/eclipse/Schedule/ScheduleDeck.hpp> 28 #include <opm/input/eclipse/Schedule/ScheduleState.hpp> 29 #include <opm/input/eclipse/Schedule/ScheduleStatic.hpp> 30 #include <opm/input/eclipse/Schedule/Well/PAvg.hpp> 31 #include <opm/input/eclipse/Schedule/Well/Well.hpp> 32 #include <opm/input/eclipse/Schedule/Well/Connection.hpp> 33 #include <opm/input/eclipse/Schedule/WriteRestartFileEvents.hpp> 35 #include <opm/input/eclipse/Units/UnitSystem.hpp> 47 #include <unordered_map> 52 class ActiveGridCells;
56 enum class ConnectionOrder;
60 class FieldPropsManager;
63 class GuideRateConfig;
66 enum class InputErrorAction;
67 class NumericalAquifers;
73 class SCHEDULESection;
79 enum class WellGasInflowEquation : std::uint8_t;
81 enum class WellProducerCMode : std::uint16_t;
82 enum class WellStatus : std::uint8_t;
107 explicit Schedule(std::shared_ptr<const Python> python_handle);
132 std::shared_ptr<const Python> python,
133 const bool lowActionParsingStrictness =
false,
134 const bool slave_mode =
false,
135 const bool keepKeywords =
true,
136 const std::optional<int>& output_interval = {},
148 std::shared_ptr<const Python> python,
149 const bool lowActionParsingStrictness =
false,
150 const bool slave_mode =
false,
151 const bool keepKeywords =
true,
152 const std::optional<int>& output_interval = {},
161 std::shared_ptr<const Python> python,
162 const bool lowActionParsingStrictness =
false,
163 const bool slave_mode =
false,
164 const bool keepKeywords =
true,
165 const std::optional<int>& output_interval = {},
173 std::shared_ptr<const Python> python,
174 const bool lowActionParsingStrictness =
false,
175 const bool slave_mode =
false,
176 const bool keepKeywords =
true,
177 const std::optional<int>& output_interval = {},
180 template <
typename T>
185 std::shared_ptr<const Python> python,
186 const bool lowActionParsingStrictness =
false,
187 const bool slave_mode =
false,
188 const bool keepKeywords =
true,
189 const std::optional<int>& output_interval = {},
194 std::shared_ptr<const Python> python,
195 const bool lowActionParsingStrictness =
false,
196 const bool slave_mode =
false,
197 const bool keepKeywords =
true,
198 const std::optional<int>& output_interval = {},
204 const std::optional<int>& output_interval = {},
209 static Schedule serializationTestObject();
215 std::time_t getStartTime()
const;
216 std::time_t posixStartTime()
const;
217 std::time_t posixEndTime()
const;
218 std::time_t simTime(std::size_t timeStep)
const;
219 double seconds(std::size_t timeStep)
const;
220 double stepLength(std::size_t timeStep)
const;
221 std::optional<int> exitStatus()
const;
225 std::size_t numWells()
const;
226 std::size_t numWells(std::size_t timestep)
const;
227 bool hasWell(
const std::string& wellName)
const;
228 bool hasWell(
const std::string& wellName, std::size_t timeStep)
const;
230 WellMatcher wellMatcher(std::size_t report_step)
const;
231 std::function<std::unique_ptr<SegmentMatcher>()> segmentMatcherFactory(std::size_t report_step)
const;
232 std::vector<std::string> wellNames(
const std::string& pattern, std::size_t timeStep,
const std::vector<std::string>& matching_wells = {})
const;
233 std::vector<std::string> wellNames(
const std::string& pattern)
const;
234 std::vector<std::string> wellNames(std::size_t timeStep)
const;
235 std::vector<std::string> wellNames()
const;
244 bool hasGroup(
const std::string& groupName, std::size_t timeStep)
const;
257 std::vector<std::string>
258 groupNames(
const std::string& pattern, std::size_t timeStep)
const;
266 const std::vector<std::string>&
groupNames(std::size_t timeStep)
const;
276 std::vector<std::string>
groupNames(
const std::string& pattern)
const;
281 const std::vector<std::string>&
groupNames()
const;
293 std::vector<const Group*>
restart_groups(std::size_t timeStep)
const;
311 std::vector<std::string>
313 std::size_t initialStep = 0)
const;
333 std::size_t initialStep = 0)
const;
335 const Well& getWell(std::size_t well_index, std::size_t timeStep)
const;
336 const Well& getWell(
const std::string& wellName, std::size_t timeStep)
const;
337 const Well& getWellatEnd(
const std::string& well_name)
const;
339 std::unordered_set<int> getAquiferFluxSchedule()
const;
340 std::vector<Well> getWells(std::size_t timeStep)
const;
341 std::vector<Well> getWellsatEnd()
const;
344 std::vector<Well> getActiveWellsAtEnd()
const;
347 std::vector<std::string> getInactiveWellNamesAtEnd()
const;
349 const std::unordered_map<std::string, std::set<int>>&
350 getPossibleFutureConnections()
const;
352 void shut_well(
const std::string& well_name, std::size_t report_step);
353 void shut_well(
const std::string& well_name);
354 void stop_well(
const std::string& well_name, std::size_t report_step);
355 void stop_well(
const std::string& well_name);
356 void open_well(
const std::string& well_name, std::size_t report_step);
357 void open_well(
const std::string& well_name);
358 void clear_event(ScheduleEvents::Events, std::size_t report_step);
359 void add_event(ScheduleEvents::Events, std::size_t report_step);
360 void applyWellProdIndexScaling(
const std::string& well_name,
const std::size_t reportStep,
const double scalingFactor);
365 WellProducerCMode getGlobalWhistctlMmode(std::size_t timestep)
const;
367 const UDQConfig& getUDQConfig(std::size_t timeStep)
const;
369 GTNode groupTree(std::size_t report_step)
const;
370 GTNode groupTree(
const std::string& root_node, std::size_t report_step)
const;
371 const Group& getGroup(
const std::string& groupName, std::size_t timeStep)
const;
373 std::optional<std::size_t> first_RFT()
const;
374 std::size_t size()
const;
376 bool write_rst_file(std::size_t report_step)
const;
377 const std::map< std::string, int >& rst_keywords( std::size_t timestep )
const;
387 const std::unordered_map<std::string, double>& wellpi,
388 const bool iterateSchedule);
393 const std::unordered_map<std::string, float>& wellpi,
394 const bool iterateSchedule);
413 const std::unordered_map<std::string, double>& target_wellpi);
420 const std::unordered_map<std::string, float>& target_wellpi);
423 const std::map<std::string, std::vector<Connection>>& extraConns);
425 const GasLiftOpt& glo(std::size_t report_step)
const;
427 bool operator==(
const Schedule& data)
const;
428 std::shared_ptr<const Python> python()
const;
440 std::vector<ScheduleState>::const_iterator begin()
const;
441 std::vector<ScheduleState>::const_iterator end()
const;
442 void create_next(
const time_point& start_time,
const std::optional<time_point>& end_time);
444 void create_first(
const time_point& start_time,
const std::optional<time_point>& end_time);
446 void treat_critical_as_non_critical(
bool value) { this->m_treat_critical_as_non_critical =
value; }
454 static bool cmp(
const Schedule& sched1,
const Schedule& sched2, std::size_t report_step);
455 void applyKeywords(std::vector<std::unique_ptr<DeckKeyword>>& keywords, std::unordered_map<std::string, double>& target_wellpi,
bool action_mode, std::size_t report_step);
456 void applyKeywords(std::vector<std::unique_ptr<DeckKeyword>>& keywords, std::unordered_map<std::string, double>& target_wellpi,
bool action_mode);
458 template<
class Serializer>
461 serializer(this->m_static);
462 serializer(this->m_sched_deck);
463 serializer(this->action_wgnames);
464 serializer(this->potential_wellopen_patterns);
465 serializer(this->exit_status);
466 serializer(this->snapshots);
467 serializer(this->restart_output);
468 serializer(this->completed_cells);
469 serializer(this->completed_cells_lgr);
470 serializer(this->completed_cells_lgr_map);
471 serializer(this->m_treat_critical_as_non_critical);
472 serializer(this->current_report_step);
473 serializer(this->m_lowActionParsingStrictness);
474 serializer(this->simUpdateFromPython);
483 for (
auto& snapshot : snapshots) {
484 for (
auto& well : snapshot.wells) {
491 template <
typename T>
492 std::vector<std::pair<std::size_t, T>> unique()
const 494 std::vector<std::pair<std::size_t, T>> values;
495 for (std::size_t index = 0; index < this->snapshots.size(); index++) {
496 const auto& member = this->snapshots[index].get<T>();
497 const auto&
value = member.get();
498 if (values.empty() || !(
value == values.back().second))
499 values.push_back( std::make_pair(index,
value));
504 friend std::ostream& operator<<(std::ostream& os,
const Schedule& sched);
505 void dump_deck(std::ostream& os)
const;
523 bool m_treat_critical_as_non_critical =
false;
527 std::unordered_set<std::string> potential_wellopen_patterns{};
528 std::optional<int> exit_status{};
529 std::vector<ScheduleState> snapshots{};
532 std::vector<CompletedCells> completed_cells_lgr{};
533 std::unordered_map<std::string, std::size_t> completed_cells_lgr_map;
538 bool m_lowActionParsingStrictness =
false;
543 std::unordered_map<std::string, std::set<int>> possibleFutureConnections;
548 std::size_t current_report_step = 0;
553 std::shared_ptr<SimulatorUpdate> simUpdateFromPython{};
555 void init_completed_cells_lgr(
const EclipseGrid& ecl_grid);
556 void init_completed_cells_lgr_map(
const EclipseGrid& ecl_grid);
562 void addWell(
Well well);
563 void addWell(
const std::string& wellName,
564 const std::string& group,
567 Phase preferredPhase,
568 const std::optional<double>& refDepth,
569 double drainageRadius,
571 bool automaticShutIn,
573 WellGasInflowEquation gas_inflow,
574 std::size_t timeStep,
575 ConnectionOrder wellConnectionOrder);
576 bool updateWPAVE(
const std::string& wname, std::size_t report_step,
const PAvg& pavg);
578 void updateGuideRateModel(
const GuideRateModel& new_model, std::size_t report_step);
579 GTNode groupTree(
const std::string& root_node, std::size_t report_step, std::size_t level,
const std::optional<std::string>& parent_name)
const;
580 bool updateWellStatus(
const std::string& well, std::size_t reportStep, WellStatus status, std::optional<KeywordLocation> = {});
581 void addWellToGroup(
const std::string& group_name,
const std::string& well_name , std::size_t timeStep);
582 void iterateScheduleSection(std::size_t load_start,
583 std::size_t load_end,
587 const std::unordered_map<std::string, double> * target_wellpi,
588 const std::string& prefix,
589 const bool keepKeywords,
590 const bool log_to_debug =
false);
592 void addGroupToGroup(
const std::string& parent_group,
const std::string& child_group);
593 void addGroup(
const std::string& groupName , std::size_t timeStep);
594 void addGroup(
Group group);
596 void addWell(
const std::string& wellName,
const DeckRecord& record,
597 std::size_t timeStep, ConnectionOrder connection_order);
598 void checkIfAllConnectionsIsShut(std::size_t reportStep);
599 void end_report(std::size_t report_step);
602 void handleKeyword(std::size_t currentStep,
611 const std::unordered_map<std::string, double>* target_wellpi,
612 std::unordered_map<std::string, double>& wpimult_global_factor,
614 std::set<std::string>* compsegs_wells =
nullptr,
615 std::set<std::string>* comptraj_wells =
nullptr);
617 void internalWELLSTATUSACTIONXFromPYACTION(
const std::string& well_name, std::size_t report_step,
const std::string& wellStatus);
621 std::vector<std::string> wellNames(
const std::string& pattern,
623 bool allowEmpty =
false);
624 static std::string formatDate(std::time_t t);
625 void applyGlobalWPIMULT(
const std::unordered_map<std::string, double>& wpimult_global_factor);
626 void updateICDScalingFactors();
628 bool must_write_rst_file(std::size_t report_step)
const;
630 bool isWList(std::size_t report_step,
const std::string& pattern)
const;
632 SimulatorUpdate applyAction(std::size_t reportStep,
const std::string& action_name,
const std::vector<std::string>& matching_wells);
Collection of all user-defined quantities in the current simulation run.
Definition: UDQConfig.hpp:68
Definition: GuideRateModel.hpp:30
Definition: Python.hpp:35
Container of matching entities.
Definition: ActionResult.hpp:172
std::vector< std::string > changed_wells(std::size_t reportStep, std::size_t initialStep=0) const
List of wells with structural changes since previous report step.
Definition: Schedule.cpp:1263
void markSlaveProductionGroup(std::size_t report_step, const std::string &group_name)
Mark a slave group as receiving production targets from the master.
Definition: Schedule.cpp:3080
This struct is used to communicate back from the Schedule::applyAction() what needs to be updated in ...
Definition: SimulatorUpdate.hpp:35
Definition: Schedule.hpp:102
Sparse collection of cells, and their properties, intersected by one or more well connections...
Definition: CompletedCells.hpp:35
All SCHEDULE section keywords in a simulation run.
Definition: ScheduleDeck.hpp:55
Definition: FieldPropsManager.hpp:42
const std::vector< std::string > & groupNames() const
Retrieve names of all groups in model.
Definition: Schedule.cpp:1519
Definition: ScheduleBlock.hpp:51
About cell information and dimension: The actual grid information is held in a pointer to an ERT ecl_...
Definition: EclipseGrid.hpp:63
Runspec m_runspec
Run's descriptive meta information (RUNSPEC section).
Definition: ScheduleStatic.hpp:71
Management information about the current run's ACTION system, especially concerning the number of tim...
Definition: State.hpp:50
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:30
bool hasGroup(const std::string &groupName, std::size_t timeStep) const
Query for group existence at particular time.
Definition: Schedule.cpp:1255
Collection of intersected cells and associate properties for all simulation grids, i.e., the main grid and all LGRs in the simulation run.
Definition: ScheduleGrid.hpp:49
Definition: Runspec.hpp:608
Definition: GrupSlav.cpp:69
Gas lift optimisation parameters for all wells and groups.
Definition: GasLiftOpt.hpp:355
Definition: EclipseState.hpp:66
Definition: WGNames.hpp:29
Initial state of Schedule object created from information in SOLUTION section.
Definition: ScheduleStatic.hpp:49
bool changedWellLists(std::size_t reportStep, std::size_t initialStep=0) const
Well lists change predicate.
Definition: Schedule.cpp:1293
Definition: PyAction.hpp:39
Definition: TracerConfig.hpp:34
Definition: WriteRestartFileEvents.hpp:30
void markSlaveInjectionGroup(std::size_t report_step, const std::string &group_name)
Mark a slave group as receiving injection targets from the master.
Definition: Schedule.cpp:3090
UnitSystem m_unit_system
Run's input/output unit system conventions.
Definition: ScheduleStatic.hpp:68
Definition: ActionX.hpp:71
Definition: UnitSystem.hpp:34
Definition: SummaryState.hpp:72
Control parser behaviour in failure conditions.
Definition: ParseContext.hpp:114
Definition: ScheduleState.hpp:108
void clearEvents(const std::size_t report_step)
Clear out all registered events at a given report step.
Definition: Schedule.cpp:1069
Definition: Aquancon.hpp:40
const std::optional< RPTConfig > & initialReportConfiguration() const
Retrieve initial report configuration object.
Definition: Schedule.cpp:2730
bool isSerializing() const
Returns true if we are currently doing a serialization operation.
Definition: Serializer.hpp:208
Definition: NumericalAquifers.hpp:36
Definition: DeckRecord.hpp:33
Class for (de-)serializing.
Definition: Serializer.hpp:95
Definition: WelSegsSet.hpp:33
Definition: GTNode.hpp:33
Definition: HandlerContext.hpp:54
Definition: DeckKeyword.hpp:38
Definition: ErrorGuard.hpp:30
std::vector< const Group * > restart_groups(std::size_t timeStep) const
Retrieve collection of group objects suiteable for restart file output.
Definition: Schedule.cpp:1524