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)
98 const SamplingPoints& samplePoints)
99 { saturatedWaterVaporizationFactorTable_[regionIdx].setContainerOfTuples(samplePoints); }
115 { inverseGasB_[regionIdx] = invBg; }
123 { gasMu_[regionIdx] = mug; }
133 const SamplingPoints& samplePoints);
144 {
return gasReferenceDensity_.size(); }
149 template <
class Evaluation>
154 const Evaluation&)
const
156 throw std::runtime_error(
"Requested the enthalpy of gas but the thermal "
157 "option is not enabled");
160 Scalar hVap(
unsigned)
const
162 throw std::runtime_error(
"Requested the hvap of oil but the thermal "
163 "option is not enabled");
169 template <
class Evaluation>
172 const Evaluation& pressure,
174 const Evaluation& Rvw)
const
176 const Evaluation& invBg = inverseGasB_[regionIdx].eval(pressure, Rvw,
true);
177 const Evaluation& invMugBg = inverseGasBMu_[regionIdx].eval(pressure, Rvw,
true);
179 return invBg / invMugBg;
185 template <
class Evaluation>
188 const Evaluation& pressure)
const
190 const Evaluation& invBg = inverseSaturatedGasB_[regionIdx].eval(pressure,
true);
191 const Evaluation& invMugBg = inverseSaturatedGasBMu_[regionIdx].eval(pressure,
true);
193 return invBg / invMugBg;
199 template <
class Evaluation>
202 const Evaluation& pressure,
204 const Evaluation& Rvw)
const
205 {
return inverseGasB_[regionIdx].eval(pressure, Rvw,
true); }
210 template <
class Evaluation>
213 const Evaluation& pressure)
const
214 {
return inverseSaturatedGasB_[regionIdx].eval(pressure,
true); }
219 template <
class Evaluation>
222 const Evaluation& pressure)
const
224 return saturatedWaterVaporizationFactorTable_[regionIdx].eval(pressure,
231 template <
class Evaluation>
234 const Evaluation& pressure,
235 const Evaluation& saltConcentration)
const
237 if (enableRwgSalt_) {
238 return saturatedWaterVaporizationSaltFactorTable_[regionIdx].eval(pressure,
243 return saturatedWaterVaporizationFactorTable_[regionIdx].eval(pressure,
251 template <
class Evaluation>
256 const Evaluation& )
const
262 template <
class Evaluation>
265 const Evaluation& )
const
275 template <
class Evaluation>
278 const Evaluation& Rw)
const
282 const auto& RwTable = saturatedWaterVaporizationFactorTable_[regionIdx];
283 const Scalar eps = std::numeric_limits<typename Toolbox::Scalar>::epsilon() * 1e6;
286 Evaluation pSat = saturationPressure_[regionIdx].eval(Rw,
true);
291 bool onProbation =
false;
292 for (
unsigned i = 0; i < 20; ++i) {
293 const Evaluation& f = RwTable.eval(pSat,
true) - Rw;
294 const Evaluation& fPrime = RwTable.evalDerivative(pSat,
true);
298 if (std::abs(scalarValue(fPrime)) < 1.0e-30) {
302 const Evaluation& delta = f / fPrime;
317 if (std::abs(scalarValue(delta)) < std::abs(scalarValue(pSat)) * eps) {
322 const std::string msg =
323 "Finding saturation pressure did not converge: "
324 " pSat = " + std::to_string(getValue(pSat)) +
325 ", Rw = " + std::to_string(getValue(Rw));
326 OpmLog::debug(
"Wet gas saturation pressure", msg);
330 template <
class Evaluation>
331 Evaluation diffusionCoefficient(
const Evaluation& ,
335 throw std::runtime_error(
"Not implemented: The PVT model does not provide "
336 "a diffusionCoefficient()");
339 Scalar gasReferenceDensity(
unsigned regionIdx)
const
340 {
return gasReferenceDensity_[regionIdx]; }
342 Scalar waterReferenceDensity(
unsigned regionIdx)
const
343 {
return waterReferenceDensity_[regionIdx]; }
345 const std::vector<TabulatedTwoDFunction>& inverseGasB()
const
346 {
return inverseGasB_; }
348 const std::vector<TabulatedOneDFunction>& inverseSaturatedGasB()
const
349 {
return inverseSaturatedGasB_; }
351 const std::vector<TabulatedTwoDFunction>& gasMu()
const
354 const std::vector<TabulatedTwoDFunction>& inverseGasBMu()
const
355 {
return inverseGasBMu_; }
357 const std::vector<TabulatedOneDFunction>& inverseSaturatedGasBMu()
const
358 {
return inverseSaturatedGasBMu_; }
360 const std::vector<TabulatedOneDFunction>& saturatedWaterVaporizationFactorTable()
const
361 {
return saturatedWaterVaporizationFactorTable_; }
363 const std::vector<TabulatedTwoDFunction>& saturatedWaterVaporizationSaltFactorTable()
const
364 {
return saturatedWaterVaporizationSaltFactorTable_; }
367 {
return saturationPressure_; }
369 Scalar vapPar1()
const
373 void updateSaturationPressure_(
unsigned regionIdx);
375 std::vector<Scalar> gasReferenceDensity_{};
376 std::vector<Scalar> waterReferenceDensity_{};
377 std::vector<TabulatedTwoDFunction> inverseGasB_{};
378 std::vector<TabulatedOneDFunction> inverseSaturatedGasB_{};
379 std::vector<TabulatedTwoDFunction> gasMu_{};
380 std::vector<TabulatedTwoDFunction> inverseGasBMu_{};
381 std::vector<TabulatedOneDFunction> inverseSaturatedGasBMu_{};
382 std::vector<TabulatedOneDFunction> saturatedWaterVaporizationFactorTable_{};
383 std::vector<TabulatedTwoDFunction> saturatedWaterVaporizationSaltFactorTable_{};
384 std::vector<TabulatedOneDFunction> saturationPressure_{};
386 bool enableRwgSalt_ =
false;
387 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:200
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:252
void setGasViscosity(unsigned regionIdx, const TabulatedTwoDFunction &mug)
Initialize the viscosity of the gas phase.
Definition DryHumidGasPvt.hpp:122
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:276
void setInverseGasFormationVolumeFactor(unsigned regionIdx, const TabulatedTwoDFunction &invBg)
Initialize the function for the gas formation volume factor.
Definition DryHumidGasPvt.hpp:113
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:143
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:150
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:220
void setSaturatedGasWaterVaporizationFactor(unsigned regionIdx, const SamplingPoints &samplePoints)
Initialize the function for the oil vaporization factor .
Definition DryHumidGasPvt.hpp:97
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:170
void setSaturatedGasViscosity(unsigned regionIdx, const SamplingPoints &samplePoints)
Initialize the phase viscosity for oil saturated gas.
Definition DryHumidGasPvt.cpp:268
Evaluation saturatedOilVaporizationFactor(unsigned, const Evaluation &, const Evaluation &) const
Returns the oil vaporization factor [m^3/m^3] of the oil phase.
Definition DryHumidGasPvt.hpp:263
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:232
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:186
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:211
Definition EclipseState.hpp:63
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