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 <tuple>
31#include <variant>
32#include <vector>
33
34namespace Opm
35{
36
37class DeferredLogger;
38enum class Phase;
39template<class FluidSystem, class Indices> class WellInterfaceIndices;
40template<class Scalar> class WellState;
41template<class Scalar> class PerfData;
42
43template<class FluidSystem, class Indices>
45{
46public:
47 using Scalar = typename FluidSystem::Scalar;
49
51 {
52 std::vector<Scalar> b_perf{};
53 std::vector<Scalar> rsmax_perf{};
54 std::vector<Scalar> rvmax_perf{};
55 std::vector<Scalar> rvwmax_perf{};
56 std::vector<Scalar> rswmax_perf{};
57 std::vector<Scalar> surf_dens_perf{};
58 };
59
61 {
62 std::function<Scalar(int,int)> getTemperature{};
63 std::function<Scalar(int)> getSaltConcentration{};
64 std::function<int(int)> pvtRegionIdx{};
66 std::function<Scalar(int)> solventRefDensity{};
67 };
68
70 {
71 std::function<void(int, const std::vector<int>&, std::vector<Scalar>&)> mobility{};
72 std::function<void(int, const std::vector<int>&, std::vector<Scalar>&)> densityInCell{};
73 };
74
75 Properties
77 const PressurePropertyFunctions& propFunc) const;
78
80 void computeProperties(const bool stop_or_zero_rate_target,
81 const WellState<Scalar>& well_state,
82 const DensityPropertyFunctions& prop_func,
83 const Properties& props,
84 DeferredLogger& deferred_logger);
85
87 Scalar rho() const
88 {
89 return this->rho(0);
90 }
91
97 Scalar rho(const typename std::vector<Scalar>::size_type i) const
98 {
99 return (i < this->perf_densities_.size())
100 ? this->perf_densities_[i]
101 : 0.0;
102 }
103
105 Scalar pressure_diff(const unsigned perf) const
106 { return perf_pressure_diffs_[perf]; }
107
110
112 const Scalar vap_wat_rate,
113 const std::vector<EvalWell>& cq_s,
114 const std::variant<Scalar,EvalWell>& saltConcentration) const;
115
116 Eval connectionRateFoam(const std::vector<EvalWell>& cq_s,
117 const std::variant<Scalar,EvalWell>& foamConcentration,
118 const Phase transportPhase,
119 DeferredLogger& deferred_logger) const;
120
121 std::tuple<Eval,EvalWell>
123 const std::vector<EvalWell>& cq_s,
124 const std::variant<Scalar,EvalWell>& polymerConcentration) const;
125
126 std::tuple<Eval,Eval,Eval>
127 connectionRatesMICP(const std::vector<EvalWell>& cq_s,
128 const std::variant<Scalar,EvalWell>& microbialConcentration,
129 const std::variant<Scalar,EvalWell>& oxygenConcentration,
130 const std::variant<Scalar,EvalWell>& ureaConcentration) const;
131
132 std::tuple<Eval,EvalWell>
134 const Scalar dis_gas_rate,
135 const std::vector<EvalWell>& cq_s,
136 const std::variant<Scalar, std::array<EvalWell,2>>& solventConcentration) const;
137
138private:
139 void computePressureDelta();
140
141 // TODO: not total sure whether it is a good idea to put this function here
142 // the major reason to put here is to avoid the usage of Wells struct
143 void computeDensities(const std::vector<Scalar>& perfComponentRates,
144 const Properties& props,
145 DeferredLogger& deferred_logger);
146
147 void computeDensitiesForStoppedProducer(const DensityPropertyFunctions& prop_func);
148
149 std::vector<Scalar>
150 calculatePerforationOutflow(const std::vector<Scalar>& perfComponentRates) const;
151
152 void initialiseConnectionMixture(const int num_comp,
153 const int perf,
154 const std::vector<Scalar>& q_out_perf,
155 const std::vector<Scalar>& currentMixture,
156 std::vector<Scalar>& previousMixture) const;
157
158 std::vector<Scalar>
159 copyInPerforationRates(const Properties& props,
160 const PerfData<Scalar>& perf_data) const;
161
163
164 std::vector<Scalar> perf_densities_;
165 std::vector<Scalar> perf_pressure_diffs_;
166};
167
168}
169
170#endif // OPM_STANDARDWELL_CONNECTIONS_HEADER_INCLUDED
Definition: DeferredLogger.hpp:57
Definition: PerfData.hpp:33
Definition: StandardWellConnections.hpp:45
Properties computePropertiesForPressures(const WellState< Scalar > &well_state, const PressurePropertyFunctions &propFunc) const
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 WellInterfaceIndices< FluidSystem, Indices >::Eval Eval
Definition: StandardWellConnections.hpp:108
void computeProperties(const bool stop_or_zero_rate_target, const WellState< Scalar > &well_state, const DensityPropertyFunctions &prop_func, const Properties &props, DeferredLogger &deferred_logger)
Compute connection properties (densities, pressure drop, ...)
std::tuple< Eval, EvalWell > connectionRatePolymer(Scalar &rate, const std::vector< EvalWell > &cq_s, const std::variant< Scalar, EvalWell > &polymerConcentration) const
Scalar pressure_diff(const unsigned perf) const
Returns pressure drop for a given perforation.
Definition: StandardWellConnections.hpp:105
std::tuple< Eval, Eval, Eval > connectionRatesMICP(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
Scalar rho() const
Returns density for first perforation.
Definition: StandardWellConnections.hpp:87
Scalar rho(const typename std::vector< Scalar >::size_type i) const
Returns density for specific perforation/connection.
Definition: StandardWellConnections.hpp:97
typename FluidSystem::Scalar Scalar
Definition: StandardWellConnections.hpp:47
typename StandardWellPrimaryVariables< FluidSystem, Indices >::EvalWell EvalWell
Definition: StandardWellConnections.hpp:109
DenseAd::DynamicEvaluation< Scalar, numStaticWellEq+Indices::numEq+1 > EvalWell
Evaluation for the well equations.
Definition: StandardWellPrimaryVariables.hpp:87
Definition: WellInterfaceIndices.hpp:34
DenseAd::Evaluation< Scalar, Indices::numEq > Eval
Definition: WellInterfaceIndices.hpp:40
Definition: WellState.hpp:62
Definition: blackoilboundaryratevector.hh:37
Definition: StandardWellConnections.hpp:70
std::function< void(int, const std::vector< int > &, std::vector< Scalar > &)> mobility
Definition: StandardWellConnections.hpp:71
std::function< void(int, const std::vector< int > &, std::vector< Scalar > &)> densityInCell
Definition: StandardWellConnections.hpp:72
Definition: StandardWellConnections.hpp:61
std::function< Scalar(int)> solventRefDensity
Definition: StandardWellConnections.hpp:66
std::function< Scalar(int, int)> getTemperature
Definition: StandardWellConnections.hpp:62
std::function< Scalar(int)> getSaltConcentration
Definition: StandardWellConnections.hpp:63
std::function< int(int)> pvtRegionIdx
Definition: StandardWellConnections.hpp:64
std::function< Scalar(int)> solventInverseFormationVolumeFactor
Definition: StandardWellConnections.hpp:65
Definition: StandardWellConnections.hpp:51
std::vector< Scalar > surf_dens_perf
Definition: StandardWellConnections.hpp:57
std::vector< Scalar > rvwmax_perf
Definition: StandardWellConnections.hpp:55
std::vector< Scalar > rsmax_perf
Definition: StandardWellConnections.hpp:53
std::vector< Scalar > b_perf
Definition: StandardWellConnections.hpp:52
std::vector< Scalar > rswmax_perf
Definition: StandardWellConnections.hpp:56
std::vector< Scalar > rvmax_perf
Definition: StandardWellConnections.hpp:54