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,
91 { saturatedWaterVaporizationFactorTable_[regionIdx].setContainerOfTuples(samplePoints); }
106 { inverseGasB_[regionIdx] = invBg; }
114 { gasMu_[regionIdx] = mug; }
124 const SamplingPoints& samplePoints);
135 {
return gasReferenceDensity_.size(); }
140 template <
class Evaluation>
145 const Evaluation&)
const
147 throw std::runtime_error(
"Requested the enthalpy of gas but the thermal option is not enabled");
153 template <
class Evaluation>
156 const Evaluation& pressure,
158 const Evaluation& Rvw)
const
160 const Evaluation& invBg = inverseGasB_[regionIdx].eval(pressure, Rvw,
true);
161 const Evaluation& invMugBg = inverseGasBMu_[regionIdx].eval(pressure, Rvw,
true);
163 return invBg/invMugBg;
169 template <
class Evaluation>
172 const Evaluation& pressure)
const
174 const Evaluation& invBg = inverseSaturatedGasB_[regionIdx].eval(pressure,
true);
175 const Evaluation& invMugBg = inverseSaturatedGasBMu_[regionIdx].eval(pressure,
true);
177 return invBg/invMugBg;
183 template <
class Evaluation>
186 const Evaluation& pressure,
188 const Evaluation& Rvw)
const
189 {
return inverseGasB_[regionIdx].eval(pressure, Rvw,
true); }
194 template <
class Evaluation>
197 const Evaluation& pressure)
const
198 {
return inverseSaturatedGasB_[regionIdx].eval(pressure,
true); }
203 template <
class Evaluation>
206 const Evaluation& pressure)
const
208 return saturatedWaterVaporizationFactorTable_[regionIdx].eval(pressure,
true);
214 template <
class Evaluation>
217 const Evaluation& pressure,
218 const Evaluation& saltConcentration)
const
221 return saturatedWaterVaporizationSaltFactorTable_[regionIdx].eval(pressure, saltConcentration,
true);
223 return saturatedWaterVaporizationFactorTable_[regionIdx].eval(pressure,
true);
230 template <
class Evaluation>
235 const Evaluation& )
const
241 template <
class Evaluation>
244 const Evaluation& )
const
254 template <
class Evaluation>
257 const Evaluation& Rw)
const
261 const auto& RwTable = saturatedWaterVaporizationFactorTable_[regionIdx];
262 const Scalar eps = std::numeric_limits<typename Toolbox::Scalar>::epsilon()*1e6;
265 Evaluation pSat = saturationPressure_[regionIdx].eval(Rw,
true);
270 bool onProbation =
false;
271 for (
unsigned i = 0; i < 20; ++i) {
272 const Evaluation& f = RwTable.eval(pSat,
true) - Rw;
273 const Evaluation& fPrime = RwTable.evalDerivative(pSat,
true);
277 if (std::abs(scalarValue(fPrime)) < 1.0e-30) {
281 const Evaluation& delta = f/fPrime;
295 if (std::abs(scalarValue(delta)) < std::abs(scalarValue(pSat))*eps)
299 const std::string msg =
300 "Finding saturation pressure did not converge: "
301 " pSat = " + std::to_string(getValue(pSat)) +
302 ", Rw = " + std::to_string(getValue(Rw));
303 OpmLog::debug(
"Wet gas saturation pressure", msg);
307 template <
class Evaluation>
308 Evaluation diffusionCoefficient(
const Evaluation& ,
312 throw std::runtime_error(
"Not implemented: The PVT model does not provide a diffusionCoefficient()");
315 Scalar gasReferenceDensity(
unsigned regionIdx)
const
316 {
return gasReferenceDensity_[regionIdx]; }
318 Scalar waterReferenceDensity(
unsigned regionIdx)
const
319 {
return waterReferenceDensity_[regionIdx]; }
321 const std::vector<TabulatedTwoDFunction>& inverseGasB()
const {
325 const std::vector<TabulatedOneDFunction>& inverseSaturatedGasB()
const {
326 return inverseSaturatedGasB_;
329 const std::vector<TabulatedTwoDFunction>& gasMu()
const {
333 const std::vector<TabulatedTwoDFunction>& inverseGasBMu()
const {
334 return inverseGasBMu_;
337 const std::vector<TabulatedOneDFunction>& inverseSaturatedGasBMu()
const {
338 return inverseSaturatedGasBMu_;
341 const std::vector<TabulatedOneDFunction>& saturatedWaterVaporizationFactorTable()
const {
342 return saturatedWaterVaporizationFactorTable_;
345 const std::vector<TabulatedTwoDFunction>& saturatedWaterVaporizationSaltFactorTable()
const {
346 return saturatedWaterVaporizationSaltFactorTable_;
350 return saturationPressure_;
353 Scalar vapPar1()
const {
358 void updateSaturationPressure_(
unsigned regionIdx);
360 std::vector<Scalar> gasReferenceDensity_;
361 std::vector<Scalar> waterReferenceDensity_;
362 std::vector<TabulatedTwoDFunction> inverseGasB_;
363 std::vector<TabulatedOneDFunction> inverseSaturatedGasB_;
364 std::vector<TabulatedTwoDFunction> gasMu_;
365 std::vector<TabulatedTwoDFunction> inverseGasBMu_;
366 std::vector<TabulatedOneDFunction> inverseSaturatedGasBMu_;
367 std::vector<TabulatedOneDFunction> saturatedWaterVaporizationFactorTable_;
368 std::vector<TabulatedTwoDFunction> saturatedWaterVaporizationSaltFactorTable_;
369 std::vector<TabulatedOneDFunction> saturationPressure_;
371 bool enableRwgSalt_ =
false;
372 Scalar vapPar1_ = 0.0;
Provides the OPM specific exception classes.
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:184
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:231
void setGasViscosity(unsigned regionIdx, const TabulatedTwoDFunction &mug)
Initialize the viscosity of the gas phase.
Definition: DryHumidGasPvt.hpp:113
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:255
void setInverseGasFormationVolumeFactor(unsigned regionIdx, const TabulatedTwoDFunction &invBg)
Initialize the function for the gas formation volume factor.
Definition: DryHumidGasPvt.hpp:105
void initEnd()
Finish initializing the gas phase PVT properties.
unsigned numRegions() const
Return the number of PVT regions which are considered by this PVT-object.
Definition: DryHumidGasPvt.hpp:134
void setReferenceDensities(unsigned regionIdx, Scalar, Scalar rhoRefGas, Scalar rhoRefWater)
Initialize the reference densities of all fluids for a given PVT region.
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:141
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:204
void setSaturatedGasWaterVaporizationFactor(unsigned regionIdx, const SamplingPoints &samplePoints)
Initialize the function for the oil vaporization factor .
Definition: DryHumidGasPvt.hpp:90
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:154
void setSaturatedGasViscosity(unsigned regionIdx, const SamplingPoints &samplePoints)
Initialize the phase viscosity for oil saturated gas.
Evaluation saturatedOilVaporizationFactor(unsigned, const Evaluation &, const Evaluation &) const
Returns the oil vaporization factor [m^3/m^3] of the oil phase.
Definition: DryHumidGasPvt.hpp:242
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:215
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:170
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:195
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 implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:30