MultisegmentWellSegments.hpp
Go to the documentation of this file.
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_SEGMENTS_HEADER_INCLUDED
23#define OPM_MULTISEGMENTWELL_SEGMENTS_HEADER_INCLUDED
24
27
28#include <array>
29#include <cstddef>
30#include <vector>
31
32namespace Opm {
33
34 class AutoICD;
35 template<class Scalar> class SegmentState;
36 class UnitSystem;
37 template<typename Scalar, typename IndexTraits> class WellInterfaceGeneric;
38 class SummaryState;
39
40} // namespace Opm
41
42namespace Opm {
43
44template<typename FluidSystem, typename Indices>
46{
48 using Scalar = typename FluidSystem::Scalar;
49 using EvalWell = typename PrimaryVariables::EvalWell;
50 using IndexTraits = typename FluidSystem::IndexTraitsType;
51
52public:
53 MultisegmentWellSegments(const int numSegments,
54 const ParallelWellInfo<Scalar>& parallel_well_info,
56
64 {
65 EvalWell pressure{0.};
66 EvalWell temperature{0.};
67 EvalWell saltConcentration{0.};
68 std::array<EvalWell, FluidSystem::numPhases> invB{};
69 EvalWell Rs{0.};
70 EvalWell Rv{0.};
71 };
72
78 void computeFluidProperties(const std::vector<SegmentPvt>& segment_pvt,
79 const PrimaryVariables& primary_variables,
80 DeferredLogger& deferred_logger);
81
83 EvalWell computeVolumeRatio(const int seg,
84 const SegmentPvt& pvt,
85 const PrimaryVariables& primary_variables,
86 DeferredLogger& deferred_logger) const;
87
89 void updateUpwindingSegments(const PrimaryVariables& primary_variables);
90
91 EvalWell getHydroPressureLoss(const int seg,
92 const int seg_side) const;
93
95 Scalar getPressureDiffSegLocalPerf(const int seg,
96 const int local_perf_index) const;
97
98 EvalWell getFrictionPressureLoss(const int seg,
99 const bool extra_reverse_flow_derivatives = false) const;
100
101 // pressure drop for Spiral ICD segment (WSEGSICD)
102 EvalWell pressureDropSpiralICD(const int seg,
103 const bool extra_reverse_flow_derivatives = false) const;
104
105 // pressure drop for Autonomous ICD segment (WSEGAICD)
106 EvalWell pressureDropAutoICD(const int seg,
107 const UnitSystem& unit_system,
108 const bool extra_reverse_flow_derivatives = false) const;
109
110 // pressure drop for sub-critical valve (WSEGVALV)
111 EvalWell pressureDropValve(const int seg,
112 const SummaryState& st,
113 const bool extra_reverse_flow_derivatives = false) const;
114
115 // pressure loss contribution due to acceleration
117 const Scalar area,
118 const bool extra_reverse_flow_derivatives = false) const;
119
120 const std::vector<std::vector<int>>& inlets() const
121 {
122 return inlets_;
123 }
124
125 const std::vector<int>& inlets(const int seg) const
126 {
127 return inlets_[seg];
128 }
129
130 const std::vector<std::vector<int>>& perforations() const
131 {
132 return perforations_;
133 }
134
135 int upwinding_segment(const int seg) const
136 {
137 return upwinding_segments_[seg];
138 }
139
140 Scalar getRefDensity() const
141 {
142 return densities_[0].value();
143 }
144
145 const EvalWell& density(const int seg) const
146 {
147 return densities_[seg];
148 }
149
153 const EvalWell& volumeRatio(const int seg) const
154 {
155 return volume_ratios_[seg];
156 }
157
158 Scalar local_perforation_depth_diff(const int local_perf_index) const
159 {
160 return local_perforation_depth_diffs_[local_perf_index];
161 }
162
164
165private:
166 // TODO: trying to use the information from the Well opm-parser as much
167 // as possible, it will possibly be re-implemented later for efficiency reason.
168
169 // the completions that is related to each segment
170 // the completions's ids are their index in the vector well_index_, well_cell_
171 // This is also assuming the order of the completions in Well is the same with
172 // the order of the completions in wells.
173 // it is for convenience reason. we can just calculate the information for segment once
174 // then using it for all the perforations belonging to this segment
175 std::vector<std::vector<int>> perforations_;
176
177 // depth difference between the segment and the perforation
178 // or in another way, the depth difference between the perforation and
179 // the segment the perforation belongs to
180 // This vector contains the depth differences for *all* perforations across all processes
181 // that this well lies on, its size is well.wellEcl().getConnections().size(),
182 // also it works with *global* perforation indices!
183 std::vector<Scalar> local_perforation_depth_diffs_;
184
185 // the inlet segments for each segment. It is for convenience and efficiency reason
186 std::vector<std::vector<int>> inlets_;
187
188 std::vector<Scalar> depth_diffs_;
189
190 std::vector<Scalar> surface_densities_;
191
192 // the densities of segment fluids
193 // we should not have this member variable
194 std::vector<EvalWell> densities_;
195
196 // Segment volume ratios (reservoir volume per unit surface volume), derived from the fluid
197 // state and surface composition.
198 std::vector<EvalWell> volume_ratios_;
199
200 // the mass rate of the segments
201 std::vector<EvalWell> mass_rates_;
202
203 // the viscosity of the segments
204 std::vector<EvalWell> viscosities_;
205
206 // the upwinding segment for each segment based on the flow direction
207 std::vector<int> upwinding_segments_;
208
209 std::vector<std::vector<EvalWell>> phase_densities_;
210 std::vector<std::vector<EvalWell>> phase_fractions_;
211 std::vector<std::vector<EvalWell>> phase_viscosities_;
212
214
215 void copyPhaseDensities(const unsigned phaseIdx,
216 const std::size_t stride,
217 Scalar* dens) const;
218
219 Scalar mixtureDensity(const int seg) const;
220 Scalar mixtureDensityWithExponents(const int seg) const;
221 Scalar mixtureDensityWithExponents(const AutoICD& aicd, const int seg) const;
222
223 // Intermediate PVT properties used to calculate segment fluid properties and volume ratios.
224 struct PhaseState
225 {
226 explicit PhaseState(const std::size_t num_quantities)
227 : b(num_quantities, 0.0)
228 , mix(num_quantities, 0.0)
229 {}
230
231 std::vector<EvalWell> b;
232 std::vector<EvalWell> mix;
233 EvalWell rs{0.};
234 EvalWell rv{0.};
235 EvalWell vol_ratio{0.};
236 };
237
242 void calculatePhaseState(const SegmentPvt& pvt,
243 const std::vector<EvalWell>& mix_s,
244 PhaseState& state,
245 DeferredLogger& deferred_logger) const;
246};
247
248} // namespace Opm
249
250#endif // OPM_MULTISEGMENTWELL_SEGMENTS_HEADER_INCLUDED
Definition: DeferredLogger.hpp:57
Definition: MultisegmentWellPrimaryVariables.hpp:45
DenseAd::Evaluation< Scalar, Indices::numEq+numWellEq > EvalWell
Definition: MultisegmentWellPrimaryVariables.hpp:79
Definition: MultisegmentWellSegments.hpp:46
const EvalWell & volumeRatio(const int seg) const
Segment volume ratio (reservoir volume per unit surface volume).
Definition: MultisegmentWellSegments.hpp:153
EvalWell pressureDropAutoICD(const int seg, const UnitSystem &unit_system, const bool extra_reverse_flow_derivatives=false) const
EvalWell pressureDropValve(const int seg, const SummaryState &st, const bool extra_reverse_flow_derivatives=false) const
void copyPhaseDensities(SegmentState< Scalar > &segSol) const
EvalWell accelerationPressureLossContribution(const int seg, const Scalar area, const bool extra_reverse_flow_derivatives=false) const
const std::vector< std::vector< int > > & inlets() const
Definition: MultisegmentWellSegments.hpp:120
EvalWell getHydroPressureLoss(const int seg, const int seg_side) const
const EvalWell & density(const int seg) const
Definition: MultisegmentWellSegments.hpp:145
Scalar getPressureDiffSegLocalPerf(const int seg, const int local_perf_index) const
Pressure difference between segment and perforation.
Scalar getRefDensity() const
Definition: MultisegmentWellSegments.hpp:140
void updateUpwindingSegments(const PrimaryVariables &primary_variables)
Update upwinding segments.
EvalWell getFrictionPressureLoss(const int seg, const bool extra_reverse_flow_derivatives=false) const
const std::vector< std::vector< int > > & perforations() const
Definition: MultisegmentWellSegments.hpp:130
MultisegmentWellSegments(const int numSegments, const ParallelWellInfo< Scalar > &parallel_well_info, WellInterfaceGeneric< Scalar, IndexTraits > &well)
int upwinding_segment(const int seg) const
Definition: MultisegmentWellSegments.hpp:135
Scalar local_perforation_depth_diff(const int local_perf_index) const
Definition: MultisegmentWellSegments.hpp:158
void computeFluidProperties(const std::vector< SegmentPvt > &segment_pvt, const PrimaryVariables &primary_variables, DeferredLogger &deferred_logger)
Compute per-segment fluid properties from the pre-computed segment PVT values.
EvalWell computeVolumeRatio(const int seg, const SegmentPvt &pvt, const PrimaryVariables &primary_variables, DeferredLogger &deferred_logger) const
Volume ratio of a segment from its PVT values and composition.
const std::vector< int > & inlets(const int seg) const
Definition: MultisegmentWellSegments.hpp:125
EvalWell pressureDropSpiralICD(const int seg, const bool extra_reverse_flow_derivatives=false) const
Class encapsulating some information about parallel wells.
Definition: ParallelWellInfo.hpp:217
Definition: SegmentState.hpp:34
Definition: WellInterfaceGeneric.hpp:56
Definition: blackoilbioeffectsmodules.hh:45
The quantities taken from a segment fluid state.
Definition: MultisegmentWellSegments.hpp:64
EvalWell Rv
Definition: MultisegmentWellSegments.hpp:70
std::array< EvalWell, FluidSystem::numPhases > invB
Definition: MultisegmentWellSegments.hpp:68
EvalWell Rs
Definition: MultisegmentWellSegments.hpp:69
EvalWell pressure
Definition: MultisegmentWellSegments.hpp:65
EvalWell temperature
Definition: MultisegmentWellSegments.hpp:66
EvalWell saltConcentration
Definition: MultisegmentWellSegments.hpp:67