My Project
Loading...
Searching...
No Matches
GasPvtMultiplexer.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_GAS_PVT_MULTIPLEXER_HPP
28#define OPM_GAS_PVT_MULTIPLEXER_HPP
29
37
38namespace Opm {
39
40#if HAVE_ECL_INPUT
41class EclipseState;
42class Schedule;
43#endif
44
45#define OPM_GAS_PVT_MULTIPLEXER_CALL(codeToCall, ...) \
46 switch (gasPvtApproach_) { \
47 case GasPvtApproach::DryGas: { \
48 auto& pvtImpl = getRealPvt<GasPvtApproach::DryGas>(); \
49 codeToCall; \
50 __VA_ARGS__; \
51 } \
52 case GasPvtApproach::DryHumidGas: { \
53 auto& pvtImpl = getRealPvt<GasPvtApproach::DryHumidGas>(); \
54 codeToCall; \
55 __VA_ARGS__; \
56 } \
57 case GasPvtApproach::WetHumidGas: { \
58 auto& pvtImpl = getRealPvt<GasPvtApproach::WetHumidGas>(); \
59 codeToCall; \
60 __VA_ARGS__; \
61 } \
62 case GasPvtApproach::WetGas: { \
63 auto& pvtImpl = getRealPvt<GasPvtApproach::WetGas>(); \
64 codeToCall; \
65 __VA_ARGS__; \
66 } \
67 case GasPvtApproach::ThermalGas: { \
68 auto& pvtImpl = getRealPvt<GasPvtApproach::ThermalGas>(); \
69 codeToCall; \
70 __VA_ARGS__; \
71 } \
72 case GasPvtApproach::Co2Gas: { \
73 auto& pvtImpl = getRealPvt<GasPvtApproach::Co2Gas>(); \
74 codeToCall; \
75 __VA_ARGS__; \
76 } \
77 case GasPvtApproach::H2Gas: { \
78 auto& pvtImpl = getRealPvt<GasPvtApproach::H2Gas>(); \
79 codeToCall; \
80 __VA_ARGS__; \
81 } \
82 default: \
83 case GasPvtApproach::NoGas: \
84 throw std::logic_error("Not implemented: Gas PVT of this deck!"); \
85 }
86
87enum class GasPvtApproach {
88 NoGas,
89 DryGas,
90 DryHumidGas,
91 WetHumidGas,
92 WetGas,
93 ThermalGas,
94 Co2Gas,
95 H2Gas
96};
97
108template <class Scalar, bool enableThermal = true>
110{
111public:
113 : gasPvtApproach_(GasPvtApproach::NoGas)
114 , realGasPvt_(nullptr)
115 {
116 }
117
118 GasPvtMultiplexer(GasPvtApproach approach, void* realGasPvt)
119 : gasPvtApproach_(approach)
120 , realGasPvt_(realGasPvt)
121 { }
122
124 {
125 *this = data;
126 }
127
129
130 bool mixingEnergy() const
131 {
132 return gasPvtApproach_ == GasPvtApproach::ThermalGas;
133 }
134
135#if HAVE_ECL_INPUT
141 void initFromState(const EclipseState& eclState, const Schedule& schedule);
142#endif // HAVE_ECL_INPUT
143
144 void setApproach(GasPvtApproach gasPvtAppr);
145
146 void initEnd();
147
151 unsigned numRegions() const;
152
153 void setVapPars(const Scalar par1, const Scalar par2);
154
158 Scalar gasReferenceDensity(unsigned regionIdx);
159
163 template <class Evaluation>
164 Evaluation internalEnergy(unsigned regionIdx,
165 const Evaluation& temperature,
166 const Evaluation& pressure,
167 const Evaluation& Rv,
168 const Evaluation& Rvw) const
169 { OPM_GAS_PVT_MULTIPLEXER_CALL(return pvtImpl.internalEnergy(regionIdx, temperature, pressure, Rv, Rvw)); }
170
171 Scalar hVap(unsigned regionIdx) const;
172
176 template <class Evaluation = Scalar>
177 Evaluation viscosity(unsigned regionIdx,
178 const Evaluation& temperature,
179 const Evaluation& pressure,
180 const Evaluation& Rv,
181 const Evaluation& Rvw ) const
182 { OPM_GAS_PVT_MULTIPLEXER_CALL(return pvtImpl.viscosity(regionIdx, temperature, pressure, Rv, Rvw)); }
183
187 template <class Evaluation = Scalar>
188 Evaluation saturatedViscosity(unsigned regionIdx,
189 const Evaluation& temperature,
190 const Evaluation& pressure) const
191 { OPM_GAS_PVT_MULTIPLEXER_CALL(return pvtImpl.saturatedViscosity(regionIdx, temperature, pressure)); }
192
196 template <class Evaluation = Scalar>
197 Evaluation inverseFormationVolumeFactor(unsigned regionIdx,
198 const Evaluation& temperature,
199 const Evaluation& pressure,
200 const Evaluation& Rv,
201 const Evaluation& Rvw) const
202 { OPM_GAS_PVT_MULTIPLEXER_CALL(return pvtImpl.inverseFormationVolumeFactor(regionIdx, temperature, pressure, Rv, Rvw)); }
203
207 template <class Evaluation = Scalar>
208 Evaluation saturatedInverseFormationVolumeFactor(unsigned regionIdx,
209 const Evaluation& temperature,
210 const Evaluation& pressure) const
211 { OPM_GAS_PVT_MULTIPLEXER_CALL(return pvtImpl.saturatedInverseFormationVolumeFactor(regionIdx, temperature, pressure)); }
212
216 template <class Evaluation = Scalar>
217 Evaluation saturatedOilVaporizationFactor(unsigned regionIdx,
218 const Evaluation& temperature,
219 const Evaluation& pressure) const
220 { OPM_GAS_PVT_MULTIPLEXER_CALL(return pvtImpl.saturatedOilVaporizationFactor(regionIdx, temperature, pressure)); }
221
225 template <class Evaluation = Scalar>
226 Evaluation saturatedOilVaporizationFactor(unsigned regionIdx,
227 const Evaluation& temperature,
228 const Evaluation& pressure,
229 const Evaluation& oilSaturation,
230 const Evaluation& maxOilSaturation) const
231 { OPM_GAS_PVT_MULTIPLEXER_CALL(return pvtImpl.saturatedOilVaporizationFactor(regionIdx, temperature, pressure, oilSaturation, maxOilSaturation)); }
232
236 template <class Evaluation = Scalar>
237 Evaluation saturatedWaterVaporizationFactor(unsigned regionIdx,
238 const Evaluation& temperature,
239 const Evaluation& pressure) const
240 { OPM_GAS_PVT_MULTIPLEXER_CALL(return pvtImpl.saturatedWaterVaporizationFactor(regionIdx, temperature, pressure)); }
241
245 template <class Evaluation = Scalar>
246 Evaluation saturatedWaterVaporizationFactor(unsigned regionIdx,
247 const Evaluation& temperature,
248 const Evaluation& pressure,
249 const Evaluation& saltConcentration) const
250 { OPM_GAS_PVT_MULTIPLEXER_CALL(return pvtImpl.saturatedWaterVaporizationFactor(regionIdx, temperature, pressure, saltConcentration)); }
251
258 template <class Evaluation = Scalar>
259 Evaluation saturationPressure(unsigned regionIdx,
260 const Evaluation& temperature,
261 const Evaluation& Rv) const
262 { OPM_GAS_PVT_MULTIPLEXER_CALL(return pvtImpl.saturationPressure(regionIdx, temperature, Rv)); }
263
267 template <class Evaluation>
268 Evaluation diffusionCoefficient(const Evaluation& temperature,
269 const Evaluation& pressure,
270 unsigned compIdx) const
271 {
272 OPM_GAS_PVT_MULTIPLEXER_CALL(return pvtImpl.diffusionCoefficient(temperature, pressure, compIdx));
273 }
274
280 GasPvtApproach gasPvtApproach() const
281 { return gasPvtApproach_; }
282
283 // get the parameter object for the dry gas case
284 template <GasPvtApproach approachV>
285 typename std::enable_if<approachV == GasPvtApproach::DryGas, DryGasPvt<Scalar> >::type& getRealPvt()
286 {
287 assert(gasPvtApproach() == approachV);
288 return *static_cast<DryGasPvt<Scalar>* >(realGasPvt_);
289 }
290
291 template <GasPvtApproach approachV>
292 typename std::enable_if<approachV == GasPvtApproach::DryGas, const DryGasPvt<Scalar> >::type& getRealPvt() const
293 {
294 assert(gasPvtApproach() == approachV);
295 return *static_cast<const DryGasPvt<Scalar>* >(realGasPvt_);
296 }
297
298 // get the parameter object for the dry humid gas case
299 template <GasPvtApproach approachV>
300 typename std::enable_if<approachV == GasPvtApproach::DryHumidGas, DryHumidGasPvt<Scalar> >::type& getRealPvt()
301 {
302 assert(gasPvtApproach() == approachV);
303 return *static_cast<DryHumidGasPvt<Scalar>* >(realGasPvt_);
304 }
305
306 template <GasPvtApproach approachV>
307 typename std::enable_if<approachV == GasPvtApproach::DryHumidGas, const DryHumidGasPvt<Scalar> >::type& getRealPvt() const
308 {
309 assert(gasPvtApproach() == approachV);
310 return *static_cast<const DryHumidGasPvt<Scalar>* >(realGasPvt_);
311 }
312
313 // get the parameter object for the wet humid gas case
314 template <GasPvtApproach approachV>
315 typename std::enable_if<approachV == GasPvtApproach::WetHumidGas, WetHumidGasPvt<Scalar> >::type& getRealPvt()
316 {
317 assert(gasPvtApproach() == approachV);
318 return *static_cast<WetHumidGasPvt<Scalar>* >(realGasPvt_);
319 }
320
321 template <GasPvtApproach approachV>
322 typename std::enable_if<approachV == GasPvtApproach::WetHumidGas, const WetHumidGasPvt<Scalar> >::type& getRealPvt() const
323 {
324 assert(gasPvtApproach() == approachV);
325 return *static_cast<const WetHumidGasPvt<Scalar>* >(realGasPvt_);
326 }
327
328 // get the parameter object for the wet gas case
329 template <GasPvtApproach approachV>
330 typename std::enable_if<approachV == GasPvtApproach::WetGas, WetGasPvt<Scalar> >::type& getRealPvt()
331 {
332 assert(gasPvtApproach() == approachV);
333 return *static_cast<WetGasPvt<Scalar>* >(realGasPvt_);
334 }
335
336 template <GasPvtApproach approachV>
337 typename std::enable_if<approachV == GasPvtApproach::WetGas, const WetGasPvt<Scalar> >::type& getRealPvt() const
338 {
339 assert(gasPvtApproach() == approachV);
340 return *static_cast<const WetGasPvt<Scalar>* >(realGasPvt_);
341 }
342
343 // get the parameter object for the thermal gas case
344 template <GasPvtApproach approachV>
345 typename std::enable_if<approachV == GasPvtApproach::ThermalGas, GasPvtThermal<Scalar> >::type& getRealPvt()
346 {
347 assert(gasPvtApproach() == approachV);
348 return *static_cast<GasPvtThermal<Scalar>* >(realGasPvt_);
349 }
350 template <GasPvtApproach approachV>
351 typename std::enable_if<approachV == GasPvtApproach::ThermalGas, const GasPvtThermal<Scalar> >::type& getRealPvt() const
352 {
353 assert(gasPvtApproach() == approachV);
354 return *static_cast<const GasPvtThermal<Scalar>* >(realGasPvt_);
355 }
356
357 template <GasPvtApproach approachV>
358 typename std::enable_if<approachV == GasPvtApproach::Co2Gas, Co2GasPvt<Scalar> >::type& getRealPvt()
359 {
360 assert(gasPvtApproach() == approachV);
361 return *static_cast<Co2GasPvt<Scalar>* >(realGasPvt_);
362 }
363
364 template <GasPvtApproach approachV>
365 typename std::enable_if<approachV == GasPvtApproach::Co2Gas, const Co2GasPvt<Scalar> >::type& getRealPvt() const
366 {
367 assert(gasPvtApproach() == approachV);
368 return *static_cast<const Co2GasPvt<Scalar>* >(realGasPvt_);
369 }
370
371 template <GasPvtApproach approachV>
372 typename std::enable_if<approachV == GasPvtApproach::H2Gas, H2GasPvt<Scalar> >::type& getRealPvt()
373 {
374 assert(gasPvtApproach() == approachV);
375 return *static_cast<H2GasPvt<Scalar>* >(realGasPvt_);
376 }
377
378 template <GasPvtApproach approachV>
379 typename std::enable_if<approachV == GasPvtApproach::H2Gas, const H2GasPvt<Scalar> >::type& getRealPvt() const
380 {
381 assert(gasPvtApproach() == approachV);
382 return *static_cast<const H2GasPvt<Scalar>* >(realGasPvt_);
383 }
384
385 const void* realGasPvt() const { return realGasPvt_; }
386
387 GasPvtMultiplexer<Scalar,enableThermal>&
388 operator=(const GasPvtMultiplexer<Scalar,enableThermal>& data);
389
390private:
391 GasPvtApproach gasPvtApproach_{GasPvtApproach::NoGas};
392 void* realGasPvt_{nullptr};
393};
394
395} // namespace Opm
396
397#endif
This class represents the Pressure-Volume-Temperature relations of the gas phase for CO2.
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 with vaporized water...
This class implements temperature dependence of the PVT properties of gas.
This class represents the Pressure-Volume-Temperature relations of the gas phase for H2.
This class represents the Pressure-Volume-Temperature relations of the gas phas with vaporized oil.
This class represents the Pressure-Volume-Temperature relations of the gas phase with vaporized oil a...
This class represents the Pressure-Volume-Temperature relations of the gas phase without vaporized oi...
Definition DryGasPvt.hpp:50
Definition EclipseState.hpp:63
This class represents the Pressure-Volume-Temperature relations of the gas phase in the black-oil mod...
Definition GasPvtMultiplexer.hpp:110
GasPvtApproach gasPvtApproach() const
Returns the concrete approach for calculating the PVT relations.
Definition GasPvtMultiplexer.hpp:280
Scalar gasReferenceDensity(unsigned regionIdx)
Return the reference density which are considered by this PVT-object.
Definition GasPvtMultiplexer.cpp:94
Evaluation saturatedInverseFormationVolumeFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure) const
Returns the formation volume factor [-] of oil saturated gas given a set of parameters.
Definition GasPvtMultiplexer.hpp:208
unsigned numRegions() const
Return the number of PVT regions which are considered by this PVT-object.
Definition GasPvtMultiplexer.cpp:78
Evaluation saturatedWaterVaporizationFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure) const
Returns the water vaporization factor [m^3/m^3] of water saturated gas.
Definition GasPvtMultiplexer.hpp:237
Evaluation inverseFormationVolumeFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &Rv, const Evaluation &Rvw) const
Returns the formation volume factor [-] of the fluid phase.
Definition GasPvtMultiplexer.hpp:197
Evaluation internalEnergy(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &Rv, const Evaluation &Rvw) const
Returns the specific enthalpy [J/kg] of gas given a set of parameters.
Definition GasPvtMultiplexer.hpp:164
Evaluation viscosity(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &Rv, const Evaluation &Rvw) const
Returns the dynamic viscosity [Pa s] of the fluid phase given a set of parameters.
Definition GasPvtMultiplexer.hpp:177
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 GasPvtMultiplexer.hpp:268
Evaluation saturatedWaterVaporizationFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &saltConcentration) const
Returns the water vaporization factor [m^3/m^3] of water saturated gas.
Definition GasPvtMultiplexer.hpp:246
Evaluation saturatedOilVaporizationFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure) const
Returns the oil vaporization factor [m^3/m^3] of oil saturated gas.
Definition GasPvtMultiplexer.hpp:217
Evaluation saturationPressure(unsigned regionIdx, const Evaluation &temperature, const Evaluation &Rv) const
Returns the saturation pressure of the gas phase [Pa] depending on its mass fraction of the oil compo...
Definition GasPvtMultiplexer.hpp:259
Evaluation saturatedOilVaporizationFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &oilSaturation, const Evaluation &maxOilSaturation) const
Returns the oil vaporization factor [m^3/m^3] of oil saturated gas.
Definition GasPvtMultiplexer.hpp:226
Evaluation saturatedViscosity(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure) const
Returns the dynamic viscosity [Pa s] of oil saturated gas given a set of parameters.
Definition GasPvtMultiplexer.hpp:188
Definition Schedule.hpp:89
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30