opm-common
Loading...
Searching...
No Matches
WaterPvtMultiplexer.hpp
Go to the documentation of this file.
1// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2// vi: set et ts=4 sw=4 sts=4:
3/*
4 This file is part of the Open Porous Media project (OPM).
5
6 OPM is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 2 of the License, or
9 (at your option) any later version.
10
11 OPM is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with OPM. If not, see <http://www.gnu.org/licenses/>.
18
19 Consult the COPYING file in the top-level source directory of this
20 module for the precise wording of the license and the list of
21 copyright holders.
22*/
27#ifndef OPM_WATER_PVT_MULTIPLEXER_HPP
28#define OPM_WATER_PVT_MULTIPLEXER_HPP
29
35
36#define OPM_WATER_PVT_MULTIPLEXER_CALL(codeToCall, ...) \
37 switch (approach_) { \
38 case WaterPvtApproach::ConstantCompressibilityWater: { \
39 auto& pvtImpl = getRealPvt<WaterPvtApproach::ConstantCompressibilityWater>(); \
40 codeToCall; \
41 __VA_ARGS__; \
42 } \
43 case WaterPvtApproach::ConstantCompressibilityBrine: { \
44 auto& pvtImpl = getRealPvt<WaterPvtApproach::ConstantCompressibilityBrine>(); \
45 codeToCall; \
46 __VA_ARGS__; \
47 } \
48 case WaterPvtApproach::ThermalWater: { \
49 auto& pvtImpl = getRealPvt<WaterPvtApproach::ThermalWater>(); \
50 codeToCall; \
51 __VA_ARGS__; \
52 } \
53 case WaterPvtApproach::BrineCo2: { \
54 auto& pvtImpl = getRealPvt<WaterPvtApproach::BrineCo2>(); \
55 codeToCall; \
56 __VA_ARGS__; \
57 } \
58 case WaterPvtApproach::BrineH2: { \
59 auto& pvtImpl = getRealPvt<WaterPvtApproach::BrineH2>(); \
60 codeToCall; \
61 __VA_ARGS__; \
62 } \
63 default: \
64 case WaterPvtApproach::NoWater: \
65 throw std::logic_error("Not implemented: Water PVT of this deck!"); \
66 }
67
68namespace Opm {
69
70enum class WaterPvtApproach {
71 NoWater,
72 ConstantCompressibilityBrine,
73 ConstantCompressibilityWater,
74 ThermalWater,
75 BrineCo2,
76 BrineH2
77};
78
79#if HAVE_ECL_INPUT
80class EclipseState;
81class Schedule;
82#endif
83
88template <class Scalar, bool enableThermal = true, bool enableBrine = true>
89class WaterPvtMultiplexer
90{
91public:
92 WaterPvtMultiplexer()
93 : approach_(WaterPvtApproach::NoWater)
94 , realWaterPvt_(nullptr)
95 {
96 }
97
98 WaterPvtMultiplexer(WaterPvtApproach approach, void* realWaterPvt)
99 : approach_(approach)
100 , realWaterPvt_(realWaterPvt)
101 { }
102
103 WaterPvtMultiplexer(const WaterPvtMultiplexer<Scalar,enableThermal,enableBrine>& data)
104 {
105 *this = data;
106 }
107
108 ~WaterPvtMultiplexer();
109
110 bool mixingEnergy() const
111 {
112 return approach_ == WaterPvtApproach::ThermalWater;
113 }
114
115#if HAVE_ECL_INPUT
121 void initFromState(const EclipseState& eclState, const Schedule& schedule);
122#endif // HAVE_ECL_INPUT
123
124 void initEnd();
125
129 unsigned numRegions() const;
130
131 void setVapPars(const Scalar par1, const Scalar par2);
132
136 Scalar waterReferenceDensity(unsigned regionIdx) const;
137
141 template <class Evaluation>
142 Evaluation internalEnergy(unsigned regionIdx,
143 const Evaluation& temperature,
144 const Evaluation& pressure,
145 const Evaluation& Rsw,
146 const Evaluation& saltconcentration) const
147 { OPM_WATER_PVT_MULTIPLEXER_CALL(return pvtImpl.internalEnergy(regionIdx, temperature, pressure, Rsw, saltconcentration)); }
148
149 Scalar hVap(unsigned regionIdx) const;
150
154 template <class Evaluation>
155 Evaluation viscosity(unsigned regionIdx,
156 const Evaluation& temperature,
157 const Evaluation& pressure,
158 const Evaluation& Rsw,
159 const Evaluation& saltconcentration) const
160 {
161 OPM_WATER_PVT_MULTIPLEXER_CALL(return pvtImpl.viscosity(regionIdx, temperature, pressure, Rsw, saltconcentration));
162 }
163
164 bool isActive() const
165 {
166 return approach_ != WaterPvtApproach::NoWater;
167 }
168
172 template <class Evaluation>
173 Evaluation saturatedViscosity(unsigned regionIdx,
174 const Evaluation& temperature,
175 const Evaluation& pressure,
176 const Evaluation& saltconcentration) const
177 {
178 OPM_WATER_PVT_MULTIPLEXER_CALL(return pvtImpl.saturatedViscosity(regionIdx, temperature, pressure, saltconcentration));
179 }
180
184 template <class Evaluation>
185 Evaluation inverseFormationVolumeFactor(unsigned regionIdx,
186 const Evaluation& temperature,
187 const Evaluation& pressure,
188 const Evaluation& Rsw,
189 const Evaluation& saltconcentration) const
190 {
191 OPM_WATER_PVT_MULTIPLEXER_CALL(return pvtImpl.inverseFormationVolumeFactor(regionIdx, temperature, pressure, Rsw, saltconcentration));
192 }
193
197 template <class FluidState, class LhsEval = typename FluidState::Scalar>
198 std::pair<LhsEval, LhsEval>
199 inverseFormationVolumeFactorAndViscosity(const FluidState& fluidState, unsigned regionIdx)
200 { OPM_WATER_PVT_MULTIPLEXER_CALL(return pvtImpl.inverseFormationVolumeFactorAndViscosity(fluidState, regionIdx)); }
201
205 template <class Evaluation>
206 Evaluation saturatedInverseFormationVolumeFactor(unsigned regionIdx,
207 const Evaluation& temperature,
208 const Evaluation& pressure,
209 const Evaluation& saltconcentration) const
210 {
211 OPM_WATER_PVT_MULTIPLEXER_CALL(return pvtImpl.saturatedInverseFormationVolumeFactor(regionIdx, temperature, pressure, saltconcentration));
212 }
213
217 template <class Evaluation>
218 Evaluation saturatedGasDissolutionFactor(unsigned regionIdx,
219 const Evaluation& temperature,
220 const Evaluation& pressure,
221 const Evaluation& saltconcentration) const
222 {
223 OPM_WATER_PVT_MULTIPLEXER_CALL(return pvtImpl.saturatedGasDissolutionFactor(regionIdx, temperature, pressure, saltconcentration));
224 }
225
233 template <class Evaluation>
234 Evaluation saturationPressure(unsigned regionIdx,
235 const Evaluation& temperature,
236 const Evaluation& Rs,
237 const Evaluation& saltconcentration) const
238 { OPM_WATER_PVT_MULTIPLEXER_CALL(return pvtImpl.saturationPressure(regionIdx, temperature, Rs, saltconcentration)); }
239
243 template <class Evaluation>
244 Evaluation diffusionCoefficient(const Evaluation& temperature,
245 const Evaluation& pressure,
246 unsigned compIdx) const
247 {
248 OPM_WATER_PVT_MULTIPLEXER_CALL(return pvtImpl.diffusionCoefficient(temperature, pressure, compIdx));
249 }
250
251 void setApproach(WaterPvtApproach appr);
252
258 WaterPvtApproach approach() const
259 { return approach_; }
260
261 // get the concrete parameter object for the water phase
262 template <WaterPvtApproach approachV>
263 typename std::enable_if<approachV == WaterPvtApproach::ConstantCompressibilityWater, ConstantCompressibilityWaterPvt<Scalar> >::type& getRealPvt()
264 {
265 assert(approach() == approachV);
266 return *static_cast<ConstantCompressibilityWaterPvt<Scalar>* >(realWaterPvt_);
267 }
268
269 template <WaterPvtApproach approachV>
270 typename std::enable_if<approachV == WaterPvtApproach::ConstantCompressibilityWater, const ConstantCompressibilityWaterPvt<Scalar> >::type& getRealPvt() const
271 {
272 assert(approach() == approachV);
273 return *static_cast<ConstantCompressibilityWaterPvt<Scalar>* >(realWaterPvt_);
274 }
275
276 template <WaterPvtApproach approachV>
277 typename std::enable_if<approachV == WaterPvtApproach::ConstantCompressibilityBrine, ConstantCompressibilityBrinePvt<Scalar> >::type& getRealPvt()
278 {
279 assert(approach() == approachV);
280 return *static_cast<ConstantCompressibilityBrinePvt<Scalar>* >(realWaterPvt_);
281 }
282
283 template <WaterPvtApproach approachV>
284 typename std::enable_if<approachV == WaterPvtApproach::ConstantCompressibilityBrine, const ConstantCompressibilityBrinePvt<Scalar> >::type& getRealPvt() const
285 {
286 assert(approach() == approachV);
287 return *static_cast<ConstantCompressibilityBrinePvt<Scalar>* >(realWaterPvt_);
288 }
289
290 template <WaterPvtApproach approachV>
291 typename std::enable_if<approachV == WaterPvtApproach::ThermalWater, WaterPvtThermal<Scalar, enableBrine> >::type& getRealPvt()
292 {
293 assert(approach() == approachV);
294 return *static_cast<WaterPvtThermal<Scalar, enableBrine>* >(realWaterPvt_);
295 }
296
297 template <WaterPvtApproach approachV>
298 typename std::enable_if<approachV == WaterPvtApproach::ThermalWater, const WaterPvtThermal<Scalar, enableBrine> >::type& getRealPvt() const
299 {
300 assert(approach() == approachV);
301 return *static_cast<WaterPvtThermal<Scalar, enableBrine>* >(realWaterPvt_);
302 }
303
304 template <WaterPvtApproach approachV>
305 typename std::enable_if<approachV == WaterPvtApproach::BrineCo2, BrineCo2Pvt<Scalar> >::type& getRealPvt()
306 {
307 assert(approach() == approachV);
308 return *static_cast<BrineCo2Pvt<Scalar>* >(realWaterPvt_);
309 }
310
311 template <WaterPvtApproach approachV>
312 typename std::enable_if<approachV == WaterPvtApproach::BrineCo2, const BrineCo2Pvt<Scalar> >::type& getRealPvt() const
313 {
314 assert(approach() == approachV);
315 return *static_cast<const BrineCo2Pvt<Scalar>* >(realWaterPvt_);
316 }
317
318 template <WaterPvtApproach approachV>
319 typename std::enable_if<approachV == WaterPvtApproach::BrineH2, BrineH2Pvt<Scalar> >::type& getRealPvt()
320 {
321 assert(approach() == approachV);
322 return *static_cast<BrineH2Pvt<Scalar>* >(realWaterPvt_);
323 }
324
325 template <WaterPvtApproach approachV>
326 typename std::enable_if<approachV == WaterPvtApproach::BrineH2, const BrineH2Pvt<Scalar> >::type& getRealPvt() const
327 {
328 assert(approach() == approachV);
329 return *static_cast<const BrineH2Pvt<Scalar>* >(realWaterPvt_);
330 }
331
332 const void* realWaterPvt() const { return realWaterPvt_; }
333
334 WaterPvtMultiplexer<Scalar,enableThermal,enableBrine>&
335 operator=(const WaterPvtMultiplexer<Scalar,enableThermal,enableBrine>& data);
336
337private:
338 WaterPvtApproach approach_{WaterPvtApproach::NoWater};
339 void* realWaterPvt_{nullptr};
340};
341
342} // namespace Opm
343
344#endif
This class represents the Pressure-Volume-Temperature relations of the liquid phase for a CO2-Brine s...
This class represents the Pressure-Volume-Temperature relations of the liquid phase for a H2-Brine sy...
This class represents the Pressure-Volume-Temperature relations of the gas phase without vaporized oi...
This class represents the Pressure-Volume-Temperature relations of the gas phase without vaporized oi...
This class implements temperature dependence of the PVT properties of water.
This class represents the Pressure-Volume-Temperature relations of the gas phase without vaporized oi...
Definition ConstantCompressibilityWaterPvt.hpp:49
Definition EclipseState.hpp:62
Definition Schedule.hpp:101
Evaluation viscosity(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &Rsw, const Evaluation &saltconcentration) const
Returns the dynamic viscosity [Pa s] of the fluid phase given a set of parameters.
Definition WaterPvtMultiplexer.hpp:155
Evaluation saturatedInverseFormationVolumeFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &saltconcentration) const
Returns the formation volume factor [-] of the fluid phase.
Definition WaterPvtMultiplexer.hpp:206
Evaluation saturatedViscosity(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &saltconcentration) const
Returns the dynamic viscosity [Pa s] of the fluid phase given a set of parameters.
Definition WaterPvtMultiplexer.hpp:173
unsigned numRegions() const
Return the number of PVT regions which are considered by this PVT-object.
Definition WaterPvtMultiplexer.cpp:97
std::pair< LhsEval, LhsEval > inverseFormationVolumeFactorAndViscosity(const FluidState &fluidState, unsigned regionIdx)
Returns the formation volume factor [-] and viscosity [Pa s] of the fluid phase.
Definition WaterPvtMultiplexer.hpp:199
Evaluation saturatedGasDissolutionFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &saltconcentration) const
Returns the gas dissolution factor [m^3/m^3] of saturated water.
Definition WaterPvtMultiplexer.hpp:218
Evaluation internalEnergy(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &Rsw, const Evaluation &saltconcentration) const
Returns the specific enthalpy [J/kg] of gas given a set of parameters.
Definition WaterPvtMultiplexer.hpp:142
Evaluation saturationPressure(unsigned regionIdx, const Evaluation &temperature, const Evaluation &Rs, const Evaluation &saltconcentration) const
Returns the saturation pressure [Pa] of water given the mass fraction of the gas component in the wat...
Definition WaterPvtMultiplexer.hpp:234
WaterPvtApproach approach() const
Returns the concrete approach for calculating the PVT relations.
Definition WaterPvtMultiplexer.hpp:258
Scalar waterReferenceDensity(unsigned regionIdx) const
Return the reference density which are considered by this PVT-object.
Definition WaterPvtMultiplexer.cpp:111
Evaluation inverseFormationVolumeFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &Rsw, const Evaluation &saltconcentration) const
Returns the formation volume factor [-] of the fluid phase.
Definition WaterPvtMultiplexer.hpp:185
Evaluation diffusionCoefficient(const Evaluation &temperature, const Evaluation &pressure, unsigned compIdx) const
Calculate the binary molecular diffusion coefficient for a component in a fluid phase [mol^2 * s / (k...
Definition WaterPvtMultiplexer.hpp:244
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30