27#ifndef OPM_DRY_HUMID_GAS_PVT_HPP
28#define OPM_DRY_HUMID_GAS_PVT_HPP
31#include <opm/common/OpmLog/OpmLog.hpp>
52template <
class Scalar>
55 using SamplingPoints = std::vector<std::pair<Scalar, Scalar>>;
70 void extendPvtgwTable_(
unsigned regionIdx,
79 void setVapPars(
const Scalar par1,
const Scalar)
99 const SamplingPoints& samplePoints)
100 { saturatedWaterVaporizationFactorTable_[regionIdx].setContainerOfTuples(samplePoints); }
115 const TabulatedTwoDFunction& invBg)
116 { inverseGasB_[regionIdx] = invBg; }
124 { gasMu_[regionIdx] = mug; }
134 const SamplingPoints& samplePoints);
145 {
return gasReferenceDensity_.size(); }
150 template <
class Evaluation>
155 const Evaluation&)
const
157 throw std::runtime_error(
"Requested the enthalpy of gas but the thermal "
158 "option is not enabled");
161 Scalar hVap(
unsigned)
const
163 throw std::runtime_error(
"Requested the hvap of oil but the thermal "
164 "option is not enabled");
170 template <
class Evaluation>
173 const Evaluation& pressure,
175 const Evaluation& Rvw)
const
177 const Evaluation& invBg = inverseGasB_[regionIdx].eval(pressure, Rvw,
true);
178 const Evaluation& invMugBg = inverseGasBMu_[regionIdx].eval(pressure, Rvw,
true);
180 return invBg / invMugBg;
186 template <
class Evaluation>
189 const Evaluation& pressure)
const
191 const Evaluation& invBg = inverseSaturatedGasB_[regionIdx].eval(pressure,
true);
192 const Evaluation& invMugBg = inverseSaturatedGasBMu_[regionIdx].eval(pressure,
true);
194 return invBg / invMugBg;
200 template <
class Evaluation>
203 const Evaluation& pressure,
205 const Evaluation& Rvw)
const
206 {
return inverseGasB_[regionIdx].eval(pressure, Rvw,
true); }
211 template <
class Flu
idState,
class LhsEval =
typename Flu
idState::Scalar>
212 std::pair<LhsEval, LhsEval>
215 const LhsEval& p = decay<LhsEval>(fluidState.pressure(FluidState::gasPhaseIdx));
216 const LhsEval& Rvw = decay<LhsEval>(fluidState.Rvw());
218 const auto satSegIdx = this->saturatedWaterVaporizationFactorTable_[regionIdx].findSegmentIndex(p,
true);
219 const auto RvwSat = this->saturatedWaterVaporizationFactorTable_[regionIdx].eval(p,
SegmentIndex{satSegIdx});
220 const bool useSaturatedTables = (fluidState.saturation(FluidState::waterPhaseIdx) > 0.0) && (Rvw >= (1.0 - 1e-10) * RvwSat);
222 if (useSaturatedTables) {
223 const LhsEval b = this->inverseSaturatedGasB_[regionIdx].eval(p,
SegmentIndex{satSegIdx});
224 const LhsEval invBMu = this->inverseSaturatedGasBMu_[regionIdx].eval(p,
SegmentIndex{satSegIdx});
225 const LhsEval mu = b / invBMu;
228 unsigned ii, jj1, jj2;
229 LhsEval alpha, beta1, beta2;
230 this->inverseGasB_[regionIdx].findPoints(ii, jj1, jj2, alpha, beta1, beta2, p, Rvw,
true);
231 const LhsEval b = this->inverseGasB_[regionIdx].eval(ii, jj1, jj2, alpha, beta1, beta2);
232 const LhsEval invBMu = this->inverseGasBMu_[regionIdx].eval(ii, jj1, jj2, alpha, beta1, beta2);
233 const LhsEval mu = b / invBMu;
241 template <
class Evaluation>
244 const Evaluation& pressure)
const
245 {
return inverseSaturatedGasB_[regionIdx].eval(pressure,
true); }
250 template <
class Evaluation>
253 const Evaluation& pressure)
const
255 return saturatedWaterVaporizationFactorTable_[regionIdx].eval(pressure,
262 template <
class Evaluation>
265 const Evaluation& pressure,
266 const Evaluation& saltConcentration)
const
268 if (enableRwgSalt_) {
269 return saturatedWaterVaporizationSaltFactorTable_[regionIdx].eval(pressure,
274 return saturatedWaterVaporizationFactorTable_[regionIdx].eval(pressure,
282 template <
class Evaluation>
287 const Evaluation& )
const
293 template <
class Evaluation>
296 const Evaluation& )
const
307 template <
class Evaluation>
310 const Evaluation& Rw)
const
314 const auto& RwTable = saturatedWaterVaporizationFactorTable_[regionIdx];
315 const Scalar eps = std::numeric_limits<typename Toolbox::Scalar>::epsilon() * 1e6;
318 Evaluation pSat = saturationPressure_[regionIdx].eval(Rw,
true);
323 bool onProbation =
false;
324 for (
unsigned i = 0; i < 20; ++i) {
325 const Evaluation& f = RwTable.eval(pSat,
true) - Rw;
326 const Evaluation& fPrime = RwTable.evalDerivative(pSat,
true);
330 if (std::abs(scalarValue(fPrime)) < 1.0e-30) {
334 const Evaluation& delta = f / fPrime;
349 if (std::abs(scalarValue(delta)) < std::abs(scalarValue(pSat)) * eps) {
354 const std::string msg =
355 "Finding saturation pressure did not converge: "
356 " pSat = " + std::to_string(getValue(pSat)) +
357 ", Rw = " + std::to_string(getValue(Rw));
358 OpmLog::debug(
"Wet gas saturation pressure", msg);
362 template <
class Evaluation>
363 Evaluation diffusionCoefficient(
const Evaluation& ,
367 throw std::runtime_error(
"Not implemented: The PVT model does not provide "
368 "a diffusionCoefficient()");
371 Scalar gasReferenceDensity(
unsigned regionIdx)
const
372 {
return gasReferenceDensity_[regionIdx]; }
374 Scalar waterReferenceDensity(
unsigned regionIdx)
const
375 {
return waterReferenceDensity_[regionIdx]; }
377 const std::vector<TabulatedTwoDFunction>& inverseGasB()
const
378 {
return inverseGasB_; }
380 const std::vector<TabulatedOneDFunction>& inverseSaturatedGasB()
const
381 {
return inverseSaturatedGasB_; }
383 const std::vector<TabulatedTwoDFunction>& gasMu()
const
386 const std::vector<TabulatedTwoDFunction>& inverseGasBMu()
const
387 {
return inverseGasBMu_; }
389 const std::vector<TabulatedOneDFunction>& inverseSaturatedGasBMu()
const
390 {
return inverseSaturatedGasBMu_; }
392 const std::vector<TabulatedOneDFunction>& saturatedWaterVaporizationFactorTable()
const
393 {
return saturatedWaterVaporizationFactorTable_; }
395 const std::vector<TabulatedTwoDFunction>& saturatedWaterVaporizationSaltFactorTable()
const
396 {
return saturatedWaterVaporizationSaltFactorTable_; }
399 {
return saturationPressure_; }
401 Scalar vapPar1()
const
405 void updateSaturationPressure_(
unsigned regionIdx);
407 std::vector<Scalar> gasReferenceDensity_{};
408 std::vector<Scalar> waterReferenceDensity_{};
409 std::vector<TabulatedTwoDFunction> inverseGasB_{};
410 std::vector<TabulatedOneDFunction> inverseSaturatedGasB_{};
411 std::vector<TabulatedTwoDFunction> gasMu_{};
412 std::vector<TabulatedTwoDFunction> inverseGasBMu_{};
413 std::vector<TabulatedOneDFunction> inverseSaturatedGasBMu_{};
414 std::vector<TabulatedOneDFunction> saturatedWaterVaporizationFactorTable_{};
415 std::vector<TabulatedTwoDFunction> saturatedWaterVaporizationSaltFactorTable_{};
416 std::vector<TabulatedOneDFunction> saturationPressure_{};
418 bool enableRwgSalt_ =
false;
419 Scalar vapPar1_ = 0.0;
Provides the OPM specific exception classes.
Implements a linearly interpolated scalar function that depends on one variable.
This class represents the Pressure-Volume-Temperature relations of the gas phase with vaporized water...
Definition DryHumidGasPvt.hpp:54
Evaluation inverseFormationVolumeFactor(unsigned regionIdx, const Evaluation &, const Evaluation &pressure, const Evaluation &, const Evaluation &Rvw) const
Returns the formation volume factor [-] of the fluid phase.
Definition DryHumidGasPvt.hpp:201
Evaluation saturatedOilVaporizationFactor(unsigned, const Evaluation &, const Evaluation &, const Evaluation &, const Evaluation &) const
Returns the oil vaporization factor [m^3/m^3] of the oil phase.
Definition DryHumidGasPvt.hpp:283
void setGasViscosity(unsigned regionIdx, const TabulatedTwoDFunction &mug)
Initialize the viscosity of the gas phase.
Definition DryHumidGasPvt.hpp:123
Evaluation saturationPressure(unsigned regionIdx, const Evaluation &, const Evaluation &Rw) const
Returns the saturation pressure of the gas phase [Pa] depending on its mass fraction of the water com...
Definition DryHumidGasPvt.hpp:308
void setInverseGasFormationVolumeFactor(unsigned regionIdx, const TabulatedTwoDFunction &invBg)
Initialize the function for the gas formation volume factor.
Definition DryHumidGasPvt.hpp:114
void initEnd()
Finish initializing the gas phase PVT properties.
Definition DryHumidGasPvt.cpp:302
unsigned numRegions() const
Return the number of PVT regions which are considered by this PVT-object.
Definition DryHumidGasPvt.hpp:144
void setReferenceDensities(unsigned regionIdx, Scalar, Scalar rhoRefGas, Scalar rhoRefWater)
Initialize the reference densities of all fluids for a given PVT region.
Definition DryHumidGasPvt.cpp:257
Evaluation internalEnergy(unsigned, const Evaluation &, const Evaluation &, const Evaluation &, const Evaluation &) const
Returns the specific enthalpy [J/kg] of gas given a set of parameters.
Definition DryHumidGasPvt.hpp:151
Evaluation saturatedWaterVaporizationFactor(unsigned regionIdx, const Evaluation &, const Evaluation &pressure) const
Returns the water vaporization factor [m^3/m^3] of the water phase.
Definition DryHumidGasPvt.hpp:251
void setSaturatedGasWaterVaporizationFactor(unsigned regionIdx, const SamplingPoints &samplePoints)
Initialize the function for the oil vaporization factor .
Definition DryHumidGasPvt.hpp:98
Evaluation viscosity(unsigned regionIdx, const Evaluation &, const Evaluation &pressure, const Evaluation &, const Evaluation &Rvw) const
Returns the dynamic viscosity [Pa s] of the fluid phase given a set of parameters.
Definition DryHumidGasPvt.hpp:171
void setSaturatedGasViscosity(unsigned regionIdx, const SamplingPoints &samplePoints)
Initialize the phase viscosity for oil saturated gas.
Definition DryHumidGasPvt.cpp:268
std::pair< LhsEval, LhsEval > inverseFormationVolumeFactorAndViscosity(const FluidState &fluidState, unsigned regionIdx)
Returns the formation volume factor [-] and viscosity [Pa s] of the fluid phase.
Definition DryHumidGasPvt.hpp:213
Evaluation saturatedOilVaporizationFactor(unsigned, const Evaluation &, const Evaluation &) const
Returns the oil vaporization factor [m^3/m^3] of the oil phase.
Definition DryHumidGasPvt.hpp:294
Evaluation saturatedWaterVaporizationFactor(unsigned regionIdx, const Evaluation &, const Evaluation &pressure, const Evaluation &saltConcentration) const
Returns the water vaporization factor [m^3/m^3] of the water phase.
Definition DryHumidGasPvt.hpp:263
Evaluation saturatedViscosity(unsigned regionIdx, const Evaluation &, const Evaluation &pressure) const
Returns the dynamic viscosity [Pa s] of oil saturated gas at a given pressure.
Definition DryHumidGasPvt.hpp:187
Evaluation saturatedInverseFormationVolumeFactor(unsigned regionIdx, const Evaluation &, const Evaluation &pressure) const
Returns the formation volume factor [-] of water saturated gas at a given pressure.
Definition DryHumidGasPvt.hpp:242
Definition EclipseState.hpp:62
Definition Exceptions.hpp:40
Definition Schedule.hpp:101
Definition SimpleTable.hpp:35
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
Definition Tabulated1DFunction.hpp:41