Loading...
Searching...
No Matches
GasPvtMultiplexer.hpp
Go to the documentation of this file.
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
Consult the COPYING file in the top-level source directory of this
module for the precise wording of the license and the list of
copyright holders.
*/
#ifndef OPM_GAS_PVT_MULTIPLEXER_HPP
#define OPM_GAS_PVT_MULTIPLEXER_HPP
#include <opm/material/fluidsystems/blackoilpvt/Co2GasPvt.hpp>
#include <opm/material/fluidsystems/blackoilpvt/DryGasPvt.hpp>
#include <opm/material/fluidsystems/blackoilpvt/DryHumidGasPvt.hpp>
#include <opm/material/fluidsystems/blackoilpvt/GasPvtThermal.hpp>
#include <opm/material/fluidsystems/blackoilpvt/H2GasPvt.hpp>
#include <opm/material/fluidsystems/blackoilpvt/WetGasPvt.hpp>
#include <opm/material/fluidsystems/blackoilpvt/WetHumidGasPvt.hpp>
namespace Opm {
#if HAVE_ECL_INPUT
class EclipseState;
class Schedule;
#endif
#define OPM_GAS_PVT_MULTIPLEXER_CALL(codeToCall, ...) \
switch (gasPvtApproach_) { \
case GasPvtApproach::DryGas: { \
auto& pvtImpl = getRealPvt<GasPvtApproach::DryGas>(); \
codeToCall; \
__VA_ARGS__; \
} \
case GasPvtApproach::DryHumidGas: { \
auto& pvtImpl = getRealPvt<GasPvtApproach::DryHumidGas>(); \
codeToCall; \
__VA_ARGS__; \
} \
case GasPvtApproach::WetHumidGas: { \
auto& pvtImpl = getRealPvt<GasPvtApproach::WetHumidGas>(); \
codeToCall; \
__VA_ARGS__; \
} \
case GasPvtApproach::WetGas: { \
auto& pvtImpl = getRealPvt<GasPvtApproach::WetGas>(); \
codeToCall; \
__VA_ARGS__; \
} \
case GasPvtApproach::ThermalGas: { \
auto& pvtImpl = getRealPvt<GasPvtApproach::ThermalGas>(); \
codeToCall; \
__VA_ARGS__; \
} \
case GasPvtApproach::Co2Gas: { \
auto& pvtImpl = getRealPvt<GasPvtApproach::Co2Gas>(); \
codeToCall; \
__VA_ARGS__; \
} \
case GasPvtApproach::H2Gas: { \
auto& pvtImpl = getRealPvt<GasPvtApproach::H2Gas>(); \
codeToCall; \
__VA_ARGS__; \
} \
default: \
case GasPvtApproach::NoGas: \
throw std::logic_error("Not implemented: Gas PVT of this deck!"); \
}
enum class GasPvtApproach {
NoGas,
DryGas,
DryHumidGas,
WetHumidGas,
WetGas,
ThermalGas,
Co2Gas,
H2Gas
};
template <class Scalar, bool enableThermal = true>
class GasPvtMultiplexer
{
public:
GasPvtMultiplexer()
: gasPvtApproach_(GasPvtApproach::NoGas)
, realGasPvt_(nullptr)
{
}
GasPvtMultiplexer(GasPvtApproach approach, void* realGasPvt)
: gasPvtApproach_(approach)
, realGasPvt_(realGasPvt)
{ }
GasPvtMultiplexer(const GasPvtMultiplexer<Scalar,enableThermal>& data)
{
*this = data;
}
~GasPvtMultiplexer();
bool mixingEnergy() const
{
return gasPvtApproach_ == GasPvtApproach::ThermalGas;
}
#if HAVE_ECL_INPUT
void initFromState(const EclipseState& eclState, const Schedule& schedule);
#endif // HAVE_ECL_INPUT
void setApproach(GasPvtApproach gasPvtAppr);
void initEnd();
unsigned numRegions() const;
void setVapPars(const Scalar par1, const Scalar par2);
Scalar gasReferenceDensity(unsigned regionIdx);
template <class Evaluation>
Evaluation internalEnergy(unsigned regionIdx,
const Evaluation& temperature,
const Evaluation& pressure,
const Evaluation& Rv,
const Evaluation& Rvw) const
{ OPM_GAS_PVT_MULTIPLEXER_CALL(return pvtImpl.internalEnergy(regionIdx, temperature, pressure, Rv, Rvw)); }
Scalar hVap(unsigned regionIdx) const;
template <class Evaluation = Scalar>
Evaluation viscosity(unsigned regionIdx,
const Evaluation& temperature,
const Evaluation& pressure,
const Evaluation& Rv,
const Evaluation& Rvw ) const
{ OPM_GAS_PVT_MULTIPLEXER_CALL(return pvtImpl.viscosity(regionIdx, temperature, pressure, Rv, Rvw)); }
template <class Evaluation = Scalar>
Evaluation saturatedViscosity(unsigned regionIdx,
const Evaluation& temperature,
const Evaluation& pressure) const
{ OPM_GAS_PVT_MULTIPLEXER_CALL(return pvtImpl.saturatedViscosity(regionIdx, temperature, pressure)); }
template <class Evaluation = Scalar>
Evaluation inverseFormationVolumeFactor(unsigned regionIdx,
const Evaluation& temperature,
const Evaluation& pressure,
const Evaluation& Rv,
const Evaluation& Rvw) const
{ OPM_GAS_PVT_MULTIPLEXER_CALL(return pvtImpl.inverseFormationVolumeFactor(regionIdx, temperature, pressure, Rv, Rvw)); }
template <class Evaluation = Scalar>
Evaluation saturatedInverseFormationVolumeFactor(unsigned regionIdx,
const Evaluation& temperature,
const Evaluation& pressure) const
{ OPM_GAS_PVT_MULTIPLEXER_CALL(return pvtImpl.saturatedInverseFormationVolumeFactor(regionIdx, temperature, pressure)); }
template <class Evaluation = Scalar>
Evaluation saturatedOilVaporizationFactor(unsigned regionIdx,
const Evaluation& temperature,
const Evaluation& pressure) const
{ OPM_GAS_PVT_MULTIPLEXER_CALL(return pvtImpl.saturatedOilVaporizationFactor(regionIdx, temperature, pressure)); }
template <class Evaluation = Scalar>
Evaluation saturatedOilVaporizationFactor(unsigned regionIdx,
const Evaluation& temperature,
const Evaluation& pressure,
const Evaluation& oilSaturation,
const Evaluation& maxOilSaturation) const
{ OPM_GAS_PVT_MULTIPLEXER_CALL(return pvtImpl.saturatedOilVaporizationFactor(regionIdx, temperature, pressure, oilSaturation, maxOilSaturation)); }
template <class Evaluation = Scalar>
Evaluation saturatedWaterVaporizationFactor(unsigned regionIdx,
const Evaluation& temperature,
const Evaluation& pressure) const
{ OPM_GAS_PVT_MULTIPLEXER_CALL(return pvtImpl.saturatedWaterVaporizationFactor(regionIdx, temperature, pressure)); }
template <class Evaluation = Scalar>
Evaluation saturatedWaterVaporizationFactor(unsigned regionIdx,
const Evaluation& temperature,
const Evaluation& pressure,
const Evaluation& saltConcentration) const
{ OPM_GAS_PVT_MULTIPLEXER_CALL(return pvtImpl.saturatedWaterVaporizationFactor(regionIdx, temperature, pressure, saltConcentration)); }
template <class Evaluation = Scalar>
Evaluation saturationPressure(unsigned regionIdx,
const Evaluation& temperature,
const Evaluation& Rv) const
{ OPM_GAS_PVT_MULTIPLEXER_CALL(return pvtImpl.saturationPressure(regionIdx, temperature, Rv)); }
template <class Evaluation>
Evaluation diffusionCoefficient(const Evaluation& temperature,
const Evaluation& pressure,
unsigned compIdx) const
{
OPM_GAS_PVT_MULTIPLEXER_CALL(return pvtImpl.diffusionCoefficient(temperature, pressure, compIdx));
}
GasPvtApproach gasPvtApproach() const
{ return gasPvtApproach_; }
// get the parameter object for the dry gas case
template <GasPvtApproach approachV>
typename std::enable_if<approachV == GasPvtApproach::DryGas, DryGasPvt<Scalar> >::type& getRealPvt()
{
assert(gasPvtApproach() == approachV);
return *static_cast<DryGasPvt<Scalar>* >(realGasPvt_);
}
template <GasPvtApproach approachV>
typename std::enable_if<approachV == GasPvtApproach::DryGas, const DryGasPvt<Scalar> >::type& getRealPvt() const
{
assert(gasPvtApproach() == approachV);
return *static_cast<const DryGasPvt<Scalar>* >(realGasPvt_);
}
// get the parameter object for the dry humid gas case
template <GasPvtApproach approachV>
typename std::enable_if<approachV == GasPvtApproach::DryHumidGas, DryHumidGasPvt<Scalar> >::type& getRealPvt()
{
assert(gasPvtApproach() == approachV);
return *static_cast<DryHumidGasPvt<Scalar>* >(realGasPvt_);
}
template <GasPvtApproach approachV>
typename std::enable_if<approachV == GasPvtApproach::DryHumidGas, const DryHumidGasPvt<Scalar> >::type& getRealPvt() const
{
assert(gasPvtApproach() == approachV);
return *static_cast<const DryHumidGasPvt<Scalar>* >(realGasPvt_);
}
// get the parameter object for the wet humid gas case
template <GasPvtApproach approachV>
typename std::enable_if<approachV == GasPvtApproach::WetHumidGas, WetHumidGasPvt<Scalar> >::type& getRealPvt()
{
assert(gasPvtApproach() == approachV);
return *static_cast<WetHumidGasPvt<Scalar>* >(realGasPvt_);
}
template <GasPvtApproach approachV>
typename std::enable_if<approachV == GasPvtApproach::WetHumidGas, const WetHumidGasPvt<Scalar> >::type& getRealPvt() const
{
assert(gasPvtApproach() == approachV);
return *static_cast<const WetHumidGasPvt<Scalar>* >(realGasPvt_);
}
// get the parameter object for the wet gas case
template <GasPvtApproach approachV>
typename std::enable_if<approachV == GasPvtApproach::WetGas, WetGasPvt<Scalar> >::type& getRealPvt()
{
assert(gasPvtApproach() == approachV);
return *static_cast<WetGasPvt<Scalar>* >(realGasPvt_);
}
template <GasPvtApproach approachV>
typename std::enable_if<approachV == GasPvtApproach::WetGas, const WetGasPvt<Scalar> >::type& getRealPvt() const
{
assert(gasPvtApproach() == approachV);
return *static_cast<const WetGasPvt<Scalar>* >(realGasPvt_);
}
// get the parameter object for the thermal gas case
template <GasPvtApproach approachV>
typename std::enable_if<approachV == GasPvtApproach::ThermalGas, GasPvtThermal<Scalar> >::type& getRealPvt()
{
assert(gasPvtApproach() == approachV);
return *static_cast<GasPvtThermal<Scalar>* >(realGasPvt_);
}
template <GasPvtApproach approachV>
typename std::enable_if<approachV == GasPvtApproach::ThermalGas, const GasPvtThermal<Scalar> >::type& getRealPvt() const
{
assert(gasPvtApproach() == approachV);
return *static_cast<const GasPvtThermal<Scalar>* >(realGasPvt_);
}
template <GasPvtApproach approachV>
typename std::enable_if<approachV == GasPvtApproach::Co2Gas, Co2GasPvt<Scalar> >::type& getRealPvt()
{
assert(gasPvtApproach() == approachV);
return *static_cast<Co2GasPvt<Scalar>* >(realGasPvt_);
}
template <GasPvtApproach approachV>
typename std::enable_if<approachV == GasPvtApproach::Co2Gas, const Co2GasPvt<Scalar> >::type& getRealPvt() const
{
assert(gasPvtApproach() == approachV);
return *static_cast<const Co2GasPvt<Scalar>* >(realGasPvt_);
}
template <GasPvtApproach approachV>
typename std::enable_if<approachV == GasPvtApproach::H2Gas, H2GasPvt<Scalar> >::type& getRealPvt()
{
assert(gasPvtApproach() == approachV);
return *static_cast<H2GasPvt<Scalar>* >(realGasPvt_);
}
template <GasPvtApproach approachV>
typename std::enable_if<approachV == GasPvtApproach::H2Gas, const H2GasPvt<Scalar> >::type& getRealPvt() const
{
assert(gasPvtApproach() == approachV);
return *static_cast<const H2GasPvt<Scalar>* >(realGasPvt_);
}
const void* realGasPvt() const { return realGasPvt_; }
GasPvtMultiplexer<Scalar,enableThermal>&
operator=(const GasPvtMultiplexer<Scalar,enableThermal>& data);
private:
GasPvtApproach gasPvtApproach_{GasPvtApproach::NoGas};
void* realGasPvt_{nullptr};
};
} // namespace Opm
#endif
Co2GasPvt.hpp
This class represents the Pressure-Volume-Temperature relations of the gas phase for CO2.
DryGasPvt.hpp
This class represents the Pressure-Volume-Temperature relations of the gas phase without vaporized oi...
DryHumidGasPvt.hpp
This class represents the Pressure-Volume-Temperature relations of the gas phase with vaporized water...
GasPvtThermal.hpp
This class implements temperature dependence of the PVT properties of gas.
H2GasPvt.hpp
This class represents the Pressure-Volume-Temperature relations of the gas phase for H2.
WetGasPvt.hpp
This class represents the Pressure-Volume-Temperature relations of the gas phas with vaporized oil.
WetHumidGasPvt.hpp
This class represents the Pressure-Volume-Temperature relations of the gas phase with vaporized oil a...
Opm::DryGasPvt
This class represents the Pressure-Volume-Temperature relations of the gas phase without vaporized oi...
Definition DryGasPvt.hpp:50
Opm::EclipseState
Definition EclipseState.hpp:63
Opm::GasPvtMultiplexer
This class represents the Pressure-Volume-Temperature relations of the gas phase in the black-oil mod...
Definition GasPvtMultiplexer.hpp:110
Opm::GasPvtMultiplexer::gasPvtApproach
GasPvtApproach gasPvtApproach() const
Returns the concrete approach for calculating the PVT relations.
Definition GasPvtMultiplexer.hpp:280
Opm::GasPvtMultiplexer::gasReferenceDensity
Scalar gasReferenceDensity(unsigned regionIdx)
Return the reference density which are considered by this PVT-object.
Definition GasPvtMultiplexer.cpp:94
Opm::GasPvtMultiplexer::saturatedInverseFormationVolumeFactor
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
Opm::GasPvtMultiplexer::numRegions
unsigned numRegions() const
Return the number of PVT regions which are considered by this PVT-object.
Definition GasPvtMultiplexer.cpp:78
Opm::GasPvtMultiplexer::saturatedWaterVaporizationFactor
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
Opm::GasPvtMultiplexer::inverseFormationVolumeFactor
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
Opm::GasPvtMultiplexer::internalEnergy
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
Opm::GasPvtMultiplexer::viscosity
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
Opm::GasPvtMultiplexer::diffusionCoefficient
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
Opm::GasPvtMultiplexer::saturatedWaterVaporizationFactor
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
Opm::GasPvtMultiplexer::saturatedOilVaporizationFactor
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
Opm::GasPvtMultiplexer::saturationPressure
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
Opm::GasPvtMultiplexer::saturatedOilVaporizationFactor
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
Opm::GasPvtMultiplexer::saturatedViscosity
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
Opm::Schedule
Definition Schedule.hpp:89
Opm
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30