27#ifndef OPM_WET_GAS_PVT_HPP
28#define OPM_WET_GAS_PVT_HPP
31#include <opm/common/OpmLog/OpmLog.hpp>
51template <
class Scalar>
54 using SamplingPoints = std::vector<std::pair<Scalar, Scalar>>;
69 void extendPvtgTable_(
unsigned regionIdx,
79 void setVapPars(
const Scalar par1,
const Scalar)
98 const SamplingPoints& samplePoints)
99 { saturatedOilVaporizationFactorTable_[regionIdx].setContainerOfTuples(samplePoints); }
111 const SamplingPoints& samplePoints);
127 { inverseGasB_[regionIdx] = invBg; }
135 { gasMu_[regionIdx] = mug; }
145 const SamplingPoints& samplePoints);
156 {
return gasReferenceDensity_.size(); }
161 template <
class Evaluation>
166 const Evaluation&)
const
168 throw std::runtime_error(
"Requested the enthalpy of gas but the thermal "
169 "option is not enabled");
172 Scalar hVap(
unsigned)
const
174 throw std::runtime_error(
"Requested the hvap of oil but the thermal "
175 "option is not enabled");
181 template <
class Evaluation>
184 const Evaluation& pressure,
185 const Evaluation& Rv,
186 const Evaluation& )
const
188 const Evaluation& invBg = inverseGasB_[regionIdx].eval(pressure, Rv,
true);
189 const Evaluation& invMugBg = inverseGasBMu_[regionIdx].eval(pressure, Rv,
true);
191 return invBg / invMugBg;
197 template <
class Evaluation>
200 const Evaluation& pressure)
const
202 const Evaluation& invBg = inverseSaturatedGasB_[regionIdx].eval(pressure,
true);
203 const Evaluation& invMugBg = inverseSaturatedGasBMu_[regionIdx].eval(pressure,
true);
205 return invBg / invMugBg;
211 template <
class Evaluation>
214 const Evaluation& pressure,
215 const Evaluation& Rv,
216 const Evaluation& )
const
217 {
return inverseGasB_[regionIdx].eval(pressure, Rv,
true); }
222 template <
class Evaluation>
225 const Evaluation& pressure)
const
226 {
return inverseSaturatedGasB_[regionIdx].eval(pressure,
true); }
231 template <
class Evaluation>
234 const Evaluation& )
const
240 template <
class Evaluation = Scalar>
244 const Evaluation& )
const
250 template <
class Evaluation>
253 const Evaluation& pressure)
const
255 return saturatedOilVaporizationFactorTable_[regionIdx].eval(pressure,
true);
265 template <
class Evaluation>
268 const Evaluation& pressure,
269 const Evaluation& oilSaturation,
270 Evaluation maxOilSaturation)
const
273 saturatedOilVaporizationFactorTable_[regionIdx].eval(pressure,
true);
277 maxOilSaturation = min(maxOilSaturation, Scalar(1.0));
278 if (vapPar1_ > 0.0 && maxOilSaturation > 0.01 && oilSaturation < maxOilSaturation) {
279 constexpr const Scalar eps = 0.001;
280 const Evaluation& So = max(oilSaturation, eps);
281 tmp *= max(1e-3, pow(So / maxOilSaturation, vapPar1_));
297 template <
class Evaluation>
300 const Evaluation& Rv)
const
304 const auto& RvTable = saturatedOilVaporizationFactorTable_[regionIdx];
305 constexpr const Scalar eps = std::numeric_limits<typename Toolbox::Scalar>::epsilon() * 1e6;
308 Evaluation pSat = saturationPressure_[regionIdx].eval(Rv,
true);
313 bool onProbation =
false;
314 for (
unsigned i = 0; i < 20; ++i) {
315 const Evaluation& f = RvTable.eval(pSat,
true) - Rv;
316 const Evaluation& fPrime = RvTable.evalDerivative(pSat,
true);
320 if (std::abs(scalarValue(fPrime)) < 1.0e-30) {
324 const Evaluation& delta = f / fPrime;
339 if (std::abs(scalarValue(delta)) < std::abs(scalarValue(pSat))*eps) {
344 const std::string msg =
345 "Finding saturation pressure did not converge: "
346 "pSat = " + std::to_string(getValue(pSat)) +
347 ", Rv = " + std::to_string(getValue(Rv));
348 OpmLog::debug(
"Wet gas saturation pressure", msg);
352 template <
class Evaluation>
353 Evaluation diffusionCoefficient(
const Evaluation& ,
357 throw std::runtime_error(
"Not implemented: The PVT model does not provide "
358 "a diffusionCoefficient()");
361 Scalar gasReferenceDensity(
unsigned regionIdx)
const
362 {
return gasReferenceDensity_[regionIdx]; }
364 Scalar oilReferenceDensity(
unsigned regionIdx)
const
365 {
return oilReferenceDensity_[regionIdx]; }
367 const std::vector<TabulatedTwoDFunction>& inverseGasB()
const
368 {
return inverseGasB_; }
370 const std::vector<TabulatedOneDFunction>& inverseSaturatedGasB()
const
371 {
return inverseSaturatedGasB_; }
373 const std::vector<TabulatedTwoDFunction>& gasMu()
const
376 const std::vector<TabulatedTwoDFunction>& inverseGasBMu()
const
377 {
return inverseGasBMu_; }
379 const std::vector<TabulatedOneDFunction>& inverseSaturatedGasBMu()
const
380 {
return inverseSaturatedGasBMu_; }
382 const std::vector<TabulatedOneDFunction>& saturatedOilVaporizationFactorTable()
const
383 {
return saturatedOilVaporizationFactorTable_; }
386 {
return saturationPressure_; }
388 Scalar vapPar1()
const
392 void updateSaturationPressure_(
unsigned regionIdx);
394 std::vector<Scalar> gasReferenceDensity_{};
395 std::vector<Scalar> oilReferenceDensity_{};
396 std::vector<TabulatedTwoDFunction> inverseGasB_{};
397 std::vector<TabulatedOneDFunction> inverseSaturatedGasB_{};
398 std::vector<TabulatedTwoDFunction> gasMu_{};
399 std::vector<TabulatedTwoDFunction> inverseGasBMu_{};
400 std::vector<TabulatedOneDFunction> inverseSaturatedGasBMu_{};
401 std::vector<TabulatedOneDFunction> saturatedOilVaporizationFactorTable_{};
402 std::vector<TabulatedOneDFunction> saturationPressure_{};
404 Scalar vapPar1_ = 0.0;
Provides the OPM specific exception classes.
Implements a linearly interpolated scalar function that depends on one variable.
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 represents the Pressure-Volume-Temperature relations of the gas phas with vaporized oil.
Definition WetGasPvt.hpp:53
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:223
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:251
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:298
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:162
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:266
void setGasViscosity(unsigned regionIdx, const TabulatedTwoDFunction &mug)
Initialize the viscosity of the gas phase.
Definition WetGasPvt.hpp:134
Evaluation saturatedWaterVaporizationFactor(unsigned, const Evaluation &, const Evaluation &) const
Returns the water vaporization factor [m^3/m^3] of the gasphase.
Definition WetGasPvt.hpp:232
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:241
unsigned numRegions() const
Return the number of PVT regions which are considered by this PVT-object.
Definition WetGasPvt.hpp:155
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:212
void setSaturatedGasOilVaporizationFactor(unsigned regionIdx, const SamplingPoints &samplePoints)
Initialize the function for the oil vaporization factor .
Definition WetGasPvt.hpp:97
void setInverseGasFormationVolumeFactor(unsigned regionIdx, const TabulatedTwoDFunction &invBg)
Initialize the function for the gas formation volume factor.
Definition WetGasPvt.hpp:125
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:198
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:182
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