My Project
Loading...
Searching...
No Matches
WCYCLE.hpp
1/*
2 Copyright 2023 Equinor.
3
4 This file is part of the Open Porous Media project (OPM).
5
6 OPM is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 OPM is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with OPM. If not, see <http://www.gnu.org/licenses/>.
18*/
19
20#ifndef OPM_WCYCLE_HPP
21#define OPM_WCYCLE_HPP
22
23#include <functional>
24#include <map>
25#include <unordered_map>
26#include <string>
27#include <vector>
28
29namespace Opm {
30
31class DeckRecord;
32class WellMatcher;
33
34class WCYCLE
35{
36public:
38 using WellEfficiencyVec = std::vector<std::pair<std::string, double>>;
40 using WellTimeMap = std::map<std::string, double>;
42 using WellIsOpenMap = std::map<std::string, bool>;
43
45 struct Entry
46 {
47 double on_time{};
48 double off_time{};
49 double startup_time{};
50 double max_time_step{};
52
54 template<class Serializer>
55 void serializeOp(Serializer& serializer)
56 {
57 serializer(on_time);
58 serializer(off_time);
59 serializer(startup_time);
60 serializer(max_time_step);
61 serializer(controlled_time_step);
62 }
63
65 bool operator==(const Entry& entry) const;
66 };
67
70 void addRecord(const DeckRecord& record);
71
73 template<class Serializer>
74 void serializeOp(Serializer& serializer)
75 {
76 serializer(entries_);
77 }
78
82
84 bool empty() const { return entries_.empty(); }
85
87 auto begin() const { return entries_.begin(); }
89 auto end() const { return entries_.end(); }
90
107 double nextTimeStep(const double current_time,
108 const double dt,
109 const WellMatcher& wmatch,
110 const WellTimeMap& open_times,
111 const WellTimeMap& close_times,
112 std::function<bool(const std::string&)> opens_this_step) const;
113
120 WellIsOpenMap wellStatus(const double current_time,
121 const WellMatcher& wmatch,
122 WellTimeMap& open_times,
123 WellTimeMap& close_times) const;
124
131 WellEfficiencyVec efficiencyScale(const double current_time,
132 const double dt,
133 const WellMatcher& wmatch,
134 const WellTimeMap& open_times,
135 std::function<bool(const std::string&)> schedule_open) const;
136
138 bool operator==(const WCYCLE& that) const;
139
140private:
141 std::unordered_map<std::string, Entry> entries_;
142};
143
144} // namespace Opm
145
146#endif // OPM_WCYCLE_HPP
Definition DeckRecord.hpp:32
Class for (de-)serializing.
Definition Serializer.hpp:94
Definition WCYCLE.hpp:35
std::map< std::string, bool > WellIsOpenMap
A vector of wells and their open status.
Definition WCYCLE.hpp:42
bool empty() const
Returns true if \this has no entries.
Definition WCYCLE.hpp:84
auto begin() const
Returns an iterator to first entry.
Definition WCYCLE.hpp:87
double nextTimeStep(const double current_time, const double dt, const WellMatcher &wmatch, const WellTimeMap &open_times, const WellTimeMap &close_times, std::function< bool(const std::string &)> opens_this_step) const
Returns a time step adjusted according to cycling wells.
Definition WCYCLE.cpp:71
std::vector< std::pair< std::string, double > > WellEfficiencyVec
A vector of wells and efficiency factor scalings to apply.
Definition WCYCLE.hpp:38
auto end() const
Returns an iterator to one past the last entry.
Definition WCYCLE.hpp:89
static WCYCLE serializationTestObject()
Create non-defaulted object suitable for testing the serialisation operation.
Definition WCYCLE.cpp:35
WellEfficiencyVec efficiencyScale(const double current_time, const double dt, const WellMatcher &wmatch, const WellTimeMap &open_times, std::function< bool(const std::string &)> schedule_open) const
Returns efficiency factor scaling factors for cycling wells.
Definition WCYCLE.cpp:178
void serializeOp(Serializer &serializer)
Convert between byte array and object representation.
Definition WCYCLE.hpp:74
void addRecord(const DeckRecord &record)
Parse a record for a WCYCLE keyword.
Definition WCYCLE.cpp:54
std::map< std::string, double > WellTimeMap
A map from well name to a time stamp.
Definition WCYCLE.hpp:40
bool operator==(const WCYCLE &that) const
Equality predicate.
Definition WCYCLE.cpp:66
WellIsOpenMap wellStatus(const double current_time, const WellMatcher &wmatch, WellTimeMap &open_times, WellTimeMap &close_times) const
Returns status (open/shut) for cycling wells.
Definition WCYCLE.cpp:129
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30
Represents a single record in a WCYCLE keyword.
Definition WCYCLE.hpp:46
double off_time
Length of well closed period.
Definition WCYCLE.hpp:48
double startup_time
Time interval to scale up well efficiency factor.
Definition WCYCLE.hpp:49
void serializeOp(Serializer &serializer)
Convert between byte array and object representation.
Definition WCYCLE.hpp:55
double max_time_step
Maximum time step when a cycling well opens.
Definition WCYCLE.hpp:50
bool controlled_time_step
Whether or not to.
Definition WCYCLE.hpp:51
double on_time
Length of well open period.
Definition WCYCLE.hpp:47
bool operator==(const Entry &entry) const
Equality predicate.
Definition WCYCLE.cpp:45