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/common/utility/TimeService.hpp>
28
29#include <opm/input/eclipse/Units/UnitSystem.hpp>
30
31#include <cstddef>
32#include <limits>
33#include <string>
34#include <string_view>
35#include <unordered_set>
36#include <vector>
37
38namespace Opm
39{
40
41class DeferredLogger;
42template<typename Scalar, typename IndexTraits> class SingleWellState;
43class UnitSystem;
44class WellEconProductionLimits;
45template<typename Scalar, typename IndexTraits> class WellInterfaceGeneric;
46class WellTestState;
47
49template<typename Scalar, typename IndexTraits>
50class WellTest {
51public:
53 explicit WellTest(const WellInterfaceGeneric<Scalar, IndexTraits>& well) : well_(well) {}
54
72 const double simulation_time,
73 const bool write_message_to_opmlog,
74 const bool during_well_test,
75 WellTestState& well_test_state,
76 bool zero_group_target,
77 const UnitSystem& unit_system,
78 const time_point start_time,
79 DeferredLogger& deferred_logger,
80 std::string* closure_reason = nullptr) const;
81
83 const double simulation_time,
84 const bool write_message_to_opmlog,
85 WellTestState& well_test_state,
86 const UnitSystem& unit_system,
87 const time_point start_time,
88 DeferredLogger& deferred_logger) const;
89
90 void updateWellTestStatePhysical(const double simulation_time,
91 const bool write_message_to_opmlog,
92 WellTestState& well_test_state,
93 DeferredLogger& deferred_logger) const;
94
95private:
96 struct RatioLimitCheckReport {
97 static constexpr int INVALIDCOMPLETION = std::numeric_limits<int>::max();
102 static constexpr Scalar INFINITE_RATIO = std::numeric_limits<Scalar>::infinity();
103 bool ratio_limit_violated = false;
104 int worst_offending_completion = INVALIDCOMPLETION;
105 Scalar violation_extent = 0.0;
108 std::string ratio_name{};
109 UnitSystem::measure ratio_measure = UnitSystem::measure::identity;
110 Scalar ratio_value = 0.0;
111 Scalar ratio_limit = 0.0;
112 };
113
115 struct RateLimitCheckReport {
118 std::string_view quantity_name{};
119 UnitSystem::measure rate_measure = UnitSystem::measure::identity;
122 Scalar rate_value = 0.0;
123 Scalar rate_limit = 0.0;
124 };
125
129 void reportEconomicLimitClosure(const std::string& when,
130 const std::string& reason,
131 const bool write_message_to_opmlog,
132 std::string* closure_reason,
133 DeferredLogger& deferred_logger) const;
134
140 static std::string rateViolationReason(const UnitSystem& unit_system,
141 const RateLimitCheckReport& report,
142 const bool on_potentials);
143
151 static std::string ratioViolationReason(const UnitSystem& unit_system,
152 std::string_view ratio_name,
153 const UnitSystem::measure ratio_measure,
154 const Scalar ratio_value,
155 const Scalar ratio_limit);
156
161 template<class RatioFunc>
162 void checkMaxRatioLimit(const SingleWellState<Scalar, IndexTraits>& ws,
163 const Scalar max_ratio_limit,
164 const RatioFunc& ratioFunc,
165 const std::unordered_set<int>& excluded_completions,
166 const std::string& ratio_name,
167 const UnitSystem::measure ratio_measure,
168 RatioLimitCheckReport& report) const;
169
187 template<class RatioFunc>
188 bool checkMaxRatioLimitWell(const SingleWellState<Scalar, IndexTraits>& ws,
189 const Scalar max_ratio_limit,
190 const RatioFunc& ratioFunc,
191 const std::unordered_set<int>& excluded_completions,
192 Scalar& well_ratio_value) const;
193
194 template<class RatioFunc>
195 void checkMaxRatioLimitCompletions(const SingleWellState<Scalar, IndexTraits>& ws,
196 const Scalar max_ratio_limit,
197 const Scalar well_ratio_value,
198 const RatioFunc& ratioFunc,
199 const std::unordered_set<int>& excluded_completions,
200 const std::string& ratio_name,
201 const UnitSystem::measure ratio_measure,
202 RatioLimitCheckReport& report) const;
203
211 bool checkRateEconLimits(const WellEconProductionLimits& econ_production_limits,
212 const std::vector<Scalar>& rates_or_potentials,
213 RateLimitCheckReport& report) const;
214
217 RatioLimitCheckReport
218 checkRatioEconLimits(const WellEconProductionLimits& econ_production_limits,
219 const SingleWellState<Scalar, IndexTraits>& ws,
220 const std::unordered_set<int>& excluded_completions,
221 DeferredLogger& deferred_logger) const;
222
226 std::string completionDescriptor(int complnum) const;
227
240 bool closeOffendingCompletion(int offending_completion,
241 bool close_connections_below,
242 double simulation_time,
243 bool write_message_to_opmlog,
244 WellTestState& well_test_state,
245 const std::string& when,
246 const std::string& reason,
247 std::string_view ratio_subject,
248 std::unordered_set<int>& closed_this_event,
249 DeferredLogger& deferred_logger) const;
250
251 const WellInterfaceGeneric<Scalar, IndexTraits>& well_;
252};
253
254}
255
256#endif // OPM_WELL_TEST_HEADER_INCLUDED
Definition: DeferredLogger.hpp:57
Definition: SingleWellState.hpp:44
Definition: WellInterfaceGeneric.hpp:59
Class for performing well tests.
Definition: WellTest.hpp:50
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 time_point start_time, DeferredLogger &deferred_logger) const
WellTest(const WellInterfaceGeneric< Scalar, IndexTraits > &well)
Constructor sets reference to well.
Definition: WellTest.hpp:53
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 time_point start_time, DeferredLogger &deferred_logger, std::string *closure_reason=nullptr) const
Definition: blackoilbioeffectsmodules.hh:45