Loading...
Searching...
No Matches
ConstantCompressibilityOilPvt.hpp
Go to the documentation of this file.
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
Consult the COPYING file in the top-level source directory of this
module for the precise wording of the license and the list of
copyright holders.
*/
#ifndef OPM_CONSTANT_COMPRESSIBILITY_OIL_PVT_HPP
#define OPM_CONSTANT_COMPRESSIBILITY_OIL_PVT_HPP
#include <opm/material/densead/Math.hpp>
#include <cstddef>
#include <stdexcept>
#include <vector>
namespace Opm {
#if HAVE_ECL_INPUT
class EclipseState;
class Schedule;
#endif
template <class Scalar>
class ConstantCompressibilityOilPvt
{
public:
#if HAVE_ECL_INPUT
void initFromState(const EclipseState& eclState, const Schedule&);
#endif
void setNumRegions(std::size_t numRegions);
void setVapPars(const Scalar, const Scalar)
{
}
void setReferenceDensities(unsigned regionIdx,
Scalar rhoRefOil,
Scalar /*rhoRefGas*/,
Scalar /*rhoRefWater*/)
{ oilReferenceDensity_[regionIdx] = rhoRefOil; }
void setViscosity(unsigned regionIdx, Scalar muo, Scalar oilViscosibility = 0.0)
{
oilViscosity_[regionIdx] = muo;
oilViscosibility_[regionIdx] = oilViscosibility;
}
void setCompressibility(unsigned regionIdx, Scalar oilCompressibility)
{ oilCompressibility_[regionIdx] = oilCompressibility; }
void setReferencePressure(unsigned regionIdx, Scalar p)
{ oilReferencePressure_[regionIdx] = p; }
void setReferenceFormationVolumeFactor(unsigned regionIdx, Scalar BoRef)
{ oilReferenceFormationVolumeFactor_[regionIdx] = BoRef; }
void setViscosibility(unsigned regionIdx, Scalar muComp)
{ oilViscosibility_[regionIdx] = muComp; }
void initEnd()
{ }
unsigned numRegions() const
{ return oilViscosity_.size(); }
template <class Evaluation>
Evaluation internalEnergy(unsigned,
const Evaluation&,
const Evaluation&,
const Evaluation&) const
{
throw std::runtime_error("Requested the enthalpy of oil but the thermal "
"option is not enabled");
}
Scalar hVap(unsigned) const
{
throw std::runtime_error("Requested the hvap of oil but the thermal "
"option is not enabled");
}
template <class Evaluation>
Evaluation viscosity(unsigned regionIdx,
const Evaluation& temperature,
const Evaluation& pressure,
const Evaluation& /*Rs*/) const
{ return saturatedViscosity(regionIdx, temperature, pressure); }
template <class Evaluation>
Evaluation saturatedViscosity(unsigned regionIdx,
const Evaluation& temperature,
const Evaluation& pressure) const
{
Scalar BoMuoRef = oilViscosity_[regionIdx]*oilReferenceFormationVolumeFactor_[regionIdx];
const Evaluation& bo = saturatedInverseFormationVolumeFactor(regionIdx, temperature, pressure);
Scalar pRef = oilReferencePressure_[regionIdx];
const Evaluation& Y =
(oilCompressibility_[regionIdx] - oilViscosibility_[regionIdx])
* (pressure - pRef);
return BoMuoRef * bo / (1.0 + Y * (1.0 + Y / 2.0));
}
template <class Evaluation>
Evaluation inverseFormationVolumeFactor(unsigned regionIdx,
const Evaluation& temperature,
const Evaluation& pressure,
const Evaluation& /*Rs*/) const
{ return saturatedInverseFormationVolumeFactor(regionIdx, temperature, pressure); }
template <class FluidState, class LhsEval = typename FluidState::Scalar>
std::pair<LhsEval, LhsEval>
inverseFormationVolumeFactorAndViscosity(const FluidState& fluidState, unsigned regionIdx)
{
const LhsEval& p = decay<LhsEval>(fluidState.pressure(FluidState::oilPhaseIdx));
// Calculate bo(p).
Scalar pRef = oilReferencePressure_[regionIdx];
const LhsEval X = oilCompressibility_[regionIdx] * (p - pRef);
Scalar BoRef = oilReferenceFormationVolumeFactor_[regionIdx];
const LhsEval bo = (1.0 + X * (1.0 + X / 2.0)) / BoRef;
// Calculate mu(p) as (Bo * mu) * bo. Recall bo = 1/Bo.
const LhsEval Y = (oilCompressibility_[regionIdx] - oilViscosibility_[regionIdx]) * (p - pRef);
Scalar BoMuoRef = oilViscosity_[regionIdx]*oilReferenceFormationVolumeFactor_[regionIdx];
const LhsEval muo = BoMuoRef * bo / (1.0 + Y * (1.0 + Y / 2.0));
return { bo, muo };
}
template <class Evaluation>
Evaluation saturatedInverseFormationVolumeFactor(unsigned regionIdx,
const Evaluation& /*temperature*/,
const Evaluation& pressure) const
{
// cf. ECLiPSE 2011 technical description, p. 116
Scalar pRef = oilReferencePressure_[regionIdx];
const Evaluation& X = oilCompressibility_[regionIdx]*(pressure - pRef);
Scalar BoRef = oilReferenceFormationVolumeFactor_[regionIdx];
return (1 + X*(1 + X/2))/BoRef;
}
template <class Evaluation>
Evaluation saturatedGasDissolutionFactor(unsigned /*regionIdx*/,
const Evaluation& /*temperature*/,
const Evaluation& /*pressure*/) const
{ return 0.0; /* this is dead oil! */ }
template <class Evaluation>
Evaluation saturatedGasDissolutionFactor(unsigned /*regionIdx*/,
const Evaluation& /*temperature*/,
const Evaluation& /*pressure*/,
const Evaluation& /*oilSaturation*/,
const Evaluation& /*maxOilSaturation*/) const
{ return 0.0; /* this is dead oil! */ }
template <class Evaluation>
Evaluation saturationPressure(unsigned /*regionIdx*/,
const Evaluation& /*temperature*/,
const Evaluation& /*Rs*/) const
{ return 0.0; /* this is dead oil, so there isn't any meaningful saturation pressure! */ }
template <class Evaluation>
Evaluation diffusionCoefficient(const Evaluation& /*temperature*/,
const Evaluation& /*pressure*/,
unsigned /*compIdx*/) const
{
throw std::runtime_error("Not implemented: The PVT model does not "
"provide a diffusionCoefficient()");
}
Scalar oilReferenceDensity(unsigned regionIdx) const
{ return oilReferenceDensity_[regionIdx]; }
const std::vector<Scalar>& oilReferenceFormationVolumeFactor() const
{ return oilReferenceFormationVolumeFactor_; }
const std::vector<Scalar>& oilCompressibility() const
{ return oilCompressibility_; }
const std::vector<Scalar>& oilViscosity() const
{ return oilViscosity_; }
const std::vector<Scalar>& oilViscosibility() const
{ return oilViscosibility_; }
private:
std::vector<Scalar> oilReferenceDensity_{};
std::vector<Scalar> oilReferencePressure_{};
std::vector<Scalar> oilReferenceFormationVolumeFactor_{};
std::vector<Scalar> oilCompressibility_{};
std::vector<Scalar> oilViscosity_{};
std::vector<Scalar> oilViscosibility_{};
};
} // namespace Opm
#endif
Math.hpp
A number of commonly used algebraic functions for the localized OPM automatic differentiation (AD) fr...
Opm::ConstantCompressibilityOilPvt
This class represents the Pressure-Volume-Temperature relations of the oil phase without dissolved ga...
Definition ConstantCompressibilityOilPvt.hpp:49
Opm::ConstantCompressibilityOilPvt::internalEnergy
Evaluation internalEnergy(unsigned, const Evaluation &, const Evaluation &, const Evaluation &) const
Returns the specific enthalpy [J/kg] of oil given a set of parameters.
Definition ConstantCompressibilityOilPvt.hpp:126
Opm::ConstantCompressibilityOilPvt::saturationPressure
Evaluation saturationPressure(unsigned, const Evaluation &, const Evaluation &) const
Returns the saturation pressure of the oil phase [Pa] depending on its mass fraction of the gas compo...
Definition ConstantCompressibilityOilPvt.hpp:245
Opm::ConstantCompressibilityOilPvt::setViscosity
void setViscosity(unsigned regionIdx, Scalar muo, Scalar oilViscosibility=0.0)
Set the viscosity and "viscosibility" of the oil phase.
Definition ConstantCompressibilityOilPvt.hpp:80
Opm::ConstantCompressibilityOilPvt::initEnd
void initEnd()
Finish initializing the oil phase PVT properties.
Definition ConstantCompressibilityOilPvt.hpp:113
Opm::ConstantCompressibilityOilPvt::saturatedGasDissolutionFactor
Evaluation saturatedGasDissolutionFactor(unsigned, const Evaluation &, const Evaluation &, const Evaluation &, const Evaluation &) const
Returns the gas dissolution factor [m^3/m^3] of the oil phase.
Definition ConstantCompressibilityOilPvt.hpp:230
Opm::ConstantCompressibilityOilPvt::inverseFormationVolumeFactorAndViscosity
std::pair< LhsEval, LhsEval > inverseFormationVolumeFactorAndViscosity(const FluidState &fluidState, unsigned regionIdx)
Returns the formation volume factor [-] and viscosity [Pa s] of the fluid phase.
Definition ConstantCompressibilityOilPvt.hpp:183
Opm::ConstantCompressibilityOilPvt::setReferencePressure
void setReferencePressure(unsigned regionIdx, Scalar p)
Set the oil reference pressure [Pa].
Definition ConstantCompressibilityOilPvt.hpp:95
Opm::ConstantCompressibilityOilPvt::setCompressibility
void setCompressibility(unsigned regionIdx, Scalar oilCompressibility)
Set the compressibility of the oil phase.
Definition ConstantCompressibilityOilPvt.hpp:89
Opm::ConstantCompressibilityOilPvt::viscosity
Evaluation viscosity(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &) const
Returns the dynamic viscosity [Pa s] of gas saturated oil given a pressure and a phase composition.
Definition ConstantCompressibilityOilPvt.hpp:144
Opm::ConstantCompressibilityOilPvt::setReferenceDensities
void setReferenceDensities(unsigned regionIdx, Scalar rhoRefOil, Scalar, Scalar)
Initialize the reference densities of all fluids for a given PVT region.
Definition ConstantCompressibilityOilPvt.hpp:71
Opm::ConstantCompressibilityOilPvt::setViscosibility
void setViscosibility(unsigned regionIdx, Scalar muComp)
Set the oil "viscosibility" [1/ (Pa s)].
Definition ConstantCompressibilityOilPvt.hpp:107
Opm::ConstantCompressibilityOilPvt::inverseFormationVolumeFactor
Evaluation inverseFormationVolumeFactor(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure, const Evaluation &) const
Returns the formation volume factor [-] of the fluid phase.
Definition ConstantCompressibilityOilPvt.hpp:172
Opm::ConstantCompressibilityOilPvt::saturatedInverseFormationVolumeFactor
Evaluation saturatedInverseFormationVolumeFactor(unsigned regionIdx, const Evaluation &, const Evaluation &pressure) const
Returns the formation volume factor [-] of gas saturated oil.
Definition ConstantCompressibilityOilPvt.hpp:205
Opm::ConstantCompressibilityOilPvt::setReferenceFormationVolumeFactor
void setReferenceFormationVolumeFactor(unsigned regionIdx, Scalar BoRef)
Set the oil reference formation volume factor [-].
Definition ConstantCompressibilityOilPvt.hpp:101
Opm::ConstantCompressibilityOilPvt::saturatedGasDissolutionFactor
Evaluation saturatedGasDissolutionFactor(unsigned, const Evaluation &, const Evaluation &) const
Returns the gas dissolution factor [m^3/m^3] of the oil phase.
Definition ConstantCompressibilityOilPvt.hpp:221
Opm::ConstantCompressibilityOilPvt::saturatedViscosity
Evaluation saturatedViscosity(unsigned regionIdx, const Evaluation &temperature, const Evaluation &pressure) const
Returns the dynamic viscosity [Pa s] of gas saturated oil given a pressure.
Definition ConstantCompressibilityOilPvt.hpp:154
Opm::ConstantCompressibilityOilPvt::numRegions
unsigned numRegions() const
Return the number of PVT regions which are considered by this PVT-object.
Definition ConstantCompressibilityOilPvt.hpp:119
Opm::EclipseState
Definition EclipseState.hpp:62
Opm::Schedule
Definition Schedule.hpp:101
Opm
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30