27 #ifndef OPM_GAS_PVT_MULTIPLEXER_HPP
28 #define OPM_GAS_PVT_MULTIPLEXER_HPP
38 #include <opm/input/eclipse/EclipseState/EclipseState.hpp>
42 #define OPM_GAS_PVT_MULTIPLEXER_CALL(codeToCall) \
43 switch (gasPvtApproach_) { \
44 case GasPvtApproach::DryGasPvt: { \
45 auto& pvtImpl = getRealPvt<GasPvtApproach::DryGasPvt>(); \
49 case GasPvtApproach::DryHumidGasPvt: { \
50 auto& pvtImpl = getRealPvt<GasPvtApproach::DryHumidGasPvt>(); \
54 case GasPvtApproach::WetHumidGasPvt: { \
55 auto& pvtImpl = getRealPvt<GasPvtApproach::WetHumidGasPvt>(); \
59 case GasPvtApproach::WetGasPvt: { \
60 auto& pvtImpl = getRealPvt<GasPvtApproach::WetGasPvt>(); \
64 case GasPvtApproach::ThermalGasPvt: { \
65 auto& pvtImpl = getRealPvt<GasPvtApproach::ThermalGasPvt>(); \
69 case GasPvtApproach::Co2GasPvt: { \
70 auto& pvtImpl = getRealPvt<GasPvtApproach::Co2GasPvt>(); \
74 case GasPvtApproach::NoGasPvt: \
75 throw std::logic_error("Not implemented: Gas PVT of this deck!"); \
78 enum class GasPvtApproach {
98 template <
class Scalar,
bool enableThermal = true>
104 gasPvtApproach_ = GasPvtApproach::NoGasPvt;
105 realGasPvt_ =
nullptr;
109 : gasPvtApproach_(approach)
110 , realGasPvt_(realGasPvt)
120 switch (gasPvtApproach_) {
121 case GasPvtApproach::DryGasPvt: {
122 delete &getRealPvt<GasPvtApproach::DryGasPvt>();
125 case GasPvtApproach::DryHumidGasPvt: {
126 delete &getRealPvt<GasPvtApproach::DryHumidGasPvt>();
129 case GasPvtApproach::WetHumidGasPvt: {
130 delete &getRealPvt<GasPvtApproach::WetHumidGasPvt>();
133 case GasPvtApproach::WetGasPvt: {
134 delete &getRealPvt<GasPvtApproach::WetGasPvt>();
137 case GasPvtApproach::ThermalGasPvt: {
138 delete &getRealPvt<GasPvtApproach::ThermalGasPvt>();
141 case GasPvtApproach::Co2GasPvt: {
142 delete &getRealPvt<GasPvtApproach::Co2GasPvt>();
145 case GasPvtApproach::NoGasPvt:
156 void initFromState(
const EclipseState& eclState,
const Schedule& schedule)
158 if (!eclState.runspec().phases().active(Phase::GAS))
160 if (eclState.runspec().co2Storage())
161 setApproach(GasPvtApproach::Co2GasPvt);
162 else if (enableThermal && eclState.getSimulationConfig().isThermal())
163 setApproach(GasPvtApproach::ThermalGasPvt);
164 else if (!eclState.getTableManager().getPvtgwTables().empty() && !eclState.getTableManager().getPvtgTables().empty())
165 setApproach(GasPvtApproach::WetHumidGasPvt);
166 else if (!eclState.getTableManager().getPvtgTables().empty())
167 setApproach(GasPvtApproach::WetGasPvt);
168 else if (eclState.getTableManager().hasTables(
"PVDG"))
169 setApproach(GasPvtApproach::DryGasPvt);
170 else if (!eclState.getTableManager().getPvtgwTables().empty())
171 setApproach(GasPvtApproach::DryHumidGasPvt);
174 OPM_GAS_PVT_MULTIPLEXER_CALL(pvtImpl.initFromState(eclState, schedule));
178 void setApproach(GasPvtApproach gasPvtAppr)
180 switch (gasPvtAppr) {
181 case GasPvtApproach::DryGasPvt:
185 case GasPvtApproach::DryHumidGasPvt:
189 case GasPvtApproach::WetHumidGasPvt:
193 case GasPvtApproach::WetGasPvt:
197 case GasPvtApproach::ThermalGasPvt:
201 case GasPvtApproach::Co2GasPvt:
205 case GasPvtApproach::NoGasPvt:
206 throw std::logic_error(
"Not implemented: Gas PVT of this deck!");
209 gasPvtApproach_ = gasPvtAppr;
213 { OPM_GAS_PVT_MULTIPLEXER_CALL(pvtImpl.initEnd()); }
219 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.numRegions());
return 1; }
225 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.gasReferenceDensity(regionIdx));
return 2.; }
230 template <
class Evaluation>
232 const Evaluation& temperature,
233 const Evaluation& pressure,
234 const Evaluation& Rv)
const
235 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.internalEnergy(regionIdx, temperature, pressure, Rv));
return 0; }
240 template <
class Evaluation = Scalar>
242 const Evaluation& temperature,
243 const Evaluation& pressure,
244 const Evaluation& Rv,
245 const Evaluation& Rvw )
const
246 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.viscosity(regionIdx, temperature, pressure, Rv, Rvw));
return 0; }
251 template <
class Evaluation = Scalar>
253 const Evaluation& temperature,
254 const Evaluation& pressure)
const
255 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.saturatedViscosity(regionIdx, temperature, pressure));
return 0; }
260 template <
class Evaluation = Scalar>
262 const Evaluation& temperature,
263 const Evaluation& pressure,
264 const Evaluation& Rv,
265 const Evaluation& Rvw)
const
266 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.inverseFormationVolumeFactor(regionIdx, temperature, pressure, Rv, Rvw));
return 0; }
271 template <
class Evaluation = Scalar>
273 const Evaluation& temperature,
274 const Evaluation& pressure)
const
275 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.saturatedInverseFormationVolumeFactor(regionIdx, temperature, pressure));
return 0; }
280 template <
class Evaluation = Scalar>
282 const Evaluation& temperature,
283 const Evaluation& pressure)
const
284 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.saturatedOilVaporizationFactor(regionIdx, temperature, pressure));
return 0; }
289 template <
class Evaluation = Scalar>
291 const Evaluation& temperature,
292 const Evaluation& pressure,
293 const Evaluation& oilSaturation,
294 const Evaluation& maxOilSaturation)
const
295 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.saturatedOilVaporizationFactor(regionIdx, temperature, pressure, oilSaturation, maxOilSaturation));
return 0; }
300 template <
class Evaluation = Scalar>
302 const Evaluation& temperature,
303 const Evaluation& pressure)
const
304 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.saturatedWaterVaporizationFactor(regionIdx, temperature, pressure));
return 0; }
312 template <
class Evaluation = Scalar>
314 const Evaluation& temperature,
315 const Evaluation& Rv)
const
316 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.saturationPressure(regionIdx, temperature, Rv));
return 0; }
321 template <
class Evaluation>
323 const Evaluation& pressure,
324 unsigned compIdx)
const
326 OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.diffusionCoefficient(temperature, pressure, compIdx));
return 0;
335 {
return gasPvtApproach_; }
338 template <GasPvtApproach approachV>
339 typename std::enable_if<approachV == GasPvtApproach::DryGasPvt, DryGasPvt<Scalar> >::type& getRealPvt()
345 template <GasPvtApproach approachV>
346 typename std::enable_if<approachV == GasPvtApproach::DryGasPvt, const DryGasPvt<Scalar> >::type& getRealPvt()
const
349 return *
static_cast<const DryGasPvt<Scalar>*
>(realGasPvt_);
353 template <GasPvtApproach approachV>
354 typename std::enable_if<approachV == GasPvtApproach::DryHumidGasPvt, DryHumidGasPvt<Scalar> >::type& getRealPvt()
357 return *
static_cast<DryHumidGasPvt<Scalar>*
>(realGasPvt_);
360 template <GasPvtApproach approachV>
361 typename std::enable_if<approachV == GasPvtApproach::DryHumidGasPvt, const DryHumidGasPvt<Scalar> >::type& getRealPvt()
const
364 return *
static_cast<const DryHumidGasPvt<Scalar>*
>(realGasPvt_);
368 template <GasPvtApproach approachV>
369 typename std::enable_if<approachV == GasPvtApproach::WetHumidGasPvt, WetHumidGasPvt<Scalar> >::type& getRealPvt()
372 return *
static_cast<WetHumidGasPvt<Scalar>*
>(realGasPvt_);
375 template <GasPvtApproach approachV>
376 typename std::enable_if<approachV == GasPvtApproach::WetHumidGasPvt, const WetHumidGasPvt<Scalar> >::type& getRealPvt()
const
379 return *
static_cast<const WetHumidGasPvt<Scalar>*
>(realGasPvt_);
383 template <GasPvtApproach approachV>
384 typename std::enable_if<approachV == GasPvtApproach::WetGasPvt, WetGasPvt<Scalar> >::type& getRealPvt()
387 return *
static_cast<WetGasPvt<Scalar>*
>(realGasPvt_);
390 template <GasPvtApproach approachV>
391 typename std::enable_if<approachV == GasPvtApproach::WetGasPvt, const WetGasPvt<Scalar> >::type& getRealPvt()
const
394 return *
static_cast<const WetGasPvt<Scalar>*
>(realGasPvt_);
398 template <GasPvtApproach approachV>
399 typename std::enable_if<approachV == GasPvtApproach::ThermalGasPvt, GasPvtThermal<Scalar> >::type& getRealPvt()
402 return *
static_cast<GasPvtThermal<Scalar>*
>(realGasPvt_);
404 template <GasPvtApproach approachV>
405 typename std::enable_if<approachV == GasPvtApproach::ThermalGasPvt, const GasPvtThermal<Scalar> >::type& getRealPvt()
const
408 return *
static_cast<const GasPvtThermal<Scalar>*
>(realGasPvt_);
411 template <GasPvtApproach approachV>
412 typename std::enable_if<approachV == GasPvtApproach::Co2GasPvt, Co2GasPvt<Scalar> >::type& getRealPvt()
415 return *
static_cast<Co2GasPvt<Scalar>*
>(realGasPvt_);
418 template <GasPvtApproach approachV>
419 typename std::enable_if<approachV == GasPvtApproach::Co2GasPvt, const Co2GasPvt<Scalar> >::type& getRealPvt()
const
422 return *
static_cast<const Co2GasPvt<Scalar>*
>(realGasPvt_);
425 const void* realGasPvt()
const {
return realGasPvt_; }
427 bool operator==(
const GasPvtMultiplexer<Scalar,enableThermal>& data)
const
432 switch (gasPvtApproach_) {
433 case GasPvtApproach::DryGasPvt:
434 return *
static_cast<const DryGasPvt<Scalar>*
>(realGasPvt_) ==
435 *
static_cast<const DryGasPvt<Scalar>*
>(data.realGasPvt_);
436 case GasPvtApproach::DryHumidGasPvt:
437 return *
static_cast<const DryHumidGasPvt<Scalar>*
>(realGasPvt_) ==
438 *
static_cast<const DryHumidGasPvt<Scalar>*
>(data.realGasPvt_);
439 case GasPvtApproach::WetHumidGasPvt:
440 return *
static_cast<const WetHumidGasPvt<Scalar>*
>(realGasPvt_) ==
441 *
static_cast<const WetHumidGasPvt<Scalar>*
>(data.realGasPvt_);
442 case GasPvtApproach::WetGasPvt:
443 return *
static_cast<const WetGasPvt<Scalar>*
>(realGasPvt_) ==
444 *
static_cast<const WetGasPvt<Scalar>*
>(data.realGasPvt_);
445 case GasPvtApproach::ThermalGasPvt:
446 return *
static_cast<const GasPvtThermal<Scalar>*
>(realGasPvt_) ==
447 *
static_cast<const GasPvtThermal<Scalar>*
>(data.realGasPvt_);
448 case GasPvtApproach::Co2GasPvt:
449 return *
static_cast<const Co2GasPvt<Scalar>*
>(realGasPvt_) ==
450 *
static_cast<const Co2GasPvt<Scalar>*
>(data.realGasPvt_);
456 GasPvtMultiplexer<Scalar,enableThermal>& operator=(
const GasPvtMultiplexer<Scalar,enableThermal>& data)
458 gasPvtApproach_ = data.gasPvtApproach_;
459 switch (gasPvtApproach_) {
460 case GasPvtApproach::DryGasPvt:
461 realGasPvt_ =
new DryGasPvt<Scalar>(*
static_cast<const DryGasPvt<Scalar>*
>(data.realGasPvt_));
463 case GasPvtApproach::DryHumidGasPvt:
464 realGasPvt_ =
new DryHumidGasPvt<Scalar>(*
static_cast<const DryHumidGasPvt<Scalar>*
>(data.realGasPvt_));
466 case GasPvtApproach::WetHumidGasPvt:
467 realGasPvt_ =
new WetHumidGasPvt<Scalar>(*
static_cast<const WetHumidGasPvt<Scalar>*
>(data.realGasPvt_));
469 case GasPvtApproach::WetGasPvt:
470 realGasPvt_ =
new WetGasPvt<Scalar>(*
static_cast<const WetGasPvt<Scalar>*
>(data.realGasPvt_));
472 case GasPvtApproach::ThermalGasPvt:
473 realGasPvt_ =
new GasPvtThermal<Scalar>(*
static_cast<const GasPvtThermal<Scalar>*
>(data.realGasPvt_));
475 case GasPvtApproach::Co2GasPvt:
476 realGasPvt_ =
new Co2GasPvt<Scalar>(*
static_cast<const Co2GasPvt<Scalar>*
>(data.realGasPvt_));
486 GasPvtApproach gasPvtApproach_;
490 #undef OPM_GAS_PVT_MULTIPLEXER_CALL
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 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 for CO2.
Definition: Co2GasPvt.hpp:53
This class represents the Pressure-Volume-Temperature relations of the gas phase without vaporized oi...
Definition: DryGasPvt.hpp:50
This class represents the Pressure-Volume-Temperature relations of the gas phase with vaporized water...
Definition: DryHumidGasPvt.hpp:53
This class represents the Pressure-Volume-Temperature relations of the gas phase in the black-oil mod...
Definition: GasPvtMultiplexer.hpp:100
GasPvtApproach gasPvtApproach() const
Returns the concrete approach for calculating the PVT relations.
Definition: GasPvtMultiplexer.hpp:334
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:272
unsigned numRegions() const
Return the number of PVT regions which are considered by this PVT-object.
Definition: GasPvtMultiplexer.hpp:218
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:301
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:261
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:241
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:322
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:281
const Scalar gasReferenceDensity(unsigned regionIdx)
Return the reference density which are considered by this PVT-object.
Definition: GasPvtMultiplexer.hpp:224
Evaluation internalEnergy(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &Rv) const
Returns the specific enthalpy [J/kg] of gas given a set of parameters.
Definition: GasPvtMultiplexer.hpp:231
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:313
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:290
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:252
This class implements temperature dependence of the PVT properties of gas.
Definition: GasPvtThermal.hpp:50
This class represents the Pressure-Volume-Temperature relations of the gas phas with vaporized oil.
Definition: WetGasPvt.hpp:52
This class represents the Pressure-Volume-Temperature relations of the gas phase with vaporized oil a...
Definition: WetHumidGasPvt.hpp:52