27#ifndef OPM_LIVE_OIL_PVT_HPP
28#define OPM_LIVE_OIL_PVT_HPP
31#include <opm/common/OpmLog/OpmLog.hpp>
49template <
class Scalar>
52 using SamplingPoints = std::vector<std::pair<Scalar, Scalar>>;
65 void extendPvtoTable_(
unsigned regionIdx,
75 void setVapPars(
const Scalar,
const Scalar par2)
94 { saturatedGasDissolutionFactorTable_[regionIdx].setContainerOfTuples(samplePoints); }
106 const SamplingPoints& samplePoints);
121 { inverseOilBTable_[regionIdx] = invBo; }
129 { oilMuTable_[regionIdx] = muo; }
139 const SamplingPoints& samplePoints);
150 {
return inverseOilBMuTable_.size(); }
155 template <
class Evaluation>
159 const Evaluation&)
const
161 throw std::runtime_error(
"Requested the enthalpy of oil but the thermal option is not enabled");
167 template <
class Evaluation>
170 const Evaluation& pressure,
171 const Evaluation& Rs)
const
174 const Evaluation& invBo = inverseOilBTable_[regionIdx].eval(Rs, pressure,
true);
175 const Evaluation& invMuoBo = inverseOilBMuTable_[regionIdx].eval(Rs, pressure,
true);
177 return invBo/invMuoBo;
183 template <
class Evaluation>
186 const Evaluation& pressure)
const
189 const Evaluation& invBo = inverseSaturatedOilBTable_[regionIdx].eval(pressure,
true);
190 const Evaluation& invMuoBo = inverseSaturatedOilBMuTable_[regionIdx].eval(pressure,
true);
192 return invBo/invMuoBo;
198 template <
class Evaluation>
201 const Evaluation& pressure,
202 const Evaluation& Rs)
const
205 return inverseOilBTable_[regionIdx].eval(Rs, pressure,
true);
211 template <
class Evaluation>
214 const Evaluation& pressure)
const
217 return inverseSaturatedOilBTable_[regionIdx].eval(pressure,
true);
223 template <
class Evaluation>
226 const Evaluation& pressure)
const
227 {
return saturatedGasDissolutionFactorTable_[regionIdx].eval(pressure,
true); }
236 template <
class Evaluation>
239 const Evaluation& pressure,
240 const Evaluation& oilSaturation,
241 Evaluation maxOilSaturation)
const
244 saturatedGasDissolutionFactorTable_[regionIdx].eval(pressure,
true);
248 maxOilSaturation = min(maxOilSaturation, Scalar(1.0));
249 if (vapPar2_ > 0.0 && maxOilSaturation > 0.01 && oilSaturation < maxOilSaturation) {
250 constexpr const Scalar eps = 0.001;
251 const Evaluation& So = max(oilSaturation, eps);
252 tmp *= max(1e-3, pow(So/maxOilSaturation, vapPar2_));
264 template <
class Evaluation>
267 const Evaluation& Rs)
const
271 const auto& RsTable = saturatedGasDissolutionFactorTable_[regionIdx];
272 constexpr const Scalar eps = std::numeric_limits<typename Toolbox::Scalar>::epsilon()*1e6;
275 Evaluation pSat = saturationPressure_[regionIdx].eval(Rs,
true);
280 bool onProbation =
false;
281 for (
int i = 0; i < 20; ++i) {
282 const Evaluation& f = RsTable.eval(pSat,
true) - Rs;
283 const Evaluation& fPrime = RsTable.evalDerivative(pSat,
true);
287 if (std::abs(scalarValue(fPrime)) < 1.0e-30) {
291 const Evaluation& delta = f/fPrime;
305 if (std::abs(scalarValue(delta)) < std::abs(scalarValue(pSat))*eps)
309 const std::string msg =
310 "Finding saturation pressure did not converge: "
311 " pSat = " + std::to_string(getValue(pSat)) +
312 ", Rs = " + std::to_string(getValue(Rs));
313 OpmLog::debug(
"Live oil saturation pressure", msg);
317 template <
class Evaluation>
318 Evaluation diffusionCoefficient(
const Evaluation& ,
322 throw std::runtime_error(
"Not implemented: The PVT model does not provide a diffusionCoefficient()");
325 Scalar gasReferenceDensity(
unsigned regionIdx)
const
326 {
return gasReferenceDensity_[regionIdx]; }
328 Scalar oilReferenceDensity(
unsigned regionIdx)
const
329 {
return oilReferenceDensity_[regionIdx]; }
331 const std::vector<TabulatedTwoDFunction>& inverseOilBTable()
const
332 {
return inverseOilBTable_; }
334 const std::vector<TabulatedTwoDFunction>& oilMuTable()
const
335 {
return oilMuTable_; }
337 const std::vector<TabulatedTwoDFunction>& inverseOilBMuTable()
const
338 {
return inverseOilBMuTable_; }
340 const std::vector<TabulatedOneDFunction>& saturatedOilMuTable()
const
341 {
return saturatedOilMuTable_; }
343 const std::vector<TabulatedOneDFunction>& inverseSaturatedOilBTable()
const
344 {
return inverseSaturatedOilBTable_; }
346 const std::vector<TabulatedOneDFunction>& inverseSaturatedOilBMuTable()
const
347 {
return inverseSaturatedOilBMuTable_; }
349 const std::vector<TabulatedOneDFunction>& saturatedGasDissolutionFactorTable()
const
350 {
return saturatedGasDissolutionFactorTable_; }
353 {
return saturationPressure_; }
355 Scalar vapPar2()
const
359 void updateSaturationPressure_(
unsigned regionIdx);
361 std::vector<Scalar> gasReferenceDensity_;
362 std::vector<Scalar> oilReferenceDensity_;
363 std::vector<TabulatedTwoDFunction> inverseOilBTable_;
364 std::vector<TabulatedTwoDFunction> oilMuTable_;
365 std::vector<TabulatedTwoDFunction> inverseOilBMuTable_;
366 std::vector<TabulatedOneDFunction> saturatedOilMuTable_;
367 std::vector<TabulatedOneDFunction> inverseSaturatedOilBTable_;
368 std::vector<TabulatedOneDFunction> inverseSaturatedOilBMuTable_;
369 std::vector<TabulatedOneDFunction> saturatedGasDissolutionFactorTable_;
370 std::vector<TabulatedOneDFunction> saturationPressure_;
372 Scalar vapPar2_ = 0.0;
Provides the OPM specific exception classes.
Implements a linearly interpolated scalar function that depends on one variable.
Definition EclipseState.hpp:63
This class represents the Pressure-Volume-Temperature relations of the oil phas with dissolved gas.
Definition LiveOilPvt.hpp:51
Evaluation internalEnergy(unsigned, const Evaluation &, const Evaluation &, const Evaluation &) const
Returns the specific enthalpy [J/kg] of oil given a set of parameters.
Definition LiveOilPvt.hpp:156
void setSaturatedOilFormationVolumeFactor(unsigned regionIdx, const SamplingPoints &samplePoints)
Initialize the function for the oil formation volume factor.
Definition LiveOilPvt.cpp:246
Evaluation inverseFormationVolumeFactor(unsigned regionIdx, const Evaluation &, const Evaluation &pressure, const Evaluation &Rs) const
Returns the formation volume factor [-] of the fluid phase.
Definition LiveOilPvt.hpp:199
Evaluation saturatedGasDissolutionFactor(unsigned regionIdx, const Evaluation &, const Evaluation &pressure, const Evaluation &oilSaturation, Evaluation maxOilSaturation) const
Returns the gas dissolution factor [m^3/m^3] of the oil phase.
Definition LiveOilPvt.hpp:237
Evaluation saturatedInverseFormationVolumeFactor(unsigned regionIdx, const Evaluation &, const Evaluation &pressure) const
Returns the formation volume factor [-] of the fluid phase.
Definition LiveOilPvt.hpp:212
void setSaturatedOilViscosity(unsigned regionIdx, const SamplingPoints &samplePoints)
Initialize the phase viscosity for gas saturated oil.
Definition LiveOilPvt.cpp:273
Evaluation saturationPressure(unsigned regionIdx, const Evaluation &, const Evaluation &Rs) const
Returns the saturation pressure of the oil phase [Pa] depending on its mass fraction of the gas compo...
Definition LiveOilPvt.hpp:265
void setSaturatedOilGasDissolutionFactor(unsigned regionIdx, const SamplingPoints &samplePoints)
Initialize the function for the gas dissolution factor .
Definition LiveOilPvt.hpp:93
Evaluation viscosity(unsigned regionIdx, const Evaluation &, const Evaluation &pressure, const Evaluation &Rs) const
Returns the dynamic viscosity [Pa s] of the fluid phase given a set of parameters.
Definition LiveOilPvt.hpp:168
void setReferenceDensities(unsigned regionIdx, Scalar rhoRefOil, Scalar rhoRefGas, Scalar)
Initialize the reference densities of all fluids for a given PVT region.
Definition LiveOilPvt.cpp:235
void setOilViscosity(unsigned regionIdx, const TabulatedTwoDFunction &muo)
Initialize the viscosity of the oil phase.
Definition LiveOilPvt.hpp:128
Evaluation saturatedGasDissolutionFactor(unsigned regionIdx, const Evaluation &, const Evaluation &pressure) const
Returns the gas dissolution factor [m^3/m^3] of the oil phase.
Definition LiveOilPvt.hpp:224
Evaluation saturatedViscosity(unsigned regionIdx, const Evaluation &, const Evaluation &pressure) const
Returns the dynamic viscosity [Pa s] of the fluid phase given a set of parameters.
Definition LiveOilPvt.hpp:184
unsigned numRegions() const
Return the number of PVT regions which are considered by this PVT-object.
Definition LiveOilPvt.hpp:149
void initEnd()
Finish initializing the oil phase PVT properties.
Definition LiveOilPvt.cpp:300
void setInverseOilFormationVolumeFactor(unsigned regionIdx, const TabulatedTwoDFunction &invBo)
Initialize the function for the oil formation volume factor.
Definition LiveOilPvt.hpp:120
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 implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30