WellBhpThpCalculator.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_BPH_THP_CALCULATOR_HEADER_INCLUDED
25#define OPM_WELL_BPH_THP_CALCULATOR_HEADER_INCLUDED
26
27#include <functional>
28#include <optional>
29#include <string>
30#include <vector>
31
32namespace Opm
33{
34
35class DeferredLogger;
36class SummaryState;
37class Well;
38class WellInterfaceGeneric;
39template<class Scalar> class WellState;
40
43public:
45 WellBhpThpCalculator(const WellInterfaceGeneric& well) : well_(well) {}
46
48 bool wellHasTHPConstraints(const SummaryState& summaryState) const;
49
51 double getTHPConstraint(const SummaryState& summaryState) const;
52
54 double mostStrictBhpFromBhpLimits(const SummaryState& summaryState) const;
55
57 double calculateThpFromBhp(const std::vector<double>& rates,
58 const double bhp,
59 const double rho,
60 const std::optional<double>& alq,
61 const double thp_limit,
62 DeferredLogger& deferred_logger) const;
63
65 std::optional<double>
66 computeBhpAtThpLimitProd(const std::function<std::vector<double>(const double)>& frates,
67 const SummaryState& summary_state,
68 const double maxPerfPress,
69 const double rho,
70 const double alq_value,
71 const double thp_limit,
72 DeferredLogger& deferred_logger) const;
73
75 std::optional<double>
76 computeBhpAtThpLimitInj(const std::function<std::vector<double>(const double)>& frates,
77 const SummaryState& summary_state,
78 const double rho,
79 const double flo_rel_tol,
80 const int max_iteration,
81 const bool throwOnError,
82 DeferredLogger& deferred_logger) const;
83
85 void updateThp(const double rho,
86 const bool stop_or_zero_rate_target,
87 const std::function<double()>& alq_value,
88 const std::array<unsigned,3>& active,
89 WellState<double>& well_state,
90 const SummaryState& summary_state,
91 DeferredLogger& deferred_logger) const;
92
93 template<class EvalWell>
94 EvalWell calculateBhpFromThp(const WellState<double>& well_state,
95 const std::vector<EvalWell>& rates,
96 const Well& well,
97 const SummaryState& summaryState,
98 const double rho,
99 DeferredLogger& deferred_logger) const;
100
102 const Well& well,
103 const SummaryState& summaryState,
104 const double rho) const;
105
106 bool isStableSolution(const WellState<double>& well_state,
107 const Well& well,
108 const std::vector<double>& rates,
109 const SummaryState& summaryState) const;
110
111 std::optional<double>
113 const Well& well,
114 const std::vector<double>& rates,
115 const double rho,
116 const SummaryState& summaryState) const;
117
118 std::pair<double, double>
119 getFloIPR(const WellState<double>& well_state,
120 const Well& well,
121 const SummaryState& summary_state) const;
122
123private:
125 template<class ErrorPolicy>
126 std::optional<double>
127 computeBhpAtThpLimitInjImpl(const std::function<std::vector<double>(const double)>& frates,
128 const SummaryState& summary_state,
129 const double rho,
130 const double flo_rel_tol,
131 const int max_iteration,
132 DeferredLogger& deferred_logger) const;
133
135 std::optional<double>
136 bhpMax(const std::function<double(const double)>& fflo,
137 const double bhp_limit,
138 const double maxPerfPress,
139 const double vfp_flo_front,
140 DeferredLogger& deferred_logger) const;
141
143 std::optional<double>
144 computeBhpAtThpLimit(const std::function<std::vector<double>(const double)>& frates,
145 const std::function<double(const std::vector<double>)>& fbhp,
146 const std::array<double, 2>& range,
147 DeferredLogger& deferred_logger) const;
148
150 double getVfpBhpAdjustment(const double bph_tab, const double thp_limit) const;
151
153 bool bisectBracket(const std::function<double(const double)>& eq,
154 const std::array<double, 2>& range,
155 double& low, double& high,
156 std::optional<double>& approximate_solution,
157 DeferredLogger& deferred_logger) const;
158
160 static bool bruteForceBracket(const std::function<double(const double)>& eq,
161 const std::array<double, 2>& range,
162 double& low, double& high,
163 DeferredLogger& deferred_logger);
164
165 double findThpFromBhpIteratively(const std::function<double(const double, const double)>& thp_func,
166 const double bhp,
167 const double thp_limit,
168 const double dp,
169 DeferredLogger& deferred_logger) const;
170
171 const WellInterfaceGeneric& well_;
172};
173
174}
175
176#endif // OPM_WELL_BHP_THP_CALCULATOR_HEADER_INCLUDED
Definition: DeferredLogger.hpp:57
Class for computing BHP limits.
Definition: WellBhpThpCalculator.hpp:42
void updateThp(const double rho, const bool stop_or_zero_rate_target, const std::function< double()> &alq_value, const std::array< unsigned, 3 > &active, WellState< double > &well_state, const SummaryState &summary_state, DeferredLogger &deferred_logger) const
Update THP.
std::optional< double > computeBhpAtThpLimitProd(const std::function< std::vector< double >(const double)> &frates, const SummaryState &summary_state, const double maxPerfPress, const double rho, const double alq_value, const double thp_limit, DeferredLogger &deferred_logger) const
Compute BHP from THP limit for a producer.
double calculateMinimumBhpFromThp(const WellState< double > &well_state, const Well &well, const SummaryState &summaryState, const double rho) const
bool isStableSolution(const WellState< double > &well_state, const Well &well, const std::vector< double > &rates, const SummaryState &summaryState) const
std::pair< double, double > getFloIPR(const WellState< double > &well_state, const Well &well, const SummaryState &summary_state) const
double mostStrictBhpFromBhpLimits(const SummaryState &summaryState) const
Obtain the most strict BHP from BHP limits.
bool wellHasTHPConstraints(const SummaryState &summaryState) const
Checks if well has THP constraints.
std::optional< double > estimateStableBhp(const WellState< double > &well_state, const Well &well, const std::vector< double > &rates, const double rho, const SummaryState &summaryState) const
double getTHPConstraint(const SummaryState &summaryState) const
Get THP constraint for well.
EvalWell calculateBhpFromThp(const WellState< double > &well_state, const std::vector< EvalWell > &rates, const Well &well, const SummaryState &summaryState, const double rho, DeferredLogger &deferred_logger) const
double calculateThpFromBhp(const std::vector< double > &rates, const double bhp, const double rho, const std::optional< double > &alq, const double thp_limit, DeferredLogger &deferred_logger) const
Calculates THP from BHP.
std::optional< double > computeBhpAtThpLimitInj(const std::function< std::vector< double >(const double)> &frates, const SummaryState &summary_state, const double rho, const double flo_rel_tol, const int max_iteration, const bool throwOnError, DeferredLogger &deferred_logger) const
Compute BHP from THP limit for an injector.
WellBhpThpCalculator(const WellInterfaceGeneric &well)
Constructor sets reference to well.
Definition: WellBhpThpCalculator.hpp:45
Definition: WellInterfaceGeneric.hpp:50
VFPEvaluation bhp(const VFPProdTable &table, const double aqua, const double liquid, const double vapour, const double thp, const double alq, const double explicit_wfr, const double explicit_gfr, const bool use_vfpexplicit)
Definition: BlackoilPhases.hpp:27