27#ifndef OPM_OIL_PVT_THERMAL_HPP
28#define OPM_OIL_PVT_THERMAL_HPP
41template <
class Scalar,
bool enableThermal>
50template <
class Scalar>
57 OilPvtThermal() =
default;
59 OilPvtThermal(IsothermalPvt* isothermalPvt,
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)
91 OilPvtThermal(
const OilPvtThermal& data)
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
253 isothermalPvt_->inverseFormationVolumeFactor(regionIdx, temperature, pressure, Rs);
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 Flu
idState,
class LhsEval =
typename Flu
idState::Scalar>
273 std::pair<LhsEval, LhsEval>
276 auto [b, mu] = isothermalPvt_->inverseFormationVolumeFactorAndViscosity(fluidState, regionIdx);
277 const LhsEval& temperature = decay<LhsEval>(fluidState.temperature(FluidState::oilPhaseIdx));
281 Scalar TRef = oildentRefTemp_[regionIdx];
282 Scalar cT1 = oildentCT1_[regionIdx];
283 Scalar cT2 = oildentCT2_[regionIdx];
284 const LhsEval Y = temperature - TRef;
285 b /= (1.0 + (cT1 + cT2 * Y) * Y);
289 const auto muOilvisct = oilvisctCurves_[regionIdx].eval(temperature,
true);
290 mu *= (muOilvisct / viscRef_[regionIdx]);
298 template <
class Evaluation>
300 const Evaluation& temperature,
301 const Evaluation& pressure)
const
304 isothermalPvt_->saturatedInverseFormationVolumeFactor(regionIdx, temperature, pressure);
312 Scalar TRef = oildentRefTemp_[regionIdx];
313 Scalar cT1 = oildentCT1_[regionIdx];
314 Scalar cT2 = oildentCT2_[regionIdx];
315 const Evaluation& Y = temperature - TRef;
317 return b / (1 + (cT1 + cT2 * Y) * Y);
327 template <
class Evaluation>
329 const Evaluation& temperature,
330 const Evaluation& pressure)
const
331 {
return isothermalPvt_->saturatedGasDissolutionFactor(regionIdx, temperature, pressure); }
340 template <
class Evaluation>
342 const Evaluation& temperature,
343 const Evaluation& pressure,
344 const Evaluation& oilSaturation,
345 const Evaluation& maxOilSaturation)
const
346 {
return isothermalPvt_->saturatedGasDissolutionFactor(regionIdx, temperature, pressure, oilSaturation, maxOilSaturation); }
355 template <
class Evaluation>
357 const Evaluation& temperature,
358 const Evaluation& pressure)
const
359 {
return isothermalPvt_->saturationPressure(regionIdx, temperature, pressure); }
361 template <
class Evaluation>
362 Evaluation diffusionCoefficient(
const Evaluation& temperature,
363 const Evaluation& pressure,
364 unsigned compIdx)
const
369 const IsothermalPvt* isoThermalPvt()
const
370 {
return isothermalPvt_; }
372 Scalar oilReferenceDensity(
unsigned regionIdx)
const
375 Scalar hVap(
unsigned regionIdx)
const
376 {
return this->hVap_[regionIdx]; }
378 const std::vector<TabulatedOneDFunction>& oilvisctCurves()
const
379 {
return oilvisctCurves_; }
381 const std::vector<Scalar>& viscrefPress()
const
382 {
return viscrefPress_; }
384 const std::vector<Scalar>& viscrefRs()
const
385 {
return viscrefRs_; }
387 const std::vector<Scalar>& viscRef()
const
390 const std::vector<Scalar>& oildentRefTemp()
const
391 {
return oildentRefTemp_; }
393 const std::vector<Scalar>& oildentCT1()
const
394 {
return oildentCT1_; }
396 const std::vector<Scalar>& oildentCT2()
const
397 {
return oildentCT2_; }
399 const std::vector<TabulatedOneDFunction>& internalEnergyCurves()
const
400 {
return internalEnergyCurves_; }
402 bool enableInternalEnergy()
const
403 {
return enableInternalEnergy_; }
405 const std::vector<Scalar>& oilJTRefPres()
const
406 {
return oilJTRefPres_; }
408 const std::vector<Scalar>& oilJTC()
const
411 bool operator==(
const OilPvtThermal<Scalar>& data)
const;
413 OilPvtThermal<Scalar>& operator=(
const OilPvtThermal<Scalar>& data);
416 IsothermalPvt* isothermalPvt_{
nullptr};
420 std::vector<TabulatedOneDFunction> oilvisctCurves_{};
421 std::vector<Scalar> viscrefPress_{};
422 std::vector<Scalar> viscrefRs_{};
423 std::vector<Scalar> viscRef_{};
426 std::vector<Scalar> oildentRefTemp_{};
427 std::vector<Scalar> oildentCT1_{};
428 std::vector<Scalar> oildentCT2_{};
430 std::vector<Scalar> oilJTRefPres_{};
431 std::vector<Scalar> oilJTC_{};
433 std::vector<Scalar> rhoRefG_{};
434 std::vector<Scalar> hVap_{};
437 std::vector<TabulatedOneDFunction> internalEnergyCurves_{};
439 bool enableThermalDensity_{
false};
440 bool enableJouleThomson_{
false};
441 bool enableThermalViscosity_{
false};
442 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 oil phase in the black-oil mod...
Definition OilPvtMultiplexer.hpp:105
Scalar oilReferenceDensity(unsigned regionIdx) const
Return the reference density which are considered by this PVT-object.
Definition OilPvtMultiplexer.cpp:116
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:253
std::pair< LhsEval, LhsEval > inverseFormationVolumeFactorAndViscosity(const FluidState &fluidState, unsigned regionIdx)
Returns the formation volume factor [-] and viscosity [Pa s] of the fluid phase.
Definition OilPvtThermal.hpp:274
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:328
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:356
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:341
Evaluation saturatedInverseFormationVolumeFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure) const
Returns the formation volume factor [-] of gas-saturated oil phase.
Definition OilPvtThermal.hpp:299
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