27 #ifndef OPM_GAS_PVT_THERMAL_HPP
28 #define OPM_GAS_PVT_THERMAL_HPP
38 #include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
39 #include <opm/parser/eclipse/EclipseState/Tables/SimpleTable.hpp>
40 #include <opm/parser/eclipse/EclipseState/Tables/TableManager.hpp>
44 template <
class Scalar,
bool enableThermal>
45 class GasPvtMultiplexer;
53 template <
class Scalar>
62 enableThermalDensity_ =
false;
63 enableThermalViscosity_ =
false;
64 enableInternalEnergy_ =
false;
65 isothermalPvt_ =
nullptr;
69 const std::vector<TabulatedOneDFunction>& gasvisctCurves,
70 const std::vector<Scalar>& gasdentRefTemp,
71 const std::vector<Scalar>& gasdentCT1,
72 const std::vector<Scalar>& gasdentCT2,
73 const std::vector<TabulatedOneDFunction>& internalEnergyCurves,
76 bool enableInternalEnergy)
77 : isothermalPvt_(isothermalPvt)
78 , gasvisctCurves_(gasvisctCurves)
79 , gasdentRefTemp_(gasdentRefTemp)
80 , gasdentCT1_(gasdentCT1)
81 , gasdentCT2_(gasdentCT2)
82 , internalEnergyCurves_(internalEnergyCurves)
85 , enableInternalEnergy_(enableInternalEnergy)
92 {
delete isothermalPvt_; }
98 void initFromState(
const EclipseState& eclState,
const Schedule& schedule)
104 isothermalPvt_->initFromState(eclState, schedule);
109 const auto& tables = eclState.getTableManager();
111 enableThermalDensity_ = tables.GasDenT().size() > 0;
112 enableThermalViscosity_ = tables.hasTables(
"GASVISCT");
113 enableInternalEnergy_ = tables.hasTables(
"SPECHEAT");
115 unsigned numRegions = isothermalPvt_->
numRegions();
119 if (enableThermalViscosity_) {
120 const auto& gasvisctTables = tables.getGasvisctTables();
121 auto gasCompIdx = tables.gas_comp_index();
122 std::string gasvisctColumnName =
"Viscosity" + std::to_string(
static_cast<long long>(gasCompIdx));
124 for (
unsigned regionIdx = 0; regionIdx < numRegions; ++regionIdx) {
125 const auto& T = gasvisctTables[regionIdx].getColumn(
"Temperature").vectorCopy();
126 const auto& mu = gasvisctTables[regionIdx].getColumn(gasvisctColumnName).vectorCopy();
127 gasvisctCurves_[regionIdx].setXYContainers(T, mu);
132 if (tables.GasDenT().size() > 0) {
133 const auto& gasDenT = tables.GasDenT();
135 assert(gasDenT.size() == numRegions);
136 for (
unsigned regionIdx = 0; regionIdx < numRegions; ++regionIdx) {
137 const auto& record = gasDenT[regionIdx];
139 gasdentRefTemp_[regionIdx] = record.T0;
140 gasdentCT1_[regionIdx] = record.C1;
141 gasdentCT2_[regionIdx] = record.C2;
143 enableThermalDensity_ =
true;
146 if (enableInternalEnergy_) {
150 for (
unsigned regionIdx = 0; regionIdx < numRegions; ++regionIdx) {
151 const auto& specHeatTable = tables.getSpecheatTables()[regionIdx];
152 const auto& temperatureColumn = specHeatTable.getColumn(
"TEMPERATURE");
153 const auto& cvGasColumn = specHeatTable.getColumn(
"CV_GAS");
155 std::vector<double> uSamples(temperatureColumn.size());
162 const Scalar hVap = 480.6e3;
164 Scalar u = temperatureColumn[0]*cvGasColumn[0] + hVap;
165 for (
size_t i = 0;; ++i) {
168 if (i >= temperatureColumn.size() - 1)
173 Scalar c_v0 = cvGasColumn[i];
174 Scalar c_v1 = cvGasColumn[i + 1];
175 Scalar T0 = temperatureColumn[i];
176 Scalar T1 = temperatureColumn[i + 1];
177 u += 0.5*(c_v0 + c_v1)*(T1 - T0);
180 internalEnergyCurves_[regionIdx].setXYContainers(temperatureColumn.vectorCopy(), uSamples);
191 gasvisctCurves_.resize(numRegions);
192 internalEnergyCurves_.resize(numRegions);
193 gasdentRefTemp_.resize(numRegions);
194 gasdentCT1_.resize(numRegions);
195 gasdentCT2_.resize(numRegions);
204 size_t numRegions()
const
205 {
return gasvisctCurves_.size(); }
211 {
return enableThermalDensity_; }
217 {
return enableThermalViscosity_; }
222 template <
class Evaluation>
224 const Evaluation& temperature,
226 const Evaluation&)
const
228 if (!enableInternalEnergy_)
229 throw std::runtime_error(
"Requested the internal energy of oil but it is disabled");
234 return internalEnergyCurves_[regionIdx].eval(temperature,
true);
240 template <
class Evaluation>
242 const Evaluation& temperature,
243 const Evaluation& pressure,
244 const Evaluation& Rv)
const
247 return isothermalPvt_->
viscosity(regionIdx, temperature, pressure, Rv);
250 const auto& muGasvisct = gasvisctCurves_[regionIdx].eval(temperature);
257 template <
class Evaluation>
259 const Evaluation& temperature,
260 const Evaluation& pressure)
const
266 const auto& muGasvisct = gasvisctCurves_[regionIdx].eval(temperature,
true);
273 template <
class Evaluation>
275 const Evaluation& temperature,
276 const Evaluation& pressure,
277 const Evaluation& Rv)
const
292 Scalar TRef = gasdentRefTemp_[regionIdx];
293 Scalar cT1 = gasdentCT1_[regionIdx];
294 Scalar cT2 = gasdentCT2_[regionIdx];
295 const Evaluation& Y = temperature - TRef;
297 return b/(1 + (cT1 + cT2*Y)*Y);
303 template <
class Evaluation>
305 const Evaluation& temperature,
306 const Evaluation& pressure)
const
321 Scalar TRef = gasdentRefTemp_[regionIdx];
322 Scalar cT1 = gasdentCT1_[regionIdx];
323 Scalar cT2 = gasdentCT2_[regionIdx];
324 const Evaluation& Y = temperature - TRef;
326 return b/(1 + (cT1 + cT2*Y)*Y);
336 template <
class Evaluation>
338 const Evaluation& temperature,
339 const Evaluation& pressure)
const
349 template <
class Evaluation>
351 const Evaluation& temperature,
352 const Evaluation& pressure,
353 const Evaluation& oilSaturation,
354 const Evaluation& maxOilSaturation)
const
364 template <
class Evaluation>
366 const Evaluation& temperature,
367 const Evaluation& pressure)
const
370 template <
class Evaluation>
371 Evaluation diffusionCoefficient(
const Evaluation& temperature,
372 const Evaluation& pressure,
373 unsigned compIdx)
const
377 const IsothermalPvt* isoThermalPvt()
const
378 {
return isothermalPvt_; }
380 const Scalar gasReferenceDensity(
unsigned regionIdx)
const
383 const std::vector<TabulatedOneDFunction>& gasvisctCurves()
const
384 {
return gasvisctCurves_; }
386 const std::vector<Scalar>& gasdentRefTemp()
const
387 {
return gasdentRefTemp_; }
389 const std::vector<Scalar>& gasdentCT1()
const
390 {
return gasdentCT1_; }
392 const std::vector<Scalar>& gasdentCT2()
const
393 {
return gasdentCT2_; }
395 const std::vector<TabulatedOneDFunction>& internalEnergyCurves()
const
396 {
return internalEnergyCurves_; }
398 bool enableInternalEnergy()
const
399 {
return enableInternalEnergy_; }
401 bool operator==(
const GasPvtThermal<Scalar>& data)
const
403 if (isothermalPvt_ && !data.isothermalPvt_)
405 if (!isothermalPvt_ && data.isothermalPvt_)
408 return (!this->isoThermalPvt() ||
409 (*this->isoThermalPvt() == *data.isoThermalPvt())) &&
410 this->gasvisctCurves() == data.gasvisctCurves() &&
411 this->gasdentRefTemp() == data.gasdentRefTemp() &&
412 this->gasdentCT1() == data.gasdentCT1() &&
413 this->gasdentCT2() == data.gasdentCT2() &&
414 this->internalEnergyCurves() == data.internalEnergyCurves() &&
417 this->enableInternalEnergy() == data.enableInternalEnergy();
420 GasPvtThermal<Scalar>& operator=(
const GasPvtThermal<Scalar>& data)
422 if (data.isothermalPvt_)
423 isothermalPvt_ =
new IsothermalPvt(*data.isothermalPvt_);
425 isothermalPvt_ =
nullptr;
426 gasvisctCurves_ = data.gasvisctCurves_;
427 gasdentRefTemp_ = data.gasdentRefTemp_;
428 gasdentCT1_ = data.gasdentCT1_;
429 gasdentCT2_ = data.gasdentCT2_;
430 internalEnergyCurves_ = data.internalEnergyCurves_;
431 enableThermalDensity_ = data.enableThermalDensity_;
432 enableThermalViscosity_ = data.enableThermalViscosity_;
433 enableInternalEnergy_ = data.enableInternalEnergy_;
439 IsothermalPvt* isothermalPvt_;
443 std::vector<TabulatedOneDFunction> gasvisctCurves_;
445 std::vector<Scalar> gasdentRefTemp_;
446 std::vector<Scalar> gasdentCT1_;
447 std::vector<Scalar> gasdentCT2_;
450 std::vector<TabulatedOneDFunction> internalEnergyCurves_;
452 bool enableThermalDensity_;
453 bool enableThermalViscosity_;
454 bool enableInternalEnergy_;
A central place for various physical constants occuring in some equations.
This file provides a wrapper around the "final" C++-2011 statement.
Class implementing cubic splines.
Implements a linearly interpolated scalar function that depends on one variable.
This class represents the Pressure-Volume-Temperature relations of the gas phase in the black-oil mod...
Definition: GasPvtMultiplexer.hpp:86
Evaluation inverseFormationVolumeFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &Rv) const
Returns the formation volume factor [-] of the fluid phase.
Definition: GasPvtMultiplexer.hpp:225
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:235
unsigned numRegions() const
Return the number of PVT regions which are considered by this PVT-object.
Definition: GasPvtMultiplexer.hpp:183
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:276
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:244
const Scalar gasReferenceDensity(unsigned regionIdx)
Return the reference density which are considered by this PVT-object.
Definition: GasPvtMultiplexer.hpp:189
Evaluation viscosity(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &Rv) const
Returns the dynamic viscosity [Pa s] of the fluid phase given a set of parameters.
Definition: GasPvtMultiplexer.hpp:206
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:267
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:216
This class implements temperature dependence of the PVT properties of gas.
Definition: GasPvtThermal.hpp:55
bool enableThermalDensity() const
Returns true iff the density of the gas phase is temperature dependent.
Definition: GasPvtThermal.hpp:210
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:350
Evaluation saturatedInverseFormationVolumeFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure) const
Returns the formation volume factor [-] of oil-saturated gas.
Definition: GasPvtThermal.hpp:304
Evaluation internalEnergy(unsigned regionIdx, const Evaluation &temperature, const Evaluation &, const Evaluation &) const
Returns the specific internal energy [J/kg] of gas given a set of parameters.
Definition: GasPvtThermal.hpp:223
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:337
void initEnd()
Finish initializing the thermal part of the gas phase PVT properties.
Definition: GasPvtThermal.hpp:201
void setNumRegions(size_t numRegions)
Set the number of PVT-regions considered by this object.
Definition: GasPvtThermal.hpp:189
Evaluation viscosity(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &Rv) const
Returns the dynamic viscosity [Pa s] of the fluid phase given a set of parameters.
Definition: GasPvtThermal.hpp:241
bool enableThermalViscosity() const
Returns true iff the viscosity of the gas phase is temperature dependent.
Definition: GasPvtThermal.hpp:216
Evaluation inverseFormationVolumeFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &Rv) const
Returns the formation volume factor [-] of the fluid phase.
Definition: GasPvtThermal.hpp:274
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:258
Evaluation saturationPressure(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure) const
Returns the saturation pressure of the gas phase [Pa].
Definition: GasPvtThermal.hpp:365
Implements a linearly interpolated scalar function that depends on one variable.
Definition: Tabulated1DFunction.hpp:47