WellTest.hpp
Go to the documentation of this file.
1/*
2 Copyright 2017 SINTEF Digital, Mathematics and Cybernetics.
3 Copyright 2017 Statoil ASA.
4 Copyright 2017 IRIS
5 Copyright 2019 Norce
6
7 This file is part of the Open Porous Media project (OPM).
8
9 OPM is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13
14 OPM is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with OPM. If not, see <http://www.gnu.org/licenses/>.
21*/
22
23
24#ifndef OPM_WELL_TEST_HEADER_INCLUDED
25#define OPM_WELL_TEST_HEADER_INCLUDED
26
27#include <opm/input/eclipse/Units/UnitSystem.hpp>
28
29#include <cstddef>
30#include <ctime>
31#include <limits>
32#include <string>
33#include <string_view>
34#include <unordered_set>
35#include <vector>
36
37namespace Opm
38{
39
40class DeferredLogger;
41template<typename Scalar, typename IndexTraits> class SingleWellState;
42class UnitSystem;
43class WellEconProductionLimits;
44template<typename Scalar, typename IndexTraits> class WellInterfaceGeneric;
45class WellTestState;
46
48template<typename Scalar, typename IndexTraits>
49class WellTest {
50public:
52 explicit WellTest(const WellInterfaceGeneric<Scalar, IndexTraits>& well) : well_(well) {}
53
71 const double simulation_time,
72 const bool write_message_to_opmlog,
73 const bool during_well_test,
74 WellTestState& well_test_state,
75 bool zero_group_target,
76 const UnitSystem& unit_system,
77 const std::time_t start_time,
78 DeferredLogger& deferred_logger,
79 std::string* closure_reason = nullptr) const;
80
82 const double simulation_time,
83 const bool write_message_to_opmlog,
84 WellTestState& well_test_state,
85 const UnitSystem& unit_system,
86 const std::time_t start_time,
87 DeferredLogger& deferred_logger) const;
88
89 void updateWellTestStatePhysical(const double simulation_time,
90 const bool write_message_to_opmlog,
91 WellTestState& well_test_state,
92 DeferredLogger& deferred_logger) const;
93
94private:
95 struct RatioLimitCheckReport {
96 static constexpr int INVALIDCOMPLETION = std::numeric_limits<int>::max();
101 static constexpr Scalar INFINITE_RATIO = std::numeric_limits<Scalar>::infinity();
102 bool ratio_limit_violated = false;
103 int worst_offending_completion = INVALIDCOMPLETION;
104 Scalar violation_extent = 0.0;
107 std::string ratio_name{};
108 UnitSystem::measure ratio_measure = UnitSystem::measure::identity;
109 Scalar ratio_value = 0.0;
110 Scalar ratio_limit = 0.0;
111 };
112
114 struct RateLimitCheckReport {
117 std::string_view quantity_name{};
118 UnitSystem::measure rate_measure = UnitSystem::measure::identity;
121 Scalar rate_value = 0.0;
122 Scalar rate_limit = 0.0;
123 };
124
128 void reportEconomicLimitClosure(const std::string& when,
129 const std::string& reason,
130 const bool write_message_to_opmlog,
131 std::string* closure_reason,
132 DeferredLogger& deferred_logger) const;
133
139 static std::string rateViolationReason(const UnitSystem& unit_system,
140 const RateLimitCheckReport& report,
141 const bool on_potentials);
142
150 static std::string ratioViolationReason(const UnitSystem& unit_system,
151 std::string_view ratio_name,
152 const UnitSystem::measure ratio_measure,
153 const Scalar ratio_value,
154 const Scalar ratio_limit);
155
160 template<class RatioFunc>
161 void checkMaxRatioLimit(const SingleWellState<Scalar, IndexTraits>& ws,
162 const Scalar max_ratio_limit,
163 const RatioFunc& ratioFunc,
164 const std::unordered_set<int>& excluded_completions,
165 const std::string& ratio_name,
166 const UnitSystem::measure ratio_measure,
167 RatioLimitCheckReport& report) const;
168
186 template<class RatioFunc>
187 bool checkMaxRatioLimitWell(const SingleWellState<Scalar, IndexTraits>& ws,
188 const Scalar max_ratio_limit,
189 const RatioFunc& ratioFunc,
190 const std::unordered_set<int>& excluded_completions,
191 Scalar& well_ratio_value) const;
192
193 template<class RatioFunc>
194 void checkMaxRatioLimitCompletions(const SingleWellState<Scalar, IndexTraits>& ws,
195 const Scalar max_ratio_limit,
196 const Scalar well_ratio_value,
197 const RatioFunc& ratioFunc,
198 const std::unordered_set<int>& excluded_completions,
199 const std::string& ratio_name,
200 const UnitSystem::measure ratio_measure,
201 RatioLimitCheckReport& report) const;
202
210 bool checkRateEconLimits(const WellEconProductionLimits& econ_production_limits,
211 const std::vector<Scalar>& rates_or_potentials,
212 RateLimitCheckReport& report) const;
213
216 RatioLimitCheckReport
217 checkRatioEconLimits(const WellEconProductionLimits& econ_production_limits,
218 const SingleWellState<Scalar, IndexTraits>& ws,
219 const std::unordered_set<int>& excluded_completions,
220 DeferredLogger& deferred_logger) const;
221
225 std::string completionDescriptor(int complnum) const;
226
239 bool closeOffendingCompletion(int offending_completion,
240 bool close_connections_below,
241 double simulation_time,
242 bool write_message_to_opmlog,
243 WellTestState& well_test_state,
244 const std::string& when,
245 const std::string& reason,
246 std::string_view ratio_subject,
247 std::unordered_set<int>& closed_this_event,
248 DeferredLogger& deferred_logger) const;
249
250 const WellInterfaceGeneric<Scalar, IndexTraits>& well_;
251};
252
253}
254
255#endif // OPM_WELL_TEST_HEADER_INCLUDED
Definition: DeferredLogger.hpp:57
Definition: SingleWellState.hpp:44
Definition: WellInterfaceGeneric.hpp:56
Class for performing well tests.
Definition: WellTest.hpp:49
WellTest(const WellInterfaceGeneric< Scalar, IndexTraits > &well)
Constructor sets reference to well.
Definition: WellTest.hpp:52
void updateWellTestStatePhysical(const double simulation_time, const bool write_message_to_opmlog, WellTestState &well_test_state, DeferredLogger &deferred_logger) const
void updateWellTestStateEconomic(const SingleWellState< Scalar, IndexTraits > &ws, const double simulation_time, const bool write_message_to_opmlog, const bool during_well_test, WellTestState &well_test_state, bool zero_group_target, const UnitSystem &unit_system, const std::time_t start_time, DeferredLogger &deferred_logger, std::string *closure_reason=nullptr) const
void updateWellTestStateCECON(const SingleWellState< Scalar, IndexTraits > &ws, const double simulation_time, const bool write_message_to_opmlog, WellTestState &well_test_state, const UnitSystem &unit_system, const std::time_t start_time, DeferredLogger &deferred_logger) const
Definition: blackoilbioeffectsmodules.hh:45