opm-simulators
Loading...
Searching...
No Matches
StandardWellConnections.hpp
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
26#include <opm/simulators/wells/StandardWellPrimaryVariables.hpp>
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<typename FluidSystem, typename Indices> class WellInterfaceIndices;
40template<typename Scalar, typename IndexTraits> class WellState;
41template<class Scalar> class PerfData;
42
43template<class FluidSystem, class Indices>
44class StandardWellConnections
45{
46public:
47 using Scalar = typename FluidSystem::Scalar;
48 using IndexTraits = typename FluidSystem::IndexTraitsType;
49 explicit StandardWellConnections(const WellInterfaceIndices<FluidSystem, Indices>& well);
50
52 {
53 std::vector<Scalar> b_perf{};
54 std::vector<Scalar> rsmax_perf{};
55 std::vector<Scalar> rvmax_perf{};
56 std::vector<Scalar> rvwmax_perf{};
57 std::vector<Scalar> rswmax_perf{};
58 std::vector<Scalar> surf_dens_perf{};
59 };
60
62 {
63 std::function<Scalar(int,int)> getTemperature{};
64 std::function<Scalar(int)> getSaltConcentration{};
65 std::function<int(int)> pvtRegionIdx{};
66 std::function<Scalar(int)> solventInverseFormationVolumeFactor{};
67 std::function<Scalar(int)> solventRefDensity{};
68 };
69
71 {
72 std::function<void(int, const std::vector<int>&, std::vector<Scalar>&)> mobility{};
73 std::function<void(int, const std::vector<int>&, std::vector<Scalar>&)> densityInCell{};
74 };
75
77 computePropertiesForPressures(const WellState<Scalar, IndexTraits>& well_state,
78 const PressurePropertyFunctions& propFunc) const;
79
81 void computeProperties(const bool stop_or_zero_rate_target,
82 const WellState<Scalar, IndexTraits>& well_state,
83 const DensityPropertyFunctions& prop_func,
84 const Properties& props,
85 DeferredLogger& deferred_logger);
86
92 Scalar rho(const typename std::vector<Scalar>::size_type i) const
93 {
94 return (i < this->perf_densities_.size())
95 ? this->perf_densities_[i]
96 : 0.0;
97 }
98
100 Scalar pressure_diff(const unsigned perf) const
101 { return perf_pressure_diffs_[perf]; }
102
103 using Eval = typename WellInterfaceIndices<FluidSystem, Indices>::Eval;
105
106 Eval connectionRateBrine(Scalar& rate,
107 const Scalar vap_wat_rate,
108 const std::vector<EvalWell>& cq_s,
109 const std::variant<Scalar,EvalWell>& saltConcentration) const;
110
111 Eval connectionRateFoam(const std::vector<EvalWell>& cq_s,
112 const std::variant<Scalar,EvalWell>& foamConcentration,
113 const Phase transportPhase,
114 DeferredLogger& deferred_logger) const;
115
116 std::tuple<Eval,EvalWell>
117 connectionRatePolymer(Scalar& rate,
118 const std::vector<EvalWell>& cq_s,
119 const std::variant<Scalar,EvalWell>& polymerConcentration) const;
120
121 Eval connectionRateBioeffects(Scalar& rate,
122 const Scalar vap_wat_rate,
123 const std::vector<EvalWell>& cq_s,
124 const std::variant<Scalar,EvalWell>& microbialConcentration) const;
125
126 std::tuple<Eval,Eval,Eval>
127 connectionRatesMICP(Scalar& rate_m,
128 Scalar& rate_o,
129 Scalar& rate_u,
130 const std::vector<EvalWell>& cq_s,
131 const std::variant<Scalar,EvalWell>& microbialConcentration,
132 const std::variant<Scalar,EvalWell>& oxygenConcentration,
133 const std::variant<Scalar,EvalWell>& ureaConcentration) const;
134
135 std::tuple<Eval,EvalWell>
136 connectionRatezFraction(Scalar& rate,
137 const Scalar dis_gas_rate,
138 const std::vector<EvalWell>& cq_s,
139 const std::variant<Scalar, std::array<EvalWell,2>>& solventConcentration) const;
140
141private:
142 void computePressureDelta();
143
144 // TODO: not total sure whether it is a good idea to put this function here
145 // the major reason to put here is to avoid the usage of Wells struct
146 void computeDensities(const std::vector<Scalar>& perfComponentRates,
147 const Properties& props,
148 DeferredLogger& deferred_logger);
149
150 void computeDensitiesForStoppedProducer(const DensityPropertyFunctions& prop_func);
151
152 std::vector<Scalar>
153 calculatePerforationOutflow(const std::vector<Scalar>& perfComponentRates) const;
154
155 void initialiseConnectionMixture(const int num_comp,
156 const int perf,
157 const std::vector<Scalar>& q_out_perf,
158 const std::vector<Scalar>& currentMixture,
159 std::vector<Scalar>& previousMixture) const;
160
161 std::vector<Scalar>
162 copyInPerforationRates(const Properties& props,
163 const PerfData<Scalar>& perf_data) const;
164
166
167 std::vector<Scalar> perf_densities_;
168 std::vector<Scalar> perf_pressure_diffs_;
169};
170
171}
172
173#endif // OPM_STANDARDWELL_CONNECTIONS_HEADER_INCLUDED
Definition DeferredLogger.hpp:57
Definition PerfData.hpp:34
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, ...).
Definition StandardWellConnections.cpp:671
Scalar pressure_diff(const unsigned perf) const
Returns pressure drop for a given perforation.
Definition StandardWellConnections.hpp:100
Scalar rho(const typename std::vector< Scalar >::size_type i) const
Returns density for specific perforation/connection.
Definition StandardWellConnections.hpp:92
DenseAd::DynamicEvaluation< Scalar, numStaticWellEq+Indices::numEq+1 > EvalWell
Evaluation for the well equations.
Definition StandardWellPrimaryVariables.hpp:88
Definition WellInterfaceIndices.hpp:34
The state of a set of wells, tailored for use by the fully implicit blackoil simulator.
Definition WellState.hpp:66
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition blackoilbioeffectsmodules.hh:43
Definition StandardWellConnections.hpp:71
Definition StandardWellConnections.hpp:62
Definition StandardWellConnections.hpp:52