27 #ifndef OPM_WATER_PVT_THERMAL_HPP 28 #define OPM_WATER_PVT_THERMAL_HPP 39 template <
class Scalar,
bool enableThermal,
bool enableBrine>
40 class WaterPvtMultiplexer;
48 template <
class Scalar,
bool enableBrine>
58 const std::vector<Scalar>& viscrefPress,
59 const std::vector<Scalar>& watdentRefTemp,
60 const std::vector<Scalar>& watdentCT1,
61 const std::vector<Scalar>& watdentCT2,
62 const std::vector<Scalar>& watJTRefPres,
63 const std::vector<Scalar>& watJTC,
64 const std::vector<Scalar>& pvtwRefPress,
65 const std::vector<Scalar>& pvtwRefB,
66 const std::vector<Scalar>& pvtwCompressibility,
67 const std::vector<Scalar>& pvtwViscosity,
68 const std::vector<Scalar>& pvtwViscosibility,
69 const std::vector<Scalar>& referenceSaltConcentration,
70 const std::vector<TabulatedOneDFunction>& watvisctCurves,
71 const std::vector<TabulatedOneDFunction>& internalEnergyCurves,
75 bool enableInternalEnergy,
76 bool enableBrineViscosity)
77 : isothermalPvt_(isothermalPvt)
78 , viscrefPress_(viscrefPress)
79 , watdentRefTemp_(watdentRefTemp)
80 , watdentCT1_(watdentCT1)
81 , watdentCT2_(watdentCT2)
82 , watJTRefPres_(watJTRefPres)
84 , pvtwRefPress_(pvtwRefPress)
86 , pvtwCompressibility_(pvtwCompressibility)
87 , pvtwViscosity_(pvtwViscosity)
88 , pvtwViscosibility_(pvtwViscosibility)
89 , referenceSaltConcentration_(referenceSaltConcentration)
90 , watvisctCurves_(watvisctCurves)
91 , internalEnergyCurves_(internalEnergyCurves)
95 , enableInternalEnergy_(enableInternalEnergy)
96 , enableBrineViscosity_(enableBrineViscosity)
103 {
delete isothermalPvt_; }
115 void setVapPars(
const Scalar par1,
const Scalar par2)
117 isothermalPvt_->setVapPars(par1, par2);
130 {
return enableThermalDensity_; }
136 {
return enableJouleThomson_; }
142 {
return enableThermalViscosity_; }
144 Scalar hVap(
unsigned regionIdx)
const 145 {
return this->hVap_[regionIdx]; }
147 std::size_t numRegions()
const 148 {
return pvtwRefPress_.size(); }
153 template <
class Evaluation>
155 const Evaluation& temperature,
156 const Evaluation& pressure,
157 const Evaluation& Rsw,
158 const Evaluation& saltconcentration)
const 160 if (!enableInternalEnergy_) {
161 throw std::runtime_error(
"Requested the internal energy of water but it is disabled");
164 if (!enableJouleThomson_) {
168 return internalEnergyCurves_[regionIdx].eval(temperature,
true);
171 Evaluation Tref = watdentRefTemp_[regionIdx];
172 Evaluation Pref = watJTRefPres_[regionIdx];
173 Scalar JTC = watJTC_[regionIdx];
176 Evaluation Cp = internalEnergyCurves_[regionIdx].eval(temperature,
true)/temperature;
177 Evaluation density = invB * waterReferenceDensity(regionIdx);
179 Evaluation enthalpyPres;
181 enthalpyPres = -Cp * JTC * (pressure - Pref);
183 else if (enableThermalDensity_) {
184 Scalar c1T = watdentCT1_[regionIdx];
185 Scalar c2T = watdentCT2_[regionIdx];
187 Evaluation alpha = (c1T + 2 * c2T * (temperature - Tref)) /
188 (1 + c1T *(temperature - Tref) + c2T * (temperature - Tref) * (temperature - Tref));
190 constexpr
const int N = 100;
191 Evaluation deltaP = (pressure - Pref) / N;
192 Evaluation enthalpyPresPrev = 0;
193 for (std::size_t i = 0; i < N; ++i) {
194 Evaluation Pnew = Pref + i * deltaP;
196 Pnew, Rsw, saltconcentration) *
197 waterReferenceDensity(regionIdx);
198 Evaluation jouleThomsonCoefficient = -(1.0 / Cp) * (1.0 - alpha * temperature) / rho;
199 Evaluation deltaEnthalpyPres = -Cp * jouleThomsonCoefficient * deltaP;
200 enthalpyPres = enthalpyPresPrev + deltaEnthalpyPres;
201 enthalpyPresPrev = enthalpyPres;
205 throw std::runtime_error(
"Requested Joule-thomson calculation but " 206 "thermal water density (WATDENT) is not provided");
209 Evaluation enthalpy = Cp * (temperature - Tref) + enthalpyPres;
211 return enthalpy - pressure/density;
218 template <
class Evaluation>
220 const Evaluation& temperature,
221 const Evaluation& pressure,
222 const Evaluation& Rsw,
223 const Evaluation& saltconcentration)
const 225 const auto& isothermalMu = isothermalPvt_->
viscosity(regionIdx, temperature,
226 pressure, Rsw, saltconcentration);
231 const auto& muWatvisct = watvisctCurves_[regionIdx].eval(temperature,
true);
232 if (enableBrineViscosity()) {
233 auto muRef = isothermalPvt_->
viscosity(regionIdx, temperature, Evaluation(viscrefPress_[regionIdx]), Rsw, Evaluation(referenceSaltConcentration_[regionIdx]));
234 return isothermalMu * muWatvisct / muRef;
236 Scalar x = -pvtwViscosibility_[regionIdx] * (viscrefPress_[regionIdx] - pvtwRefPress_[regionIdx]);
237 Scalar muRef = pvtwViscosity_[regionIdx] / (1.0 + x + 0.5 * x * x);
238 return isothermalMu * muWatvisct / muRef;
245 template <
class Evaluation>
247 const Evaluation& temperature,
248 const Evaluation& pressure,
249 const Evaluation& saltconcentration)
const 252 pressure, saltconcentration);
257 Scalar x = -pvtwViscosibility_[regionIdx] * (viscrefPress_[regionIdx] -
258 pvtwRefPress_[regionIdx]);
259 Scalar muRef = pvtwViscosity_[regionIdx] / (1.0 + x + 0.5 * x * x);
262 const auto& muWatvisct = watvisctCurves_[regionIdx].eval(temperature,
true);
263 return isothermalMu * muWatvisct / muRef;
269 template <
class Evaluation>
271 const Evaluation& temperature,
272 const Evaluation& pressure,
273 const Evaluation& saltconcentration)
const 275 Evaluation Rsw = 0.0;
277 Rsw, saltconcentration);
282 template <
class Evaluation>
284 const Evaluation& temperature,
285 const Evaluation& pressure,
286 const Evaluation& Rsw,
287 const Evaluation& saltconcentration)
const 291 pressure, Rsw, saltconcentration);
294 Scalar BwRef = pvtwRefB_[regionIdx];
295 Scalar TRef = watdentRefTemp_[regionIdx];
296 const Evaluation& X = pvtwCompressibility_[regionIdx] * (pressure -
297 pvtwRefPress_[regionIdx]);
298 Scalar cT1 = watdentCT1_[regionIdx];
299 Scalar cT2 = watdentCT2_[regionIdx];
300 const Evaluation& Y = temperature - TRef;
305 return 1.0 / (((1 - X) * (1 + cT1 * Y + cT2 * Y * Y)) * BwRef);
311 template <
class Flu
idState,
class LhsEval =
typename Flu
idState::ValueType>
312 std::pair<LhsEval, LhsEval>
316 const LhsEval& pressure = decay<LhsEval>(fluidState.pressure(FluidState::waterPhaseIdx));
317 const LhsEval& temperature = decay<LhsEval>(fluidState.temperature(FluidState::waterPhaseIdx));
319 Scalar BwRef = pvtwRefB_[regionIdx];
320 Scalar TRef = watdentRefTemp_[regionIdx];
321 const LhsEval X = pvtwCompressibility_[regionIdx] * (pressure - pvtwRefPress_[regionIdx]);
322 Scalar cT1 = watdentCT1_[regionIdx];
323 Scalar cT2 = watdentCT2_[regionIdx];
324 const LhsEval Y = temperature - TRef;
329 b = 1.0 / (((1 - X) * (1 + cT1 * Y + cT2 * Y * Y)) * BwRef);
332 Scalar x = -pvtwViscosibility_[regionIdx] * (viscrefPress_[regionIdx] - pvtwRefPress_[regionIdx]);
333 Scalar muRef = pvtwViscosity_[regionIdx] / (1.0 + x + 0.5 * x * x);
335 const auto muWatvisct = watvisctCurves_[regionIdx].eval(temperature,
true);
350 template <
class Evaluation>
354 const Evaluation& )
const 360 template <
class Evaluation>
364 const Evaluation& )
const 367 template <
class Evaluation>
368 Evaluation diffusionCoefficient(
const Evaluation& ,
373 throw std::runtime_error(
"Not implemented: The PVT model does not provide " 374 "a diffusionCoefficient()");
377 const IsothermalPvt* isoThermalPvt()
const 378 {
return isothermalPvt_; }
380 Scalar waterReferenceDensity(
unsigned regionIdx)
const 383 const std::vector<Scalar>& viscrefPress()
const 384 {
return viscrefPress_; }
386 const std::vector<Scalar>& watdentRefTemp()
const 387 {
return watdentRefTemp_; }
389 const std::vector<Scalar>& watdentCT1()
const 390 {
return watdentCT1_; }
392 const std::vector<Scalar>& watdentCT2()
const 393 {
return watdentCT2_; }
395 const std::vector<Scalar>& pvtwRefPress()
const 396 {
return pvtwRefPress_; }
398 const std::vector<Scalar>& pvtwRefB()
const 399 {
return pvtwRefB_; }
401 const std::vector<Scalar>& pvtwCompressibility()
const 402 {
return pvtwCompressibility_; }
404 const std::vector<Scalar>& pvtwViscosity()
const 405 {
return pvtwViscosity_; }
407 const std::vector<Scalar>& pvtwViscosibility()
const 408 {
return pvtwViscosibility_; }
410 const std::vector<Scalar>& referenceSaltConcentration()
const 411 {
return referenceSaltConcentration_; }
413 const std::vector<TabulatedOneDFunction>& watvisctCurves()
const 414 {
return watvisctCurves_; }
416 const std::vector<TabulatedOneDFunction>& internalEnergyCurves()
const 417 {
return internalEnergyCurves_; }
419 bool enableInternalEnergy()
const 420 {
return enableInternalEnergy_; }
422 bool enableBrineViscosity()
const 423 {
return enableBrineViscosity_; }
425 const std::vector<Scalar>& watJTRefPres()
const 426 {
return watJTRefPres_; }
428 const std::vector<Scalar>& watJTC()
const 431 bool operator==(
const WaterPvtThermal<Scalar, enableBrine>& data)
const;
433 WaterPvtThermal<Scalar, enableBrine>&
434 operator=(
const WaterPvtThermal<Scalar, enableBrine>& data);
437 IsothermalPvt* isothermalPvt_{
nullptr};
441 std::vector<Scalar> viscrefPress_{};
443 std::vector<Scalar> watdentRefTemp_{};
444 std::vector<Scalar> watdentCT1_{};
445 std::vector<Scalar> watdentCT2_{};
447 std::vector<Scalar> watJTRefPres_{};
448 std::vector<Scalar> watJTC_{};
450 std::vector<Scalar> pvtwRefPress_{};
451 std::vector<Scalar> pvtwRefB_{};
452 std::vector<Scalar> pvtwCompressibility_{};
453 std::vector<Scalar> pvtwViscosity_{};
454 std::vector<Scalar> pvtwViscosibility_{};
455 std::vector<Scalar> referenceSaltConcentration_{};
457 std::vector<TabulatedOneDFunction> watvisctCurves_{};
460 std::vector<TabulatedOneDFunction> internalEnergyCurves_{};
461 std::vector<Scalar> hVap_{};
463 bool enableThermalDensity_{
false};
464 bool enableJouleThomson_{
false};
465 bool enableThermalViscosity_{
false};
466 bool enableInternalEnergy_{
false};
467 bool enableBrineViscosity_{
false};
Evaluation saturationPressure(unsigned, const Evaluation &, const Evaluation &, const Evaluation &) const
Returns the saturation pressure of the water phase [Pa] depending on its mass fraction of the gas com...
Definition: WaterPvtThermal.hpp:351
This class implements temperature dependence of the PVT properties of water.
Definition: WaterPvtThermal.hpp:49
Evaluation internalEnergy(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &Rsw, const Evaluation &saltconcentration) const
Returns the specific internal energy [J/kg] of water given a set of parameters.
Definition: WaterPvtThermal.hpp:154
std::pair< LhsEval, LhsEval > inverseFormationVolumeFactorAndViscosity(const FluidState &fluidState, unsigned regionIdx)
Returns the formation volume factor [-] and viscosity [Pa s] of the fluid phase.
Definition: WaterPvtMultiplexer.hpp:195
Evaluation inverseFormationVolumeFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &Rsw, const Evaluation &saltconcentration) const
Returns the formation volume factor [-] of the fluid phase.
Definition: WaterPvtMultiplexer.hpp:181
Evaluation viscosity(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &Rsw, const Evaluation &saltconcentration) const
Returns the dynamic viscosity [Pa s] of the fluid phase given a set of parameters.
Definition: WaterPvtThermal.hpp:219
Definition: Schedule.hpp:100
Evaluation saturatedViscosity(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &saltconcentration) const
Returns the dynamic viscosity [Pa s] of the fluid phase given a set of parameters.
Definition: WaterPvtThermal.hpp:246
Evaluation viscosity(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &Rsw, const Evaluation &saltconcentration) const
Returns the dynamic viscosity [Pa s] of the fluid phase given a set of parameters.
Definition: WaterPvtMultiplexer.hpp:151
Evaluation inverseFormationVolumeFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &Rsw, const Evaluation &saltconcentration) const
Returns the formation volume factor [-] of the fluid phase.
Definition: WaterPvtThermal.hpp:283
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:30
void initEnd()
Finish initializing the thermal part of the water phase PVT properties.
Definition: WaterPvtThermal.hpp:123
Evaluation saturatedInverseFormationVolumeFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &saltconcentration) const
Returns the formation volume factor [-] of the fluid phase.
Definition: WaterPvtThermal.hpp:270
Definition: EclipseState.hpp:66
std::pair< LhsEval, LhsEval > inverseFormationVolumeFactorAndViscosity(const FluidState &fluidState, unsigned regionIdx)
Returns the formation volume factor [-] and viscosity [Pa s] of the fluid phase.
Definition: WaterPvtThermal.hpp:313
Evaluation saturatedGasDissolutionFactor(unsigned, const Evaluation &, const Evaluation &, const Evaluation &) const
Returns the gas dissolution factor [m^3/m^3] of the water phase.
Definition: WaterPvtThermal.hpp:361
This class represents the Pressure-Volume-Temperature relations of the water phase in the black-oil m...
Definition: ConstantCompressibilityBrinePvt.hpp:39
bool enableThermalDensity() const
Returns true iff the density of the water phase is temperature dependent.
Definition: WaterPvtThermal.hpp:129
void setNumRegions(std::size_t numRegions)
Set the number of PVT-regions considered by this object.
Definition: WaterPvtThermal.cpp:198
Implements a linearly interpolated scalar function that depends on one variable.
bool enableJouleThomson() const
Returns true iff Joule-Thomson effect for the water phase is active.
Definition: WaterPvtThermal.hpp:135
bool enableThermalViscosity() const
Returns true iff the viscosity of the water phase is temperature dependent.
Definition: WaterPvtThermal.hpp:141
void initFromState(const EclipseState &eclState, const Schedule &schedule)
Implement the temperature part of the water PVT properties.
Definition: WaterPvtThermal.cpp:41
Implements a linearly interpolated scalar function that depends on one variable.
Definition: Tabulated1DFunction.hpp:50
Scalar waterReferenceDensity(unsigned regionIdx) const
Return the reference density which are considered by this PVT-object.
Definition: WaterPvtMultiplexer.cpp:109
Evaluation saturatedViscosity(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &saltconcentration) const
Returns the dynamic viscosity [Pa s] of the fluid phase given a set of parameters.
Definition: WaterPvtMultiplexer.hpp:169