27#ifndef OPM_WET_GAS_PVT_HPP
28#define OPM_WET_GAS_PVT_HPP
31#include <opm/common/OpmLog/OpmLog.hpp>
49template <
class Scalar>
52 using SamplingPoints = std::vector<std::pair<Scalar, Scalar>>;
67 void extendPvtgTable_(
unsigned regionIdx,
77 void setVapPars(
const Scalar par1,
const Scalar)
96 { saturatedOilVaporizationFactorTable_[regionIdx].setContainerOfTuples(samplePoints); }
108 const SamplingPoints& samplePoints);
123 { inverseGasB_[regionIdx] = invBg; }
131 { gasMu_[regionIdx] = mug; }
141 const SamplingPoints& samplePoints);
152 {
return gasReferenceDensity_.size(); }
157 template <
class Evaluation>
162 const Evaluation&)
const
164 throw std::runtime_error(
"Requested the enthalpy of gas but the thermal option is not enabled");
170 template <
class Evaluation>
173 const Evaluation& pressure,
174 const Evaluation& Rv,
175 const Evaluation& )
const
177 const Evaluation& invBg = inverseGasB_[regionIdx].eval(pressure, Rv,
true);
178 const Evaluation& invMugBg = inverseGasBMu_[regionIdx].eval(pressure, Rv,
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,
204 const Evaluation& Rv,
205 const Evaluation& )
const
206 {
return inverseGasB_[regionIdx].eval(pressure, Rv,
true); }
211 template <
class Evaluation>
214 const Evaluation& pressure)
const
215 {
return inverseSaturatedGasB_[regionIdx].eval(pressure,
true); }
220 template <
class Evaluation>
223 const Evaluation& )
const
229 template <
class Evaluation = Scalar>
233 const Evaluation& )
const
239 template <
class Evaluation>
242 const Evaluation& pressure)
const
244 return saturatedOilVaporizationFactorTable_[regionIdx].eval(pressure,
true);
254 template <
class Evaluation>
257 const Evaluation& pressure,
258 const Evaluation& oilSaturation,
259 Evaluation maxOilSaturation)
const
262 saturatedOilVaporizationFactorTable_[regionIdx].eval(pressure,
true);
266 maxOilSaturation = min(maxOilSaturation, Scalar(1.0));
267 if (vapPar1_ > 0.0 && maxOilSaturation > 0.01 && oilSaturation < maxOilSaturation) {
268 constexpr const Scalar eps = 0.001;
269 const Evaluation& So = max(oilSaturation, eps);
270 tmp *= max(1e-3, pow(So/maxOilSaturation, vapPar1_));
286 template <
class Evaluation>
289 const Evaluation& Rv)
const
293 const auto& RvTable = saturatedOilVaporizationFactorTable_[regionIdx];
294 constexpr const Scalar eps = std::numeric_limits<typename Toolbox::Scalar>::epsilon()*1e6;
297 Evaluation pSat = saturationPressure_[regionIdx].eval(Rv,
true);
302 bool onProbation =
false;
303 for (
unsigned i = 0; i < 20; ++i) {
304 const Evaluation& f = RvTable.eval(pSat,
true) - Rv;
305 const Evaluation& fPrime = RvTable.evalDerivative(pSat,
true);
309 if (std::abs(scalarValue(fPrime)) < 1.0e-30) {
313 const Evaluation& delta = f/fPrime;
327 if (std::abs(scalarValue(delta)) < std::abs(scalarValue(pSat))*eps)
331 const std::string msg =
332 "Finding saturation pressure did not converge: "
333 "pSat = " + std::to_string(getValue(pSat)) +
334 ", Rv = " + std::to_string(getValue(Rv));
335 OpmLog::debug(
"Wet gas saturation pressure", msg);
339 template <
class Evaluation>
340 Evaluation diffusionCoefficient(
const Evaluation& ,
344 throw std::runtime_error(
"Not implemented: The PVT model does not provide a diffusionCoefficient()");
347 Scalar gasReferenceDensity(
unsigned regionIdx)
const
348 {
return gasReferenceDensity_[regionIdx]; }
350 Scalar oilReferenceDensity(
unsigned regionIdx)
const
351 {
return oilReferenceDensity_[regionIdx]; }
353 const std::vector<TabulatedTwoDFunction>& inverseGasB()
const {
357 const std::vector<TabulatedOneDFunction>& inverseSaturatedGasB()
const {
358 return inverseSaturatedGasB_;
361 const std::vector<TabulatedTwoDFunction>& gasMu()
const {
365 const std::vector<TabulatedTwoDFunction>& inverseGasBMu()
const {
366 return inverseGasBMu_;
369 const std::vector<TabulatedOneDFunction>& inverseSaturatedGasBMu()
const {
370 return inverseSaturatedGasBMu_;
373 const std::vector<TabulatedOneDFunction>& saturatedOilVaporizationFactorTable()
const {
374 return saturatedOilVaporizationFactorTable_;
378 return saturationPressure_;
381 Scalar vapPar1()
const {
386 void updateSaturationPressure_(
unsigned regionIdx);
388 std::vector<Scalar> gasReferenceDensity_;
389 std::vector<Scalar> oilReferenceDensity_;
390 std::vector<TabulatedTwoDFunction> inverseGasB_;
391 std::vector<TabulatedOneDFunction> inverseSaturatedGasB_;
392 std::vector<TabulatedTwoDFunction> gasMu_;
393 std::vector<TabulatedTwoDFunction> inverseGasBMu_;
394 std::vector<TabulatedOneDFunction> inverseSaturatedGasBMu_;
395 std::vector<TabulatedOneDFunction> saturatedOilVaporizationFactorTable_;
396 std::vector<TabulatedOneDFunction> saturationPressure_;
398 Scalar vapPar1_ = 0.0;
Provides the OPM specific exception classes.
Implements a linearly interpolated scalar function that depends on one variable.
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 represents the Pressure-Volume-Temperature relations of the gas phas with vaporized oil.
Definition WetGasPvt.hpp:51
Evaluation saturatedInverseFormationVolumeFactor(unsigned regionIdx, const Evaluation &, const Evaluation &pressure) const
Returns the formation volume factor [-] of oil saturated gas at a given pressure.
Definition WetGasPvt.hpp:212
Evaluation saturatedOilVaporizationFactor(unsigned regionIdx, const Evaluation &, const Evaluation &pressure) const
Returns the oil vaporization factor [m^3/m^3] of the gas phase.
Definition WetGasPvt.hpp:240
void initEnd()
Finish initializing the gas phase PVT properties.
Definition WetGasPvt.cpp:331
Evaluation saturationPressure(unsigned regionIdx, const Evaluation &, const Evaluation &Rv) const
Returns the saturation pressure of the gas phase [Pa] depending on its mass fraction of the oil compo...
Definition WetGasPvt.hpp:287
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 WetGasPvt.hpp:158
Evaluation saturatedOilVaporizationFactor(unsigned regionIdx, const Evaluation &, const Evaluation &pressure, const Evaluation &oilSaturation, Evaluation maxOilSaturation) const
Returns the oil vaporization factor [m^3/m^3] of the gas phase.
Definition WetGasPvt.hpp:255
void setGasViscosity(unsigned regionIdx, const TabulatedTwoDFunction &mug)
Initialize the viscosity of the gas phase.
Definition WetGasPvt.hpp:130
Evaluation saturatedWaterVaporizationFactor(unsigned, const Evaluation &, const Evaluation &) const
Returns the water vaporization factor [m^3/m^3] of the gasphase.
Definition WetGasPvt.hpp:221
Evaluation saturatedWaterVaporizationFactor(unsigned, const Evaluation &, const Evaluation &, const Evaluation &) const
Returns the water vaporization factor [m^3/m^3] of water saturated gas.
Definition WetGasPvt.hpp:230
unsigned numRegions() const
Return the number of PVT regions which are considered by this PVT-object.
Definition WetGasPvt.hpp:151
void setSaturatedGasViscosity(unsigned regionIdx, const SamplingPoints &samplePoints)
Initialize the phase viscosity for oil saturated gas.
Definition WetGasPvt.cpp:297
void setSaturatedGasFormationVolumeFactor(unsigned regionIdx, const SamplingPoints &samplePoints)
Initialize the function for the gas formation volume factor.
Definition WetGasPvt.cpp:246
Evaluation inverseFormationVolumeFactor(unsigned regionIdx, const Evaluation &, const Evaluation &pressure, const Evaluation &Rv, const Evaluation &) const
Returns the formation volume factor [-] of the fluid phase.
Definition WetGasPvt.hpp:201
void setSaturatedGasOilVaporizationFactor(unsigned regionIdx, const SamplingPoints &samplePoints)
Initialize the function for the oil vaporization factor .
Definition WetGasPvt.hpp:95
void setInverseGasFormationVolumeFactor(unsigned regionIdx, const TabulatedTwoDFunction &invBg)
Initialize the function for the gas formation volume factor.
Definition WetGasPvt.hpp:122
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 WetGasPvt.hpp:187
Evaluation viscosity(unsigned regionIdx, const Evaluation &, const Evaluation &pressure, const Evaluation &Rv, const Evaluation &) const
Returns the dynamic viscosity [Pa s] of the fluid phase given a set of parameters.
Definition WetGasPvt.hpp:171
void setReferenceDensities(unsigned regionIdx, Scalar rhoRefOil, Scalar rhoRefGas, Scalar)
Initialize the reference densities of all fluids for a given PVT region.
Definition WetGasPvt.cpp:235
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30