GroupEconomicLimitsChecker.hpp
Go to the documentation of this file.
1/*
2 Copyright 2023 Equinor ASA.
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_GROUP_ECONOMIC_LIMITS_CHECKER_HEADER_INCLUDED
21#define OPM_GROUP_ECONOMIC_LIMITS_CHECKER_HEADER_INCLUDED
22
23#include <opm/input/eclipse/Schedule/Group/GroupEconProductionLimits.hpp>
24#include <opm/input/eclipse/Units/UnitSystem.hpp>
25
26#include <array>
27#include <map>
28#include <optional>
29#include <string>
30#include <vector>
31
32namespace Opm
33{
34
35template<typename Scalar, typename IndexTraits> class BlackoilWellModelGeneric;
36class DeferredLogger;
37class Group;
38template<typename Scalar, typename IndexTraits> class WellState;
39class WellTestState;
40
41template<typename Scalar, typename IndexTraits>
43{
44public:
45 enum class RatioViolation {
46 NONE,
47 WATER_CUT,
48 GOR,
49 WGR
50 };
51
53 {
55 std::string ratio_type;
56 Scalar ratio;
57 Scalar limit;
58 UnitSystem::measure measure;
59 };
60
62 WellTestState& well_test_state,
63 const Group& group,
64 const double simulation_time,
65 const int report_step_idx,
66 DeferredLogger& deferred_logger);
67 void closeWells();
68 bool minGasRate();
69 bool minOilRate();
70 std::optional<RatioDetails> waterCut();
71 std::optional<RatioDetails> GOR();
72 std::optional<RatioDetails> WGR();
73 std::optional<RatioDetails> ratioViolation();
74 void doWorkOver(const RatioDetails& ratio_details);
75 bool endRun();
79 std::string message_separator(const char sep_char = '*',
80 const size_t sep_length = 110) const
81 { return std::string(sep_length, sep_char); }
82
83 static constexpr int NUM_PHASES = 3;
84
85private:
86 void displayDebugMessage(const std::string& msg) const;
87 void addPrintMessage(const std::string& msg,
88 const Scalar value,
89 const Scalar limit,
90 const UnitSystem::measure measure);
91 bool closeWellsRecursive(const Group& group, int level = 0);
92 void throwNotImplementedError(const std::string& error) const;
93
95 void collectProducerWells(const Group& group,
96 std::vector<std::string>& well_names) const;
97
101 std::optional<Scalar> computeWellRatio(const std::string& well_name,
102 const RatioViolation ratio_violation) const;
103
107 void closeWorstOffendingRatioWell(const RatioDetails& ratio_details);
108
109 std::optional<RatioDetails> groupRatioDetails(const RatioViolation ratio_violation) const;
110
112 const Group& group_;
113 const double simulation_time_;
114 const int report_step_idx_;
115 DeferredLogger& deferred_logger_;
116 const std::string date_string_;
117 const UnitSystem& unit_system_;
118 const WellState<Scalar, IndexTraits>& well_state_;
119 WellTestState& well_test_state_;
120 const Schedule& schedule_;
121 GroupEconProductionLimits::GEconGroupProp gecon_props_;
122 bool debug_ = true;
123 std::array<Scalar,NUM_PHASES> production_rates_;
124 std::map<int, unsigned> phase_idx_map_ = {
125 {0, IndexTraits::oilPhaseIdx},
126 {1, IndexTraits::gasPhaseIdx},
127 {2, IndexTraits::waterPhaseIdx}
128 };
129 std::map<unsigned, int> phase_idx_reverse_map_;
130 std::string message_;
131};
132
133} // namespace Opm
134
135#endif // OPM_GROUP_ECONOMIC_LIMITS_CHECKER_HEADER_INCLUDED
Definition: DeferredLogger.hpp:57
Definition: GroupEconomicLimitsChecker.hpp:43
GroupEconomicLimitsChecker(const BlackoilWellModelGeneric< Scalar, IndexTraits > &well_model, WellTestState &well_test_state, const Group &group, const double simulation_time, const int report_step_idx, DeferredLogger &deferred_logger)
std::optional< RatioDetails > WGR()
std::string message_separator(const char sep_char=' *', const size_t sep_length=110) const
Definition: GroupEconomicLimitsChecker.hpp:79
std::optional< RatioDetails > waterCut()
RatioViolation
Definition: GroupEconomicLimitsChecker.hpp:45
void doWorkOver(const RatioDetails &ratio_details)
std::optional< RatioDetails > ratioViolation()
static constexpr int NUM_PHASES
Definition: GroupEconomicLimitsChecker.hpp:83
std::optional< RatioDetails > GOR()
Definition: WellState.hpp:66
Definition: blackoilbioeffectsmodules.hh:45
Definition: GroupEconomicLimitsChecker.hpp:53
std::string ratio_type
Definition: GroupEconomicLimitsChecker.hpp:55
RatioViolation violation
Definition: GroupEconomicLimitsChecker.hpp:54
Scalar limit
Definition: GroupEconomicLimitsChecker.hpp:57
UnitSystem::measure measure
Definition: GroupEconomicLimitsChecker.hpp:58
Scalar ratio
Definition: GroupEconomicLimitsChecker.hpp:56