StandardWellConnections.hpp
Go to the documentation of this file.
1/*
2 Copyright 2017 SINTEF Digital, Mathematics and Cybernetics.
3 Copyright 2017 Statoil ASA.
4 Copyright 2016 - 2017 IRIS AS.
5
6 This file is part of the Open Porous Media project (OPM).
7
8 OPM is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
12
13 OPM is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with OPM. If not, see <http://www.gnu.org/licenses/>.
20*/
21
22
23#ifndef OPM_STANDARDWELL_CONNECTIONS_HEADER_INCLUDED
24#define OPM_STANDARDWELL_CONNECTIONS_HEADER_INCLUDED
25
27
28#include <array>
29#include <functional>
30#include <optional>
31#include <tuple>
32#include <variant>
33#include <vector>
34
35namespace Opm
36{
37
38class DeferredLogger;
39enum class Phase;
40template<typename FluidSystem, typename Indices> class WellInterfaceIndices;
41template<typename Scalar, typename IndexTraits> class WellState;
42template<class Scalar> class PerfData;
43
44template<class FluidSystem, class Indices>
46{
47public:
48 using Scalar = typename FluidSystem::Scalar;
49 using IndexTraits = typename FluidSystem::IndexTraitsType;
51
53 {
54 std::vector<Scalar> b_perf{};
55 std::vector<Scalar> rsmax_perf{};
56 std::vector<Scalar> rvmax_perf{};
57 std::vector<Scalar> rvwmax_perf{};
58 std::vector<Scalar> rswmax_perf{};
59 std::vector<Scalar> surf_dens_perf{};
60 };
61
63 {
64 std::function<Scalar(int,int)> getTemperature{};
65 std::function<Scalar(int)> getSaltConcentration{};
66 std::function<int(int)> pvtRegionIdx{};
68 std::function<Scalar(int)> solventRefDensity{};
69 };
70
72 {
73 std::function<void(int, const std::vector<int>&, std::vector<Scalar>&)> mobility{};
74 std::function<void(int, const std::vector<int>&, std::vector<Scalar>&)> densityInCell{};
75 };
76
77 Properties
79 const PressurePropertyFunctions& propFunc) const;
80
82 void computeProperties(const bool stop_or_zero_rate_target,
83 const WellState<Scalar, IndexTraits>& well_state,
84 const DensityPropertyFunctions& prop_func,
85 const Properties& props,
86 DeferredLogger& deferred_logger);
87
93 Scalar rho(const typename std::vector<Scalar>::size_type i) const
94 {
95 return (i < this->perf_densities_.size())
96 ? this->perf_densities_[i]
97 : 0.0;
98 }
99
101 Scalar pressure_diff(const unsigned perf) const
102 { return perf_pressure_diffs_[perf]; }
103
106
108 const Scalar vap_wat_rate,
109 const std::vector<EvalWell>& cq_s,
110 const std::variant<Scalar,EvalWell>& saltConcentration) const;
111
112 Eval connectionRateFoam(const std::vector<EvalWell>& cq_s,
113 const std::variant<Scalar,EvalWell>& foamConcentration,
114 const Phase transportPhase,
115 DeferredLogger& deferred_logger) const;
116
117 std::tuple<Eval,EvalWell>
119 const std::vector<EvalWell>& cq_s,
120 const std::variant<Scalar,EvalWell>& polymerConcentration) const;
121
123 const Scalar vap_wat_rate,
124 const std::vector<EvalWell>& cq_s,
125 const std::variant<Scalar,EvalWell>& microbialConcentration) const;
126
127 std::tuple<Eval,Eval,Eval>
129 Scalar& rate_o,
130 Scalar& rate_u,
131 const std::vector<EvalWell>& cq_s,
132 const std::variant<Scalar,EvalWell>& microbialConcentration,
133 const std::variant<Scalar,EvalWell>& oxygenConcentration,
134 const std::variant<Scalar,EvalWell>& ureaConcentration) const;
135
136 std::tuple<Eval,EvalWell>
138 const Scalar dis_gas_rate,
139 const std::vector<EvalWell>& cq_s,
140 const std::variant<Scalar, std::array<EvalWell,2>>& solventConcentration) const;
141
142private:
143 void computePressureDelta();
144
145 // TODO: not total sure whether it is a good idea to put this function here
146 // the major reason to put here is to avoid the usage of Wells struct
147 void computeDensities(const std::vector<Scalar>& perfComponentRates,
148 const Properties& props,
149 DeferredLogger& deferred_logger);
150
151 void computeDensitiesForStoppedProducer(const DensityPropertyFunctions& prop_func);
152
153 std::vector<Scalar>
154 calculatePerforationOutflow(const std::vector<Scalar>& perfComponentRates) const;
155
156 template <typename Ix>
157 void initialiseConnectionMixture(const int num_comp,
158 const int perf,
159 const std::optional<Ix> preferredPhaseIdx,
160 const std::vector<Scalar>& q_out_perf,
161 const std::vector<Scalar>& currentMixture,
162 std::vector<Scalar>& previousMixture) const;
163
164 std::vector<Scalar>
165 copyInPerforationRates(const Properties& props,
166 const PerfData<Scalar>& perf_data) const;
167
169
170 std::vector<Scalar> perf_densities_;
171 std::vector<Scalar> perf_pressure_diffs_;
172};
173
174}
175
176#endif // OPM_STANDARDWELL_CONNECTIONS_HEADER_INCLUDED
Definition: DeferredLogger.hpp:57
Definition: PerfData.hpp:34
Definition: StandardWellConnections.hpp:46
StandardWellConnections(const WellInterfaceIndices< FluidSystem, Indices > &well)
Eval connectionRateFoam(const std::vector< EvalWell > &cq_s, const std::variant< Scalar, EvalWell > &foamConcentration, const Phase transportPhase, DeferredLogger &deferred_logger) const
Eval connectionRateBrine(Scalar &rate, const Scalar vap_wat_rate, const std::vector< EvalWell > &cq_s, const std::variant< Scalar, EvalWell > &saltConcentration) const
std::tuple< Eval, EvalWell > connectionRatezFraction(Scalar &rate, const Scalar dis_gas_rate, const std::vector< EvalWell > &cq_s, const std::variant< Scalar, std::array< EvalWell, 2 > > &solventConcentration) const
typename FluidSystem::IndexTraitsType IndexTraits
Definition: StandardWellConnections.hpp:49
Eval connectionRateBioeffects(Scalar &rate, const Scalar vap_wat_rate, const std::vector< EvalWell > &cq_s, const std::variant< Scalar, EvalWell > &microbialConcentration) const
std::tuple< Eval, Eval, Eval > connectionRatesMICP(Scalar &rate_m, Scalar &rate_o, Scalar &rate_u, const std::vector< EvalWell > &cq_s, const std::variant< Scalar, EvalWell > &microbialConcentration, const std::variant< Scalar, EvalWell > &oxygenConcentration, const std::variant< Scalar, EvalWell > &ureaConcentration) const
typename WellInterfaceIndices< FluidSystem, Indices >::Eval Eval
Definition: StandardWellConnections.hpp:104
std::tuple< Eval, EvalWell > connectionRatePolymer(Scalar &rate, const std::vector< EvalWell > &cq_s, const std::variant< Scalar, EvalWell > &polymerConcentration) const
Properties computePropertiesForPressures(const WellState< Scalar, IndexTraits > &well_state, const PressurePropertyFunctions &propFunc) const
typename StandardWellPrimaryVariables< FluidSystem, Indices >::EvalWell EvalWell
Definition: StandardWellConnections.hpp:105
void computeProperties(const bool stop_or_zero_rate_target, const WellState< Scalar, IndexTraits > &well_state, const DensityPropertyFunctions &prop_func, const Properties &props, DeferredLogger &deferred_logger)
Compute connection properties (densities, pressure drop, ...)
Scalar pressure_diff(const unsigned perf) const
Returns pressure drop for a given perforation.
Definition: StandardWellConnections.hpp:101
Scalar rho(const typename std::vector< Scalar >::size_type i) const
Returns density for specific perforation/connection.
Definition: StandardWellConnections.hpp:93
typename FluidSystem::Scalar Scalar
Definition: StandardWellConnections.hpp:48
DenseAd::DynamicEvaluation< Scalar, numStaticWellEq+Indices::numEq+1 > EvalWell
Evaluation for the well equations.
Definition: StandardWellPrimaryVariables.hpp:88
Definition: WellInterfaceIndices.hpp:34
DenseAd::Evaluation< Scalar, Indices::numDerivatives > Eval
Definition: WellInterfaceIndices.hpp:40
Definition: WellState.hpp:66
Phase
Phase indices for reservoir coupling, we currently only support black-oil phases (oil,...
Definition: ReservoirCoupling.hpp:141
Definition: blackoilbioeffectsmodules.hh:43
Definition: StandardWellConnections.hpp:72
std::function< void(int, const std::vector< int > &, std::vector< Scalar > &)> mobility
Definition: StandardWellConnections.hpp:73
std::function< void(int, const std::vector< int > &, std::vector< Scalar > &)> densityInCell
Definition: StandardWellConnections.hpp:74
Definition: StandardWellConnections.hpp:63
std::function< Scalar(int)> solventRefDensity
Definition: StandardWellConnections.hpp:68
std::function< Scalar(int, int)> getTemperature
Definition: StandardWellConnections.hpp:64
std::function< Scalar(int)> getSaltConcentration
Definition: StandardWellConnections.hpp:65
std::function< int(int)> pvtRegionIdx
Definition: StandardWellConnections.hpp:66
std::function< Scalar(int)> solventInverseFormationVolumeFactor
Definition: StandardWellConnections.hpp:67
Definition: StandardWellConnections.hpp:53
std::vector< Scalar > surf_dens_perf
Definition: StandardWellConnections.hpp:59
std::vector< Scalar > rvwmax_perf
Definition: StandardWellConnections.hpp:57
std::vector< Scalar > rsmax_perf
Definition: StandardWellConnections.hpp:55
std::vector< Scalar > b_perf
Definition: StandardWellConnections.hpp:54
std::vector< Scalar > rswmax_perf
Definition: StandardWellConnections.hpp:58
std::vector< Scalar > rvmax_perf
Definition: StandardWellConnections.hpp:56