27#ifndef OPM_OIL_PVT_THERMAL_HPP
28#define OPM_OIL_PVT_THERMAL_HPP
41template <
class Scalar,
bool enableThermal>
42class OilPvtMultiplexer;
50template <
class Scalar>
60 const std::vector<TabulatedOneDFunction>& oilvisctCurves,
61 const std::vector<Scalar>& viscrefPress,
62 const std::vector<Scalar>& viscrefRs,
63 const std::vector<Scalar>& viscRef,
64 const std::vector<Scalar>& oildentRefTemp,
65 const std::vector<Scalar>& oildentCT1,
66 const std::vector<Scalar>& oildentCT2,
67 const std::vector<Scalar>& oilJTRefPres,
68 const std::vector<Scalar>& oilJTC,
69 const std::vector<TabulatedOneDFunction>& internalEnergyCurves,
73 bool enableInternalEnergy)
74 : isothermalPvt_(isothermalPvt)
75 , oilvisctCurves_(oilvisctCurves)
76 , viscrefPress_(viscrefPress)
77 , viscrefRs_(viscrefRs)
79 , oildentRefTemp_(oildentRefTemp)
80 , oildentCT1_(oildentCT1)
81 , oildentCT2_(oildentCT2)
82 , oilJTRefPres_(oilJTRefPres)
84 , internalEnergyCurves_(internalEnergyCurves)
88 , enableInternalEnergy_(enableInternalEnergy)
95 {
delete isothermalPvt_; }
109 void setVapPars(
const Scalar par1,
const Scalar par2)
111 isothermalPvt_->setVapPars(par1, par2);
124 {
return enableThermalDensity_; }
130 {
return enableJouleThomson_; }
136 {
return enableThermalViscosity_; }
138 std::size_t numRegions()
const
139 {
return viscrefRs_.size(); }
144 template <
class Evaluation>
146 const Evaluation& temperature,
147 const Evaluation& pressure,
148 const Evaluation& Rs)
const
150 if (!enableInternalEnergy_) {
151 throw std::runtime_error(
"Requested the internal energy of oil but it is disabled");
154 if (!enableJouleThomson_) {
158 return internalEnergyCurves_[regionIdx].eval(temperature,
true);
161 OpmLog::warning(
"Experimental code for jouleThomson: simulation will be slower");
162 Evaluation Tref = oildentRefTemp_[regionIdx];
163 Evaluation Pref = oilJTRefPres_[regionIdx];
164 Scalar JTC = oilJTC_[regionIdx];
167 Evaluation Cp = internalEnergyCurves_[regionIdx].eval(temperature,
true)/temperature;
168 Evaluation density = invB * (oilReferenceDensity(regionIdx) + Rs * rhoRefG_[regionIdx]);
170 Evaluation enthalpyPres;
172 enthalpyPres = -Cp * JTC * (pressure - Pref);
174 else if (enableThermalDensity_) {
175 Scalar c1T = oildentCT1_[regionIdx];
176 Scalar c2T = oildentCT2_[regionIdx];
178 Evaluation alpha = (c1T + 2 * c2T * (temperature - Tref)) /
179 (1 + c1T *(temperature - Tref) + c2T * (temperature - Tref) * (temperature - Tref));
182 Evaluation deltaP = (pressure - Pref) / N;
183 Evaluation enthalpyPresPrev = 0;
184 for (std::size_t i = 0; i < N; ++i) {
185 Evaluation Pnew = Pref + i * deltaP;
187 (oilReferenceDensity(regionIdx) + Rs * rhoRefG_[regionIdx]) ;
189 Evaluation jouleThomsonCoefficient = -(1.0/Cp) * (1.0 - alpha * temperature)/rho;
190 Evaluation deltaEnthalpyPres = -Cp * jouleThomsonCoefficient * deltaP;
191 enthalpyPres = enthalpyPresPrev + deltaEnthalpyPres;
192 enthalpyPresPrev = enthalpyPres;
196 throw std::runtime_error(
"Requested Joule-thomson calculation but thermal oil"
197 "density (OILDENT) is not provided");
200 Evaluation enthalpy = Cp * (temperature - Tref) + enthalpyPres;
202 return enthalpy - pressure/density;
209 template <
class Evaluation>
211 const Evaluation& temperature,
212 const Evaluation& pressure,
213 const Evaluation& Rs)
const
215 const auto& isothermalMu = isothermalPvt_->
viscosity(regionIdx, temperature, pressure, Rs);
221 const auto& muOilvisct = oilvisctCurves_[regionIdx].eval(temperature,
true);
222 return muOilvisct / viscRef_[regionIdx] * isothermalMu;
228 template <
class Evaluation>
230 const Evaluation& temperature,
231 const Evaluation& pressure)
const
233 const auto& isothermalMu = isothermalPvt_->
saturatedViscosity(regionIdx, temperature, pressure);
239 const auto& muOilvisct = oilvisctCurves_[regionIdx].eval(temperature,
true);
240 return muOilvisct / viscRef_[regionIdx] * isothermalMu;
246 template <
class Evaluation>
248 const Evaluation& temperature,
249 const Evaluation& pressure,
250 const Evaluation& Rs)
const
261 Scalar TRef = oildentRefTemp_[regionIdx];
262 Scalar cT1 = oildentCT1_[regionIdx];
263 Scalar cT2 = oildentCT2_[regionIdx];
264 const Evaluation& Y = temperature - TRef;
266 return b / (1 + (cT1 + cT2 * Y) * Y);
272 template <
class Evaluation>
274 const Evaluation& temperature,
275 const Evaluation& pressure)
const
286 Scalar TRef = oildentRefTemp_[regionIdx];
287 Scalar cT1 = oildentCT1_[regionIdx];
288 Scalar cT2 = oildentCT2_[regionIdx];
289 const Evaluation& Y = temperature - TRef;
291 return b / (1 + (cT1 + cT2 * Y) * Y);
301 template <
class Evaluation>
303 const Evaluation& temperature,
304 const Evaluation& pressure)
const
314 template <
class Evaluation>
316 const Evaluation& temperature,
317 const Evaluation& pressure,
318 const Evaluation& oilSaturation,
319 const Evaluation& maxOilSaturation)
const
329 template <
class Evaluation>
331 const Evaluation& temperature,
332 const Evaluation& pressure)
const
335 template <
class Evaluation>
336 Evaluation diffusionCoefficient(
const Evaluation& temperature,
337 const Evaluation& pressure,
338 unsigned compIdx)
const
343 const IsothermalPvt* isoThermalPvt()
const
344 {
return isothermalPvt_; }
346 Scalar oilReferenceDensity(
unsigned regionIdx)
const
349 Scalar hVap(
unsigned regionIdx)
const
350 {
return this->hVap_[regionIdx]; }
352 const std::vector<TabulatedOneDFunction>& oilvisctCurves()
const
353 {
return oilvisctCurves_; }
355 const std::vector<Scalar>& viscrefPress()
const
356 {
return viscrefPress_; }
358 const std::vector<Scalar>& viscrefRs()
const
359 {
return viscrefRs_; }
361 const std::vector<Scalar>& viscRef()
const
364 const std::vector<Scalar>& oildentRefTemp()
const
365 {
return oildentRefTemp_; }
367 const std::vector<Scalar>& oildentCT1()
const
368 {
return oildentCT1_; }
370 const std::vector<Scalar>& oildentCT2()
const
371 {
return oildentCT2_; }
373 const std::vector<TabulatedOneDFunction>& internalEnergyCurves()
const
374 {
return internalEnergyCurves_; }
376 bool enableInternalEnergy()
const
377 {
return enableInternalEnergy_; }
379 const std::vector<Scalar>& oilJTRefPres()
const
380 {
return oilJTRefPres_; }
382 const std::vector<Scalar>& oilJTC()
const
385 bool operator==(
const OilPvtThermal<Scalar>& data)
const;
387 OilPvtThermal<Scalar>& operator=(
const OilPvtThermal<Scalar>& data);
390 IsothermalPvt* isothermalPvt_{
nullptr};
394 std::vector<TabulatedOneDFunction> oilvisctCurves_{};
395 std::vector<Scalar> viscrefPress_{};
396 std::vector<Scalar> viscrefRs_{};
397 std::vector<Scalar> viscRef_{};
400 std::vector<Scalar> oildentRefTemp_{};
401 std::vector<Scalar> oildentCT1_{};
402 std::vector<Scalar> oildentCT2_{};
404 std::vector<Scalar> oilJTRefPres_{};
405 std::vector<Scalar> oilJTC_{};
407 std::vector<Scalar> rhoRefG_{};
408 std::vector<Scalar> hVap_{};
411 std::vector<TabulatedOneDFunction> internalEnergyCurves_{};
413 bool enableThermalDensity_{
false};
414 bool enableJouleThomson_{
false};
415 bool enableThermalViscosity_{
false};
416 bool enableInternalEnergy_{
false};
Implements a linearly interpolated scalar function that depends on one variable.
Definition EclipseState.hpp:63
This class represents the Pressure-Volume-Temperature relations of the oil phase in the black-oil mod...
Definition OilPvtMultiplexer.hpp:105
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:188
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:179
Evaluation saturatedInverseFormationVolumeFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure) const
Returns the formation volume factor [-] of the fluid phase.
Definition OilPvtMultiplexer.hpp:198
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:207
Scalar oilReferenceDensity(unsigned regionIdx) const
Return the reference density which are considered by this PVT-object.
Definition OilPvtMultiplexer.cpp:116
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:169
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:231
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:240
This class implements temperature dependence of the PVT properties of oil.
Definition OilPvtThermal.hpp:52
void initEnd()
Finish initializing the thermal part of the oil phase PVT properties.
Definition OilPvtThermal.hpp:117
bool enableThermalDensity() const
Returns true iff the density of the oil phase is temperature dependent.
Definition OilPvtThermal.hpp:123
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:302
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:247
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:229
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:145
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:210
void setNumRegions(std::size_t numRegions)
Set the number of PVT-regions considered by this object.
Definition OilPvtThermal.cpp:183
bool enableThermalViscosity() const
Returns true iff the viscosity of the oil phase is temperature dependent.
Definition OilPvtThermal.hpp:135
Evaluation saturationPressure(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure) const
Returns the saturation pressure of the oil phase [Pa].
Definition OilPvtThermal.hpp:330
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:315
Evaluation saturatedInverseFormationVolumeFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure) const
Returns the formation volume factor [-] of gas-saturated oil phase.
Definition OilPvtThermal.hpp:273
bool enableJouleThomson() const
Returns true iff Joule-Thomson effect for the oil phase is active.
Definition OilPvtThermal.hpp:129
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