Loading...
Searching...
No Matches
BlackOilFluidSystem.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_BLACK_OIL_FLUID_SYSTEM_HPP
#define OPM_BLACK_OIL_FLUID_SYSTEM_HPP
#include "BlackOilDefaultIndexTraits.hpp"
#include "blackoilpvt/OilPvtMultiplexer.hpp"
#include "blackoilpvt/GasPvtMultiplexer.hpp"
#include "blackoilpvt/WaterPvtMultiplexer.hpp"
#include <opm/common/TimingMacros.hpp>
#include <opm/material/fluidsystems/BaseFluidSystem.hpp>
#include <opm/material/Constants.hpp>
#include <opm/material/common/MathToolbox.hpp>
#include <opm/material/common/Valgrind.hpp>
#include <opm/material/common/HasMemberGeneratorMacros.hpp>
#include <opm/material/fluidsystems/NullParameterCache.hpp>
#include <array>
#include <cstddef>
#include <memory>
#include <stdexcept>
#include <string_view>
#include <vector>
namespace Opm {
#if HAVE_ECL_INPUT
class EclipseState;
class Schedule;
#endif
namespace BlackOil {
OPM_GENERATE_HAS_MEMBER(Rs, ) // Creates 'HasMember_Rs<T>'.
OPM_GENERATE_HAS_MEMBER(Rv, ) // Creates 'HasMember_Rv<T>'.
OPM_GENERATE_HAS_MEMBER(Rvw, ) // Creates 'HasMember_Rvw<T>'.
OPM_GENERATE_HAS_MEMBER(Rsw, ) // Creates 'HasMember_Rsw<T>'.
OPM_GENERATE_HAS_MEMBER(saltConcentration, )
OPM_GENERATE_HAS_MEMBER(saltSaturation, )
template <class FluidSystem, class FluidState, class LhsEval>
LhsEval getRs_(typename std::enable_if<!HasMember_Rs<FluidState>::value, const FluidState&>::type fluidState,
unsigned regionIdx)
{
const auto& XoG =
decay<LhsEval>(fluidState.massFraction(FluidSystem::oilPhaseIdx, FluidSystem::gasCompIdx));
return FluidSystem::convertXoGToRs(XoG, regionIdx);
}
template <class FluidSystem, class FluidState, class LhsEval>
auto getRs_(typename std::enable_if<HasMember_Rs<FluidState>::value, const FluidState&>::type fluidState,
unsigned)
-> decltype(decay<LhsEval>(fluidState.Rs()))
{ return decay<LhsEval>(fluidState.Rs()); }
template <class FluidSystem, class FluidState, class LhsEval>
LhsEval getRv_(typename std::enable_if<!HasMember_Rv<FluidState>::value, const FluidState&>::type fluidState,
unsigned regionIdx)
{
const auto& XgO =
decay<LhsEval>(fluidState.massFraction(FluidSystem::gasPhaseIdx, FluidSystem::oilCompIdx));
return FluidSystem::convertXgOToRv(XgO, regionIdx);
}
template <class FluidSystem, class FluidState, class LhsEval>
auto getRv_(typename std::enable_if<HasMember_Rv<FluidState>::value, const FluidState&>::type fluidState,
unsigned)
-> decltype(decay<LhsEval>(fluidState.Rv()))
{ return decay<LhsEval>(fluidState.Rv()); }
template <class FluidSystem, class FluidState, class LhsEval>
LhsEval getRvw_(typename std::enable_if<!HasMember_Rvw<FluidState>::value, const FluidState&>::type fluidState,
unsigned regionIdx)
{
const auto& XgW =
decay<LhsEval>(fluidState.massFraction(FluidSystem::gasPhaseIdx, FluidSystem::waterCompIdx));
return FluidSystem::convertXgWToRvw(XgW, regionIdx);
}
template <class FluidSystem, class FluidState, class LhsEval>
auto getRvw_(typename std::enable_if<HasMember_Rvw<FluidState>::value, const FluidState&>::type fluidState,
unsigned)
-> decltype(decay<LhsEval>(fluidState.Rvw()))
{ return decay<LhsEval>(fluidState.Rvw()); }
template <class FluidSystem, class FluidState, class LhsEval>
LhsEval getRsw_(typename std::enable_if<!HasMember_Rsw<FluidState>::value, const FluidState&>::type fluidState,
unsigned regionIdx)
{
const auto& XwG =
decay<LhsEval>(fluidState.massFraction(FluidSystem::waterPhaseIdx, FluidSystem::gasCompIdx));
return FluidSystem::convertXwGToRsw(XwG, regionIdx);
}
template <class FluidSystem, class FluidState, class LhsEval>
auto getRsw_(typename std::enable_if<HasMember_Rsw<FluidState>::value, const FluidState&>::type fluidState,
unsigned)
-> decltype(decay<LhsEval>(fluidState.Rsw()))
{ return decay<LhsEval>(fluidState.Rsw()); }
template <class FluidSystem, class FluidState, class LhsEval>
LhsEval getSaltConcentration_(typename std::enable_if<!HasMember_saltConcentration<FluidState>::value,
const FluidState&>::type,
unsigned)
{return 0.0;}
template <class FluidSystem, class FluidState, class LhsEval>
auto getSaltConcentration_(typename std::enable_if<HasMember_saltConcentration<FluidState>::value, const FluidState&>::type fluidState,
unsigned)
-> decltype(decay<LhsEval>(fluidState.saltConcentration()))
{ return decay<LhsEval>(fluidState.saltConcentration()); }
template <class FluidSystem, class FluidState, class LhsEval>
LhsEval getSaltSaturation_(typename std::enable_if<!HasMember_saltSaturation<FluidState>::value,
const FluidState&>::type,
unsigned)
{return 0.0;}
template <class FluidSystem, class FluidState, class LhsEval>
auto getSaltSaturation_(typename std::enable_if<HasMember_saltSaturation<FluidState>::value, const FluidState&>::type fluidState,
unsigned)
-> decltype(decay<LhsEval>(fluidState.saltSaturation()))
{ return decay<LhsEval>(fluidState.saltSaturation()); }
}
template <class Scalar, class IndexTraits = BlackOilDefaultIndexTraits>
class BlackOilFluidSystem : public BaseFluidSystem<Scalar, BlackOilFluidSystem<Scalar, IndexTraits> >
{
using ThisType = BlackOilFluidSystem;
public:
using GasPvt = GasPvtMultiplexer<Scalar>;
using OilPvt = OilPvtMultiplexer<Scalar>;
using WaterPvt = WaterPvtMultiplexer<Scalar>;
template <class EvaluationT>
struct ParameterCache : public NullParameterCache<EvaluationT>
{
using Evaluation = EvaluationT;
public:
explicit ParameterCache(Scalar maxOilSat = 1.0, unsigned regionIdx = 0)
: maxOilSat_(maxOilSat)
, regionIdx_(regionIdx)
{
}
template <class OtherCache>
void assignPersistentData(const OtherCache& other)
{
regionIdx_ = other.regionIndex();
maxOilSat_ = other.maxOilSat();
}
unsigned regionIndex() const
{ return regionIdx_; }
void setRegionIndex(unsigned val)
{ regionIdx_ = val; }
const Evaluation& maxOilSat() const
{ return maxOilSat_; }
void setMaxOilSat(const Evaluation& val)
{ maxOilSat_ = val; }
private:
Evaluation maxOilSat_;
unsigned regionIdx_;
};
/****************************************
* Initialization
****************************************/
#if HAVE_ECL_INPUT
static void initFromState(const EclipseState& eclState, const Schedule& schedule);
#endif // HAVE_ECL_INPUT
static void initBegin(std::size_t numPvtRegions);
static void setEnableDissolvedGas(bool yesno)
{ enableDissolvedGas_ = yesno; }
static void setEnableVaporizedOil(bool yesno)
{ enableVaporizedOil_ = yesno; }
static void setEnableVaporizedWater(bool yesno)
{ enableVaporizedWater_ = yesno; }
static void setEnableDissolvedGasInWater(bool yesno)
{ enableDissolvedGasInWater_ = yesno; }
static void setEnableDiffusion(bool yesno)
{ enableDiffusion_ = yesno; }
static void setUseSaturatedTables(bool yesno)
{ useSaturatedTables_ = yesno; }
static void setGasPvt(std::shared_ptr<GasPvt> pvtObj)
{ gasPvt_ = pvtObj; }
static void setOilPvt(std::shared_ptr<OilPvt> pvtObj)
{ oilPvt_ = pvtObj; }
static void setWaterPvt(std::shared_ptr<WaterPvt> pvtObj)
{ waterPvt_ = pvtObj; }
static void setVapPars(const Scalar par1, const Scalar par2)
{
if (gasPvt_) {
gasPvt_->setVapPars(par1, par2);
}
if (oilPvt_) {
oilPvt_->setVapPars(par1, par2);
}
if (waterPvt_) {
waterPvt_->setVapPars(par1, par2);
}
}
static void setReferenceDensities(Scalar rhoOil,
Scalar rhoWater,
Scalar rhoGas,
unsigned regionIdx);
static void initEnd();
static bool isInitialized()
{ return isInitialized_; }
/****************************************
* Generic phase properties
****************************************/
static constexpr unsigned numPhases = 3;
static constexpr unsigned waterPhaseIdx = IndexTraits::waterPhaseIdx;
static constexpr unsigned oilPhaseIdx = IndexTraits::oilPhaseIdx;
static constexpr unsigned gasPhaseIdx = IndexTraits::gasPhaseIdx;
static Scalar surfacePressure;
static Scalar surfaceTemperature;
static std::string_view phaseName(unsigned phaseIdx);
static bool isLiquid(unsigned phaseIdx)
{
assert(phaseIdx < numPhases);
return phaseIdx != gasPhaseIdx;
}
/****************************************
* Generic component related properties
****************************************/
static constexpr unsigned numComponents = 3;
static constexpr unsigned oilCompIdx = IndexTraits::oilCompIdx;
static constexpr unsigned waterCompIdx = IndexTraits::waterCompIdx;
static constexpr unsigned gasCompIdx = IndexTraits::gasCompIdx;
protected:
static unsigned char numActivePhases_;
static std::array<bool,numPhases> phaseIsActive_;
public:
static unsigned numActivePhases()
{ return numActivePhases_; }
static bool phaseIsActive(unsigned phaseIdx)
{
assert(phaseIdx < numPhases);
return phaseIsActive_[phaseIdx];
}
static unsigned solventComponentIndex(unsigned phaseIdx);
static unsigned soluteComponentIndex(unsigned phaseIdx);
static std::string_view componentName(unsigned compIdx);
static Scalar molarMass(unsigned compIdx, unsigned regionIdx = 0)
{ return molarMass_[regionIdx][compIdx]; }
static bool isIdealMixture(unsigned /*phaseIdx*/)
{
// fugacity coefficients are only pressure dependent -> we
// have an ideal mixture
return true;
}
static bool isCompressible(unsigned /*phaseIdx*/)
{ return true; /* all phases are compressible */ }
static bool isIdealGas(unsigned /*phaseIdx*/)
{ return false; }
/****************************************
* Black-oil specific properties
****************************************/
static std::size_t numRegions()
{ return molarMass_.size(); }
static bool enableDissolvedGas()
{ return enableDissolvedGas_; }
static bool enableDissolvedGasInWater()
{ return enableDissolvedGasInWater_; }
static bool enableVaporizedOil()
{ return enableVaporizedOil_; }
static bool enableVaporizedWater()
{ return enableVaporizedWater_; }
static bool enableDiffusion()
{ return enableDiffusion_; }
static bool useSaturatedTables()
{ return useSaturatedTables_; }
static Scalar referenceDensity(unsigned phaseIdx, unsigned regionIdx)
{ return referenceDensity_[regionIdx][phaseIdx]; }
/****************************************
* thermodynamic quantities (generic version)
****************************************/
template <class FluidState, class LhsEval = typename FluidState::Scalar, class ParamCacheEval = LhsEval>
static LhsEval density(const FluidState& fluidState,
const ParameterCache<ParamCacheEval>& paramCache,
unsigned phaseIdx)
{ return density<FluidState, LhsEval>(fluidState, phaseIdx, paramCache.regionIndex()); }
template <class FluidState, class LhsEval = typename FluidState::Scalar, class ParamCacheEval = LhsEval>
static LhsEval fugacityCoefficient(const FluidState& fluidState,
const ParameterCache<ParamCacheEval>& paramCache,
unsigned phaseIdx,
unsigned compIdx)
{
return fugacityCoefficient<FluidState, LhsEval>(fluidState,
phaseIdx,
compIdx,
paramCache.regionIndex());
}
template <class FluidState, class LhsEval = typename FluidState::Scalar, class ParamCacheEval = LhsEval>
static LhsEval viscosity(const FluidState& fluidState,
const ParameterCache<ParamCacheEval>& paramCache,
unsigned phaseIdx)
{ return viscosity<FluidState, LhsEval>(fluidState, phaseIdx, paramCache.regionIndex()); }
template <class FluidState, class LhsEval = typename FluidState::Scalar, class ParamCacheEval = LhsEval>
static LhsEval enthalpy(const FluidState& fluidState,
const ParameterCache<ParamCacheEval>& paramCache,
unsigned phaseIdx)
{ return enthalpy<FluidState, LhsEval>(fluidState, phaseIdx, paramCache.regionIndex()); }
template <class FluidState, class LhsEval = typename FluidState::Scalar, class ParamCacheEval = LhsEval>
static LhsEval internalEnergy(const FluidState& fluidState,
const ParameterCache<ParamCacheEval>& paramCache,
unsigned phaseIdx)
{ return internalEnergy<FluidState, LhsEval>(fluidState, phaseIdx, paramCache.regionIndex()); }
/****************************************
* thermodynamic quantities (black-oil specific version: Note that the PVT region
* index is explicitly passed instead of a parameter cache object)
****************************************/
template <class FluidState, class LhsEval = typename FluidState::Scalar>
static LhsEval density(const FluidState& fluidState,
unsigned phaseIdx,
unsigned regionIdx)
{
assert(phaseIdx <= numPhases);
assert(regionIdx <= numRegions());
const LhsEval& p = decay<LhsEval>(fluidState.pressure(phaseIdx));
const LhsEval& T = decay<LhsEval>(fluidState.temperature(phaseIdx));
const LhsEval& saltConcentration = BlackOil::template getSaltConcentration_<ThisType, FluidState, LhsEval>(fluidState, regionIdx);
switch (phaseIdx) {
case oilPhaseIdx: {
if (enableDissolvedGas()) {
// miscible oil
const LhsEval& Rs = BlackOil::template getRs_<ThisType, FluidState, LhsEval>(fluidState, regionIdx);
const LhsEval& bo = oilPvt_->inverseFormationVolumeFactor(regionIdx, T, p, Rs);
return
bo*referenceDensity(oilPhaseIdx, regionIdx)
+ Rs*bo*referenceDensity(gasPhaseIdx, regionIdx);
}
// immiscible oil
const LhsEval Rs(0.0);
const auto& bo = oilPvt_->inverseFormationVolumeFactor(regionIdx, T, p, Rs);
return referenceDensity(phaseIdx, regionIdx)*bo;
}
case gasPhaseIdx: {
if (enableVaporizedOil() && enableVaporizedWater()) {
// gas containing vaporized oil and vaporized water
const LhsEval& Rv = BlackOil::template getRv_<ThisType, FluidState, LhsEval>(fluidState, regionIdx);
const LhsEval& Rvw = BlackOil::template getRvw_<ThisType, FluidState, LhsEval>(fluidState, regionIdx);
const LhsEval& bg = gasPvt_->inverseFormationVolumeFactor(regionIdx, T, p, Rv, Rvw);
return
bg*referenceDensity(gasPhaseIdx, regionIdx)
+ Rv*bg*referenceDensity(oilPhaseIdx, regionIdx)
+ Rvw*bg*referenceDensity(waterPhaseIdx, regionIdx);
}
if (enableVaporizedOil()) {
// miscible gas
const LhsEval Rvw(0.0);
const LhsEval& Rv = BlackOil::template getRv_<ThisType, FluidState, LhsEval>(fluidState, regionIdx);
const LhsEval& bg = gasPvt_->inverseFormationVolumeFactor(regionIdx, T, p, Rv, Rvw);
return
bg*referenceDensity(gasPhaseIdx, regionIdx)
+ Rv*bg*referenceDensity(oilPhaseIdx, regionIdx);
}
if (enableVaporizedWater()) {
// gas containing vaporized water
const LhsEval Rv(0.0);
const LhsEval& Rvw = BlackOil::template getRvw_<ThisType, FluidState, LhsEval>(fluidState, regionIdx);
const LhsEval& bg = gasPvt_->inverseFormationVolumeFactor(regionIdx, T, p, Rv, Rvw);
return
bg*referenceDensity(gasPhaseIdx, regionIdx)
+ Rvw*bg*referenceDensity(waterPhaseIdx, regionIdx);
}
// immiscible gas
const LhsEval Rv(0.0);
const LhsEval Rvw(0.0);
const auto& bg = gasPvt_->inverseFormationVolumeFactor(regionIdx, T, p, Rv, Rvw);
return bg*referenceDensity(phaseIdx, regionIdx);
}
case waterPhaseIdx:
if (enableDissolvedGasInWater()) {
// gas miscible in water
const LhsEval& Rsw =BlackOil::template getRsw_<ThisType, FluidState, LhsEval>(fluidState, regionIdx);
const LhsEval& bw = waterPvt_->inverseFormationVolumeFactor(regionIdx, T, p, Rsw, saltConcentration);
return
bw*referenceDensity(waterPhaseIdx, regionIdx)
+ Rsw*bw*referenceDensity(gasPhaseIdx, regionIdx);
}
const LhsEval Rsw(0.0);
return
referenceDensity(waterPhaseIdx, regionIdx)
* waterPvt_->inverseFormationVolumeFactor(regionIdx, T, p, Rsw, saltConcentration);
}
throw std::logic_error("Unhandled phase index "+std::to_string(phaseIdx));
}
template <class FluidState, class LhsEval = typename FluidState::Scalar>
static LhsEval saturatedDensity(const FluidState& fluidState,
unsigned phaseIdx,
unsigned regionIdx)
{
assert(phaseIdx <= numPhases);
assert(regionIdx <= numRegions());
const auto& p = fluidState.pressure(phaseIdx);
const auto& T = fluidState.temperature(phaseIdx);
switch (phaseIdx) {
case oilPhaseIdx: {
if (enableDissolvedGas()) {
// miscible oil
const LhsEval& Rs = saturatedDissolutionFactor<FluidState, LhsEval>(fluidState, oilPhaseIdx, regionIdx);
const LhsEval& bo = oilPvt_->inverseFormationVolumeFactor(regionIdx, T, p, Rs);
return
bo*referenceDensity(oilPhaseIdx, regionIdx)
+ Rs*bo*referenceDensity(gasPhaseIdx, regionIdx);
}
// immiscible oil
const LhsEval Rs(0.0);
const LhsEval& bo = oilPvt_->inverseFormationVolumeFactor(regionIdx, T, p, Rs);
return referenceDensity(phaseIdx, regionIdx)*bo;
}
case gasPhaseIdx: {
if (enableVaporizedOil() && enableVaporizedWater()) {
// gas containing vaporized oil and vaporized water
const LhsEval& Rv = saturatedDissolutionFactor<FluidState, LhsEval>(fluidState, gasPhaseIdx, regionIdx);
const LhsEval& Rvw = saturatedVaporizationFactor<FluidState, LhsEval>(fluidState, gasPhaseIdx, regionIdx);
const LhsEval& bg = gasPvt_->inverseFormationVolumeFactor(regionIdx, T, p, Rv, Rvw);
return
bg*referenceDensity(gasPhaseIdx, regionIdx)
+ Rv*bg*referenceDensity(oilPhaseIdx, regionIdx)
+ Rvw*bg*referenceDensity(waterPhaseIdx, regionIdx) ;
}
if (enableVaporizedOil()) {
// miscible gas
const LhsEval Rvw(0.0);
const LhsEval& Rv = saturatedDissolutionFactor<FluidState, LhsEval>(fluidState, gasPhaseIdx, regionIdx);
const LhsEval& bg = gasPvt_->inverseFormationVolumeFactor(regionIdx, T, p, Rv, Rvw);
return
bg*referenceDensity(gasPhaseIdx, regionIdx)
+ Rv*bg*referenceDensity(oilPhaseIdx, regionIdx);
}
if (enableVaporizedWater()) {
// gas containing vaporized water
const LhsEval Rv(0.0);
const LhsEval& Rvw = saturatedVaporizationFactor<FluidState, LhsEval>(fluidState, gasPhaseIdx, regionIdx);
const LhsEval& bg = gasPvt_->inverseFormationVolumeFactor(regionIdx, T, p, Rv, Rvw);
return
bg*referenceDensity(gasPhaseIdx, regionIdx)
+ Rvw*bg*referenceDensity(waterPhaseIdx, regionIdx);
}
// immiscible gas
const LhsEval Rv(0.0);
const LhsEval Rvw(0.0);
const LhsEval& bg = gasPvt_->inverseFormationVolumeFactor(regionIdx, T, p, Rv, Rvw);
return referenceDensity(phaseIdx, regionIdx)*bg;
}
case waterPhaseIdx:
{
if (enableDissolvedGasInWater()) {
// miscible in water
const auto& saltConcentration = decay<LhsEval>(fluidState.saltConcentration());
const LhsEval& Rsw = saturatedDissolutionFactor<FluidState, LhsEval>(fluidState, waterPhaseIdx, regionIdx);
const LhsEval& bw = waterPvt_->inverseFormationVolumeFactor(regionIdx, T, p, Rsw, saltConcentration);
return
bw*referenceDensity(waterPhaseIdx, regionIdx)
+ Rsw*bw*referenceDensity(gasPhaseIdx, regionIdx);
}
return
referenceDensity(waterPhaseIdx, regionIdx)
*inverseFormationVolumeFactor<FluidState, LhsEval>(fluidState, waterPhaseIdx, regionIdx);
}
}
throw std::logic_error("Unhandled phase index "+std::to_string(phaseIdx));
}
template <class FluidState, class LhsEval = typename FluidState::Scalar>
static LhsEval inverseFormationVolumeFactor(const FluidState& fluidState,
unsigned phaseIdx,
unsigned regionIdx)
{
OPM_TIMEBLOCK_LOCAL(inverseFormationVolumeFactor);
assert(phaseIdx <= numPhases);
assert(regionIdx <= numRegions());
const auto& p = decay<LhsEval>(fluidState.pressure(phaseIdx));
const auto& T = decay<LhsEval>(fluidState.temperature(phaseIdx));
switch (phaseIdx) {
case oilPhaseIdx: {
if (enableDissolvedGas()) {
const auto& Rs = BlackOil::template getRs_<ThisType, FluidState, LhsEval>(fluidState, regionIdx);
if (useSaturatedTables() && fluidState.saturation(gasPhaseIdx) > 0.0
&& Rs >= (1.0 - 1e-10)*oilPvt_->saturatedGasDissolutionFactor(regionIdx, scalarValue(T), scalarValue(p)))
{
return oilPvt_->saturatedInverseFormationVolumeFactor(regionIdx, T, p);
} else {
return oilPvt_->inverseFormationVolumeFactor(regionIdx, T, p, Rs);
}
}
const LhsEval Rs(0.0);
return oilPvt_->inverseFormationVolumeFactor(regionIdx, T, p, Rs);
}
case gasPhaseIdx: {
if (enableVaporizedOil() && enableVaporizedWater()) {
const auto& Rvw = BlackOil::template getRvw_<ThisType, FluidState, LhsEval>(fluidState, regionIdx);
const auto& Rv = BlackOil::template getRv_<ThisType, FluidState, LhsEval>(fluidState, regionIdx);
if (useSaturatedTables() && fluidState.saturation(waterPhaseIdx) > 0.0
&& Rvw >= (1.0 - 1e-10)*gasPvt_->saturatedWaterVaporizationFactor(regionIdx, scalarValue(T), scalarValue(p))
&& fluidState.saturation(oilPhaseIdx) > 0.0
&& Rv >= (1.0 - 1e-10)*gasPvt_->saturatedOilVaporizationFactor(regionIdx, scalarValue(T), scalarValue(p)))
{
return gasPvt_->saturatedInverseFormationVolumeFactor(regionIdx, T, p);
} else {
return gasPvt_->inverseFormationVolumeFactor(regionIdx, T, p, Rv, Rvw);
}
}
if (enableVaporizedOil()) {
const auto& Rv = BlackOil::template getRv_<ThisType, FluidState, LhsEval>(fluidState, regionIdx);
if (useSaturatedTables() && fluidState.saturation(oilPhaseIdx) > 0.0
&& Rv >= (1.0 - 1e-10)*gasPvt_->saturatedOilVaporizationFactor(regionIdx, scalarValue(T), scalarValue(p)))
{
return gasPvt_->saturatedInverseFormationVolumeFactor(regionIdx, T, p);
} else {
const LhsEval Rvw(0.0);
return gasPvt_->inverseFormationVolumeFactor(regionIdx, T, p, Rv, Rvw);
}
}
if (enableVaporizedWater()) {
const auto& Rvw = BlackOil::template getRvw_<ThisType, FluidState, LhsEval>(fluidState, regionIdx);
if (useSaturatedTables() && fluidState.saturation(waterPhaseIdx) > 0.0
&& Rvw >= (1.0 - 1e-10)*gasPvt_->saturatedWaterVaporizationFactor(regionIdx, scalarValue(T), scalarValue(p)))
{
return gasPvt_->saturatedInverseFormationVolumeFactor(regionIdx, T, p);
} else {
const LhsEval Rv(0.0);
return gasPvt_->inverseFormationVolumeFactor(regionIdx, T, p, Rv, Rvw);
}
}
const LhsEval Rv(0.0);
const LhsEval Rvw(0.0);
return gasPvt_->inverseFormationVolumeFactor(regionIdx, T, p, Rv, Rvw);
}
case waterPhaseIdx:
{
const auto& saltConcentration = BlackOil::template getSaltConcentration_<ThisType, FluidState, LhsEval>(fluidState, regionIdx);
if (enableDissolvedGasInWater()) {
const auto& Rsw = BlackOil::template getRsw_<ThisType, FluidState, LhsEval>(fluidState, regionIdx);
if (useSaturatedTables() && fluidState.saturation(gasPhaseIdx) > 0.0
&& Rsw >= (1.0 - 1e-10)*waterPvt_->saturatedGasDissolutionFactor(regionIdx, scalarValue(T), scalarValue(p), scalarValue(saltConcentration)))
{
return waterPvt_->saturatedInverseFormationVolumeFactor(regionIdx, T, p, saltConcentration);
} else {
return waterPvt_->inverseFormationVolumeFactor(regionIdx, T, p, Rsw, saltConcentration);
}
}
const LhsEval Rsw(0.0);
return waterPvt_->inverseFormationVolumeFactor(regionIdx, T, p, Rsw, saltConcentration);
}
default: throw std::logic_error("Unhandled phase index "+std::to_string(phaseIdx));
}
}
template <class FluidState, class LhsEval = typename FluidState::Scalar>
static LhsEval saturatedInverseFormationVolumeFactor(const FluidState& fluidState,
unsigned phaseIdx,
unsigned regionIdx)
{
OPM_TIMEBLOCK_LOCAL(saturatedInverseFormationVolumeFactor);
assert(phaseIdx <= numPhases);
assert(regionIdx <= numRegions());
const auto& p = decay<LhsEval>(fluidState.pressure(phaseIdx));
const auto& T = decay<LhsEval>(fluidState.temperature(phaseIdx));
const auto& saltConcentration = BlackOil::template getSaltConcentration_<ThisType, FluidState, LhsEval>(fluidState, regionIdx);
switch (phaseIdx) {
case oilPhaseIdx: return oilPvt_->saturatedInverseFormationVolumeFactor(regionIdx, T, p);
case gasPhaseIdx: return gasPvt_->saturatedInverseFormationVolumeFactor(regionIdx, T, p);
case waterPhaseIdx: return waterPvt_->saturatedInverseFormationVolumeFactor(regionIdx, T, p, saltConcentration);
default: throw std::logic_error("Unhandled phase index "+std::to_string(phaseIdx));
}
}
template <class FluidState, class LhsEval = typename FluidState::Scalar>
static LhsEval fugacityCoefficient(const FluidState& fluidState,
unsigned phaseIdx,
unsigned compIdx,
unsigned regionIdx)
{
assert(phaseIdx <= numPhases);
assert(compIdx <= numComponents);
assert(regionIdx <= numRegions());
const auto& p = decay<LhsEval>(fluidState.pressure(phaseIdx));
const auto& T = decay<LhsEval>(fluidState.temperature(phaseIdx));
// for the fugacity coefficient of the oil component in the oil phase, we use
// some pseudo-realistic value for the vapor pressure to ease physical
// interpretation of the results
const LhsEval phi_oO = 20e3/p;
// for the gas component in the gas phase, assume it to be an ideal gas
constexpr const Scalar phi_gG = 1.0;
// for the fugacity coefficient of the water component in the water phase, we use
// the same approach as for the oil component in the oil phase
const LhsEval phi_wW = 30e3/p;
switch (phaseIdx) {
case gasPhaseIdx: // fugacity coefficients for all components in the gas phase
switch (compIdx) {
case gasCompIdx:
return phi_gG;
// for the oil component, we calculate the Rv value for saturated gas and Rs
// for saturated oil, and compute the fugacity coefficients at the
// equilibrium. for this, we assume that in equilibrium the fugacities of the
// oil component is the same in both phases.
case oilCompIdx: {
if (!enableVaporizedOil())
// if there's no vaporized oil, the gas phase is assumed to be
// immiscible with the oil component
return phi_gG*1e6;
const auto& R_vSat = gasPvt_->saturatedOilVaporizationFactor(regionIdx, T, p);
const auto& X_gOSat = convertRvToXgO(R_vSat, regionIdx);
const auto& x_gOSat = convertXgOToxgO(X_gOSat, regionIdx);
const auto& R_sSat = oilPvt_->saturatedGasDissolutionFactor(regionIdx, T, p);
const auto& X_oGSat = convertRsToXoG(R_sSat, regionIdx);
const auto& x_oGSat = convertXoGToxoG(X_oGSat, regionIdx);
const auto& x_oOSat = 1.0 - x_oGSat;
const auto& p_o = decay<LhsEval>(fluidState.pressure(oilPhaseIdx));
const auto& p_g = decay<LhsEval>(fluidState.pressure(gasPhaseIdx));
return phi_oO*p_o*x_oOSat / (p_g*x_gOSat);
}
case waterCompIdx:
// the water component is assumed to be never miscible with the gas phase
return phi_gG*1e6;
default:
throw std::logic_error("Invalid component index "+std::to_string(compIdx));
}
case oilPhaseIdx: // fugacity coefficients for all components in the oil phase
switch (compIdx) {
case oilCompIdx:
return phi_oO;
// for the oil and water components, we proceed analogous to the gas and
// water components in the gas phase
case gasCompIdx: {
if (!enableDissolvedGas())
// if there's no dissolved gas, the oil phase is assumed to be
// immiscible with the gas component
return phi_oO*1e6;
const auto& R_vSat = gasPvt_->saturatedOilVaporizationFactor(regionIdx, T, p);
const auto& X_gOSat = convertRvToXgO(R_vSat, regionIdx);
const auto& x_gOSat = convertXgOToxgO(X_gOSat, regionIdx);
const auto& x_gGSat = 1.0 - x_gOSat;
const auto& R_sSat = oilPvt_->saturatedGasDissolutionFactor(regionIdx, T, p);
const auto& X_oGSat = convertRsToXoG(R_sSat, regionIdx);
const auto& x_oGSat = convertXoGToxoG(X_oGSat, regionIdx);
const auto& p_o = decay<LhsEval>(fluidState.pressure(oilPhaseIdx));
const auto& p_g = decay<LhsEval>(fluidState.pressure(gasPhaseIdx));
return phi_gG*p_g*x_gGSat / (p_o*x_oGSat);
}
case waterCompIdx:
return phi_oO*1e6;
default:
throw std::logic_error("Invalid component index "+std::to_string(compIdx));
}
case waterPhaseIdx: // fugacity coefficients for all components in the water phase
// the water phase fugacity coefficients are pretty simple: because the water
// phase is assumed to consist entirely from the water component, we just
// need to make sure that the fugacity coefficients for the other components
// are a few orders of magnitude larger than the one of the water
// component. (i.e., the affinity of the gas and oil components to the water
// phase is lower by a few orders of magnitude)
switch (compIdx) {
case waterCompIdx: return phi_wW;
case oilCompIdx: return 1.1e6*phi_wW;
case gasCompIdx: return 1e6*phi_wW;
default:
throw std::logic_error("Invalid component index "+std::to_string(compIdx));
}
default:
throw std::logic_error("Invalid phase index "+std::to_string(phaseIdx));
}
throw std::logic_error("Unhandled phase or component index");
}
template <class FluidState, class LhsEval = typename FluidState::Scalar>
static LhsEval viscosity(const FluidState& fluidState,
unsigned phaseIdx,
unsigned regionIdx)
{
OPM_TIMEBLOCK_LOCAL(viscosity);
assert(phaseIdx <= numPhases);
assert(regionIdx <= numRegions());
const LhsEval& p = decay<LhsEval>(fluidState.pressure(phaseIdx));
const LhsEval& T = decay<LhsEval>(fluidState.temperature(phaseIdx));
switch (phaseIdx) {
case oilPhaseIdx: {
if (enableDissolvedGas()) {
const auto& Rs = BlackOil::template getRs_<ThisType, FluidState, LhsEval>(fluidState, regionIdx);
if (useSaturatedTables() && fluidState.saturation(gasPhaseIdx) > 0.0
&& Rs >= (1.0 - 1e-10)*oilPvt_->saturatedGasDissolutionFactor(regionIdx, scalarValue(T), scalarValue(p)))
{
return oilPvt_->saturatedViscosity(regionIdx, T, p);
} else {
return oilPvt_->viscosity(regionIdx, T, p, Rs);
}
}
const LhsEval Rs(0.0);
return oilPvt_->viscosity(regionIdx, T, p, Rs);
}
case gasPhaseIdx: {
if (enableVaporizedOil() && enableVaporizedWater()) {
const auto& Rvw = BlackOil::template getRvw_<ThisType, FluidState, LhsEval>(fluidState, regionIdx);
const auto& Rv = BlackOil::template getRv_<ThisType, FluidState, LhsEval>(fluidState, regionIdx);
if (useSaturatedTables() && fluidState.saturation(waterPhaseIdx) > 0.0
&& Rvw >= (1.0 - 1e-10)*gasPvt_->saturatedWaterVaporizationFactor(regionIdx, scalarValue(T), scalarValue(p))
&& fluidState.saturation(oilPhaseIdx) > 0.0
&& Rv >= (1.0 - 1e-10)*gasPvt_->saturatedOilVaporizationFactor(regionIdx, scalarValue(T), scalarValue(p)))
{
return gasPvt_->saturatedViscosity(regionIdx, T, p);
} else {
return gasPvt_->viscosity(regionIdx, T, p, Rv, Rvw);
}
}
if (enableVaporizedOil()) {
const auto& Rv = BlackOil::template getRv_<ThisType, FluidState, LhsEval>(fluidState, regionIdx);
if (useSaturatedTables() && fluidState.saturation(oilPhaseIdx) > 0.0
&& Rv >= (1.0 - 1e-10)*gasPvt_->saturatedOilVaporizationFactor(regionIdx, scalarValue(T), scalarValue(p)))
{
return gasPvt_->saturatedViscosity(regionIdx, T, p);
} else {
const LhsEval Rvw(0.0);
return gasPvt_->viscosity(regionIdx, T, p, Rv, Rvw);
}
}
if (enableVaporizedWater()) {
const auto& Rvw = BlackOil::template getRvw_<ThisType, FluidState, LhsEval>(fluidState, regionIdx);
if (useSaturatedTables() && fluidState.saturation(waterPhaseIdx) > 0.0
&& Rvw >= (1.0 - 1e-10)*gasPvt_->saturatedWaterVaporizationFactor(regionIdx, scalarValue(T), scalarValue(p)))
{
return gasPvt_->saturatedViscosity(regionIdx, T, p);
} else {
const LhsEval Rv(0.0);
return gasPvt_->viscosity(regionIdx, T, p, Rv, Rvw);
}
}
const LhsEval Rv(0.0);
const LhsEval Rvw(0.0);
return gasPvt_->viscosity(regionIdx, T, p, Rv, Rvw);
}
case waterPhaseIdx:
{
const LhsEval& saltConcentration = BlackOil::template getSaltConcentration_<ThisType, FluidState, LhsEval>(fluidState, regionIdx);
if (enableDissolvedGasInWater()) {
const auto& Rsw = BlackOil::template getRsw_<ThisType, FluidState, LhsEval>(fluidState, regionIdx);
if (useSaturatedTables() && fluidState.saturation(gasPhaseIdx) > 0.0
&& Rsw >= (1.0 - 1e-10)*waterPvt_->saturatedGasDissolutionFactor(regionIdx, scalarValue(T), scalarValue(p), scalarValue(saltConcentration)))
{
return waterPvt_->saturatedViscosity(regionIdx, T, p, saltConcentration);
} else {
return waterPvt_->viscosity(regionIdx, T, p, Rsw, saltConcentration);
}
}
const LhsEval Rsw(0.0);
return waterPvt_->viscosity(regionIdx, T, p, Rsw, saltConcentration);
}
}
throw std::logic_error("Unhandled phase index "+std::to_string(phaseIdx));
}
template <class FluidState, class LhsEval = typename FluidState::Scalar>
static LhsEval internalEnergy(const FluidState& fluidState,
unsigned phaseIdx,
unsigned regionIdx){
bool is_mixing = false;
const LhsEval& p = decay<LhsEval>(fluidState.pressure(phaseIdx));
const LhsEval& T = decay<LhsEval>(fluidState.temperature(phaseIdx));
switch (phaseIdx) {
case oilPhaseIdx: {
if(!oilPvt_->mixingEnergy()){
const auto& oilEnergy =
oilPvt_->internalEnergy(regionIdx, T, p,
BlackOil::template getRs_<ThisType, FluidState, LhsEval>(fluidState, regionIdx));
return oilEnergy;
}
is_mixing = true;
break;
}
case waterPhaseIdx: {
if(!waterPvt_->mixingEnergy()){
const auto waterEnergy =
waterPvt_->internalEnergy(regionIdx, T, p,
BlackOil::template getRsw_<ThisType, FluidState, LhsEval>(fluidState, regionIdx),
BlackOil::template getSaltConcentration_<ThisType, FluidState, LhsEval>(fluidState, regionIdx));
return waterEnergy;
}
is_mixing = true;
break;
}
case gasPhaseIdx: {
if(!gasPvt_->mixingEnergy()){
const auto gasEnergy =
gasPvt_->internalEnergy(regionIdx, T, p,
BlackOil::template getRv_<ThisType, FluidState, LhsEval>(fluidState, regionIdx),
BlackOil::template getRvw_<ThisType, FluidState, LhsEval>(fluidState, regionIdx));
return gasEnergy;
}
is_mixing = true;
break;
}
}
assert(is_mixing==true);
const auto& energy = internalMixingTotalEnergy<FluidState,LhsEval>(fluidState, phaseIdx, regionIdx);
const auto& phase_density = density<FluidState,LhsEval>(fluidState, phaseIdx, regionIdx);
return energy/phase_density;
}
template <class FluidState, class LhsEval = typename FluidState::Scalar>
static LhsEval internalMixingTotalEnergy(const FluidState& fluidState,
unsigned phaseIdx,
unsigned regionIdx)
{
assert(phaseIdx <= numPhases);
assert(regionIdx <= numRegions());
const LhsEval& p = decay<LhsEval>(fluidState.pressure(phaseIdx));
const LhsEval& T = decay<LhsEval>(fluidState.temperature(phaseIdx));
const LhsEval& saltConcentration = BlackOil::template getSaltConcentration_<ThisType, FluidState, LhsEval>(fluidState, regionIdx);
// to avoid putting all thermal into the interface of the multiplexer
switch (phaseIdx) {
case oilPhaseIdx: {
auto oilEnergy = oilPvt_->internalEnergy(regionIdx, T, p,
BlackOil::template getRs_<ThisType, FluidState, LhsEval>(fluidState, regionIdx));
assert(oilPvt_->mixingEnergy());
//mixing energy adsed
if (enableDissolvedGas()) {
// miscible oil
const LhsEval& Rs = BlackOil::template getRs_<ThisType, FluidState, LhsEval>(fluidState, regionIdx);
const LhsEval& bo = oilPvt_->inverseFormationVolumeFactor(regionIdx, T, p, Rs);
const auto& gasEnergy =
gasPvt_->internalEnergy(regionIdx, T, p,
BlackOil::template getRv_<ThisType, FluidState, LhsEval>(fluidState, regionIdx),
BlackOil::template getRvw_<ThisType, FluidState, LhsEval>(fluidState, regionIdx));
const auto hVapG = gasPvt_->hVap(regionIdx);// pressure correction ? assume equal to energy change
return
oilEnergy*bo*referenceDensity(oilPhaseIdx, regionIdx)
+ (gasEnergy-hVapG)*Rs*bo*referenceDensity(gasPhaseIdx, regionIdx);
}
// immiscible oil
const LhsEval Rs(0.0);
const auto& bo = oilPvt_->inverseFormationVolumeFactor(regionIdx, T, p, Rs);
return oilEnergy*referenceDensity(phaseIdx, regionIdx)*bo;
}
case gasPhaseIdx: {
const auto& gasEnergy =
gasPvt_->internalEnergy(regionIdx, T, p,
BlackOil::template getRv_<ThisType, FluidState, LhsEval>(fluidState, regionIdx),
BlackOil::template getRvw_<ThisType, FluidState, LhsEval>(fluidState, regionIdx));
assert(gasPvt_->mixingEnergy());
if (enableVaporizedOil() && enableVaporizedWater()) {
const auto& oilEnergy =
oilPvt_->internalEnergy(regionIdx, T, p,
BlackOil::template getRs_<ThisType, FluidState, LhsEval>(fluidState, regionIdx));
const auto waterEnergy =
waterPvt_->internalEnergy(regionIdx, T, p,
BlackOil::template getRsw_<ThisType, FluidState, LhsEval>(fluidState, regionIdx),
BlackOil::template getSaltConcentration_<ThisType, FluidState, LhsEval>(fluidState, regionIdx));
// gas containing vaporized oil and vaporized water
const LhsEval& Rv = BlackOil::template getRv_<ThisType, FluidState, LhsEval>(fluidState, regionIdx);
const LhsEval& Rvw = BlackOil::template getRvw_<ThisType, FluidState, LhsEval>(fluidState, regionIdx);
const LhsEval& bg = gasPvt_->inverseFormationVolumeFactor(regionIdx, T, p, Rv, Rvw);
const auto hVapO = oilPvt_->hVap(regionIdx);
const auto hVapW = waterPvt_->hVap(regionIdx);
return
gasEnergy*bg*referenceDensity(gasPhaseIdx, regionIdx)
+ (oilEnergy+hVapO)*Rv*bg*referenceDensity(oilPhaseIdx, regionIdx)
+ (waterEnergy+hVapW)*Rvw*bg*referenceDensity(waterPhaseIdx, regionIdx);
}
if (enableVaporizedOil()) {
const auto& oilEnergy =
oilPvt_->internalEnergy(regionIdx, T, p,
BlackOil::template getRs_<ThisType, FluidState, LhsEval>(fluidState, regionIdx));
// miscible gas
const LhsEval Rvw(0.0);
const LhsEval& Rv = BlackOil::template getRv_<ThisType, FluidState, LhsEval>(fluidState, regionIdx);
const LhsEval& bg = gasPvt_->inverseFormationVolumeFactor(regionIdx, T, p, Rv, Rvw);
const auto hVapO = oilPvt_->hVap(regionIdx);
return
gasEnergy*bg*referenceDensity(gasPhaseIdx, regionIdx)
+ (oilEnergy+hVapO)*Rv*bg*referenceDensity(oilPhaseIdx, regionIdx);
}
if (enableVaporizedWater()) {
// gas containing vaporized water
const LhsEval Rv(0.0);
const LhsEval& Rvw = BlackOil::template getRvw_<ThisType, FluidState, LhsEval>(fluidState, regionIdx);
const LhsEval& bg = gasPvt_->inverseFormationVolumeFactor(regionIdx, T, p, Rv, Rvw);
const auto waterEnergy =
waterPvt_->internalEnergy(regionIdx, T, p,
BlackOil::template getRsw_<ThisType, FluidState, LhsEval>(fluidState, regionIdx),
BlackOil::template getSaltConcentration_<ThisType, FluidState, LhsEval>(fluidState, regionIdx));
const auto hVapW = waterPvt_->hVap(regionIdx);
return
gasEnergy*bg*referenceDensity(gasPhaseIdx, regionIdx)
+ (waterEnergy+hVapW)*Rvw*bg*referenceDensity(waterPhaseIdx, regionIdx);
}
// immiscible gas
const LhsEval Rv(0.0);
const LhsEval Rvw(0.0);
const auto& bg = gasPvt_->inverseFormationVolumeFactor(regionIdx, T, p, Rv, Rvw);
return gasEnergy*bg*referenceDensity(phaseIdx, regionIdx);
}
case waterPhaseIdx:
const auto waterEnergy =
waterPvt_->internalEnergy(regionIdx, T, p,
BlackOil::template getRsw_<ThisType, FluidState, LhsEval>(fluidState, regionIdx),
BlackOil::template getSaltConcentration_<ThisType, FluidState, LhsEval>(fluidState, regionIdx));
assert(waterPvt_->mixingEnergy());
if (enableDissolvedGasInWater()) {
const auto& gasEnergy =
gasPvt_->internalEnergy(regionIdx, T, p,
BlackOil::template getRv_<ThisType, FluidState, LhsEval>(fluidState, regionIdx),
BlackOil::template getRvw_<ThisType, FluidState, LhsEval>(fluidState, regionIdx));
// gas miscible in water
const LhsEval& Rsw = saturatedDissolutionFactor<FluidState, LhsEval>(fluidState, waterPhaseIdx, regionIdx);
const LhsEval& bw = waterPvt_->inverseFormationVolumeFactor(regionIdx, T, p, Rsw, saltConcentration);
return
waterEnergy*bw*referenceDensity(waterPhaseIdx, regionIdx)
+ gasEnergy*Rsw*bw*referenceDensity(gasPhaseIdx, regionIdx);
}
const LhsEval Rsw(0.0);
return
waterEnergy*referenceDensity(waterPhaseIdx, regionIdx)
* waterPvt_->inverseFormationVolumeFactor(regionIdx, T, p, Rsw, saltConcentration);
}
throw std::logic_error("Unhandled phase index " + std::to_string(phaseIdx));
}
template <class FluidState, class LhsEval = typename FluidState::Scalar>
static LhsEval enthalpy(const FluidState& fluidState,
unsigned phaseIdx,
unsigned regionIdx)
{
// should preferably not be used values should be taken from intensive quantities fluid state.
const auto& p = decay<LhsEval>(fluidState.pressure(phaseIdx));
auto energy = internalEnergy<FluidState, LhsEval>(fluidState, phaseIdx, regionIdx);
if(!enthalpy_eq_energy_){
// used for simplified models
energy += p/density<FluidState, LhsEval>(fluidState, phaseIdx, regionIdx);
}
return energy;
}
template <class FluidState, class LhsEval = typename FluidState::Scalar>
static LhsEval saturatedVaporizationFactor(const FluidState& fluidState,
unsigned phaseIdx,
unsigned regionIdx)
{
assert(phaseIdx <= numPhases);
assert(regionIdx <= numRegions());
const auto& p = decay<LhsEval>(fluidState.pressure(phaseIdx));
const auto& T = decay<LhsEval>(fluidState.temperature(phaseIdx));
const auto& saltConcentration = decay<LhsEval>(fluidState.saltConcentration());
switch (phaseIdx) {
case oilPhaseIdx: return 0.0;
case gasPhaseIdx: return gasPvt_->saturatedWaterVaporizationFactor(regionIdx, T, p, saltConcentration);
case waterPhaseIdx: return 0.0;
default: throw std::logic_error("Unhandled phase index "+std::to_string(phaseIdx));
}
}
template <class FluidState, class LhsEval = typename FluidState::Scalar>
static LhsEval saturatedDissolutionFactor(const FluidState& fluidState,
unsigned phaseIdx,
unsigned regionIdx,
const LhsEval& maxOilSaturation)
{
OPM_TIMEBLOCK_LOCAL(saturatedDissolutionFactor);
assert(phaseIdx <= numPhases);
assert(regionIdx <= numRegions());
const auto& p = decay<LhsEval>(fluidState.pressure(phaseIdx));
const auto& T = decay<LhsEval>(fluidState.temperature(phaseIdx));
const auto& So = (phaseIdx == waterPhaseIdx) ? 0 : decay<LhsEval>(fluidState.saturation(oilPhaseIdx));
switch (phaseIdx) {
case oilPhaseIdx: return oilPvt_->saturatedGasDissolutionFactor(regionIdx, T, p, So, maxOilSaturation);
case gasPhaseIdx: return gasPvt_->saturatedOilVaporizationFactor(regionIdx, T, p, So, maxOilSaturation);
case waterPhaseIdx: return waterPvt_->saturatedGasDissolutionFactor(regionIdx, T, p,
BlackOil::template getSaltConcentration_<ThisType, FluidState, LhsEval>(fluidState, regionIdx));
default: throw std::logic_error("Unhandled phase index "+std::to_string(phaseIdx));
}
}
template <class FluidState, class LhsEval = typename FluidState::Scalar>
static LhsEval saturatedDissolutionFactor(const FluidState& fluidState,
unsigned phaseIdx,
unsigned regionIdx)
{
OPM_TIMEBLOCK_LOCAL(saturatedDissolutionFactor);
assert(phaseIdx <= numPhases);
assert(regionIdx <= numRegions());
const auto& p = decay<LhsEval>(fluidState.pressure(phaseIdx));
const auto& T = decay<LhsEval>(fluidState.temperature(phaseIdx));
switch (phaseIdx) {
case oilPhaseIdx: return oilPvt_->saturatedGasDissolutionFactor(regionIdx, T, p);
case gasPhaseIdx: return gasPvt_->saturatedOilVaporizationFactor(regionIdx, T, p);
case waterPhaseIdx: return waterPvt_->saturatedGasDissolutionFactor(regionIdx, T, p,
BlackOil::template getSaltConcentration_<ThisType, FluidState, LhsEval>(fluidState, regionIdx));
default: throw std::logic_error("Unhandled phase index "+std::to_string(phaseIdx));
}
}
template <class FluidState, class LhsEval = typename FluidState::Scalar>
static LhsEval bubblePointPressure(const FluidState& fluidState,
unsigned regionIdx)
{
return saturationPressure(fluidState, oilPhaseIdx, regionIdx);
}
template <class FluidState, class LhsEval = typename FluidState::Scalar>
static LhsEval dewPointPressure(const FluidState& fluidState,
unsigned regionIdx)
{
return saturationPressure(fluidState, gasPhaseIdx, regionIdx);
}
template <class FluidState, class LhsEval = typename FluidState::Scalar>
static LhsEval saturationPressure(const FluidState& fluidState,
unsigned phaseIdx,
unsigned regionIdx)
{
assert(phaseIdx <= numPhases);
assert(regionIdx <= numRegions());
const auto& T = decay<LhsEval>(fluidState.temperature(phaseIdx));
switch (phaseIdx) {
case oilPhaseIdx: return oilPvt_->saturationPressure(regionIdx, T, BlackOil::template getRs_<ThisType, FluidState, LhsEval>(fluidState, regionIdx));
case gasPhaseIdx: return gasPvt_->saturationPressure(regionIdx, T, BlackOil::template getRv_<ThisType, FluidState, LhsEval>(fluidState, regionIdx));
case waterPhaseIdx: return waterPvt_->saturationPressure(regionIdx, T,
BlackOil::template getRsw_<ThisType, FluidState, LhsEval>(fluidState, regionIdx),
BlackOil::template getSaltConcentration_<ThisType, FluidState, LhsEval>(fluidState, regionIdx));
default: throw std::logic_error("Unhandled phase index "+std::to_string(phaseIdx));
}
}
/****************************************
* Auxiliary and convenience methods for the black-oil model
****************************************/
template <class LhsEval>
static LhsEval convertXoGToRs(const LhsEval& XoG, unsigned regionIdx)
{
Scalar rho_oRef = referenceDensity_[regionIdx][oilPhaseIdx];
Scalar rho_gRef = referenceDensity_[regionIdx][gasPhaseIdx];
return XoG/(1.0 - XoG)*(rho_oRef/rho_gRef);
}
template <class LhsEval>
static LhsEval convertXwGToRsw(const LhsEval& XwG, unsigned regionIdx)
{
Scalar rho_wRef = referenceDensity_[regionIdx][waterPhaseIdx];
Scalar rho_gRef = referenceDensity_[regionIdx][gasPhaseIdx];
return XwG/(1.0 - XwG)*(rho_wRef/rho_gRef);
}
template <class LhsEval>
static LhsEval convertXgOToRv(const LhsEval& XgO, unsigned regionIdx)
{
Scalar rho_oRef = referenceDensity_[regionIdx][oilPhaseIdx];
Scalar rho_gRef = referenceDensity_[regionIdx][gasPhaseIdx];
return XgO/(1.0 - XgO)*(rho_gRef/rho_oRef);
}
template <class LhsEval>
static LhsEval convertXgWToRvw(const LhsEval& XgW, unsigned regionIdx)
{
Scalar rho_wRef = referenceDensity_[regionIdx][waterPhaseIdx];
Scalar rho_gRef = referenceDensity_[regionIdx][gasPhaseIdx];
return XgW/(1.0 - XgW)*(rho_gRef/rho_wRef);
}
template <class LhsEval>
static LhsEval convertRsToXoG(const LhsEval& Rs, unsigned regionIdx)
{
Scalar rho_oRef = referenceDensity_[regionIdx][oilPhaseIdx];
Scalar rho_gRef = referenceDensity_[regionIdx][gasPhaseIdx];
const LhsEval& rho_oG = Rs*rho_gRef;
return rho_oG/(rho_oRef + rho_oG);
}
template <class LhsEval>
static LhsEval convertRswToXwG(const LhsEval& Rsw, unsigned regionIdx)
{
Scalar rho_wRef = referenceDensity_[regionIdx][waterPhaseIdx];
Scalar rho_gRef = referenceDensity_[regionIdx][gasPhaseIdx];
const LhsEval& rho_wG = Rsw*rho_gRef;
return rho_wG/(rho_wRef + rho_wG);
}
template <class LhsEval>
static LhsEval convertRvToXgO(const LhsEval& Rv, unsigned regionIdx)
{
Scalar rho_oRef = referenceDensity_[regionIdx][oilPhaseIdx];
Scalar rho_gRef = referenceDensity_[regionIdx][gasPhaseIdx];
const LhsEval& rho_gO = Rv*rho_oRef;
return rho_gO/(rho_gRef + rho_gO);
}
template <class LhsEval>
static LhsEval convertRvwToXgW(const LhsEval& Rvw, unsigned regionIdx)
{
Scalar rho_wRef = referenceDensity_[regionIdx][waterPhaseIdx];
Scalar rho_gRef = referenceDensity_[regionIdx][gasPhaseIdx];
const LhsEval& rho_gW = Rvw*rho_wRef;
return rho_gW/(rho_gRef + rho_gW);
}
template <class LhsEval>
static LhsEval convertXgWToxgW(const LhsEval& XgW, unsigned regionIdx)
{
Scalar MW = molarMass_[regionIdx][waterCompIdx];
Scalar MG = molarMass_[regionIdx][gasCompIdx];
return XgW*MG / (MW*(1 - XgW) + XgW*MG);
}
template <class LhsEval>
static LhsEval convertXwGToxwG(const LhsEval& XwG, unsigned regionIdx)
{
Scalar MW = molarMass_[regionIdx][waterCompIdx];
Scalar MG = molarMass_[regionIdx][gasCompIdx];
return XwG*MW / (MG*(1 - XwG) + XwG*MW);
}
template <class LhsEval>
static LhsEval convertXoGToxoG(const LhsEval& XoG, unsigned regionIdx)
{
Scalar MO = molarMass_[regionIdx][oilCompIdx];
Scalar MG = molarMass_[regionIdx][gasCompIdx];
return XoG*MO / (MG*(1 - XoG) + XoG*MO);
}
template <class LhsEval>
static LhsEval convertxoGToXoG(const LhsEval& xoG, unsigned regionIdx)
{
Scalar MO = molarMass_[regionIdx][oilCompIdx];
Scalar MG = molarMass_[regionIdx][gasCompIdx];
return xoG*MG / (xoG*(MG - MO) + MO);
}
template <class LhsEval>
static LhsEval convertXgOToxgO(const LhsEval& XgO, unsigned regionIdx)
{
Scalar MO = molarMass_[regionIdx][oilCompIdx];
Scalar MG = molarMass_[regionIdx][gasCompIdx];
return XgO*MG / (MO*(1 - XgO) + XgO*MG);
}
template <class LhsEval>
static LhsEval convertxgOToXgO(const LhsEval& xgO, unsigned regionIdx)
{
Scalar MO = molarMass_[regionIdx][oilCompIdx];
Scalar MG = molarMass_[regionIdx][gasCompIdx];
return xgO*MO / (xgO*(MO - MG) + MG);
}
static const GasPvt& gasPvt()
{ return *gasPvt_; }
static const OilPvt& oilPvt()
{ return *oilPvt_; }
static const WaterPvt& waterPvt()
{ return *waterPvt_; }
static Scalar reservoirTemperature(unsigned = 0)
{ return reservoirTemperature_; }
static void setReservoirTemperature(Scalar value)
{ reservoirTemperature_ = value; }
static short activeToCanonicalPhaseIdx(unsigned activePhaseIdx);
static short canonicalToActivePhaseIdx(unsigned phaseIdx);
static Scalar diffusionCoefficient(unsigned compIdx, unsigned phaseIdx, unsigned regionIdx = 0)
{ return diffusionCoefficients_[regionIdx][numPhases*compIdx + phaseIdx]; }
static void setDiffusionCoefficient(Scalar coefficient, unsigned compIdx, unsigned phaseIdx, unsigned regionIdx = 0)
{ diffusionCoefficients_[regionIdx][numPhases*compIdx + phaseIdx] = coefficient ; }
template <class FluidState, class LhsEval = typename FluidState::Scalar, class ParamCacheEval = LhsEval>
static LhsEval diffusionCoefficient(const FluidState& fluidState,
const ParameterCache<ParamCacheEval>& paramCache,
unsigned phaseIdx,
unsigned compIdx)
{
// diffusion is disabled by the user
if(!enableDiffusion())
return 0.0;
// diffusion coefficients are set, and we use them
if(!diffusionCoefficients_.empty()) {
return diffusionCoefficient(compIdx, phaseIdx, paramCache.regionIndex());
}
const auto& p = decay<LhsEval>(fluidState.pressure(phaseIdx));
const auto& T = decay<LhsEval>(fluidState.temperature(phaseIdx));
switch (phaseIdx) {
case oilPhaseIdx: return oilPvt().diffusionCoefficient(T, p, compIdx);
case gasPhaseIdx: return gasPvt().diffusionCoefficient(T, p, compIdx);
case waterPhaseIdx: return waterPvt().diffusionCoefficient(T, p, compIdx);
default: throw std::logic_error("Unhandled phase index "+std::to_string(phaseIdx));
}
}
static void setEnergyEqualEnthalpy(bool enthalpy_eq_energy){
enthalpy_eq_energy_ = enthalpy_eq_energy;
}
static bool enthalpyEqualEnergy(){
return enthalpy_eq_energy_;
}
private:
static void resizeArrays_(std::size_t numRegions);
static Scalar reservoirTemperature_;
static std::shared_ptr<GasPvt> gasPvt_;
static std::shared_ptr<OilPvt> oilPvt_;
static std::shared_ptr<WaterPvt> waterPvt_;
static bool enableDissolvedGas_;
static bool enableDissolvedGasInWater_;
static bool enableVaporizedOil_;
static bool enableVaporizedWater_;
static bool enableDiffusion_;
// HACK for GCC 4.4: the array size has to be specified using the literal value '3'
// here, because GCC 4.4 seems to be unable to determine the number of phases from
// the BlackOil fluid system in the attribute declaration below...
static std::vector<std::array<Scalar, /*numPhases=*/3> > referenceDensity_;
static std::vector<std::array<Scalar, /*numComponents=*/3> > molarMass_;
static std::vector<std::array<Scalar, /*numComponents=*/3 * /*numPhases=*/3> > diffusionCoefficients_;
static std::array<short, numPhases> activeToCanonicalPhaseIdx_;
static std::array<short, numPhases> canonicalToActivePhaseIdx_;
static bool isInitialized_;
static bool useSaturatedTables_;
inline static bool enthalpy_eq_energy_ = false;
};
template <typename T> using BOFS = BlackOilFluidSystem<T, BlackOilDefaultIndexTraits>;
#define DECLARE_INSTANCE(T) \
template<> unsigned char BOFS<T>::numActivePhases_; \
template<> std::array<bool, BOFS<T>::numPhases> BOFS<T>::phaseIsActive_; \
template<> std::array<short, BOFS<T>::numPhases> BOFS<T>::activeToCanonicalPhaseIdx_; \
template<> std::array<short, BOFS<T>::numPhases> BOFS<T>::canonicalToActivePhaseIdx_; \
template<> T BOFS<T>::surfaceTemperature; \
template<> T BOFS<T>::surfacePressure; \
template<> T BOFS<T>::reservoirTemperature_; \
template<> bool BOFS<T>::enableDissolvedGas_; \
template<> bool BOFS<T>::enableDissolvedGasInWater_; \
template<> bool BOFS<T>::enableVaporizedOil_; \
template<> bool BOFS<T>::enableVaporizedWater_; \
template<> bool BOFS<T>::enableDiffusion_; \
template<> std::shared_ptr<OilPvtMultiplexer<T>> BOFS<T>::oilPvt_; \
template<> std::shared_ptr<GasPvtMultiplexer<T>> BOFS<T>::gasPvt_; \
template<> std::shared_ptr<WaterPvtMultiplexer<T>> BOFS<T>::waterPvt_; \
template<> std::vector<std::array<T, 3>> BOFS<T>::referenceDensity_; \
template<> std::vector<std::array<T, 3>> BOFS<T>::molarMass_; \
template<> std::vector<std::array<T, 9>> BOFS<T>::diffusionCoefficients_; \
template<> bool BOFS<T>::isInitialized_; \
template<> bool BOFS<T>::useSaturatedTables_;
DECLARE_INSTANCE(float)
DECLARE_INSTANCE(double)
#undef DECLARE_INSTANCE
} // namespace Opm
#endif
BaseFluidSystem.hpp
The base class for all fluid systems.
BlackOilDefaultIndexTraits.hpp
The class which specifies the default phase and component indices for the black-oil fluid system.
Constants.hpp
A central place for various physical constants occuring in some equations.
GasPvtMultiplexer.hpp
This class represents the Pressure-Volume-Temperature relations of the gas phase in the black-oil mod...
HasMemberGeneratorMacros.hpp
This macro generates a class HasMember_${MEMBER_NAME} which can be used for template specialization.
OPM_GENERATE_HAS_MEMBER
#define OPM_GENERATE_HAS_MEMBER(MEMBER_NAME,...)
This macro generates a class HasMember_${MEMBER_NAME} which can be used for template specialization.
Definition HasMemberGeneratorMacros.hpp:49
MathToolbox.hpp
A traits class which provides basic mathematical functions for arbitrary scalar floating point values...
NullParameterCache.hpp
A parameter cache which does nothing.
OilPvtMultiplexer.hpp
This class represents the Pressure-Volume-Temperature relations of the oil phase in the black-oil mod...
Valgrind.hpp
Some templates to wrap the valgrind client request macros.
WaterPvtMultiplexer.hpp
This class represents the Pressure-Volume-Temperature relations of the water phase in the black-oil m...
Opm::BaseFluidSystem
The base class for all fluid systems.
Definition BaseFluidSystem.hpp:43
Opm::BaseFluidSystem::Scalar
ScalarT Scalar
The type used for scalar quantities.
Definition BaseFluidSystem.hpp:48
Opm::BlackOilFluidSystem
A fluid system which uses the black-oil model assumptions to calculate termodynamically meaningful qu...
Definition BlackOilFluidSystem.hpp:161
Opm::BlackOilFluidSystem::waterCompIdx
static constexpr unsigned waterCompIdx
Index of the water component.
Definition BlackOilFluidSystem.hpp:389
Opm::BlackOilFluidSystem::numActivePhases
static unsigned numActivePhases()
Returns the number of active fluid phases (i.e., usually three)
Definition BlackOilFluidSystem.hpp:399
Opm::BlackOilFluidSystem::diffusionCoefficient
static Scalar diffusionCoefficient(unsigned compIdx, unsigned phaseIdx, unsigned regionIdx=0)
Calculate the binary molecular diffusion coefficient for a component in a fluid phase [mol^2 * s / (k...
Definition BlackOilFluidSystem.hpp:1658
Opm::BlackOilFluidSystem::convertXoGToRs
static LhsEval convertXoGToRs(const LhsEval &XoG, unsigned regionIdx)
Convert the mass fraction of the gas component in the oil phase to the corresponding gas dissolution ...
Definition BlackOilFluidSystem.hpp:1431
Opm::BlackOilFluidSystem::convertRsToXoG
static LhsEval convertRsToXoG(const LhsEval &Rs, unsigned regionIdx)
Convert a gas dissolution factor to the the corresponding mass fraction of the gas component in the o...
Definition BlackOilFluidSystem.hpp:1484
Opm::BlackOilFluidSystem::numComponents
static constexpr unsigned numComponents
Number of chemical species in the fluid system.
Definition BlackOilFluidSystem.hpp:384
Opm::BlackOilFluidSystem::convertRvwToXgW
static LhsEval convertRvwToXgW(const LhsEval &Rvw, unsigned regionIdx)
Convert an water vaporization factor to the corresponding mass fraction of the water component in the...
Definition BlackOilFluidSystem.hpp:1526
Opm::BlackOilFluidSystem::convertXwGToxwG
static LhsEval convertXwGToxwG(const LhsEval &XwG, unsigned regionIdx)
Convert a gas mass fraction in the water phase the corresponding mole fraction.
Definition BlackOilFluidSystem.hpp:1551
Opm::BlackOilFluidSystem::setUseSaturatedTables
static void setUseSaturatedTables(bool yesno)
Specify whether the saturated tables should be used.
Definition BlackOilFluidSystem.hpp:295
Opm::BlackOilFluidSystem::saturatedInverseFormationVolumeFactor
static LhsEval saturatedInverseFormationVolumeFactor(const FluidState &fluidState, unsigned phaseIdx, unsigned regionIdx)
Returns the formation volume factor of a "saturated" fluid phase.
Definition BlackOilFluidSystem.hpp:859
Opm::BlackOilFluidSystem::convertXoGToxoG
static LhsEval convertXoGToxoG(const LhsEval &XoG, unsigned regionIdx)
Convert a gas mass fraction in the oil phase the corresponding mole fraction.
Definition BlackOilFluidSystem.hpp:1563
Opm::BlackOilFluidSystem::viscosity
static LhsEval viscosity(const FluidState &fluidState, unsigned phaseIdx, unsigned regionIdx)
Calculate the dynamic viscosity of a fluid phase [Pa*s].
Definition BlackOilFluidSystem.hpp:1003
Opm::BlackOilFluidSystem::initEnd
static void initEnd()
Finish initializing the black oil fluid system.
Definition BlackOilFluidSystem.cpp:267
Opm::BlackOilFluidSystem::reservoirTemperature
static Scalar reservoirTemperature(unsigned=0)
Set the temperature of the reservoir.
Definition BlackOilFluidSystem.hpp:1642
Opm::BlackOilFluidSystem::convertRswToXwG
static LhsEval convertRswToXwG(const LhsEval &Rsw, unsigned regionIdx)
Convert a gas dissolution factor to the the corresponding mass fraction of the gas component in the w...
Definition BlackOilFluidSystem.hpp:1498
Opm::BlackOilFluidSystem::phaseIsActive
static bool phaseIsActive(unsigned phaseIdx)
Returns whether a fluid phase is active.
Definition BlackOilFluidSystem.hpp:403
Opm::BlackOilFluidSystem::setEnableDiffusion
static void setEnableDiffusion(bool yesno)
Specify whether the fluid system should consider diffusion.
Definition BlackOilFluidSystem.hpp:287
Opm::BlackOilFluidSystem::bubblePointPressure
static LhsEval bubblePointPressure(const FluidState &fluidState, unsigned regionIdx)
Returns the bubble point pressure $P_b$ using the current Rs.
Definition BlackOilFluidSystem.hpp:1376
Opm::BlackOilFluidSystem::density
static LhsEval density(const FluidState &fluidState, unsigned phaseIdx, unsigned regionIdx)
Calculate the density [kg/m^3] of a fluid phase.
Definition BlackOilFluidSystem.hpp:560
Opm::BlackOilFluidSystem::saturatedDensity
static LhsEval saturatedDensity(const FluidState &fluidState, unsigned phaseIdx, unsigned regionIdx)
Compute the density of a saturated fluid phase.
Definition BlackOilFluidSystem.hpp:658
Opm::BlackOilFluidSystem::viscosity
static LhsEval viscosity(const FluidState &fluidState, const ParameterCache< ParamCacheEval > &paramCache, unsigned phaseIdx)
Calculate the dynamic viscosity of a fluid phase [Pa*s].
Definition BlackOilFluidSystem.hpp:536
Opm::BlackOilFluidSystem::isIdealMixture
static bool isIdealMixture(unsigned)
Returns true if and only if a fluid phase is assumed to be an ideal mixture.
Definition BlackOilFluidSystem.hpp:423
Opm::BlackOilFluidSystem::enableVaporizedWater
static bool enableVaporizedWater()
Returns whether the fluid system should consider that the water component can dissolve in the gas pha...
Definition BlackOilFluidSystem.hpp:484
Opm::BlackOilFluidSystem::numPhases
static constexpr unsigned numPhases
Number of fluid phases in the fluid system.
Definition BlackOilFluidSystem.hpp:354
Opm::BlackOilFluidSystem::setWaterPvt
static void setWaterPvt(std::shared_ptr< WaterPvt > pvtObj)
Set the pressure-volume-saturation (PVT) relations for the water phase.
Definition BlackOilFluidSystem.hpp:313
Opm::BlackOilFluidSystem::initBegin
static void initBegin(std::size_t numPvtRegions)
Begin the initialization of the black oil fluid system.
Definition BlackOilFluidSystem.cpp:229
Opm::BlackOilFluidSystem::setReservoirTemperature
static void setReservoirTemperature(Scalar value)
Return the temperature of the reservoir.
Definition BlackOilFluidSystem.hpp:1650
Opm::BlackOilFluidSystem::setEnableDissolvedGasInWater
static void setEnableDissolvedGasInWater(bool yesno)
Specify whether the fluid system should consider that the gas component can dissolve in the water pha...
Definition BlackOilFluidSystem.hpp:280
Opm::BlackOilFluidSystem::saturatedDissolutionFactor
static LhsEval saturatedDissolutionFactor(const FluidState &fluidState, unsigned phaseIdx, unsigned regionIdx, const LhsEval &maxOilSaturation)
Returns the dissolution factor of a saturated fluid phase.
Definition BlackOilFluidSystem.hpp:1321
Opm::BlackOilFluidSystem::enthalpy
static LhsEval enthalpy(const FluidState &fluidState, unsigned phaseIdx, unsigned regionIdx)
Given a phase's composition, temperature, pressure and density, calculate its specific enthalpy [J/kg...
Definition BlackOilFluidSystem.hpp:1274
Opm::BlackOilFluidSystem::oilCompIdx
static constexpr unsigned oilCompIdx
Index of the oil component.
Definition BlackOilFluidSystem.hpp:387
Opm::BlackOilFluidSystem::isLiquid
static bool isLiquid(unsigned phaseIdx)
Return whether a phase is liquid.
Definition BlackOilFluidSystem.hpp:373
Opm::BlackOilFluidSystem::enthalpy
static LhsEval enthalpy(const FluidState &fluidState, const ParameterCache< ParamCacheEval > &paramCache, unsigned phaseIdx)
Given a phase's composition, temperature, pressure and density, calculate its specific enthalpy [J/kg...
Definition BlackOilFluidSystem.hpp:543
Opm::BlackOilFluidSystem::fugacityCoefficient
static LhsEval fugacityCoefficient(const FluidState &fluidState, unsigned phaseIdx, unsigned compIdx, unsigned regionIdx)
Calculate the fugacity coefficient [Pa] of an individual component in a fluid phase.
Definition BlackOilFluidSystem.hpp:881
Opm::BlackOilFluidSystem::convertxoGToXoG
static LhsEval convertxoGToXoG(const LhsEval &xoG, unsigned regionIdx)
Convert a gas mole fraction in the oil phase the corresponding mass fraction.
Definition BlackOilFluidSystem.hpp:1575
Opm::BlackOilFluidSystem::molarMass
static Scalar molarMass(unsigned compIdx, unsigned regionIdx=0)
Return the molar mass of a component in [kg/mol].
Definition BlackOilFluidSystem.hpp:419
Opm::BlackOilFluidSystem::saturatedDissolutionFactor
static LhsEval saturatedDissolutionFactor(const FluidState &fluidState, unsigned phaseIdx, unsigned regionIdx)
Returns the dissolution factor of a saturated fluid phase.
Definition BlackOilFluidSystem.hpp:1352
Opm::BlackOilFluidSystem::dewPointPressure
static LhsEval dewPointPressure(const FluidState &fluidState, unsigned regionIdx)
Returns the dew point pressure $P_d$ using the current Rv.
Definition BlackOilFluidSystem.hpp:1387
Opm::BlackOilFluidSystem::saturationPressure
static LhsEval saturationPressure(const FluidState &fluidState, unsigned phaseIdx, unsigned regionIdx)
Returns the saturation pressure of a given phase [Pa] depending on its composition.
Definition BlackOilFluidSystem.hpp:1404
Opm::BlackOilFluidSystem::convertXwGToRsw
static LhsEval convertXwGToRsw(const LhsEval &XwG, unsigned regionIdx)
Convert the mass fraction of the gas component in the water phase to the corresponding gas dissolutio...
Definition BlackOilFluidSystem.hpp:1444
Opm::BlackOilFluidSystem::componentName
static std::string_view componentName(unsigned compIdx)
Return the human readable name of a component.
Definition BlackOilFluidSystem.cpp:362
Opm::BlackOilFluidSystem::convertXgOToxgO
static LhsEval convertXgOToxgO(const LhsEval &XgO, unsigned regionIdx)
Convert a oil mass fraction in the gas phase the corresponding mole fraction.
Definition BlackOilFluidSystem.hpp:1587
Opm::BlackOilFluidSystem::diffusionCoefficient
static LhsEval diffusionCoefficient(const FluidState &fluidState, const ParameterCache< ParamCacheEval > &paramCache, unsigned phaseIdx, unsigned compIdx)
Calculate the binary molecular diffusion coefficient for a component in a fluid phase [mol^2 * s / (k...
Definition BlackOilFluidSystem.hpp:1669
Opm::BlackOilFluidSystem::saturatedVaporizationFactor
static LhsEval saturatedVaporizationFactor(const FluidState &fluidState, unsigned phaseIdx, unsigned regionIdx)
Returns the water vaporization factor of saturated phase.
Definition BlackOilFluidSystem.hpp:1295
Opm::BlackOilFluidSystem::enableDissolvedGas
static bool enableDissolvedGas()
Returns whether the fluid system should consider that the gas component can dissolve in the oil phase...
Definition BlackOilFluidSystem.hpp:456
Opm::BlackOilFluidSystem::referenceDensity
static Scalar referenceDensity(unsigned phaseIdx, unsigned regionIdx)
Returns the density of a fluid phase at surface pressure [kg/m^3].
Definition BlackOilFluidSystem.hpp:508
Opm::BlackOilFluidSystem::surfaceTemperature
static Scalar surfaceTemperature
The temperature at the surface.
Definition BlackOilFluidSystem.hpp:367
Opm::BlackOilFluidSystem::setOilPvt
static void setOilPvt(std::shared_ptr< OilPvt > pvtObj)
Set the pressure-volume-saturation (PVT) relations for the oil phase.
Definition BlackOilFluidSystem.hpp:307
Opm::BlackOilFluidSystem::waterPhaseIdx
static constexpr unsigned waterPhaseIdx
Index of the water phase.
Definition BlackOilFluidSystem.hpp:357
Opm::BlackOilFluidSystem::useSaturatedTables
static bool useSaturatedTables()
Returns whether the saturated tables should be used.
Definition BlackOilFluidSystem.hpp:500
Opm::BlackOilFluidSystem::convertxgOToXgO
static LhsEval convertxgOToXgO(const LhsEval &xgO, unsigned regionIdx)
Convert a oil mole fraction in the gas phase the corresponding mass fraction.
Definition BlackOilFluidSystem.hpp:1599
Opm::BlackOilFluidSystem::inverseFormationVolumeFactor
static LhsEval inverseFormationVolumeFactor(const FluidState &fluidState, unsigned phaseIdx, unsigned regionIdx)
Returns the formation volume factor of an "undersaturated" fluid phase.
Definition BlackOilFluidSystem.hpp:759
Opm::BlackOilFluidSystem::convertXgWToxgW
static LhsEval convertXgWToxgW(const LhsEval &XgW, unsigned regionIdx)
Convert a water mass fraction in the gas phase the corresponding mole fraction.
Definition BlackOilFluidSystem.hpp:1539
Opm::BlackOilFluidSystem::gasPhaseIdx
static constexpr unsigned gasPhaseIdx
Index of the gas phase.
Definition BlackOilFluidSystem.hpp:361
Opm::BlackOilFluidSystem::setEnableDissolvedGas
static void setEnableDissolvedGas(bool yesno)
Specify whether the fluid system should consider that the gas component can dissolve in the oil phase...
Definition BlackOilFluidSystem.hpp:253
Opm::BlackOilFluidSystem::convertXgOToRv
static LhsEval convertXgOToRv(const LhsEval &XgO, unsigned regionIdx)
Convert the mass fraction of the oil component in the gas phase to the corresponding oil vaporization...
Definition BlackOilFluidSystem.hpp:1457
Opm::BlackOilFluidSystem::fugacityCoefficient
static LhsEval fugacityCoefficient(const FluidState &fluidState, const ParameterCache< ParamCacheEval > &paramCache, unsigned phaseIdx, unsigned compIdx)
Calculate the fugacity coefficient [Pa] of an individual component in a fluid phase.
Definition BlackOilFluidSystem.hpp:523
Opm::BlackOilFluidSystem::density
static LhsEval density(const FluidState &fluidState, const ParameterCache< ParamCacheEval > &paramCache, unsigned phaseIdx)
Calculate the density [kg/m^3] of a fluid phase.
Definition BlackOilFluidSystem.hpp:516
Opm::BlackOilFluidSystem::gasCompIdx
static constexpr unsigned gasCompIdx
Index of the gas component.
Definition BlackOilFluidSystem.hpp:391
Opm::BlackOilFluidSystem::convertRvToXgO
static LhsEval convertRvToXgO(const LhsEval &Rv, unsigned regionIdx)
Convert an oil vaporization factor to the corresponding mass fraction of the oil component in the gas...
Definition BlackOilFluidSystem.hpp:1512
Opm::BlackOilFluidSystem::waterPvt
static const WaterPvt & waterPvt()
Return a reference to the low-level object which calculates the water phase quantities.
Definition BlackOilFluidSystem.hpp:1634
Opm::BlackOilFluidSystem::enableVaporizedOil
static bool enableVaporizedOil()
Returns whether the fluid system should consider that the oil component can dissolve in the gas phase...
Definition BlackOilFluidSystem.hpp:475
Opm::BlackOilFluidSystem::isIdealGas
static bool isIdealGas(unsigned)
Returns true if and only if a fluid phase is assumed to be an ideal gas.
Definition BlackOilFluidSystem.hpp:435
Opm::BlackOilFluidSystem::solventComponentIndex
static unsigned solventComponentIndex(unsigned phaseIdx)
returns the index of "primary" component of a phase (solvent)
Definition BlackOilFluidSystem.cpp:323
Opm::BlackOilFluidSystem::surfacePressure
static Scalar surfacePressure
The pressure at the surface.
Definition BlackOilFluidSystem.hpp:364
Opm::BlackOilFluidSystem::setEnableVaporizedWater
static void setEnableVaporizedWater(bool yesno)
Specify whether the fluid system should consider that the water component can dissolve in the gas pha...
Definition BlackOilFluidSystem.hpp:271
Opm::BlackOilFluidSystem::oilPhaseIdx
static constexpr unsigned oilPhaseIdx
Index of the oil phase.
Definition BlackOilFluidSystem.hpp:359
Opm::BlackOilFluidSystem::oilPvt
static const OilPvt & oilPvt()
Return a reference to the low-level object which calculates the oil phase quantities.
Definition BlackOilFluidSystem.hpp:1624
Opm::BlackOilFluidSystem::enableDissolvedGasInWater
static bool enableDissolvedGasInWater()
Returns whether the fluid system should consider that the gas component can dissolve in the water pha...
Definition BlackOilFluidSystem.hpp:466
Opm::BlackOilFluidSystem::soluteComponentIndex
static unsigned soluteComponentIndex(unsigned phaseIdx)
returns the index of "secondary" component of a phase (solute)
Definition BlackOilFluidSystem.cpp:340
Opm::BlackOilFluidSystem::enableDiffusion
static bool enableDiffusion()
Returns whether the fluid system should consider diffusion.
Definition BlackOilFluidSystem.hpp:492
Opm::BlackOilFluidSystem::convertXgWToRvw
static LhsEval convertXgWToRvw(const LhsEval &XgW, unsigned regionIdx)
Convert the mass fraction of the water component in the gas phase to the corresponding water vaporiza...
Definition BlackOilFluidSystem.hpp:1470
Opm::BlackOilFluidSystem::setReferenceDensities
static void setReferenceDensities(Scalar rhoOil, Scalar rhoWater, Scalar rhoGas, unsigned regionIdx)
Initialize the values of the reference densities.
Definition BlackOilFluidSystem.cpp:256
Opm::BlackOilFluidSystem::numRegions
static std::size_t numRegions()
Returns the number of PVT regions which are considered.
Definition BlackOilFluidSystem.hpp:447
Opm::BlackOilFluidSystem::setEnableVaporizedOil
static void setEnableVaporizedOil(bool yesno)
Specify whether the fluid system should consider that the oil component can dissolve in the gas phase...
Definition BlackOilFluidSystem.hpp:262
Opm::BlackOilFluidSystem::phaseName
static std::string_view phaseName(unsigned phaseIdx)
Return the human readable name of a fluid phase.
Definition BlackOilFluidSystem.cpp:306
Opm::BlackOilFluidSystem::setDiffusionCoefficient
static void setDiffusionCoefficient(Scalar coefficient, unsigned compIdx, unsigned phaseIdx, unsigned regionIdx=0)
Definition BlackOilFluidSystem.hpp:1662
Opm::BlackOilFluidSystem::gasPvt
static const GasPvt & gasPvt()
Return a reference to the low-level object which calculates the gas phase quantities.
Definition BlackOilFluidSystem.hpp:1614
Opm::BlackOilFluidSystem::isCompressible
static bool isCompressible(unsigned)
Returns true if and only if a fluid phase is assumed to be compressible.
Definition BlackOilFluidSystem.hpp:431
Opm::BlackOilFluidSystem::setGasPvt
static void setGasPvt(std::shared_ptr< GasPvt > pvtObj)
Set the pressure-volume-saturation (PVT) relations for the gas phase.
Definition BlackOilFluidSystem.hpp:301
Opm::GasPvtMultiplexer
This class represents the Pressure-Volume-Temperature relations of the gas phase in the black-oil mod...
Definition GasPvtMultiplexer.hpp:110
Opm::GasPvtMultiplexer::diffusionCoefficient
Evaluation diffusionCoefficient(const Evaluation &temperature, const Evaluation &pressure, unsigned compIdx) const
Calculate the binary molecular diffusion coefficient for a component in a fluid phase [mol^2 * s / (k...
Definition GasPvtMultiplexer.hpp:268
Opm::NullParameterCache
A parameter cache which does nothing.
Definition NullParameterCache.hpp:40
Opm::OilPvtMultiplexer
This class represents the Pressure-Volume-Temperature relations of the oil phase in the black-oil mod...
Definition OilPvtMultiplexer.hpp:105
Opm::OilPvtMultiplexer::diffusionCoefficient
Evaluation diffusionCoefficient(const Evaluation &temperature, const Evaluation &pressure, unsigned compIdx) const
Calculate the binary molecular diffusion coefficient for a component in a fluid phase [mol^2 * s / (k...
Definition OilPvtMultiplexer.hpp:240
Opm::WaterPvtMultiplexer
This class represents the Pressure-Volume-Temperature relations of the water phase in the black-oil m...
Definition WaterPvtMultiplexer.hpp:90
Opm::WaterPvtMultiplexer::diffusionCoefficient
Evaluation diffusionCoefficient(const Evaluation &temperature, const Evaluation &pressure, unsigned compIdx) const
Calculate the binary molecular diffusion coefficient for a component in a fluid phase [mol^2 * s / (k...
Definition WaterPvtMultiplexer.hpp:231
Opm
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30
Opm::BlackOilFluidSystem::ParameterCache
The type of the fluid system's parameter cache.
Definition BlackOilFluidSystem.hpp:172
Opm::BlackOilFluidSystem::ParameterCache::assignPersistentData
void assignPersistentData(const OtherCache &other)
Copy the data which is not dependent on the type of the Scalars from another parameter cache.
Definition BlackOilFluidSystem.hpp:190
Opm::BlackOilFluidSystem::ParameterCache::setRegionIndex
void setRegionIndex(unsigned val)
Set the index of the region which should be used to determine the thermodynamic properties.
Definition BlackOilFluidSystem.hpp:213
Opm::BlackOilFluidSystem::ParameterCache::regionIndex
unsigned regionIndex() const
Return the index of the region which should be used to determine the thermodynamic properties.
Definition BlackOilFluidSystem.hpp:203