27#ifndef OPM_DRY_HUMID_GAS_PVT_HPP
28#define OPM_DRY_HUMID_GAS_PVT_HPP
31#include <opm/common/OpmLog/OpmLog.hpp>
50template <
class Scalar>
53 using SamplingPoints = std::vector<std::pair<Scalar, Scalar>>;
68 void extendPvtgwTable_(
unsigned regionIdx,
77 void setVapPars(
const Scalar par1,
const Scalar)
96 { saturatedWaterVaporizationFactorTable_[regionIdx].setContainerOfTuples(samplePoints); }
111 { inverseGasB_[regionIdx] = invBg; }
119 { gasMu_[regionIdx] = mug; }
129 const SamplingPoints& samplePoints);
140 {
return gasReferenceDensity_.size(); }
145 template <
class Evaluation>
150 const Evaluation&)
const
152 throw std::runtime_error(
"Requested the enthalpy of gas but the thermal option is not enabled");
158 template <
class Evaluation>
161 const Evaluation& pressure,
163 const Evaluation& Rvw)
const
165 const Evaluation& invBg = inverseGasB_[regionIdx].eval(pressure, Rvw,
true);
166 const Evaluation& invMugBg = inverseGasBMu_[regionIdx].eval(pressure, Rvw,
true);
168 return invBg/invMugBg;
174 template <
class Evaluation>
177 const Evaluation& pressure)
const
179 const Evaluation& invBg = inverseSaturatedGasB_[regionIdx].eval(pressure,
true);
180 const Evaluation& invMugBg = inverseSaturatedGasBMu_[regionIdx].eval(pressure,
true);
182 return invBg/invMugBg;
188 template <
class Evaluation>
191 const Evaluation& pressure,
193 const Evaluation& Rvw)
const
194 {
return inverseGasB_[regionIdx].eval(pressure, Rvw,
true); }
199 template <
class Evaluation>
202 const Evaluation& pressure)
const
203 {
return inverseSaturatedGasB_[regionIdx].eval(pressure,
true); }
208 template <
class Evaluation>
211 const Evaluation& pressure)
const
213 return saturatedWaterVaporizationFactorTable_[regionIdx].eval(pressure,
true);
219 template <
class Evaluation>
222 const Evaluation& pressure,
223 const Evaluation& saltConcentration)
const
226 return saturatedWaterVaporizationSaltFactorTable_[regionIdx].eval(pressure, saltConcentration,
true);
228 return saturatedWaterVaporizationFactorTable_[regionIdx].eval(pressure,
true);
235 template <
class Evaluation>
240 const Evaluation& )
const
246 template <
class Evaluation>
249 const Evaluation& )
const
259 template <
class Evaluation>
262 const Evaluation& Rw)
const
266 const auto& RwTable = saturatedWaterVaporizationFactorTable_[regionIdx];
267 const Scalar eps = std::numeric_limits<typename Toolbox::Scalar>::epsilon()*1e6;
270 Evaluation pSat = saturationPressure_[regionIdx].eval(Rw,
true);
275 bool onProbation =
false;
276 for (
unsigned i = 0; i < 20; ++i) {
277 const Evaluation& f = RwTable.eval(pSat,
true) - Rw;
278 const Evaluation& fPrime = RwTable.evalDerivative(pSat,
true);
282 if (std::abs(scalarValue(fPrime)) < 1.0e-30) {
286 const Evaluation& delta = f/fPrime;
300 if (std::abs(scalarValue(delta)) < std::abs(scalarValue(pSat))*eps)
304 const std::string msg =
305 "Finding saturation pressure did not converge: "
306 " pSat = " + std::to_string(getValue(pSat)) +
307 ", Rw = " + std::to_string(getValue(Rw));
308 OpmLog::debug(
"Wet gas saturation pressure", msg);
312 template <
class Evaluation>
313 Evaluation diffusionCoefficient(
const Evaluation& ,
317 throw std::runtime_error(
"Not implemented: The PVT model does not provide a diffusionCoefficient()");
320 Scalar gasReferenceDensity(
unsigned regionIdx)
const
321 {
return gasReferenceDensity_[regionIdx]; }
323 Scalar waterReferenceDensity(
unsigned regionIdx)
const
324 {
return waterReferenceDensity_[regionIdx]; }
326 const std::vector<TabulatedTwoDFunction>& inverseGasB()
const {
330 const std::vector<TabulatedOneDFunction>& inverseSaturatedGasB()
const {
331 return inverseSaturatedGasB_;
334 const std::vector<TabulatedTwoDFunction>& gasMu()
const {
338 const std::vector<TabulatedTwoDFunction>& inverseGasBMu()
const {
339 return inverseGasBMu_;
342 const std::vector<TabulatedOneDFunction>& inverseSaturatedGasBMu()
const {
343 return inverseSaturatedGasBMu_;
346 const std::vector<TabulatedOneDFunction>& saturatedWaterVaporizationFactorTable()
const {
347 return saturatedWaterVaporizationFactorTable_;
350 const std::vector<TabulatedTwoDFunction>& saturatedWaterVaporizationSaltFactorTable()
const {
351 return saturatedWaterVaporizationSaltFactorTable_;
355 return saturationPressure_;
358 Scalar vapPar1()
const {
363 void updateSaturationPressure_(
unsigned regionIdx);
365 std::vector<Scalar> gasReferenceDensity_;
366 std::vector<Scalar> waterReferenceDensity_;
367 std::vector<TabulatedTwoDFunction> inverseGasB_;
368 std::vector<TabulatedOneDFunction> inverseSaturatedGasB_;
369 std::vector<TabulatedTwoDFunction> gasMu_;
370 std::vector<TabulatedTwoDFunction> inverseGasBMu_;
371 std::vector<TabulatedOneDFunction> inverseSaturatedGasBMu_;
372 std::vector<TabulatedOneDFunction> saturatedWaterVaporizationFactorTable_;
373 std::vector<TabulatedTwoDFunction> saturatedWaterVaporizationSaltFactorTable_;
374 std::vector<TabulatedOneDFunction> saturationPressure_;
376 bool enableRwgSalt_ =
false;
377 Scalar vapPar1_ = 0.0;
A central place for various physical constants occuring in some equations.
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:52
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:189
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:236
void setGasViscosity(unsigned regionIdx, const TabulatedTwoDFunction &mug)
Initialize the viscosity of the gas phase.
Definition DryHumidGasPvt.hpp:118
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:260
void setInverseGasFormationVolumeFactor(unsigned regionIdx, const TabulatedTwoDFunction &invBg)
Initialize the function for the gas formation volume factor.
Definition DryHumidGasPvt.hpp:110
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:139
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:146
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:209
void setSaturatedGasWaterVaporizationFactor(unsigned regionIdx, const SamplingPoints &samplePoints)
Initialize the function for the oil vaporization factor .
Definition DryHumidGasPvt.hpp:95
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:159
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:247
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:220
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:175
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:200
Definition EclipseState.hpp:63
Definition Exceptions.hpp:40
Definition Schedule.hpp:88
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