27#ifndef OPM_GAS_PVT_THERMAL_HPP
28#define OPM_GAS_PVT_THERMAL_HPP
41template <
class Scalar,
bool enableThermal>
42class GasPvtMultiplexer;
50template <
class Scalar>
60 const std::vector<TabulatedOneDFunction>& gasvisctCurves,
61 const std::vector<Scalar>& viscrefPress,
62 const std::vector<Scalar>& viscRef,
63 const std::vector<Scalar>& gasdentRefTemp,
64 const std::vector<Scalar>& gasdentCT1,
65 const std::vector<Scalar>& gasdentCT2,
66 const std::vector<Scalar>& gasJTRefPres,
67 const std::vector<Scalar>& gasJTC,
68 const std::vector<TabulatedOneDFunction>& internalEnergyCurves,
72 bool enableInternalEnergy)
73 : isothermalPvt_(isothermalPvt)
74 , gasvisctCurves_(gasvisctCurves)
75 , viscrefPress_(viscrefPress)
77 , gasdentRefTemp_(gasdentRefTemp)
78 , gasdentCT1_(gasdentCT1)
79 , gasdentCT2_(gasdentCT2)
80 , gasJTRefPres_(gasJTRefPres)
82 , internalEnergyCurves_(internalEnergyCurves)
86 , enableInternalEnergy_(enableInternalEnergy)
93 {
delete isothermalPvt_; }
107 void setVapPars(
const Scalar par1,
const Scalar par2)
109 isothermalPvt_->setVapPars(par1, par2);
122 {
return enableThermalDensity_; }
128 {
return enableJouleThomson_; }
134 {
return enableThermalViscosity_; }
136 std::size_t numRegions()
const
137 {
return viscrefPress_.size(); }
142 template <
class Evaluation>
144 const Evaluation& temperature,
145 const Evaluation& pressure,
146 const Evaluation& Rv,
147 [[maybe_unused]]
const Evaluation& RvW)
const
149 if (!enableInternalEnergy_) {
150 throw std::runtime_error(
"Requested the internal energy of gas but it is disabled");
153 if (!enableJouleThomson_) {
157 return internalEnergyCurves_[regionIdx].eval(temperature,
true);
161 OpmLog::warning(
"Experimental code for jouleThomson: simulation will be slower");
162 Evaluation Tref = gasdentRefTemp_[regionIdx];
163 Evaluation Pref = gasJTRefPres_[regionIdx];
164 Scalar JTC = gasJTC_[regionIdx];
165 Evaluation Rvw = 0.0;
169 Evaluation Cp = (internalEnergyCurves_[regionIdx].eval(temperature,
true))/temperature;
170 Evaluation density = invB * (gasReferenceDensity(regionIdx) + Rv * rhoRefO_[regionIdx]);
172 Evaluation enthalpyPres;
174 enthalpyPres = -Cp * JTC * (pressure -Pref);
176 else if (enableThermalDensity_) {
177 Scalar c1T = gasdentCT1_[regionIdx];
178 Scalar c2T = gasdentCT2_[regionIdx];
180 Evaluation alpha = (c1T + 2 * c2T * (temperature - Tref)) /
181 (1 + c1T *(temperature - Tref) + c2T * (temperature - Tref) * (temperature - Tref));
183 constexpr const int N = 100;
184 Evaluation deltaP = (pressure - Pref)/N;
185 Evaluation enthalpyPresPrev = 0;
186 for (std::size_t i = 0; i < N; ++i) {
187 Evaluation Pnew = Pref + i * deltaP;
189 (gasReferenceDensity(regionIdx) + Rv * rhoRefO_[regionIdx]);
191 Evaluation jouleThomsonCoefficient = -(1.0/Cp) * (1.0 - alpha * temperature)/rho;
192 Evaluation deltaEnthalpyPres = -Cp * jouleThomsonCoefficient * deltaP;
193 enthalpyPres = enthalpyPresPrev + deltaEnthalpyPres;
194 enthalpyPresPrev = enthalpyPres;
198 throw std::runtime_error(
"Requested Joule-thomson calculation but thermal "
199 "gas density (GASDENT) is not provided");
202 Evaluation enthalpy = Cp * (temperature - Tref) + enthalpyPres;
204 return enthalpy - pressure/density;
211 template <
class Evaluation>
213 const Evaluation& temperature,
214 const Evaluation& pressure,
215 const Evaluation& Rv,
216 const Evaluation& Rvw)
const
218 const auto& isothermalMu = isothermalPvt_->
viscosity(regionIdx, temperature, pressure, Rv, Rvw);
223 const auto& muGasvisct = gasvisctCurves_[regionIdx].eval(temperature,
true);
224 return muGasvisct/viscRef_[regionIdx]*isothermalMu;
230 template <
class Evaluation>
232 const Evaluation& temperature,
233 const Evaluation& pressure)
const
235 const auto& isothermalMu = isothermalPvt_->
saturatedViscosity(regionIdx, temperature, pressure);
240 const auto& muGasvisct = gasvisctCurves_[regionIdx].eval(temperature,
true);
241 return muGasvisct/viscRef_[regionIdx]*isothermalMu;
247 template <
class Evaluation>
249 const Evaluation& temperature,
250 const Evaluation& pressure,
251 const Evaluation& Rv,
252 const Evaluation& )
const
254 const Evaluation& Rvw = 0.0;
270 Scalar TRef = gasdentRefTemp_[regionIdx];
271 Scalar cT1 = gasdentCT1_[regionIdx];
272 Scalar cT2 = gasdentCT2_[regionIdx];
273 const Evaluation& Y = temperature - TRef;
275 return b / (1 + (cT1 + cT2 * Y) * Y);
281 template <
class Evaluation>
283 const Evaluation& temperature,
284 const Evaluation& pressure)
const
300 Scalar TRef = gasdentRefTemp_[regionIdx];
301 Scalar cT1 = gasdentCT1_[regionIdx];
302 Scalar cT2 = gasdentCT2_[regionIdx];
303 const Evaluation& Y = temperature - TRef;
305 return b / (1 + (cT1 + cT2 * Y) * Y);
311 template <
class Evaluation>
314 const Evaluation& )
const
320 template <
class Evaluation = Scalar>
324 const Evaluation& )
const
334 template <
class Evaluation>
336 const Evaluation& temperature,
337 const Evaluation& pressure)
const
347 template <
class Evaluation>
349 const Evaluation& temperature,
350 const Evaluation& pressure,
351 const Evaluation& oilSaturation,
352 const Evaluation& maxOilSaturation)
const
355 pressure, oilSaturation,
366 template <
class Evaluation>
368 const Evaluation& temperature,
369 const Evaluation& pressure)
const
372 template <
class Evaluation>
373 Evaluation diffusionCoefficient(
const Evaluation& temperature,
374 const Evaluation& pressure,
375 unsigned compIdx)
const
379 const IsothermalPvt* isoThermalPvt()
const
380 {
return isothermalPvt_; }
382 Scalar gasReferenceDensity(
unsigned regionIdx)
const
385 Scalar hVap(
unsigned regionIdx)
const
386 {
return this->hVap_[regionIdx]; }
388 const std::vector<TabulatedOneDFunction>& gasvisctCurves()
const
389 {
return gasvisctCurves_; }
391 const std::vector<Scalar>& viscrefPress()
const
392 {
return viscrefPress_; }
394 const std::vector<Scalar>& viscRef()
const
397 const std::vector<Scalar>& gasdentRefTemp()
const
398 {
return gasdentRefTemp_; }
400 const std::vector<Scalar>& gasdentCT1()
const
401 {
return gasdentCT1_; }
403 const std::vector<Scalar>& gasdentCT2()
const
404 {
return gasdentCT2_; }
406 const std::vector<TabulatedOneDFunction>& internalEnergyCurves()
const
407 {
return internalEnergyCurves_; }
409 bool enableInternalEnergy()
const
410 {
return enableInternalEnergy_; }
412 const std::vector<Scalar>& gasJTRefPres()
const
413 {
return gasJTRefPres_; }
415 const std::vector<Scalar>& gasJTC()
const
418 bool operator==(
const GasPvtThermal<Scalar>& data)
const;
420 GasPvtThermal<Scalar>& operator=(
const GasPvtThermal<Scalar>& data);
423 IsothermalPvt* isothermalPvt_{
nullptr};
427 std::vector<TabulatedOneDFunction> gasvisctCurves_{};
428 std::vector<Scalar> viscrefPress_{};
429 std::vector<Scalar> viscRef_{};
431 std::vector<Scalar> gasdentRefTemp_{};
432 std::vector<Scalar> gasdentCT1_{};
433 std::vector<Scalar> gasdentCT2_{};
435 std::vector<Scalar> gasJTRefPres_{};
436 std::vector<Scalar> gasJTC_{};
438 std::vector<Scalar> rhoRefO_{};
439 std::vector<Scalar> hVap_{};
442 std::vector<TabulatedOneDFunction> internalEnergyCurves_{};
444 bool enableThermalDensity_{
false};
445 bool enableJouleThomson_{
false};
446 bool enableThermalViscosity_{
false};
447 bool enableInternalEnergy_{
false};
Implements a linearly interpolated scalar function that depends on one variable.
Definition EclipseState.hpp:62
This class represents the Pressure-Volume-Temperature relations of the gas phase in the black-oil mod...
Definition GasPvtMultiplexer.hpp:111
Scalar gasReferenceDensity(unsigned regionIdx)
Return the reference density which are considered by this PVT-object.
Definition GasPvtMultiplexer.cpp:57
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:209
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
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
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:269
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:218
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:260
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 implements temperature dependence of the PVT properties of gas.
Definition GasPvtThermal.hpp:52
bool enableThermalDensity() const
Returns true iff the density of the gas phase is temperature dependent.
Definition GasPvtThermal.hpp:121
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 GasPvtThermal.hpp:212
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 the gas phase.
Definition GasPvtThermal.hpp:348
Evaluation saturatedInverseFormationVolumeFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure) const
Returns the formation volume factor [-] of oil-saturated gas.
Definition GasPvtThermal.hpp:282
Evaluation saturatedOilVaporizationFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure) const
Returns the oil vaporization factor [m^3/m^3] of the gas phase.
Definition GasPvtThermal.hpp:335
Evaluation saturatedWaterVaporizationFactor(unsigned, const Evaluation &, const Evaluation &, const Evaluation &) const
Returns the water vaporization factor [m^3/m^3] of water saturated gas.
Definition GasPvtThermal.hpp:321
Evaluation internalEnergy(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &Rv, const Evaluation &RvW) const
Returns the specific internal energy [J/kg] of gas given a set of parameters.
Definition GasPvtThermal.hpp:143
void setNumRegions(std::size_t numRegions)
Set the number of PVT-regions considered by this object.
Definition GasPvtThermal.cpp:192
void initEnd()
Finish initializing the thermal part of the gas phase PVT properties.
Definition GasPvtThermal.hpp:115
Evaluation inverseFormationVolumeFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &Rv, const Evaluation &) const
Returns the formation volume factor [-] of the fluid phase.
Definition GasPvtThermal.hpp:248
bool enableJouleThomson() const
Returns true iff Joule-Thomson effect for the gas phase is active.
Definition GasPvtThermal.hpp:127
bool enableThermalViscosity() const
Returns true iff the viscosity of the gas phase is temperature dependent.
Definition GasPvtThermal.hpp:133
Evaluation saturatedWaterVaporizationFactor(unsigned, const Evaluation &, const Evaluation &) const
Returns the water vaporization factor [m^3/m^3] of the water phase.
Definition GasPvtThermal.hpp:312
Evaluation saturatedViscosity(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure) const
Returns the dynamic viscosity [Pa s] of the oil-saturated gas phase given a set of parameters.
Definition GasPvtThermal.hpp:231
Evaluation saturationPressure(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure) const
Returns the saturation pressure of the gas phase [Pa].
Definition GasPvtThermal.hpp:367
Definition Schedule.hpp:101
Implements a linearly interpolated scalar function that depends on one variable.
Definition Tabulated1DFunction.hpp:51
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30