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>>;
67 void extendPvtgwTable_(
unsigned regionIdx,
75 void setVapPars(
const Scalar par1,
const Scalar)
95 const SamplingPoints& samplePoints)
96 { saturatedWaterVaporizationFactorTable_[regionIdx].setContainerOfTuples(samplePoints); }
111 const TabulatedTwoDFunction& invBg)
112 { inverseGasB_[regionIdx] = invBg; }
120 { gasMu_[regionIdx] = mug; }
130 const SamplingPoints& samplePoints);
141 {
return gasReferenceDensity_.size(); }
146 template <
class Evaluation>
151 const Evaluation&)
const
153 throw std::runtime_error(
"Requested the enthalpy of gas but the thermal "
154 "option is not enabled");
157 Scalar hVap(
unsigned)
const
159 throw std::runtime_error(
"Requested the hvap of oil but the thermal "
160 "option is not enabled");
166 template <
class Evaluation>
169 const Evaluation& pressure,
171 const Evaluation& Rvw)
const
173 const Evaluation& invBg = inverseGasB_[regionIdx].eval(pressure, Rvw,
true);
174 const Evaluation& invMugBg = inverseGasBMu_[regionIdx].eval(pressure, Rvw,
true);
176 return invBg / invMugBg;
182 template <
class Evaluation>
185 const Evaluation& pressure)
const
187 const Evaluation& invBg = inverseSaturatedGasB_[regionIdx].eval(pressure,
true);
188 const Evaluation& invMugBg = inverseSaturatedGasBMu_[regionIdx].eval(pressure,
true);
190 return invBg / invMugBg;
196 template <
class Evaluation>
199 const Evaluation& pressure,
201 const Evaluation& Rvw)
const
202 {
return inverseGasB_[regionIdx].eval(pressure, Rvw,
true); }
207 template <
class Flu
idState,
class LhsEval =
typename Flu
idState::ValueType>
208 std::pair<LhsEval, LhsEval>
211 const LhsEval& p = decay<LhsEval>(fluidState.pressure(FluidState::gasPhaseIdx));
212 const LhsEval& Rvw = decay<LhsEval>(fluidState.Rvw());
214 const auto satSegIdx = this->saturatedWaterVaporizationFactorTable_[regionIdx].findSegmentIndex(p,
true);
215 const auto RvwSat = this->saturatedWaterVaporizationFactorTable_[regionIdx].eval(p,
SegmentIndex{satSegIdx});
216 const bool useSaturatedTables = (fluidState.saturation(FluidState::waterPhaseIdx) > 0.0) && (Rvw >= (1.0 - 1e-10) * RvwSat);
218 if (useSaturatedTables) {
219 const LhsEval b = this->inverseSaturatedGasB_[regionIdx].eval(p,
SegmentIndex{satSegIdx});
220 const LhsEval invBMu = this->inverseSaturatedGasBMu_[regionIdx].eval(p,
SegmentIndex{satSegIdx});
221 const LhsEval mu = b / invBMu;
224 unsigned ii, jj1, jj2;
225 LhsEval alpha, beta1, beta2;
226 this->inverseGasB_[regionIdx].findPoints(ii, jj1, jj2, alpha, beta1, beta2, p, Rvw,
true);
227 const LhsEval b = this->inverseGasB_[regionIdx].eval(ii, jj1, jj2, alpha, beta1, beta2);
228 const LhsEval invBMu = this->inverseGasBMu_[regionIdx].eval(ii, jj1, jj2, alpha, beta1, beta2);
229 const LhsEval mu = b / invBMu;
237 template <
class Evaluation>
240 const Evaluation& pressure)
const
241 {
return inverseSaturatedGasB_[regionIdx].eval(pressure,
true); }
246 template <
class Evaluation>
249 const Evaluation& pressure)
const
251 return saturatedWaterVaporizationFactorTable_[regionIdx].eval(pressure,
258 template <
class Evaluation>
261 const Evaluation& pressure,
262 const Evaluation& saltConcentration)
const
264 if (enableRwgSalt_) {
265 return saturatedWaterVaporizationSaltFactorTable_[regionIdx].eval(pressure,
270 return saturatedWaterVaporizationFactorTable_[regionIdx].eval(pressure,
278 template <
class Evaluation>
283 const Evaluation& )
const
289 template <
class Evaluation>
292 const Evaluation& )
const
303 template <
class Evaluation>
306 const Evaluation& Rw)
const
310 const auto& RwTable = saturatedWaterVaporizationFactorTable_[regionIdx];
311 const Scalar eps = std::numeric_limits<typename Toolbox::Scalar>::epsilon() * 1e6;
314 Evaluation pSat = saturationPressure_[regionIdx].eval(Rw,
true);
319 bool onProbation =
false;
320 for (
unsigned i = 0; i < 20; ++i) {
321 const Evaluation& f = RwTable.eval(pSat,
true) - Rw;
322 const Evaluation& fPrime = RwTable.evalDerivative(pSat,
true);
326 if (std::abs(scalarValue(fPrime)) < 1.0e-30) {
330 const Evaluation& delta = f / fPrime;
345 if (std::abs(scalarValue(delta)) < std::abs(scalarValue(pSat)) * eps) {
350 const std::string msg =
351 "Finding saturation pressure did not converge: "
352 " pSat = " + std::to_string(getValue(pSat)) +
353 ", Rw = " + std::to_string(getValue(Rw));
354 OpmLog::debug(
"Wet gas saturation pressure", msg);
358 template <
class Evaluation>
359 Evaluation diffusionCoefficient(
const Evaluation& ,
363 throw std::runtime_error(
"Not implemented: The PVT model does not provide "
364 "a diffusionCoefficient()");
367 Scalar gasReferenceDensity(
unsigned regionIdx)
const
368 {
return gasReferenceDensity_[regionIdx]; }
370 Scalar waterReferenceDensity(
unsigned regionIdx)
const
371 {
return waterReferenceDensity_[regionIdx]; }
373 const std::vector<TabulatedTwoDFunction>& inverseGasB()
const
374 {
return inverseGasB_; }
376 const std::vector<TabulatedOneDFunction>& inverseSaturatedGasB()
const
377 {
return inverseSaturatedGasB_; }
379 const std::vector<TabulatedTwoDFunction>& gasMu()
const
382 const std::vector<TabulatedTwoDFunction>& inverseGasBMu()
const
383 {
return inverseGasBMu_; }
385 const std::vector<TabulatedOneDFunction>& inverseSaturatedGasBMu()
const
386 {
return inverseSaturatedGasBMu_; }
388 const std::vector<TabulatedOneDFunction>& saturatedWaterVaporizationFactorTable()
const
389 {
return saturatedWaterVaporizationFactorTable_; }
391 const std::vector<TabulatedTwoDFunction>& saturatedWaterVaporizationSaltFactorTable()
const
392 {
return saturatedWaterVaporizationSaltFactorTable_; }
395 {
return saturationPressure_; }
397 Scalar vapPar1()
const
401 void updateSaturationPressure_(
unsigned regionIdx);
403 std::vector<Scalar> gasReferenceDensity_{};
404 std::vector<Scalar> waterReferenceDensity_{};
405 std::vector<TabulatedTwoDFunction> inverseGasB_{};
406 std::vector<TabulatedOneDFunction> inverseSaturatedGasB_{};
407 std::vector<TabulatedTwoDFunction> gasMu_{};
408 std::vector<TabulatedTwoDFunction> inverseGasBMu_{};
409 std::vector<TabulatedOneDFunction> inverseSaturatedGasBMu_{};
410 std::vector<TabulatedOneDFunction> saturatedWaterVaporizationFactorTable_{};
411 std::vector<TabulatedTwoDFunction> saturatedWaterVaporizationSaltFactorTable_{};
412 std::vector<TabulatedOneDFunction> saturationPressure_{};
414 bool enableRwgSalt_ =
false;
415 Scalar vapPar1_ = 0.0;
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:197
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:279
void setGasViscosity(unsigned regionIdx, const TabulatedTwoDFunction &mug)
Initialize the viscosity of the gas phase.
Definition DryHumidGasPvt.hpp:119
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:304
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:298
unsigned numRegions() const
Return the number of PVT regions which are considered by this PVT-object.
Definition DryHumidGasPvt.hpp:140
void setReferenceDensities(unsigned regionIdx, Scalar, Scalar rhoRefGas, Scalar rhoRefWater)
Initialize the reference densities of all fluids for a given PVT region.
Definition DryHumidGasPvt.cpp:253
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:147
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:247
void setSaturatedGasWaterVaporizationFactor(unsigned regionIdx, const SamplingPoints &samplePoints)
Initialize the function for the oil vaporization factor .
Definition DryHumidGasPvt.hpp:94
void initFromState(const EclipseState &eclState, const Schedule &)
Initialize the parameters for wet gas using an ECL deck.
Definition DryHumidGasPvt.cpp:38
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:167
void setSaturatedGasViscosity(unsigned regionIdx, const SamplingPoints &samplePoints)
Initialize the phase viscosity for oil saturated gas.
Definition DryHumidGasPvt.cpp:264
std::pair< LhsEval, LhsEval > inverseFormationVolumeFactorAndViscosity(const FluidState &fluidState, unsigned regionIdx)
Returns the formation volume factor [-] and viscosity [Pa s] of the fluid phase.
Definition DryHumidGasPvt.hpp:209
Evaluation saturatedOilVaporizationFactor(unsigned, const Evaluation &, const Evaluation &) const
Returns the oil vaporization factor [m^3/m^3] of the oil phase.
Definition DryHumidGasPvt.hpp:290
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:259
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:183
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:238
Definition EclipseState.hpp:66
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 implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30
Definition Tabulated1DFunction.hpp:41