Loading...
Searching...
No Matches
WCYCLE.hpp
/*
Copyright 2023 Equinor.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef OPM_WCYCLE_HPP
#define OPM_WCYCLE_HPP
#include <functional>
#include <map>
#include <unordered_map>
#include <string>
#include <vector>
namespace Opm {
class DeckRecord;
class WellMatcher;
class WCYCLE
{
public:
using WellEfficiencyVec = std::vector<std::pair<std::string, double>>;
using WellTimeMap = std::map<std::string, double>;
using WellIsOpenMap = std::map<std::string, bool>;
struct Entry
{
double on_time{};
double off_time{};
double startup_time{};
double max_time_step{};
bool controlled_time_step{false};
template<class Serializer>
void serializeOp(Serializer& serializer)
{
serializer(on_time);
serializer(off_time);
serializer(startup_time);
serializer(max_time_step);
serializer(controlled_time_step);
}
bool operator==(const Entry& entry) const;
};
void addRecord(const DeckRecord& record);
template<class Serializer>
void serializeOp(Serializer& serializer)
{
serializer(entries_);
}
static WCYCLE serializationTestObject();
bool empty() const { return entries_.empty(); }
auto begin() const { return entries_.begin(); }
auto end() const { return entries_.end(); }
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;
WellIsOpenMap wellStatus(const double current_time,
const WellMatcher& wmatch,
WellTimeMap& open_times,
WellTimeMap& close_times) const;
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;
bool operator==(const WCYCLE& that) const;
private:
std::unordered_map<std::string, Entry> entries_;
};
} // namespace Opm
#endif // OPM_WCYCLE_HPP
Opm::DeckRecord
Definition DeckRecord.hpp:32
Opm::Serializer
Class for (de-)serializing.
Definition Serializer.hpp:94
Opm::WCYCLE
Definition WCYCLE.hpp:35
Opm::WCYCLE::WellIsOpenMap
std::map< std::string, bool > WellIsOpenMap
A vector of wells and their open status.
Definition WCYCLE.hpp:42
Opm::WCYCLE::empty
bool empty() const
Returns true if \this has no entries.
Definition WCYCLE.hpp:84
Opm::WCYCLE::begin
auto begin() const
Returns an iterator to first entry.
Definition WCYCLE.hpp:87
Opm::WCYCLE::nextTimeStep
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
Opm::WCYCLE::end
auto end() const
Returns an iterator to one past the last entry.
Definition WCYCLE.hpp:89
Opm::WCYCLE::serializationTestObject
static WCYCLE serializationTestObject()
Create non-defaulted object suitable for testing the serialisation operation.
Definition WCYCLE.cpp:35
Opm::WCYCLE::efficiencyScale
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
Opm::WCYCLE::serializeOp
void serializeOp(Serializer &serializer)
Convert between byte array and object representation.
Definition WCYCLE.hpp:74
Opm::WCYCLE::addRecord
void addRecord(const DeckRecord &record)
Parse a record for a WCYCLE keyword.
Definition WCYCLE.cpp:54
Opm::WCYCLE::WellTimeMap
std::map< std::string, double > WellTimeMap
A map from well name to a time stamp.
Definition WCYCLE.hpp:40
Opm::WCYCLE::operator==
bool operator==(const WCYCLE &that) const
Equality predicate.
Definition WCYCLE.cpp:66
Opm::WCYCLE::wellStatus
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
Opm::WCYCLE::WellEfficiencyVec
std::vector< std::pair< std::string, double > > WellEfficiencyVec
A vector of wells and efficiency factor scalings to apply.
Definition WCYCLE.hpp:38
Opm
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30
Opm::WCYCLE::Entry
Represents a single record in a WCYCLE keyword.
Definition WCYCLE.hpp:46
Opm::WCYCLE::Entry::off_time
double off_time
Length of well closed period.
Definition WCYCLE.hpp:48
Opm::WCYCLE::Entry::startup_time
double startup_time
Time interval to scale up well efficiency factor.
Definition WCYCLE.hpp:49
Opm::WCYCLE::Entry::serializeOp
void serializeOp(Serializer &serializer)
Convert between byte array and object representation.
Definition WCYCLE.hpp:55
Opm::WCYCLE::Entry::max_time_step
double max_time_step
Maximum time step when a cycling well opens.
Definition WCYCLE.hpp:50
Opm::WCYCLE::Entry::controlled_time_step
bool controlled_time_step
Whether or not to.
Definition WCYCLE.hpp:51
Opm::WCYCLE::Entry::on_time
double on_time
Length of well open period.
Definition WCYCLE.hpp:47
Opm::WCYCLE::Entry::operator==
bool operator==(const Entry &entry) const
Equality predicate.
Definition WCYCLE.cpp:45