27#ifndef OPM_OIL_PVT_THERMAL_HPP
28#define OPM_OIL_PVT_THERMAL_HPP
39template <
class Scalar,
bool enableThermal>
40class OilPvtMultiplexer;
48template <
class Scalar>
57 enableThermalDensity_ =
false;
58 enableJouleThomson_ =
false;
59 enableThermalViscosity_ =
false;
60 enableInternalEnergy_ =
false;
61 isothermalPvt_ =
nullptr;
65 const std::vector<TabulatedOneDFunction>& oilvisctCurves,
66 const std::vector<Scalar>& viscrefPress,
67 const std::vector<Scalar>& viscrefRs,
68 const std::vector<Scalar>& viscRef,
69 const std::vector<Scalar>& oildentRefTemp,
70 const std::vector<Scalar>& oildentCT1,
71 const std::vector<Scalar>& oildentCT2,
72 const std::vector<Scalar>& oilJTRefPres,
73 const std::vector<Scalar>& oilJTC,
74 const std::vector<TabulatedOneDFunction>& internalEnergyCurves,
78 bool enableInternalEnergy)
79 : isothermalPvt_(isothermalPvt)
80 , oilvisctCurves_(oilvisctCurves)
81 , viscrefPress_(viscrefPress)
82 , viscrefRs_(viscrefRs)
84 , oildentRefTemp_(oildentRefTemp)
85 , oildentCT1_(oildentCT1)
86 , oildentCT2_(oildentCT2)
87 , oilJTRefPres_(oilJTRefPres)
89 , internalEnergyCurves_(internalEnergyCurves)
93 , enableInternalEnergy_(enableInternalEnergy)
100 {
delete isothermalPvt_; }
114 oilvisctCurves_.resize(numRegions);
115 viscrefPress_.resize(numRegions);
116 viscrefRs_.resize(numRegions);
117 viscRef_.resize(numRegions);
118 internalEnergyCurves_.resize(numRegions);
119 oildentRefTemp_.resize(numRegions);
120 oildentCT1_.resize(numRegions);
121 oildentCT2_.resize(numRegions);
122 oilJTRefPres_.resize(numRegions);
123 oilJTC_.resize(numRegions);
124 rhoRefG_.resize(numRegions);
137 {
return enableThermalDensity_; }
143 {
return enableJouleThomson_; }
149 {
return enableThermalViscosity_; }
151 size_t numRegions()
const
152 {
return viscrefRs_.size(); }
157 template <
class Evaluation>
159 const Evaluation& temperature,
160 const Evaluation& pressure,
161 const Evaluation& Rs)
const
163 if (!enableInternalEnergy_)
164 throw std::runtime_error(
"Requested the internal energy of oil but it is disabled");
166 if (!enableJouleThomson_) {
170 return internalEnergyCurves_[regionIdx].eval(temperature,
true);
173 Evaluation Tref = oildentRefTemp_[regionIdx];
174 Evaluation Pref = oilJTRefPres_[regionIdx];
175 Scalar JTC = oilJTC_[regionIdx];
178 Evaluation Cp = internalEnergyCurves_[regionIdx].eval(temperature,
true)/temperature;
179 Evaluation density = invB * (oilReferenceDensity(regionIdx) + Rs * rhoRefG_[regionIdx]);
181 Evaluation enthalpyPres;
183 enthalpyPres = -Cp * JTC * (pressure -Pref);
185 else if(enableThermalDensity_) {
186 Scalar c1T = oildentCT1_[regionIdx];
187 Scalar c2T = oildentCT2_[regionIdx];
189 Evaluation alpha = (c1T + 2 * c2T * (temperature - Tref)) /
190 (1 + c1T *(temperature - Tref) + c2T * (temperature - Tref) * (temperature - Tref));
193 Evaluation deltaP = (pressure - Pref)/N;
194 Evaluation enthalpyPresPrev = 0;
195 for (
size_t i = 0; i < N; ++i) {
196 Evaluation Pnew = Pref + i * deltaP;
198 (oilReferenceDensity(regionIdx) + Rs * rhoRefG_[regionIdx]) ;
200 Evaluation jouleThomsonCoefficient = -(1.0/Cp) * (1.0 - alpha * temperature)/rho;
201 Evaluation deltaEnthalpyPres = -Cp * jouleThomsonCoefficient * deltaP;
202 enthalpyPres = enthalpyPresPrev + deltaEnthalpyPres;
203 enthalpyPresPrev = enthalpyPres;
207 throw std::runtime_error(
"Requested Joule-thomson calculation but thermal oil density (OILDENT) is not provided");
210 Evaluation enthalpy = Cp * (temperature - Tref) + enthalpyPres;
212 return enthalpy - pressure/density;
219 template <
class Evaluation>
221 const Evaluation& temperature,
222 const Evaluation& pressure,
223 const Evaluation& Rs)
const
225 const auto& isothermalMu = isothermalPvt_->
viscosity(regionIdx, temperature, pressure, Rs);
230 const auto& muOilvisct = oilvisctCurves_[regionIdx].eval(temperature,
true);
231 return muOilvisct/viscRef_[regionIdx]*isothermalMu;
237 template <
class Evaluation>
239 const Evaluation& temperature,
240 const Evaluation& pressure)
const
242 const auto& isothermalMu = isothermalPvt_->
saturatedViscosity(regionIdx, temperature, pressure);
247 const auto& muOilvisct = oilvisctCurves_[regionIdx].eval(temperature,
true);
248 return muOilvisct/viscRef_[regionIdx]*isothermalMu;
255 template <
class Evaluation>
257 const Evaluation& temperature,
258 const Evaluation& pressure,
259 const Evaluation& Rs)
const
269 Scalar TRef = oildentRefTemp_[regionIdx];
270 Scalar cT1 = oildentCT1_[regionIdx];
271 Scalar cT2 = oildentCT2_[regionIdx];
272 const Evaluation& Y = temperature - TRef;
274 return b/(1 + (cT1 + cT2*Y)*Y);
280 template <
class Evaluation>
282 const Evaluation& temperature,
283 const Evaluation& pressure)
const
293 Scalar TRef = oildentRefTemp_[regionIdx];
294 Scalar cT1 = oildentCT1_[regionIdx];
295 Scalar cT2 = oildentCT2_[regionIdx];
296 const Evaluation& Y = temperature - TRef;
298 return b/(1 + (cT1 + cT2*Y)*Y);
308 template <
class Evaluation>
310 const Evaluation& temperature,
311 const Evaluation& pressure)
const
321 template <
class Evaluation>
323 const Evaluation& temperature,
324 const Evaluation& pressure,
325 const Evaluation& oilSaturation,
326 const Evaluation& maxOilSaturation)
const
336 template <
class Evaluation>
338 const Evaluation& temperature,
339 const Evaluation& pressure)
const
342 template <
class Evaluation>
343 Evaluation diffusionCoefficient(
const Evaluation& temperature,
344 const Evaluation& pressure,
345 unsigned compIdx)
const
350 const IsothermalPvt* isoThermalPvt()
const
351 {
return isothermalPvt_; }
353 const Scalar oilReferenceDensity(
unsigned regionIdx)
const
356 const std::vector<TabulatedOneDFunction>& oilvisctCurves()
const
357 {
return oilvisctCurves_; }
359 const std::vector<Scalar>& viscrefPress()
const
360 {
return viscrefPress_; }
362 const std::vector<Scalar>& viscrefRs()
const
363 {
return viscrefRs_; }
365 const std::vector<Scalar>& viscRef()
const
368 const std::vector<Scalar>& oildentRefTemp()
const
369 {
return oildentRefTemp_; }
371 const std::vector<Scalar>& oildentCT1()
const
372 {
return oildentCT1_; }
374 const std::vector<Scalar>& oildentCT2()
const
375 {
return oildentCT2_; }
377 const std::vector<TabulatedOneDFunction> internalEnergyCurves()
const
378 {
return internalEnergyCurves_; }
380 bool enableInternalEnergy()
const
381 {
return enableInternalEnergy_; }
383 const std::vector<Scalar>& oilJTRefPres()
const
384 {
return oilJTRefPres_; }
386 const std::vector<Scalar>& oilJTC()
const
389 bool operator==(
const OilPvtThermal<Scalar>& data)
const
391 if (isothermalPvt_ && !data.isothermalPvt_)
393 if (!isothermalPvt_ && data.isothermalPvt_)
396 return this->oilvisctCurves() == data.oilvisctCurves() &&
397 this->viscrefPress() == data.viscrefPress() &&
398 this->viscrefRs() == data.viscrefRs() &&
399 this->viscRef() == data.viscRef() &&
400 this->oildentRefTemp() == data.oildentRefTemp() &&
401 this->oildentCT1() == data.oildentCT1() &&
402 this->oildentCT2() == data.oildentCT2() &&
403 this->oilJTRefPres() == data.oilJTRefPres() &&
404 this->oilJTC() == data.oilJTC() &&
405 this->internalEnergyCurves() == data.internalEnergyCurves() &&
409 this->enableInternalEnergy() == data.enableInternalEnergy();
412 OilPvtThermal<Scalar>& operator=(
const OilPvtThermal<Scalar>& data)
414 if (data.isothermalPvt_)
415 isothermalPvt_ =
new IsothermalPvt(*data.isothermalPvt_);
417 isothermalPvt_ =
nullptr;
418 oilvisctCurves_ = data.oilvisctCurves_;
419 viscrefPress_ = data.viscrefPress_;
420 viscrefRs_ = data.viscrefRs_;
421 viscRef_ = data.viscRef_;
422 oildentRefTemp_ = data.oildentRefTemp_;
423 oildentCT1_ = data.oildentCT1_;
424 oildentCT2_ = data.oildentCT2_;
425 oilJTRefPres_ = data.oilJTRefPres_;
426 oilJTC_ = data.oilJTC_;
427 internalEnergyCurves_ = data.internalEnergyCurves_;
428 enableThermalDensity_ = data.enableThermalDensity_;
429 enableJouleThomson_ = data.enableJouleThomson_;
430 enableThermalViscosity_ = data.enableThermalViscosity_;
431 enableInternalEnergy_ = data.enableInternalEnergy_;
437 IsothermalPvt* isothermalPvt_;
441 std::vector<TabulatedOneDFunction> oilvisctCurves_;
442 std::vector<Scalar> viscrefPress_;
443 std::vector<Scalar> viscrefRs_;
444 std::vector<Scalar> viscRef_;
447 std::vector<Scalar> oildentRefTemp_;
448 std::vector<Scalar> oildentCT1_;
449 std::vector<Scalar> oildentCT2_;
451 std::vector<Scalar> oilJTRefPres_;
452 std::vector<Scalar> oilJTC_;
454 std::vector<Scalar> rhoRefG_;
457 std::vector<TabulatedOneDFunction> internalEnergyCurves_;
459 bool enableThermalDensity_;
460 bool enableJouleThomson_;
461 bool enableThermalViscosity_;
462 bool enableInternalEnergy_;
Definition: EclipseState.hpp:55
This class represents the Pressure-Volume-Temperature relations of the oil phase in the black-oil mod...
Definition: OilPvtMultiplexer.hpp:97
Evaluation inverseFormationVolumeFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &Rs) const
Returns the formation volume factor [-] of the fluid phase.
Definition: OilPvtMultiplexer.hpp:202
Evaluation saturatedViscosity(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure) const
Returns the dynamic viscosity [Pa s] of the fluid phase given a set of parameters.
Definition: OilPvtMultiplexer.hpp:193
Evaluation saturatedInverseFormationVolumeFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure) const
Returns the formation volume factor [-] of the fluid phase.
Definition: OilPvtMultiplexer.hpp:212
Evaluation saturatedGasDissolutionFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure) const
Returns the gas dissolution factor [m^3/m^3] of saturated oil.
Definition: OilPvtMultiplexer.hpp:221
Evaluation viscosity(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &Rs) const
Returns the dynamic viscosity [Pa s] of the fluid phase given a set of parameters.
Definition: OilPvtMultiplexer.hpp:183
Evaluation saturationPressure(unsigned regionIdx, const Evaluation &temperature, const Evaluation &Rs) const
Returns the saturation pressure [Pa] of oil given the mass fraction of the gas component in the oil p...
Definition: OilPvtMultiplexer.hpp:245
const Scalar oilReferenceDensity(unsigned regionIdx) const
Return the reference density which are considered by this PVT-object.
Definition: OilPvtMultiplexer.hpp:166
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: OilPvtMultiplexer.hpp:254
This class implements temperature dependence of the PVT properties of oil.
Definition: OilPvtThermal.hpp:50
void initEnd()
Finish initializing the thermal part of the oil phase PVT properties.
Definition: OilPvtThermal.hpp:130
bool enableThermalDensity() const
Returns true iff the density of the oil phase is temperature dependent.
Definition: OilPvtThermal.hpp:136
Evaluation saturatedGasDissolutionFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure) const
Returns the gas dissolution factor [m^3/m^3] of the oil phase.
Definition: OilPvtThermal.hpp:309
Evaluation inverseFormationVolumeFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &Rs) const
Returns the formation volume factor [-] of the fluid phase.
Definition: OilPvtThermal.hpp:256
Evaluation saturatedViscosity(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure) const
Returns the dynamic viscosity [Pa s] of the fluid phase given a set of parameters.
Definition: OilPvtThermal.hpp:238
Evaluation internalEnergy(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &Rs) const
Returns the specific internal energy [J/kg] of oil given a set of parameters.
Definition: OilPvtThermal.hpp:158
Evaluation viscosity(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &Rs) const
Returns the dynamic viscosity [Pa s] of the fluid phase given a set of parameters.
Definition: OilPvtThermal.hpp:220
void setNumRegions(size_t numRegions)
Set the number of PVT-regions considered by this object.
Definition: OilPvtThermal.hpp:112
bool enableThermalViscosity() const
Returns true iff the viscosity of the oil phase is temperature dependent.
Definition: OilPvtThermal.hpp:148
Evaluation saturationPressure(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure) const
Returns the saturation pressure of the oil phase [Pa].
Definition: OilPvtThermal.hpp:337
Evaluation saturatedGasDissolutionFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &oilSaturation, const Evaluation &maxOilSaturation) const
Returns the gas dissolution factor [m^3/m^3] of the oil phase.
Definition: OilPvtThermal.hpp:322
Evaluation saturatedInverseFormationVolumeFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure) const
Returns the formation volume factor [-] of gas-saturated oil phase.
Definition: OilPvtThermal.hpp:281
bool enableJouleThomson() const
Returns true iff Joule-Thomson effect for the oil phase is active.
Definition: OilPvtThermal.hpp:142
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