57 WaterPvtThermal() =
default;
59 WaterPvtThermal(IsothermalPvt* isothermalPvt,
60 const std::vector<Scalar>& viscrefPress,
61 const std::vector<Scalar>& watdentRefTemp,
62 const std::vector<Scalar>& watdentCT1,
63 const std::vector<Scalar>& watdentCT2,
64 const std::vector<Scalar>& watJTRefPres,
65 const std::vector<Scalar>& watJTC,
66 const std::vector<Scalar>& pvtwRefPress,
67 const std::vector<Scalar>& pvtwRefB,
68 const std::vector<Scalar>& pvtwCompressibility,
69 const std::vector<Scalar>& pvtwViscosity,
70 const std::vector<Scalar>& pvtwViscosibility,
71 const std::vector<TabulatedOneDFunction>& watvisctCurves,
72 const std::vector<TabulatedOneDFunction>& internalEnergyCurves,
76 bool enableInternalEnergy)
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 , watvisctCurves_(watvisctCurves)
90 , internalEnergyCurves_(internalEnergyCurves)
94 , enableInternalEnergy_(enableInternalEnergy)
97 WaterPvtThermal(
const WaterPvtThermal& data)
101 {
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 Scalar x = -pvtwViscosibility_[regionIdx] * (viscrefPress_[regionIdx] -
232 pvtwRefPress_[regionIdx]);
233 Scalar muRef = pvtwViscosity_[regionIdx] / (1.0 + x + 0.5 * x * x);
236 const auto& muWatvisct = watvisctCurves_[regionIdx].eval(temperature,
true);
237 return isothermalMu * muWatvisct / muRef;
243 template <
class Evaluation>
245 const Evaluation& temperature,
246 const Evaluation& pressure,
247 const Evaluation& saltconcentration)
const
249 const auto& isothermalMu = isothermalPvt_->saturatedViscosity(regionIdx, temperature,
250 pressure, saltconcentration);
255 Scalar x = -pvtwViscosibility_[regionIdx] * (viscrefPress_[regionIdx] -
256 pvtwRefPress_[regionIdx]);
257 Scalar muRef = pvtwViscosity_[regionIdx] / (1.0 + x + 0.5 * x * x);
260 const auto& muWatvisct = watvisctCurves_[regionIdx].eval(temperature,
true);
261 return isothermalMu * muWatvisct / muRef;
267 template <
class Evaluation>
269 const Evaluation& temperature,
270 const Evaluation& pressure,
271 const Evaluation& saltconcentration)
const
273 Evaluation Rsw = 0.0;
275 Rsw, saltconcentration);
280 template <
class Evaluation>
282 const Evaluation& temperature,
283 const Evaluation& pressure,
284 const Evaluation& Rsw,
285 const Evaluation& saltconcentration)
const
288 return isothermalPvt_->inverseFormationVolumeFactor(regionIdx, temperature,
289 pressure, Rsw, saltconcentration);
292 Scalar BwRef = pvtwRefB_[regionIdx];
293 Scalar TRef = watdentRefTemp_[regionIdx];
294 const Evaluation& X = pvtwCompressibility_[regionIdx] * (pressure -
295 pvtwRefPress_[regionIdx]);
296 Scalar cT1 = watdentCT1_[regionIdx];
297 Scalar cT2 = watdentCT2_[regionIdx];
298 const Evaluation& Y = temperature - TRef;
303 return 1.0 / (((1 - X) * (1 + cT1 * Y + cT2 * Y * Y)) * BwRef);
309 template <
class Flu
idState,
class LhsEval =
typename Flu
idState::Scalar>
310 std::pair<LhsEval, LhsEval>
313 auto [b, mu] = isothermalPvt_->inverseFormationVolumeFactorAndViscosity(fluidState, regionIdx);
314 const LhsEval& pressure = decay<LhsEval>(fluidState.pressure(FluidState::waterPhaseIdx));
315 const LhsEval& temperature = decay<LhsEval>(fluidState.temperature(FluidState::waterPhaseIdx));
317 Scalar BwRef = pvtwRefB_[regionIdx];
318 Scalar TRef = watdentRefTemp_[regionIdx];
319 const LhsEval X = pvtwCompressibility_[regionIdx] * (pressure - pvtwRefPress_[regionIdx]);
320 Scalar cT1 = watdentCT1_[regionIdx];
321 Scalar cT2 = watdentCT2_[regionIdx];
322 const LhsEval Y = temperature - TRef;
327 b = 1.0 / (((1 - X) * (1 + cT1 * Y + cT2 * Y * Y)) * BwRef);
330 Scalar x = -pvtwViscosibility_[regionIdx] * (viscrefPress_[regionIdx] - pvtwRefPress_[regionIdx]);
331 Scalar muRef = pvtwViscosity_[regionIdx] / (1.0 + x + 0.5 * x * x);
333 const auto muWatvisct = watvisctCurves_[regionIdx].eval(temperature,
true);
348 template <
class Evaluation>
352 const Evaluation& )
const
358 template <
class Evaluation>
362 const Evaluation& )
const
365 template <
class Evaluation>
366 Evaluation diffusionCoefficient(
const Evaluation& ,
370 throw std::runtime_error(
"Not implemented: The PVT model does not provide "
371 "a diffusionCoefficient()");
374 const IsothermalPvt* isoThermalPvt()
const
375 {
return isothermalPvt_; }
377 Scalar waterReferenceDensity(
unsigned regionIdx)
const
380 const std::vector<Scalar>& viscrefPress()
const
381 {
return viscrefPress_; }
383 const std::vector<Scalar>& watdentRefTemp()
const
384 {
return watdentRefTemp_; }
386 const std::vector<Scalar>& watdentCT1()
const
387 {
return watdentCT1_; }
389 const std::vector<Scalar>& watdentCT2()
const
390 {
return watdentCT2_; }
392 const std::vector<Scalar>& pvtwRefPress()
const
393 {
return pvtwRefPress_; }
395 const std::vector<Scalar>& pvtwRefB()
const
396 {
return pvtwRefB_; }
398 const std::vector<Scalar>& pvtwCompressibility()
const
399 {
return pvtwCompressibility_; }
401 const std::vector<Scalar>& pvtwViscosity()
const
402 {
return pvtwViscosity_; }
404 const std::vector<Scalar>& pvtwViscosibility()
const
405 {
return pvtwViscosibility_; }
407 const std::vector<TabulatedOneDFunction>& watvisctCurves()
const
408 {
return watvisctCurves_; }
410 const std::vector<TabulatedOneDFunction>& internalEnergyCurves()
const
411 {
return internalEnergyCurves_; }
413 bool enableInternalEnergy()
const
414 {
return enableInternalEnergy_; }
416 const std::vector<Scalar>& watJTRefPres()
const
417 {
return watJTRefPres_; }
419 const std::vector<Scalar>& watJTC()
const
422 bool operator==(
const WaterPvtThermal<Scalar, enableBrine>& data)
const;
424 WaterPvtThermal<Scalar, enableBrine>&
425 operator=(
const WaterPvtThermal<Scalar, enableBrine>& data);
428 IsothermalPvt* isothermalPvt_{
nullptr};
432 std::vector<Scalar> viscrefPress_{};
434 std::vector<Scalar> watdentRefTemp_{};
435 std::vector<Scalar> watdentCT1_{};
436 std::vector<Scalar> watdentCT2_{};
438 std::vector<Scalar> watJTRefPres_{};
439 std::vector<Scalar> watJTC_{};
441 std::vector<Scalar> pvtwRefPress_{};
442 std::vector<Scalar> pvtwRefB_{};
443 std::vector<Scalar> pvtwCompressibility_{};
444 std::vector<Scalar> pvtwViscosity_{};
445 std::vector<Scalar> pvtwViscosibility_{};
447 std::vector<TabulatedOneDFunction> watvisctCurves_{};
450 std::vector<TabulatedOneDFunction> internalEnergyCurves_{};
451 std::vector<Scalar> hVap_{};
453 bool enableThermalDensity_{
false};
454 bool enableJouleThomson_{
false};
455 bool enableThermalViscosity_{
false};
456 bool enableInternalEnergy_{
false};