31 #include <unordered_map> 35 #include <opm/input/eclipse/Schedule/Action/ActionResult.hpp> 36 #include <opm/input/eclipse/Schedule/Action/SimulatorUpdate.hpp> 37 #include <opm/input/eclipse/Schedule/Action/WGNames.hpp> 38 #include <opm/input/eclipse/Schedule/CompletedCells.hpp> 39 #include <opm/input/eclipse/Schedule/Group/Group.hpp> 40 #include <opm/input/eclipse/Schedule/ScheduleDeck.hpp> 41 #include <opm/input/eclipse/Schedule/ScheduleState.hpp> 42 #include <opm/input/eclipse/Schedule/ScheduleStatic.hpp> 43 #include <opm/input/eclipse/Schedule/Well/PAvg.hpp> 44 #include <opm/input/eclipse/Schedule/Well/Well.hpp> 45 #include <opm/input/eclipse/Schedule/Well/Connection.hpp> 46 #include <opm/input/eclipse/Schedule/WriteRestartFileEvents.hpp> 47 #include <opm/input/eclipse/Units/UnitSystem.hpp> 50 class ActiveGridCells;
54 enum class ConnectionOrder;
58 class FieldPropsManager;
61 class GuideRateConfig;
64 enum class InputErrorAction;
65 class NumericalAquifers;
71 class SCHEDULESection;
77 enum class WellGasInflowEquation : std::uint8_t;
79 enum class WellProducerCMode : std::uint16_t;
80 enum class WellStatus : std::uint8_t;
105 explicit Schedule(std::shared_ptr<const Python> python_handle);
130 std::shared_ptr<const Python> python,
131 const bool lowActionParsingStrictness =
false,
132 const bool slave_mode =
false,
133 const bool keepKeywords =
true,
134 const std::optional<int>& output_interval = {},
146 std::shared_ptr<const Python> python,
147 const bool lowActionParsingStrictness =
false,
148 const bool slave_mode =
false,
149 const bool keepKeywords =
true,
150 const std::optional<int>& output_interval = {},
159 std::shared_ptr<const Python> python,
160 const bool lowActionParsingStrictness =
false,
161 const bool slave_mode =
false,
162 const bool keepKeywords =
true,
163 const std::optional<int>& output_interval = {},
171 std::shared_ptr<const Python> python,
172 const bool lowActionParsingStrictness =
false,
173 const bool slave_mode =
false,
174 const bool keepKeywords =
true,
175 const std::optional<int>& output_interval = {},
178 template <
typename T>
183 std::shared_ptr<const Python> python,
184 const bool lowActionParsingStrictness =
false,
185 const bool slave_mode =
false,
186 const bool keepKeywords =
true,
187 const std::optional<int>& output_interval = {},
192 std::shared_ptr<const Python> python,
193 const bool lowActionParsingStrictness =
false,
194 const bool slave_mode =
false,
195 const bool keepKeywords =
true,
196 const std::optional<int>& output_interval = {},
202 const std::optional<int>& output_interval = {},
207 static Schedule serializationTestObject();
213 std::time_t getStartTime()
const;
214 std::time_t posixStartTime()
const;
215 std::time_t posixEndTime()
const;
216 std::time_t simTime(std::size_t timeStep)
const;
217 double seconds(std::size_t timeStep)
const;
218 double stepLength(std::size_t timeStep)
const;
219 std::optional<int> exitStatus()
const;
223 std::size_t numWells()
const;
224 std::size_t numWells(std::size_t timestep)
const;
225 bool hasWell(
const std::string& wellName)
const;
226 bool hasWell(
const std::string& wellName, std::size_t timeStep)
const;
228 WellMatcher wellMatcher(std::size_t report_step)
const;
229 std::function<std::unique_ptr<SegmentMatcher>()> segmentMatcherFactory(std::size_t report_step)
const;
230 std::vector<std::string> wellNames(
const std::string& pattern, std::size_t timeStep,
const std::vector<std::string>& matching_wells = {})
const;
231 std::vector<std::string> wellNames(
const std::string& pattern)
const;
232 std::vector<std::string> wellNames(std::size_t timeStep)
const;
233 std::vector<std::string> wellNames()
const;
242 bool hasGroup(
const std::string& groupName, std::size_t timeStep)
const;
255 std::vector<std::string>
256 groupNames(
const std::string& pattern, std::size_t timeStep)
const;
264 const std::vector<std::string>&
groupNames(std::size_t timeStep)
const;
274 std::vector<std::string>
groupNames(
const std::string& pattern)
const;
279 const std::vector<std::string>&
groupNames()
const;
291 std::vector<const Group*>
restart_groups(std::size_t timeStep)
const;
309 std::vector<std::string>
311 std::size_t initialStep = 0)
const;
331 std::size_t initialStep = 0)
const;
333 const Well& getWell(std::size_t well_index, std::size_t timeStep)
const;
334 const Well& getWell(
const std::string& wellName, std::size_t timeStep)
const;
335 const Well& getWellatEnd(
const std::string& well_name)
const;
337 std::unordered_set<int> getAquiferFluxSchedule()
const;
338 std::vector<Well> getWells(std::size_t timeStep)
const;
339 std::vector<Well> getWellsatEnd()
const;
342 std::vector<Well> getActiveWellsAtEnd()
const;
345 std::vector<std::string> getInactiveWellNamesAtEnd()
const;
347 const std::unordered_map<std::string, std::set<int>>&
348 getPossibleFutureConnections()
const;
350 void shut_well(
const std::string& well_name, std::size_t report_step);
351 void shut_well(
const std::string& well_name);
352 void stop_well(
const std::string& well_name, std::size_t report_step);
353 void stop_well(
const std::string& well_name);
354 void open_well(
const std::string& well_name, std::size_t report_step);
355 void open_well(
const std::string& well_name);
356 void clear_event(ScheduleEvents::Events, std::size_t report_step);
357 void add_event(ScheduleEvents::Events, std::size_t report_step);
358 void applyWellProdIndexScaling(
const std::string& well_name,
const std::size_t reportStep,
const double scalingFactor);
363 WellProducerCMode getGlobalWhistctlMmode(std::size_t timestep)
const;
365 const UDQConfig& getUDQConfig(std::size_t timeStep)
const;
367 GTNode groupTree(std::size_t report_step)
const;
368 GTNode groupTree(
const std::string& root_node, std::size_t report_step)
const;
369 const Group& getGroup(
const std::string& groupName, std::size_t timeStep)
const;
371 std::optional<std::size_t> first_RFT()
const;
372 std::size_t size()
const;
374 bool write_rst_file(std::size_t report_step)
const;
375 const std::map< std::string, int >& rst_keywords(
size_t timestep )
const;
385 const std::unordered_map<std::string, double>& wellpi,
386 const bool iterateSchedule);
391 const std::unordered_map<std::string, float>& wellpi,
392 const bool iterateSchedule);
411 const std::unordered_map<std::string, double>& target_wellpi);
418 const std::unordered_map<std::string, float>& target_wellpi);
421 const std::map<std::string, std::vector<Connection>>& extraConns);
423 const GasLiftOpt& glo(std::size_t report_step)
const;
425 bool operator==(
const Schedule& data)
const;
426 std::shared_ptr<const Python> python()
const;
438 std::vector<ScheduleState>::const_iterator begin()
const;
439 std::vector<ScheduleState>::const_iterator end()
const;
440 void create_next(
const time_point& start_time,
const std::optional<time_point>& end_time);
442 void create_first(
const time_point& start_time,
const std::optional<time_point>& end_time);
444 void treat_critical_as_non_critical(
bool value) { this->m_treat_critical_as_non_critical =
value; }
452 static bool cmp(
const Schedule& sched1,
const Schedule& sched2, std::size_t report_step);
453 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);
454 void applyKeywords(std::vector<std::unique_ptr<DeckKeyword>>& keywords, std::unordered_map<std::string, double>& target_wellpi,
bool action_mode);
456 template<
class Serializer>
459 serializer(this->m_static);
460 serializer(this->m_sched_deck);
461 serializer(this->action_wgnames);
462 serializer(this->potential_wellopen_patterns);
463 serializer(this->exit_status);
464 serializer(this->snapshots);
465 serializer(this->restart_output);
466 serializer(this->completed_cells);
467 serializer(this->completed_cells_lgr);
468 serializer(this->completed_cells_lgr_map);
469 serializer(this->m_treat_critical_as_non_critical);
470 serializer(this->current_report_step);
471 serializer(this->m_lowActionParsingStrictness);
472 serializer(this->simUpdateFromPython);
481 for (
auto& snapshot : snapshots) {
482 for (
auto& well : snapshot.wells) {
489 template <
typename T>
490 std::vector<std::pair<std::size_t, T>> unique()
const 492 std::vector<std::pair<std::size_t, T>> values;
493 for (std::size_t index = 0; index < this->snapshots.size(); index++) {
494 const auto& member = this->snapshots[index].get<T>();
495 const auto&
value = member.get();
496 if (values.empty() || !(
value == values.back().second))
497 values.push_back( std::make_pair(index,
value));
502 friend std::ostream& operator<<(std::ostream& os,
const Schedule& sched);
503 void dump_deck(std::ostream& os)
const;
513 bool m_treat_critical_as_non_critical =
false;
517 std::unordered_set<std::string> potential_wellopen_patterns{};
518 std::optional<int> exit_status{};
519 std::vector<ScheduleState> snapshots{};
522 std::vector<CompletedCells> completed_cells_lgr{};
523 std::unordered_map<std::string, std::size_t> completed_cells_lgr_map;
528 bool m_lowActionParsingStrictness =
false;
533 std::unordered_map<std::string, std::set<int>> possibleFutureConnections;
538 std::size_t current_report_step = 0;
543 std::shared_ptr<SimulatorUpdate> simUpdateFromPython{};
545 void init_completed_cells_lgr(
const EclipseGrid& ecl_grid);
546 void init_completed_cells_lgr_map(
const EclipseGrid& ecl_grid);
552 void addWell(
Well well);
553 void addWell(
const std::string& wellName,
554 const std::string& group,
557 Phase preferredPhase,
558 const std::optional<double>& refDepth,
559 double drainageRadius,
561 bool automaticShutIn,
563 WellGasInflowEquation gas_inflow,
564 std::size_t timeStep,
565 ConnectionOrder wellConnectionOrder);
566 bool updateWPAVE(
const std::string& wname, std::size_t report_step,
const PAvg& pavg);
568 void updateGuideRateModel(
const GuideRateModel& new_model, std::size_t report_step);
569 GTNode groupTree(
const std::string& root_node, std::size_t report_step, std::size_t level,
const std::optional<std::string>& parent_name)
const;
570 bool updateWellStatus(
const std::string& well, std::size_t reportStep, WellStatus status, std::optional<KeywordLocation> = {});
571 void addWellToGroup(
const std::string& group_name,
const std::string& well_name , std::size_t timeStep);
572 void iterateScheduleSection(std::size_t load_start,
573 std::size_t load_end,
577 const std::unordered_map<std::string, double> * target_wellpi,
578 const std::string& prefix,
579 const bool keepKeywords,
580 const bool log_to_debug =
false);
582 void addGroupToGroup(
const std::string& parent_group,
const std::string& child_group);
583 void addGroup(
const std::string& groupName , std::size_t timeStep);
584 void addGroup(
Group group);
586 void addWell(
const std::string& wellName,
const DeckRecord& record,
587 std::size_t timeStep, ConnectionOrder connection_order);
588 void checkIfAllConnectionsIsShut(std::size_t reportStep);
589 void end_report(std::size_t report_step);
592 void handleKeyword(std::size_t currentStep,
601 const std::unordered_map<std::string, double>* target_wellpi,
602 std::unordered_map<std::string, double>& wpimult_global_factor,
604 std::set<std::string>* compsegs_wells =
nullptr,
605 std::set<std::string>* comptraj_wells =
nullptr);
607 void internalWELLSTATUSACTIONXFromPYACTION(
const std::string& well_name, std::size_t report_step,
const std::string& wellStatus);
611 std::vector<std::string> wellNames(
const std::string& pattern,
613 bool allowEmpty =
false);
614 static std::string formatDate(std::time_t t);
615 void applyGlobalWPIMULT(
const std::unordered_map<std::string, double>& wpimult_global_factor);
616 void updateICDScalingFactors();
618 bool must_write_rst_file(std::size_t report_step)
const;
620 bool isWList(std::size_t report_step,
const std::string& pattern)
const;
622 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:1260
This struct is used to communicate back from the Schedule::applyAction() what needs to be updated in ...
Definition: SimulatorUpdate.hpp:32
Definition: Schedule.hpp:100
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:1516
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:62
Runspec m_runspec
Run's descriptive meta information (RUNSPEC section).
Definition: ScheduleStatic.hpp:69
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:1252
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:47
bool changedWellLists(std::size_t reportStep, std::size_t initialStep=0) const
Well lists change predicate.
Definition: Schedule.cpp:1290
Definition: PyAction.hpp:39
Definition: TracerConfig.hpp:33
Definition: WriteRestartFileEvents.hpp:30
UnitSystem m_unit_system
Run's input/output unit system conventions.
Definition: ScheduleStatic.hpp:66
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:106
void clearEvents(const std::size_t report_step)
Clear out all registered events at a given report step.
Definition: Schedule.cpp:1067
Definition: Aquancon.hpp:40
const std::optional< RPTConfig > & initialReportConfiguration() const
Retrieve initial report configuration object.
Definition: Schedule.cpp:2725
bool isSerializing() const
Returns true if we are currently doing a serialization operation.
Definition: Serializer.hpp:207
Definition: NumericalAquifers.hpp:38
Definition: DeckRecord.hpp:32
Class for (de-)serializing.
Definition: Serializer.hpp:94
Definition: WelSegsSet.hpp:33
Definition: GTNode.hpp:33
Definition: HandlerContext.hpp:54
Definition: DeckKeyword.hpp:36
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:1521