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,
91 { saturatedOilVaporizationFactorTable_[regionIdx].setContainerOfTuples(samplePoints); }
103 const SamplingPoints& samplePoints);
118 { inverseGasB_[regionIdx] = invBg; }
126 { gasMu_[regionIdx] = mug; }
136 const SamplingPoints& samplePoints);
147 {
return gasReferenceDensity_.size(); }
152 template <
class Evaluation>
157 const Evaluation&)
const
159 throw std::runtime_error(
"Requested the enthalpy of gas but the thermal option is not enabled");
165 template <
class Evaluation>
168 const Evaluation& pressure,
169 const Evaluation& Rv,
170 const Evaluation& )
const
172 const Evaluation& invBg = inverseGasB_[regionIdx].eval(pressure, Rv,
true);
173 const Evaluation& invMugBg = inverseGasBMu_[regionIdx].eval(pressure, Rv,
true);
175 return invBg/invMugBg;
181 template <
class Evaluation>
184 const Evaluation& pressure)
const
186 const Evaluation& invBg = inverseSaturatedGasB_[regionIdx].eval(pressure,
true);
187 const Evaluation& invMugBg = inverseSaturatedGasBMu_[regionIdx].eval(pressure,
true);
189 return invBg/invMugBg;
195 template <
class Evaluation>
198 const Evaluation& pressure,
199 const Evaluation& Rv,
200 const Evaluation& )
const
201 {
return inverseGasB_[regionIdx].eval(pressure, Rv,
true); }
206 template <
class Evaluation>
209 const Evaluation& pressure)
const
210 {
return inverseSaturatedGasB_[regionIdx].eval(pressure,
true); }
215 template <
class Evaluation>
218 const Evaluation& )
const
224 template <
class Evaluation = Scalar>
228 const Evaluation& )
const
234 template <
class Evaluation>
237 const Evaluation& pressure)
const
239 return saturatedOilVaporizationFactorTable_[regionIdx].eval(pressure,
true);
249 template <
class Evaluation>
252 const Evaluation& pressure,
253 const Evaluation& oilSaturation,
254 Evaluation maxOilSaturation)
const
257 saturatedOilVaporizationFactorTable_[regionIdx].eval(pressure,
true);
261 maxOilSaturation = min(maxOilSaturation, Scalar(1.0));
262 if (vapPar1_ > 0.0 && maxOilSaturation > 0.01 && oilSaturation < maxOilSaturation) {
263 constexpr const Scalar eps = 0.001;
264 const Evaluation& So = max(oilSaturation, eps);
265 tmp *= max(1e-3, pow(So/maxOilSaturation, vapPar1_));
281 template <
class Evaluation>
284 const Evaluation& Rv)
const
288 const auto& RvTable = saturatedOilVaporizationFactorTable_[regionIdx];
289 constexpr const Scalar eps = std::numeric_limits<typename Toolbox::Scalar>::epsilon()*1e6;
292 Evaluation pSat = saturationPressure_[regionIdx].eval(Rv,
true);
297 bool onProbation =
false;
298 for (
unsigned i = 0; i < 20; ++i) {
299 const Evaluation& f = RvTable.eval(pSat,
true) - Rv;
300 const Evaluation& fPrime = RvTable.evalDerivative(pSat,
true);
304 if (std::abs(scalarValue(fPrime)) < 1.0e-30) {
308 const Evaluation& delta = f/fPrime;
322 if (std::abs(scalarValue(delta)) < std::abs(scalarValue(pSat))*eps)
326 const std::string msg =
327 "Finding saturation pressure did not converge: "
328 "pSat = " + std::to_string(getValue(pSat)) +
329 ", Rv = " + std::to_string(getValue(Rv));
330 OpmLog::debug(
"Wet gas saturation pressure", msg);
334 template <
class Evaluation>
335 Evaluation diffusionCoefficient(
const Evaluation& ,
339 throw std::runtime_error(
"Not implemented: The PVT model does not provide a diffusionCoefficient()");
342 Scalar gasReferenceDensity(
unsigned regionIdx)
const
343 {
return gasReferenceDensity_[regionIdx]; }
345 Scalar oilReferenceDensity(
unsigned regionIdx)
const
346 {
return oilReferenceDensity_[regionIdx]; }
348 const std::vector<TabulatedTwoDFunction>& inverseGasB()
const {
352 const std::vector<TabulatedOneDFunction>& inverseSaturatedGasB()
const {
353 return inverseSaturatedGasB_;
356 const std::vector<TabulatedTwoDFunction>& gasMu()
const {
360 const std::vector<TabulatedTwoDFunction>& inverseGasBMu()
const {
361 return inverseGasBMu_;
364 const std::vector<TabulatedOneDFunction>& inverseSaturatedGasBMu()
const {
365 return inverseSaturatedGasBMu_;
368 const std::vector<TabulatedOneDFunction>& saturatedOilVaporizationFactorTable()
const {
369 return saturatedOilVaporizationFactorTable_;
373 return saturationPressure_;
376 Scalar vapPar1()
const {
381 void updateSaturationPressure_(
unsigned regionIdx);
383 std::vector<Scalar> gasReferenceDensity_;
384 std::vector<Scalar> oilReferenceDensity_;
385 std::vector<TabulatedTwoDFunction> inverseGasB_;
386 std::vector<TabulatedOneDFunction> inverseSaturatedGasB_;
387 std::vector<TabulatedTwoDFunction> gasMu_;
388 std::vector<TabulatedTwoDFunction> inverseGasBMu_;
389 std::vector<TabulatedOneDFunction> inverseSaturatedGasBMu_;
390 std::vector<TabulatedOneDFunction> saturatedOilVaporizationFactorTable_;
391 std::vector<TabulatedOneDFunction> saturationPressure_;
393 Scalar vapPar1_ = 0.0;
Provides the OPM specific exception classes.
Definition: EclipseState.hpp:55
Definition: Exceptions.hpp:40
Definition: Schedule.hpp:130
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:207
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:235
void initEnd()
Finish initializing the gas phase PVT properties.
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:282
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:153
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:250
void setGasViscosity(unsigned regionIdx, const TabulatedTwoDFunction &mug)
Initialize the viscosity of the gas phase.
Definition: WetGasPvt.hpp:125
Evaluation saturatedWaterVaporizationFactor(unsigned, const Evaluation &, const Evaluation &) const
Returns the water vaporization factor [m^3/m^3] of the gasphase.
Definition: WetGasPvt.hpp:216
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:225
unsigned numRegions() const
Return the number of PVT regions which are considered by this PVT-object.
Definition: WetGasPvt.hpp:146
void setSaturatedGasViscosity(unsigned regionIdx, const SamplingPoints &samplePoints)
Initialize the phase viscosity for oil saturated gas.
void setSaturatedGasFormationVolumeFactor(unsigned regionIdx, const SamplingPoints &samplePoints)
Initialize the function for the gas formation volume factor.
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:196
void setSaturatedGasOilVaporizationFactor(unsigned regionIdx, const SamplingPoints &samplePoints)
Initialize the function for the oil vaporization factor .
Definition: WetGasPvt.hpp:90
void setInverseGasFormationVolumeFactor(unsigned regionIdx, const TabulatedTwoDFunction &invBg)
Initialize the function for the gas formation volume factor.
Definition: WetGasPvt.hpp:117
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:182
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:166
void setReferenceDensities(unsigned regionIdx, Scalar rhoRefOil, Scalar rhoRefGas, Scalar)
Initialize the reference densities of all fluids for a given PVT region.
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:30