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/parser/eclipse/EclipseState/Schedule/MSW/WellSegments.hpp>
26 
27 #include <functional>
28 #include <optional>
29 #include <vector>
30 
31 namespace Opm
32 {
33 
34 class DeferredLogger;
35 class SummaryState;
36 class WellInterfaceGeneric;
37 class WellState;
38 
39 template <typename Scalar>
41 {
42 protected:
44 
45  // scale the segment rates and pressure based on well rates and bhp
46  void scaleSegmentRatesWithWellRates(WellState& well_state) const;
47  void scaleSegmentPressuresWithBhp(WellState& well_state) const;
48 
49  // get the WellSegments from the well_ecl_
50  const WellSegments& segmentSet() const;
51 
52  // components of the pressure drop to be included
53  WellSegments::CompPressureDrop compPressureDrop() const;
54 
55  // segment number is an ID of the segment, it is specified in the deck
56  // get the loation of the segment with a segment number in the segmentSet
57  int segmentNumberToIndex(const int segment_number) const;
58 
60  int numberOfSegments() const;
61 
62  double calculateThpFromBhp(const std::vector<double>& rates,
63  const double bhp,
64  const double rho,
65  DeferredLogger& deferred_logger) const;
66 
67  std::optional<double> computeBhpAtThpLimitInj(const std::function<std::vector<double>(const double)>& frates,
68  const SummaryState& summary_state,
69  const double rho,
70  DeferredLogger& deferred_logger) const;
71 
72  std::optional<double> computeBhpAtThpLimitProd(const std::function<std::vector<double>(const double)>& frates,
73  const SummaryState& summary_state,
74  const double maxPerfPress,
75  const double rho,
76  DeferredLogger& deferred_logger) const;
77 
79  void detectOscillations(const std::vector<double>& measure_history,
80  const int it,
81  bool& oscillate,
82  bool& stagnate) const;
83 
84  bool accelerationalPressureLossConsidered() const;
85  bool frictionalPressureLossConsidered() const;
86 
87  const WellInterfaceGeneric& baseif_;
88 
89  // TODO: trying to use the information from the Well opm-parser as much
90  // as possible, it will possibly be re-implemented later for efficiency reason.
91 
92  // the completions that is related to each segment
93  // the completions's ids are their index in the vector well_index_, well_cell_
94  // This is also assuming the order of the completions in Well is the same with
95  // the order of the completions in wells.
96  // it is for convinience reason. we can just calcuate the inforation for segment once then using it for all the perofrations
97  // belonging to this segment
98  std::vector<std::vector<int>> segment_perforations_;
99 
100  // the inlet segments for each segment. It is for convinience and efficiency reason
101  std::vector<std::vector<int>> segment_inlets_;
102 
103  std::vector<double> segment_depth_diffs_;
104 
105  // depth difference between the segment and the perforation
106  // or in another way, the depth difference between the perforation and
107  // the segment the perforation belongs to
108  std::vector<double> perforation_segment_depth_diffs_;
109 };
110 
111 }
112 
113 #endif // OPM_MULTISEGMENTWELL_GENERIC_HEADER_INCLUDED
Definition: DeferredLogger.hpp:57
Definition: MultisegmentWellGeneric.hpp:41
int numberOfSegments() const
number of segments for this well
Definition: MultisegmentWellGeneric.cpp:156
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:222
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:26