Loading...
Searching...
No Matches
SinglePhaseFluidSystem.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_SINGLE_PHASE_FLUIDSYSTEM_HPP
#define OPM_SINGLE_PHASE_FLUIDSYSTEM_HPP
#include "BaseFluidSystem.hpp"
#include "NullParameterCache.hpp"
#include <opm/material/fluidsystems/LiquidPhase.hpp>
#include <opm/material/fluidsystems/GasPhase.hpp>
#include <opm/material/components/SimpleH2O.hpp>
#include <opm/material/components/H2O.hpp>
#include <opm/material/components/N2.hpp>
#include <opm/material/components/TabulatedComponent.hpp>
#include <limits>
#include <cassert>
#include <string_view>
namespace Opm {
template <class Scalar, class Fluid>
class SinglePhaseFluidSystem
: public BaseFluidSystem<Scalar, SinglePhaseFluidSystem<Scalar, Fluid> >
{
typedef SinglePhaseFluidSystem<Scalar, Fluid> ThisType;
typedef BaseFluidSystem<Scalar, ThisType> Base;
public:
template <class Evaluation>
struct ParameterCache : public NullParameterCache<Evaluation>
{};
/****************************************
* Fluid phase related static parameters
****************************************/
static const int numPhases = 1;
static std::string_view phaseName([[maybe_unused]] unsigned phaseIdx)
{
assert(phaseIdx < numPhases);
return Fluid::name();
}
static bool isLiquid(unsigned /*phaseIdx*/)
{
//assert(0 <= phaseIdx && phaseIdx < numPhases);
return Fluid::isLiquid();
}
static bool isCompressible(unsigned /*phaseIdx*/)
{
//assert(0 <= phaseIdx && phaseIdx < numPhases);
// let the fluid decide
return Fluid::isCompressible();
}
static bool isIdealMixture(unsigned /*phaseIdx*/)
{
//assert(0 <= phaseIdx && phaseIdx < numPhases);
// we assume immisibility
return true;
}
static bool isIdealGas(unsigned /*phaseIdx*/)
{
//assert(0 <= phaseIdx && phaseIdx < numPhases);
// let the fluid decide
return Fluid::isIdealGas();
}
/****************************************
* Component related static parameters
****************************************/
static const int numComponents = 1;
static std::string_view componentName([[maybe_unused]] unsigned compIdx)
{
assert(compIdx < numComponents);
return Fluid::name();
}
static Scalar molarMass(unsigned /*compIdx*/)
{
//assert(0 <= compIdx && compIdx < numComponents);
return Fluid::molarMass();
}
static Scalar criticalTemperature(unsigned /*compIdx*/)
{
//assert(0 <= compIdx && compIdx < numComponents);
return Fluid::criticalTemperature();
}
static Scalar criticalPressure(unsigned /*compIdx*/)
{
//assert(0 <= compIdx && compIdx < numComponents);
return Fluid::criticalPressure();
}
static Scalar acentricFactor(unsigned /*compIdx*/)
{
//assert(0 <= compIdx && compIdx < numComponents);
return Fluid::acentricFactor();
}
/****************************************
* thermodynamic relations
****************************************/
static void init()
{ }
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& T = decay<LhsEval>(fluidState.temperature(phaseIdx));
const auto& p = decay<LhsEval>(fluidState.pressure(phaseIdx));
return Fluid::density(T, p);
}
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& T = decay<LhsEval>(fluidState.temperature(phaseIdx));
const auto& p = decay<LhsEval>(fluidState.pressure(phaseIdx));
return Fluid::viscosity(T, p);
}
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& T = decay<LhsEval>(fluidState.temperature(phaseIdx));
const auto& p = decay<LhsEval>(fluidState.pressure(phaseIdx));
return Fluid::enthalpy(T, p);
}
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& T = decay<LhsEval>(fluidState.temperature(phaseIdx));
const auto& p = decay<LhsEval>(fluidState.pressure(phaseIdx));
return Fluid::thermalConductivity(T, p);
}
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& T = decay<LhsEval>(fluidState.temperature(phaseIdx));
const auto& p = decay<LhsEval>(fluidState.pressure(phaseIdx));
return Fluid::heatCapacity(T, p);
}
};
} // namespace Opm
#endif
BaseFluidSystem.hpp
The base class for all fluid systems.
GasPhase.hpp
Represents the gas phase of a single (pseudo-) component.
H2O.hpp
Material properties of pure water .
LiquidPhase.hpp
Represents the liquid phase of a single (pseudo-) component.
N2.hpp
Properties of pure molecular nitrogen .
NullParameterCache.hpp
A parameter cache which does nothing.
SimpleH2O.hpp
A simple version of pure water.
TabulatedComponent.hpp
A generic class which tabulates all thermodynamic properties of a given component.
Opm::BaseFluidSystem
The base class for all fluid systems.
Definition BaseFluidSystem.hpp:43
Opm::BaseFluidSystem< Scalar, SinglePhaseFluidSystem< Scalar, Fluid > >::Scalar
Scalar Scalar
Definition BaseFluidSystem.hpp:48
Opm::SinglePhaseFluidSystem
A fluid system for single phase models.
Definition SinglePhaseFluidSystem.hpp:58
Opm::SinglePhaseFluidSystem::thermalConductivity
static LhsEval thermalConductivity(const FluidState &fluidState, const ParameterCache< ParamCacheEval > &, unsigned phaseIdx)
Thermal conductivity of a fluid phase [W/(m K)].
Definition SinglePhaseFluidSystem.hpp:245
Opm::SinglePhaseFluidSystem::viscosity
static LhsEval viscosity(const FluidState &fluidState, const ParameterCache< ParamCacheEval > &, unsigned phaseIdx)
Calculate the dynamic viscosity of a fluid phase [Pa*s].
Definition SinglePhaseFluidSystem.hpp:200
Opm::SinglePhaseFluidSystem::numComponents
static const int numComponents
Number of chemical species in the fluid system.
Definition SinglePhaseFluidSystem.hpp:123
Opm::SinglePhaseFluidSystem::criticalTemperature
static Scalar criticalTemperature(unsigned)
Critical temperature of a component [K].
Definition SinglePhaseFluidSystem.hpp:146
Opm::SinglePhaseFluidSystem::acentricFactor
static Scalar acentricFactor(unsigned)
The acentric factor of a component [].
Definition SinglePhaseFluidSystem.hpp:170
Opm::SinglePhaseFluidSystem::numPhases
static const int numPhases
Number of fluid phases in the fluid system.
Definition SinglePhaseFluidSystem.hpp:73
Opm::SinglePhaseFluidSystem::phaseName
static std::string_view phaseName(unsigned phaseIdx)
Return the human readable name of a fluid phase.
Definition SinglePhaseFluidSystem.hpp:76
Opm::SinglePhaseFluidSystem::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 SinglePhaseFluidSystem.hpp:213
Opm::SinglePhaseFluidSystem::isIdealGas
static bool isIdealGas(unsigned)
Returns true if and only if a fluid phase is assumed to be an ideal mixture.
Definition SinglePhaseFluidSystem.hpp:110
Opm::SinglePhaseFluidSystem::init
static void init()
Initialize the fluid system's static parameters.
Definition SinglePhaseFluidSystem.hpp:182
Opm::SinglePhaseFluidSystem::density
static LhsEval density(const FluidState &fluidState, const ParameterCache< ParamCacheEval > &, unsigned phaseIdx)
Calculate the density [kg/m^3] of a fluid phase.
Definition SinglePhaseFluidSystem.hpp:187
Opm::SinglePhaseFluidSystem::molarMass
static Scalar molarMass(unsigned)
Return the molar mass of a component in [kg/mol].
Definition SinglePhaseFluidSystem.hpp:134
Opm::SinglePhaseFluidSystem::criticalPressure
static Scalar criticalPressure(unsigned)
Critical pressure of a component [Pa].
Definition SinglePhaseFluidSystem.hpp:158
Opm::SinglePhaseFluidSystem::heatCapacity
static LhsEval heatCapacity(const FluidState &fluidState, const ParameterCache< ParamCacheEval > &, unsigned phaseIdx)
Specific isobaric heat capacity of a fluid phase [J/kg].
Definition SinglePhaseFluidSystem.hpp:258
Opm::SinglePhaseFluidSystem::isCompressible
static bool isCompressible(unsigned)
Returns true if and only if a fluid phase is assumed to be compressible.
Definition SinglePhaseFluidSystem.hpp:92
Opm::SinglePhaseFluidSystem::isIdealMixture
static bool isIdealMixture(unsigned)
Returns true if and only if a fluid phase is assumed to be an ideal gas.
Definition SinglePhaseFluidSystem.hpp:101
Opm::SinglePhaseFluidSystem::componentName
static std::string_view componentName(unsigned compIdx)
Return the human readable name of a component.
Definition SinglePhaseFluidSystem.hpp:126
Opm::SinglePhaseFluidSystem::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 SinglePhaseFluidSystem.hpp:232
Opm::SinglePhaseFluidSystem::isLiquid
static bool isLiquid(unsigned)
Return whether a phase is liquid.
Definition SinglePhaseFluidSystem.hpp:84
Opm
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30
Opm::SinglePhaseFluidSystem::ParameterCache
The type of the fluid system's parameter cache.
Definition SinglePhaseFluidSystem.hpp:66