27#ifndef OPM_GAS_PVT_THERMAL_HPP
28#define OPM_GAS_PVT_THERMAL_HPP
39template <
class Scalar,
bool enableThermal>
40class GasPvtMultiplexer;
48template <
class Scalar>
57 enableThermalDensity_ =
false;
58 enableJouleThomson_ =
false;
59 enableThermalViscosity_ =
false;
60 isothermalPvt_ =
nullptr;
64 const std::vector<TabulatedOneDFunction>& gasvisctCurves,
65 const std::vector<Scalar>& gasdentRefTemp,
66 const std::vector<Scalar>& gasdentCT1,
67 const std::vector<Scalar>& gasdentCT2,
68 const std::vector<Scalar>& gasJTRefPres,
69 const std::vector<Scalar>& gasJTC,
70 const std::vector<TabulatedOneDFunction>& internalEnergyCurves,
74 bool enableInternalEnergy)
75 : isothermalPvt_(isothermalPvt)
76 , gasvisctCurves_(gasvisctCurves)
77 , gasdentRefTemp_(gasdentRefTemp)
78 , gasdentCT1_(gasdentCT1)
79 , gasdentCT2_(gasdentCT2)
80 , gasJTRefPres_(gasJTRefPres)
82 , internalEnergyCurves_(internalEnergyCurves)
86 , enableInternalEnergy_(enableInternalEnergy)
93 {
delete isothermalPvt_; }
107 gasvisctCurves_.resize(numRegions);
108 internalEnergyCurves_.resize(numRegions);
109 gasdentRefTemp_.resize(numRegions);
110 gasdentCT1_.resize(numRegions);
111 gasdentCT2_.resize(numRegions);
112 gasJTRefPres_.resize(numRegions);
113 gasJTC_.resize(numRegions);
114 rhoRefO_.resize(numRegions);
123 size_t numRegions()
const
124 {
return gasvisctCurves_.size(); }
130 {
return enableThermalDensity_; }
136 {
return enableJouleThomson_; }
142 {
return enableThermalViscosity_; }
147 template <
class Evaluation>
149 const Evaluation& temperature,
150 const Evaluation& pressure,
151 const Evaluation& Rv,
152 const Evaluation& )
const
154 if (!enableInternalEnergy_)
155 throw std::runtime_error(
"Requested the internal energy of gas but it is disabled");
157 if (!enableJouleThomson_) {
161 return internalEnergyCurves_[regionIdx].eval(temperature,
true);
164 Evaluation Tref = gasdentRefTemp_[regionIdx];
165 Evaluation Pref = gasJTRefPres_[regionIdx];
166 Scalar JTC = gasJTC_[regionIdx];
167 Evaluation Rvw = 0.0;
170 constexpr const Scalar hVap = 480.6e3;
171 Evaluation Cp = (internalEnergyCurves_[regionIdx].eval(temperature,
true) - hVap)/temperature;
172 Evaluation density = invB * (gasReferenceDensity(regionIdx) + Rv * rhoRefO_[regionIdx]);
174 Evaluation enthalpyPres;
176 enthalpyPres = -Cp * JTC * (pressure -Pref);
178 else if(enableThermalDensity_) {
179 Scalar c1T = gasdentCT1_[regionIdx];
180 Scalar c2T = gasdentCT2_[regionIdx];
182 Evaluation alpha = (c1T + 2 * c2T * (temperature - Tref)) /
183 (1 + c1T *(temperature - Tref) + c2T * (temperature - Tref) * (temperature - Tref));
185 constexpr const int N = 100;
186 Evaluation deltaP = (pressure - Pref)/N;
187 Evaluation enthalpyPresPrev = 0;
188 for (
size_t i = 0; i < N; ++i) {
189 Evaluation Pnew = Pref + i * deltaP;
191 (gasReferenceDensity(regionIdx) + Rv * rhoRefO_[regionIdx]);
193 Evaluation jouleThomsonCoefficient = -(1.0/Cp) * (1.0 - alpha * temperature)/rho;
194 Evaluation deltaEnthalpyPres = -Cp * jouleThomsonCoefficient * deltaP;
195 enthalpyPres = enthalpyPresPrev + deltaEnthalpyPres;
196 enthalpyPresPrev = enthalpyPres;
200 throw std::runtime_error(
"Requested Joule-thomson calculation but thermal gas density (GASDENT) is not provided");
203 Evaluation enthalpy = Cp * (temperature - Tref) + enthalpyPres;
205 return enthalpy - pressure/density;
212 template <
class Evaluation>
214 const Evaluation& temperature,
215 const Evaluation& pressure,
216 const Evaluation& Rv,
217 const Evaluation& Rvw)
const
220 return isothermalPvt_->
viscosity(regionIdx, temperature, pressure, Rv, Rvw);
223 const auto& muGasvisct = gasvisctCurves_[regionIdx].eval(temperature);
230 template <
class Evaluation>
232 const Evaluation& temperature,
233 const Evaluation& pressure)
const
239 const auto& muGasvisct = gasvisctCurves_[regionIdx].eval(temperature,
true);
246 template <
class Evaluation>
248 const Evaluation& temperature,
249 const Evaluation& pressure,
250 const Evaluation& Rv,
251 const Evaluation& )
const
253 const Evaluation& Rvw = 0.0;
267 Scalar TRef = gasdentRefTemp_[regionIdx];
268 Scalar cT1 = gasdentCT1_[regionIdx];
269 Scalar cT2 = gasdentCT2_[regionIdx];
270 const Evaluation& Y = temperature - TRef;
272 return b/(1 + (cT1 + cT2*Y)*Y);
278 template <
class Evaluation>
280 const Evaluation& temperature,
281 const Evaluation& pressure)
const
296 Scalar TRef = gasdentRefTemp_[regionIdx];
297 Scalar cT1 = gasdentCT1_[regionIdx];
298 Scalar cT2 = gasdentCT2_[regionIdx];
299 const Evaluation& Y = temperature - TRef;
301 return b/(1 + (cT1 + cT2*Y)*Y);
307 template <
class Evaluation>
310 const Evaluation& )
const
316 template <
class Evaluation = Scalar>
320 const Evaluation& )
const
332 template <
class Evaluation>
334 const Evaluation& temperature,
335 const Evaluation& pressure)
const
345 template <
class Evaluation>
347 const Evaluation& temperature,
348 const Evaluation& pressure,
349 const Evaluation& oilSaturation,
350 const Evaluation& maxOilSaturation)
const
360 template <
class Evaluation>
362 const Evaluation& temperature,
363 const Evaluation& pressure)
const
366 template <
class Evaluation>
367 Evaluation diffusionCoefficient(
const Evaluation& temperature,
368 const Evaluation& pressure,
369 unsigned compIdx)
const
373 const IsothermalPvt* isoThermalPvt()
const
374 {
return isothermalPvt_; }
376 const Scalar gasReferenceDensity(
unsigned regionIdx)
const
379 const std::vector<TabulatedOneDFunction>& gasvisctCurves()
const
380 {
return gasvisctCurves_; }
382 const std::vector<Scalar>& gasdentRefTemp()
const
383 {
return gasdentRefTemp_; }
385 const std::vector<Scalar>& gasdentCT1()
const
386 {
return gasdentCT1_; }
388 const std::vector<Scalar>& gasdentCT2()
const
389 {
return gasdentCT2_; }
391 const std::vector<TabulatedOneDFunction>& internalEnergyCurves()
const
392 {
return internalEnergyCurves_; }
394 bool enableInternalEnergy()
const
395 {
return enableInternalEnergy_; }
397 const std::vector<Scalar>& gasJTRefPres()
const
398 {
return gasJTRefPres_; }
400 const std::vector<Scalar>& gasJTC()
const
404 bool operator==(
const GasPvtThermal<Scalar>& data)
const
406 if (isothermalPvt_ && !data.isothermalPvt_)
408 if (!isothermalPvt_ && data.isothermalPvt_)
411 return this->gasvisctCurves() == data.gasvisctCurves() &&
412 this->gasdentRefTemp() == data.gasdentRefTemp() &&
413 this->gasdentCT1() == data.gasdentCT1() &&
414 this->gasdentCT2() == data.gasdentCT2() &&
415 this->gasJTRefPres() == data.gasJTRefPres() &&
416 this->gasJTC() == data.gasJTC() &&
417 this->internalEnergyCurves() == data.internalEnergyCurves() &&
421 this->enableInternalEnergy() == data.enableInternalEnergy();
424 GasPvtThermal<Scalar>& operator=(
const GasPvtThermal<Scalar>& data)
426 if (data.isothermalPvt_)
427 isothermalPvt_ =
new IsothermalPvt(*data.isothermalPvt_);
429 isothermalPvt_ =
nullptr;
430 gasvisctCurves_ = data.gasvisctCurves_;
431 gasdentRefTemp_ = data.gasdentRefTemp_;
432 gasdentCT1_ = data.gasdentCT1_;
433 gasdentCT2_ = data.gasdentCT2_;
434 gasJTRefPres_ = data.gasJTRefPres_;
435 gasJTC_ = data.gasJTC_;
436 internalEnergyCurves_ = data.internalEnergyCurves_;
437 enableThermalDensity_ = data.enableThermalDensity_;
438 enableJouleThomson_ = data.enableJouleThomson_;
439 enableThermalViscosity_ = data.enableThermalViscosity_;
440 enableInternalEnergy_ = data.enableInternalEnergy_;
446 IsothermalPvt* isothermalPvt_;
450 std::vector<TabulatedOneDFunction> gasvisctCurves_;
452 std::vector<Scalar> gasdentRefTemp_;
453 std::vector<Scalar> gasdentCT1_;
454 std::vector<Scalar> gasdentCT2_;
456 std::vector<Scalar> gasJTRefPres_;
457 std::vector<Scalar> gasJTC_;
459 std::vector<Scalar> rhoRefO_;
462 std::vector<TabulatedOneDFunction> internalEnergyCurves_;
464 bool enableThermalDensity_;
465 bool enableJouleThomson_;
466 bool enableThermalViscosity_;
467 bool enableInternalEnergy_;
Definition: EclipseState.hpp:55
This class represents the Pressure-Volume-Temperature relations of the gas phase in the black-oil mod...
Definition: GasPvtMultiplexer.hpp:102
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:256
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:245
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:225
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:316
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:265
const Scalar gasReferenceDensity(unsigned regionIdx)
Return the reference density which are considered by this PVT-object.
Definition: GasPvtMultiplexer.hpp:207
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:307
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:236
This class implements temperature dependence of the PVT properties of gas.
Definition: GasPvtThermal.hpp:50
bool enableThermalDensity() const
Returns true iff the density of the gas phase is temperature dependent.
Definition: GasPvtThermal.hpp:129
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:213
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:346
Evaluation saturatedInverseFormationVolumeFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure) const
Returns the formation volume factor [-] of oil-saturated gas.
Definition: GasPvtThermal.hpp:279
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:333
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:317
void initEnd()
Finish initializing the thermal part of the gas phase PVT properties.
Definition: GasPvtThermal.hpp:120
void setNumRegions(size_t numRegions)
Set the number of PVT-regions considered by this object.
Definition: GasPvtThermal.hpp:105
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:247
bool enableJouleThomson() const
Returns true iff Joule-Thomson effect for the gas phase is active.
Definition: GasPvtThermal.hpp:135
Evaluation internalEnergy(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &Rv, const Evaluation &) const
Returns the specific internal energy [J/kg] of gas given a set of parameters.
Definition: GasPvtThermal.hpp:148
bool enableThermalViscosity() const
Returns true iff the viscosity of the gas phase is temperature dependent.
Definition: GasPvtThermal.hpp:141
Evaluation saturatedWaterVaporizationFactor(unsigned, const Evaluation &, const Evaluation &) const
Returns the water vaporization factor [m^3/m^3] of the water phase.
Definition: GasPvtThermal.hpp:308
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:361
Definition: Schedule.hpp:130
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