My Project
MultisegmentWellGeneric.hpp
1 /*
2  Copyright 2017 SINTEF Digital, Mathematics and Cybernetics.
3  Copyright 2017 Statoil ASA.
4 
5  This file is part of the Open Porous Media project (OPM).
6 
7  OPM is free software: you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation, either version 3 of the License, or
10  (at your option) any later version.
11 
12  OPM is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with OPM. If not, see <http://www.gnu.org/licenses/>.
19 */
20 
21 
22 #ifndef OPM_MULTISEGMENTWELL_GENERIC_HEADER_INCLUDED
23 #define OPM_MULTISEGMENTWELL_GENERIC_HEADER_INCLUDED
24 
25 #include <opm/input/eclipse/Schedule/MSW/WellSegments.hpp>
26 
27 #include <functional>
28 #include <optional>
29 #include <vector>
30 #include <array>
31 
32 namespace Opm
33 {
34 
35 class DeferredLogger;
36 class SummaryState;
37 class WellInterfaceGeneric;
38 class WellState;
39 
40 template <typename Scalar>
42 {
43 protected:
45 
46  // scale the segment rates and pressure based on well rates and bhp
47  void scaleSegmentRatesWithWellRates(WellState& well_state) const;
48  void scaleSegmentPressuresWithBhp(WellState& well_state) const;
49 
50  // get the WellSegments from the well_ecl_
51  const WellSegments& segmentSet() const;
52 
53  // components of the pressure drop to be included
54  WellSegments::CompPressureDrop compPressureDrop() const;
55 
56  // segment number is an ID of the segment, it is specified in the deck
57  // get the loation of the segment with a segment number in the segmentSet
58  int segmentNumberToIndex(const int segment_number) const;
59 
61  int numberOfSegments() const;
62 
63  double calculateThpFromBhp(const std::vector<double>& rates,
64  const double bhp,
65  const double rho,
66  DeferredLogger& deferred_logger) const;
67 
68  std::optional<double> computeBhpAtThpLimitInj(const std::function<std::vector<double>(const double)>& frates,
69  const SummaryState& summary_state,
70  const double rho,
71  DeferredLogger& deferred_logger) const;
72 
73  std::optional<double> computeBhpAtThpLimitProdWithAlq(
74  const std::function<std::vector<double>(const double)>& frates,
75  const SummaryState& summary_state,
76  const double maxPerfPress,
77  const double rho,
78  DeferredLogger& deferred_logger,
79  double alq_value) const;
80 
81  std::optional<double> bhpMax(const std::function<double(const double)>& fflo,
82  const double bhp_limit,
83  const double maxPerfPress,
84  const double vfp_flo_front,
85  DeferredLogger& deferred_logger) const;
86 
87  bool bruteForceBracket(const std::function<double(const double)>& eq,
88  const std::array<double, 2>& range,
89  double& low, double& high,
90  DeferredLogger& deferred_logger) const;
91 
92  bool bisectBracket(const std::function<double(const double)>& eq,
93  const std::array<double, 2>& range,
94  double& low, double& high,
95  std::optional<double>& approximate_solution,
96  DeferredLogger& deferred_logger) const;
97 
99  void detectOscillations(const std::vector<double>& measure_history,
100  const int it,
101  bool& oscillate,
102  bool& stagnate) const;
103 
104  bool accelerationalPressureLossConsidered() const;
105  bool frictionalPressureLossConsidered() const;
106 
107  const WellInterfaceGeneric& baseif_;
108 
109  // TODO: trying to use the information from the Well opm-parser as much
110  // as possible, it will possibly be re-implemented later for efficiency reason.
111 
112  // the completions that is related to each segment
113  // the completions's ids are their index in the vector well_index_, well_cell_
114  // This is also assuming the order of the completions in Well is the same with
115  // the order of the completions in wells.
116  // it is for convinience reason. we can just calcuate the inforation for segment once then using it for all the perofrations
117  // belonging to this segment
118  std::vector<std::vector<int>> segment_perforations_;
119 
120  // the inlet segments for each segment. It is for convinience and efficiency reason
121  std::vector<std::vector<int>> segment_inlets_;
122 
123  std::vector<double> segment_depth_diffs_;
124 
125  // depth difference between the segment and the perforation
126  // or in another way, the depth difference between the perforation and
127  // the segment the perforation belongs to
128  std::vector<double> perforation_segment_depth_diffs_;
129 };
130 
131 }
132 
133 #endif // OPM_MULTISEGMENTWELL_GENERIC_HEADER_INCLUDED
Definition: DeferredLogger.hpp:57
Definition: MultisegmentWellGeneric.hpp:42
int numberOfSegments() const
number of segments for this well
Definition: MultisegmentWellGeneric.cpp:159
void detectOscillations(const std::vector< double > &measure_history, const int it, bool &oscillate, bool &stagnate) const
Detect oscillation or stagnation based on the residual measure history.
Definition: MultisegmentWellGeneric.cpp:225
Definition: WellInterfaceGeneric.hpp:51
The state of a set of wells, tailored for use by the fully implicit blackoil simulator.
Definition: WellState.hpp:56
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition: BlackoilPhases.hpp:27