Loading...
Searching...
No Matches
TwoPhaseImmiscibleFluidSystem.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_TWO_PHASE_IMMISCIBLE_FLUID_SYSTEM_HPP
#define OPM_TWO_PHASE_IMMISCIBLE_FLUID_SYSTEM_HPP
#include <cassert>
#include <limits>
#include <string_view>
#include <opm/material/fluidsystems/LiquidPhase.hpp>
#include <opm/material/fluidsystems/GasPhase.hpp>
#include <opm/material/fluidstates/ImmiscibleFluidState.hpp>
#include "BaseFluidSystem.hpp"
#include "NullParameterCache.hpp"
namespace Opm {
template <class Scalar, class WettingPhase, class NonwettingPhase>
class TwoPhaseImmiscibleFluidSystem
: public BaseFluidSystem<Scalar, TwoPhaseImmiscibleFluidSystem<Scalar, WettingPhase, NonwettingPhase> >
{
// do not try to instanciate this class, it has only static members!
TwoPhaseImmiscibleFluidSystem()
{}
typedef TwoPhaseImmiscibleFluidSystem<Scalar, WettingPhase, NonwettingPhase> ThisType;
typedef BaseFluidSystem<Scalar, ThisType> Base;
public:
template <class Evaluation>
struct ParameterCache : public NullParameterCache<Evaluation>
{};
/****************************************
* Fluid phase related static parameters
****************************************/
static const int numPhases = 2;
static const int wettingPhaseIdx = 0;
static const int nonWettingPhaseIdx = 1;
static std::string_view phaseName(unsigned phaseIdx)
{
assert(phaseIdx < numPhases);
static const std::string_view name[] = {
"wetting",
"nonwetting"
};
return name[phaseIdx];
}
static bool isLiquid(unsigned phaseIdx)
{
//assert(0 <= phaseIdx && phaseIdx < numPhases);
return
(phaseIdx == wettingPhaseIdx)
? WettingPhase::isLiquid()
: NonwettingPhase::isLiquid();
}
static bool isCompressible(unsigned phaseIdx)
{
//assert(0 <= phaseIdx && phaseIdx < numPhases);
return
(phaseIdx == wettingPhaseIdx)
? WettingPhase::isCompressible()
: NonwettingPhase::isCompressible();
}
static bool isIdealGas(unsigned phaseIdx)
{
//assert(0 <= phaseIdx && phaseIdx < numPhases);
// let the fluids decide
return
(phaseIdx == wettingPhaseIdx)
? WettingPhase::isIdealGas()
: NonwettingPhase::isIdealGas();
}
static bool isIdealMixture(unsigned /*phaseIdx*/)
{
//assert(0 <= phaseIdx && phaseIdx < numPhases);
// we assume immisibility
return true;
}
/****************************************
* Component related static parameters
****************************************/
static const int numComponents = 2;
static const int wettingCompIdx = 0;
static const int nonWettingCompIdx = 1;
static std::string_view componentName(unsigned compIdx)
{
assert(compIdx < numComponents);
if (compIdx == wettingCompIdx)
return WettingPhase::name();
return NonwettingPhase::name();
}
static Scalar molarMass(unsigned compIdx)
{
//assert(0 <= compIdx && compIdx < numComponents);
// let the fluids decide
return
(compIdx == wettingCompIdx)
? WettingPhase::molarMass()
: NonwettingPhase::molarMass();
}
static Scalar criticalTemperature(unsigned compIdx)
{
//assert(0 <= compIdx && compIdx < numComponents);
// let the fluids decide
return
(compIdx == wettingCompIdx)
? WettingPhase::criticalTemperature()
: NonwettingPhase::criticalTemperature();
}
static Scalar criticalPressure(unsigned compIdx)
{
//assert(0 <= compIdx && compIdx < numComponents);
// let the fluids decide
return
(compIdx == wettingCompIdx)
? WettingPhase::criticalPressure()
: NonwettingPhase::criticalPressure();
}
static Scalar acentricFactor(unsigned compIdx)
{
//assert(0 <= compIdx && compIdx < numComponents);
// let the fluids decide
return
(compIdx == wettingCompIdx)
? WettingPhase::acentricFactor()
: NonwettingPhase::acentricFactor();
}
/****************************************
* thermodynamic relations
****************************************/
static void init()
{
// two gaseous phases at once do not make sense physically!
// (But two liquids are fine)
assert(WettingPhase::isLiquid() || NonwettingPhase::isLiquid());
}
template <class FluidState, class LhsEval = typename FluidState::Scalar, class ParamCacheEval = LhsEval>
static LhsEval density(const FluidState& fluidState,
const ParameterCache<ParamCacheEval>& /*paramCache*/,
unsigned phaseIdx)
{
assert(phaseIdx < numPhases);
const auto& temperature = decay<LhsEval>(fluidState.temperature(phaseIdx));
const auto& pressure = decay<LhsEval>(fluidState.pressure(phaseIdx));
if (phaseIdx == wettingPhaseIdx)
return WettingPhase::density(temperature, pressure);
return NonwettingPhase::density(temperature, pressure);
}
template <class FluidState, class LhsEval = typename FluidState::Scalar, class ParamCacheEval = LhsEval>
static LhsEval viscosity(const FluidState& fluidState,
const ParameterCache<ParamCacheEval>& /*paramCache*/,
unsigned phaseIdx)
{
assert(phaseIdx < numPhases);
const auto& temperature = decay<LhsEval>(fluidState.temperature(phaseIdx));
const auto& pressure = decay<LhsEval>(fluidState.pressure(phaseIdx));
if (phaseIdx == wettingPhaseIdx)
return WettingPhase::viscosity(temperature, pressure);
return NonwettingPhase::viscosity(temperature, pressure);
}
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)
{
assert(phaseIdx < numPhases);
assert(compIdx < numComponents);
if (phaseIdx == compIdx)
// TODO (?): calculate the real fugacity coefficient of
// the component in the fluid. Probably that's not worth
// the effort, since the fugacity coefficient of the other
// component is infinite anyway...
return 1.0;
return std::numeric_limits<Scalar>::infinity();
}
template <class FluidState, class LhsEval = typename FluidState::Scalar, class ParamCacheEval = LhsEval>
static LhsEval enthalpy(const FluidState& fluidState,
const ParameterCache<ParamCacheEval>& /*paramCache*/,
unsigned phaseIdx)
{
assert(phaseIdx < numPhases);
const auto& temperature = decay<LhsEval>(fluidState.temperature(phaseIdx));
const auto& pressure = decay<LhsEval>(fluidState.pressure(phaseIdx));
if (phaseIdx == wettingPhaseIdx)
return WettingPhase::enthalpy(temperature, pressure);
return NonwettingPhase::enthalpy(temperature, pressure);
}
template <class FluidState, class LhsEval = typename FluidState::Scalar, class ParamCacheEval = LhsEval>
static LhsEval thermalConductivity(const FluidState& fluidState,
const ParameterCache<ParamCacheEval>& /*paramCache*/,
unsigned phaseIdx)
{
assert(phaseIdx < numPhases);
const auto& temperature = decay<LhsEval>(fluidState.temperature(phaseIdx));
const auto& pressure = decay<LhsEval>(fluidState.pressure(phaseIdx));
if (phaseIdx == wettingPhaseIdx)
return WettingPhase::thermalConductivity(temperature, pressure);
return NonwettingPhase::thermalConductivity(temperature, pressure);
}
template <class FluidState, class LhsEval = typename FluidState::Scalar, class ParamCacheEval = LhsEval>
static LhsEval heatCapacity(const FluidState& fluidState,
const ParameterCache<ParamCacheEval>& /*paramCache*/,
unsigned phaseIdx)
{
assert(phaseIdx < numPhases);
const auto& temperature = decay<LhsEval>(fluidState.temperature(phaseIdx));
const auto& pressure = decay<LhsEval>(fluidState.pressure(phaseIdx));
if (phaseIdx == wettingPhaseIdx)
return WettingPhase::heatCapacity(temperature, pressure);
return NonwettingPhase::heatCapacity(temperature, pressure);
}
};
} // namespace Opm
#endif
BaseFluidSystem.hpp
The base class for all fluid systems.
GasPhase.hpp
Represents the gas phase of a single (pseudo-) component.
ImmiscibleFluidState.hpp
Represents all relevant thermodynamic quantities of a multi-phase, multi-component fluid system assum...
LiquidPhase.hpp
Represents the liquid phase of a single (pseudo-) component.
NullParameterCache.hpp
A parameter cache which does nothing.
Opm::BaseFluidSystem
The base class for all fluid systems.
Definition BaseFluidSystem.hpp:43
Opm::BaseFluidSystem< Scalar, TwoPhaseImmiscibleFluidSystem< Scalar, WettingPhase, NonwettingPhase > >::Scalar
Scalar Scalar
Definition BaseFluidSystem.hpp:48
Opm::TwoPhaseImmiscibleFluidSystem::isIdealMixture
static bool isIdealMixture(unsigned)
Returns true if and only if a fluid phase is assumed to be an ideal mixture.
Definition TwoPhaseImmiscibleFluidSystem.hpp:130
Opm::TwoPhaseImmiscibleFluidSystem::acentricFactor
static Scalar acentricFactor(unsigned compIdx)
The acentric factor of a component [].
Definition TwoPhaseImmiscibleFluidSystem.hpp:201
Opm::TwoPhaseImmiscibleFluidSystem::thermalConductivity
static LhsEval thermalConductivity(const FluidState &fluidState, const ParameterCache< ParamCacheEval > &, unsigned phaseIdx)
Thermal conductivity of a fluid phase [W/(m K)].
Definition TwoPhaseImmiscibleFluidSystem.hpp:289
Opm::TwoPhaseImmiscibleFluidSystem::init
static void init()
Initialize the fluid system's static parameters.
Definition TwoPhaseImmiscibleFluidSystem.hpp:216
Opm::TwoPhaseImmiscibleFluidSystem::isLiquid
static bool isLiquid(unsigned phaseIdx)
Return whether a phase is liquid.
Definition TwoPhaseImmiscibleFluidSystem.hpp:97
Opm::TwoPhaseImmiscibleFluidSystem::fugacityCoefficient
static LhsEval fugacityCoefficient(const FluidState &, const ParameterCache< ParamCacheEval > &, unsigned phaseIdx, unsigned compIdx)
Calculate the fugacity coefficient [Pa] of an individual component in a fluid phase.
Definition TwoPhaseImmiscibleFluidSystem.hpp:255
Opm::TwoPhaseImmiscibleFluidSystem::molarMass
static Scalar molarMass(unsigned compIdx)
Return the molar mass of a component in [kg/mol].
Definition TwoPhaseImmiscibleFluidSystem.hpp:161
Opm::TwoPhaseImmiscibleFluidSystem::componentName
static std::string_view componentName(unsigned compIdx)
Return the human readable name of a component.
Definition TwoPhaseImmiscibleFluidSystem.hpp:151
Opm::TwoPhaseImmiscibleFluidSystem::isIdealGas
static bool isIdealGas(unsigned phaseIdx)
Returns true if and only if a fluid phase is assumed to be an ideal gas.
Definition TwoPhaseImmiscibleFluidSystem.hpp:118
Opm::TwoPhaseImmiscibleFluidSystem::numPhases
static const int numPhases
Number of fluid phases in the fluid system.
Definition TwoPhaseImmiscibleFluidSystem.hpp:77
Opm::TwoPhaseImmiscibleFluidSystem::wettingCompIdx
static const int wettingCompIdx
Index of the wetting phase's component.
Definition TwoPhaseImmiscibleFluidSystem.hpp:146
Opm::TwoPhaseImmiscibleFluidSystem::nonWettingCompIdx
static const int nonWettingCompIdx
Index of the non-wetting phase's component.
Definition TwoPhaseImmiscibleFluidSystem.hpp:148
Opm::TwoPhaseImmiscibleFluidSystem::enthalpy
static LhsEval enthalpy(const FluidState &fluidState, const ParameterCache< ParamCacheEval > &, unsigned phaseIdx)
Given a phase's composition, temperature, pressure and density, calculate its specific enthalpy [J/kg...
Definition TwoPhaseImmiscibleFluidSystem.hpp:274
Opm::TwoPhaseImmiscibleFluidSystem::viscosity
static LhsEval viscosity(const FluidState &fluidState, const ParameterCache< ParamCacheEval > &, unsigned phaseIdx)
Calculate the dynamic viscosity of a fluid phase [Pa*s].
Definition TwoPhaseImmiscibleFluidSystem.hpp:240
Opm::TwoPhaseImmiscibleFluidSystem::phaseName
static std::string_view phaseName(unsigned phaseIdx)
Return the human readable name of a fluid phase.
Definition TwoPhaseImmiscibleFluidSystem.hpp:85
Opm::TwoPhaseImmiscibleFluidSystem::criticalTemperature
static Scalar criticalTemperature(unsigned compIdx)
Critical temperature of a component [K].
Definition TwoPhaseImmiscibleFluidSystem.hpp:175
Opm::TwoPhaseImmiscibleFluidSystem::heatCapacity
static LhsEval heatCapacity(const FluidState &fluidState, const ParameterCache< ParamCacheEval > &, unsigned phaseIdx)
Specific isobaric heat capacity of a fluid phase [J/kg].
Definition TwoPhaseImmiscibleFluidSystem.hpp:304
Opm::TwoPhaseImmiscibleFluidSystem::nonWettingPhaseIdx
static const int nonWettingPhaseIdx
Index of the non-wetting phase.
Definition TwoPhaseImmiscibleFluidSystem.hpp:82
Opm::TwoPhaseImmiscibleFluidSystem::numComponents
static const int numComponents
Number of chemical species in the fluid system.
Definition TwoPhaseImmiscibleFluidSystem.hpp:143
Opm::TwoPhaseImmiscibleFluidSystem::density
static LhsEval density(const FluidState &fluidState, const ParameterCache< ParamCacheEval > &, unsigned phaseIdx)
Calculate the density [kg/m^3] of a fluid phase.
Definition TwoPhaseImmiscibleFluidSystem.hpp:225
Opm::TwoPhaseImmiscibleFluidSystem::wettingPhaseIdx
static const int wettingPhaseIdx
Index of the wetting phase.
Definition TwoPhaseImmiscibleFluidSystem.hpp:80
Opm::TwoPhaseImmiscibleFluidSystem::criticalPressure
static Scalar criticalPressure(unsigned compIdx)
Critical pressure of a component [Pa].
Definition TwoPhaseImmiscibleFluidSystem.hpp:188
Opm::TwoPhaseImmiscibleFluidSystem::isCompressible
static bool isCompressible(unsigned phaseIdx)
Returns true if and only if a fluid phase is assumed to be compressible.
Definition TwoPhaseImmiscibleFluidSystem.hpp:107
Opm
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30
Opm::TwoPhaseImmiscibleFluidSystem::ParameterCache
Definition TwoPhaseImmiscibleFluidSystem.hpp:70