27 #ifndef OPM_GAS_PVT_MULTIPLEXER_HPP 28 #define OPM_GAS_PVT_MULTIPLEXER_HPP 44 #define OPM_GAS_PVT_MULTIPLEXER_CALL(codeToCall, ...) \ 45 switch (gasPvtApproach_) { \ 46 case GasPvtApproach::DryGas: { \ 47 auto& pvtImpl = getRealPvt<GasPvtApproach::DryGas>(); \ 51 case GasPvtApproach::DryHumidGas: { \ 52 auto& pvtImpl = getRealPvt<GasPvtApproach::DryHumidGas>(); \ 56 case GasPvtApproach::WetHumidGas: { \ 57 auto& pvtImpl = getRealPvt<GasPvtApproach::WetHumidGas>(); \ 61 case GasPvtApproach::WetGas: { \ 62 auto& pvtImpl = getRealPvt<GasPvtApproach::WetGas>(); \ 66 case GasPvtApproach::ThermalGas: { \ 67 auto& pvtImpl = getRealPvt<GasPvtApproach::ThermalGas>(); \ 71 case GasPvtApproach::Co2Gas: { \ 72 auto& pvtImpl = getRealPvt<GasPvtApproach::Co2Gas>(); \ 76 case GasPvtApproach::H2Gas: { \ 77 auto& pvtImpl = getRealPvt<GasPvtApproach::H2Gas>(); \ 82 case GasPvtApproach::NoGas: \ 83 throw std::logic_error("Not implemented: Gas PVT of this deck!"); \ 86 enum class GasPvtApproach {
107 template <
class Scalar,
bool enableThermal = true>
112 : gasPvtApproach_(GasPvtApproach::NoGas)
113 , realGasPvt_(
nullptr, [](
void*){})
119 , realGasPvt_(realGasPvt, [
this](
void* ptr){ deleter(ptr); })
129 bool mixingEnergy()
const 131 return gasPvtApproach_ == GasPvtApproach::ThermalGas;
134 bool isActive()
const {
135 return gasPvtApproach_ != GasPvtApproach::NoGas;
145 void setApproach(GasPvtApproach gasPvtAppr);
154 void setVapPars(
const Scalar par1,
const Scalar par2);
164 template <
class Evaluation>
166 const Evaluation& temperature,
167 const Evaluation& pressure,
168 const Evaluation& Rv,
169 const Evaluation& Rvw)
const 170 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.internalEnergy(regionIdx, temperature, pressure, Rv, Rvw)); }
172 Scalar hVap(
unsigned regionIdx)
const;
177 template <
class Evaluation = Scalar>
179 const Evaluation& temperature,
180 const Evaluation& pressure,
181 const Evaluation& Rv,
182 const Evaluation& Rvw )
const 183 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.viscosity(regionIdx, temperature, pressure, Rv, Rvw)); }
188 template <
class Evaluation = Scalar>
190 const Evaluation& temperature,
191 const Evaluation& pressure)
const 192 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.saturatedViscosity(regionIdx, temperature, pressure)); }
197 template <
class Evaluation = Scalar>
199 const Evaluation& temperature,
200 const Evaluation& pressure,
201 const Evaluation& Rv,
202 const Evaluation& Rvw)
const 203 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.inverseFormationVolumeFactor(regionIdx, temperature, pressure, Rv, Rvw)); }
208 template <
class Flu
idState,
class LhsEval =
typename Flu
idState::ValueType>
209 std::pair<LhsEval, LhsEval>
211 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.inverseFormationVolumeFactorAndViscosity(fluidState, regionIdx)); }
216 template <
class Evaluation = Scalar>
218 const Evaluation& temperature,
219 const Evaluation& pressure)
const 220 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.saturatedInverseFormationVolumeFactor(regionIdx, temperature, pressure)); }
225 template <
class Evaluation = Scalar>
227 const Evaluation& temperature,
228 const Evaluation& pressure)
const 229 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.saturatedOilVaporizationFactor(regionIdx, temperature, pressure)); }
234 template <
class Evaluation = Scalar>
236 const Evaluation& temperature,
237 const Evaluation& pressure,
238 const Evaluation& oilSaturation,
239 const Evaluation& maxOilSaturation)
const 240 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.saturatedOilVaporizationFactor(regionIdx, temperature, pressure, oilSaturation, maxOilSaturation)); }
245 template <
class Evaluation = Scalar>
247 const Evaluation& temperature,
248 const Evaluation& pressure)
const 249 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.saturatedWaterVaporizationFactor(regionIdx, temperature, pressure)); }
254 template <
class Evaluation = Scalar>
256 const Evaluation& temperature,
257 const Evaluation& pressure,
258 const Evaluation& saltConcentration)
const 259 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.saturatedWaterVaporizationFactor(regionIdx, temperature, pressure, saltConcentration)); }
269 template <
class Evaluation = Scalar>
271 const Evaluation& temperature,
272 const Evaluation& Rv)
const 273 { OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.saturationPressure(regionIdx, temperature, Rv)); }
278 template <
class Evaluation>
280 const Evaluation& pressure,
281 unsigned compIdx)
const 283 OPM_GAS_PVT_MULTIPLEXER_CALL(
return pvtImpl.diffusionCoefficient(temperature, pressure, compIdx));
292 {
return gasPvtApproach_; }
295 template <GasPvtApproach approachV>
296 typename std::enable_if<approachV == GasPvtApproach::DryGas, DryGasPvt<Scalar> >::type& getRealPvt()
302 template <GasPvtApproach approachV>
303 typename std::enable_if<approachV == GasPvtApproach::DryGas, const DryGasPvt<Scalar> >::type& getRealPvt()
const 306 return *
static_cast<const DryGasPvt<Scalar>*
>(realGasPvt_.get());
310 template <GasPvtApproach approachV>
311 typename std::enable_if<approachV == GasPvtApproach::DryHumidGas, DryHumidGasPvt<Scalar> >::type& getRealPvt()
314 return *
static_cast<DryHumidGasPvt<Scalar>*
>(realGasPvt_.get());
317 template <GasPvtApproach approachV>
318 typename std::enable_if<approachV == GasPvtApproach::DryHumidGas, const DryHumidGasPvt<Scalar> >::type& getRealPvt()
const 321 return *
static_cast<const DryHumidGasPvt<Scalar>*
>(realGasPvt_.get());
325 template <GasPvtApproach approachV>
326 typename std::enable_if<approachV == GasPvtApproach::WetHumidGas, WetHumidGasPvt<Scalar> >::type& getRealPvt()
329 return *
static_cast<WetHumidGasPvt<Scalar>*
>(realGasPvt_.get());
332 template <GasPvtApproach approachV>
333 typename std::enable_if<approachV == GasPvtApproach::WetHumidGas, const WetHumidGasPvt<Scalar> >::type& getRealPvt()
const 336 return *
static_cast<const WetHumidGasPvt<Scalar>*
>(realGasPvt_.get());
340 template <GasPvtApproach approachV>
341 typename std::enable_if<approachV == GasPvtApproach::WetGas, WetGasPvt<Scalar> >::type& getRealPvt()
344 return *
static_cast<WetGasPvt<Scalar>*
>(realGasPvt_.get());
347 template <GasPvtApproach approachV>
348 typename std::enable_if<approachV == GasPvtApproach::WetGas, const WetGasPvt<Scalar> >::type& getRealPvt()
const 351 return *
static_cast<const WetGasPvt<Scalar>*
>(realGasPvt_.get());
355 template <GasPvtApproach approachV>
356 typename std::enable_if<approachV == GasPvtApproach::ThermalGas, GasPvtThermal<Scalar> >::type& getRealPvt()
359 return *
static_cast<GasPvtThermal<Scalar>*
>(realGasPvt_.get());
361 template <GasPvtApproach approachV>
362 typename std::enable_if<approachV == GasPvtApproach::ThermalGas, const GasPvtThermal<Scalar> >::type& getRealPvt()
const 365 return *
static_cast<const GasPvtThermal<Scalar>*
>(realGasPvt_.get());
368 template <GasPvtApproach approachV>
369 typename std::enable_if<approachV == GasPvtApproach::Co2Gas, Co2GasPvt<Scalar> >::type& getRealPvt()
372 return *
static_cast<Co2GasPvt<Scalar>*
>(realGasPvt_.get());
375 template <GasPvtApproach approachV>
376 typename std::enable_if<approachV == GasPvtApproach::Co2Gas, const Co2GasPvt<Scalar> >::type& getRealPvt()
const 379 return *
static_cast<const Co2GasPvt<Scalar>*
>(realGasPvt_.get());
382 template <GasPvtApproach approachV>
383 typename std::enable_if<approachV == GasPvtApproach::H2Gas, H2GasPvt<Scalar> >::type& getRealPvt()
386 return *
static_cast<H2GasPvt<Scalar>*
>(realGasPvt_.get());
389 template <GasPvtApproach approachV>
390 typename std::enable_if<approachV == GasPvtApproach::H2Gas, const H2GasPvt<Scalar> >::type& getRealPvt()
const 393 return *
static_cast<const H2GasPvt<Scalar>*
>(realGasPvt_.get());
396 const void* realGasPvt()
const {
return realGasPvt_.get(); }
398 GasPvtMultiplexer<Scalar,enableThermal>&
399 operator=(
const GasPvtMultiplexer<Scalar,enableThermal>& data);
402 using UniqueVoidPtrWithDeleter = std::unique_ptr<void, std::function<void(void*)>>;
404 template <
class ConcreteGasPvt> UniqueVoidPtrWithDeleter makeGasPvt();
406 template <
class ConcretePvt> UniqueVoidPtrWithDeleter copyPvt(
const UniqueVoidPtrWithDeleter&);
408 GasPvtApproach gasPvtApproach_{GasPvtApproach::NoGas};
409 UniqueVoidPtrWithDeleter realGasPvt_;
411 void deleter(
void* ptr);
unsigned numRegions() const
Return the number of PVT regions which are considered by this PVT-object.
Definition: GasPvtMultiplexer.cpp:41
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:189
This class represents the Pressure-Volume-Temperature relations of the gas phase with vaporized water...
Definition: Schedule.hpp:100
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:235
This class represents the Pressure-Volume-Temperature relations of the gas phas with vaporized oil...
GasPvtApproach approach() const
Returns the concrete approach for calculating the PVT relations.
Definition: GasPvtMultiplexer.hpp:291
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:165
This class represents the Pressure-Volume-Temperature relations of the gas phase with vaporized oil a...
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:217
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:30
This class represents the Pressure-Volume-Temperature relations of the gas phase in the black-oil mod...
Definition: GasPvtMultiplexer.hpp:108
This class implements temperature dependence of the PVT properties of gas.
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:198
Definition: EclipseState.hpp:66
Scalar gasReferenceDensity(unsigned regionIdx) const
Return the reference density which are considered by this PVT-object.
Definition: GasPvtMultiplexer.cpp:57
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:255
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:246
This class represents the Pressure-Volume-Temperature relations of the gas phase for H2...
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:279
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:226
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:178
void initFromState(const EclipseState &eclState, const Schedule &schedule)
Initialize the parameters for gas using an ECL deck.
Definition: GasPvtMultiplexer.cpp:72
This class represents the Pressure-Volume-Temperature relations of the gas phase for CO2...
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:270
This class represents the Pressure-Volume-Temperature relations of the gas phase without vaporized oi...
Definition: DryGasPvt.hpp:47
This class represents the Pressure-Volume-Temperature relations of the gas phase without vaporized oi...
std::pair< LhsEval, LhsEval > inverseFormationVolumeFactorAndViscosity(const FluidState &fluidState, unsigned regionIdx)
Returns the formation volume factor [-] and viscosity [Pa s] of the fluid phase.
Definition: GasPvtMultiplexer.hpp:210