Loading...
Searching...
No Matches
H2ON2LiquidPhaseFluidSystem.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_H2O_N2_LIQUIDPHASE_FLUID_SYSTEM_HPP
#define OPM_H2O_N2_LIQUIDPHASE_FLUID_SYSTEM_HPP
#include "BaseFluidSystem.hpp"
#include "NullParameterCache.hpp"
#include <opm/material/IdealGas.hpp>
#include <opm/material/components/N2.hpp>
#include <opm/material/components/H2O.hpp>
#include <opm/material/components/SimpleH2O.hpp>
#include <opm/material/components/TabulatedComponent.hpp>
#include <opm/material/binarycoefficients/H2O_N2.hpp>
#include <opm/material/common/Valgrind.hpp>
#include <cassert>
#include <string_view>
namespace Opm {
template <class Scalar>
class H2ON2LiquidPhaseFluidSystem
: public BaseFluidSystem<Scalar, H2ON2LiquidPhaseFluidSystem<Scalar> >
{
typedef H2ON2LiquidPhaseFluidSystem<Scalar> ThisType;
typedef BaseFluidSystem<Scalar, ThisType> Base;
// convenience typedefs
typedef ::Opm::H2O<Scalar> IapwsH2O;
typedef ::Opm::TabulatedComponent<Scalar, IapwsH2O > TabulatedH2O;
typedef ::Opm::N2<Scalar> SimpleN2;
public:
template <class Evaluation>
struct ParameterCache : public NullParameterCache<Evaluation>
{};
/****************************************
* Fluid phase related static parameters
****************************************/
static const int numPhases = 1;
static const int liquidPhaseIdx = 0;
static std::string_view phaseName([[maybe_unused]] unsigned phaseIdx)
{
assert(phaseIdx == liquidPhaseIdx);
return "liquid";
}
static bool isLiquid(unsigned /*phaseIdx*/)
{
//assert(phaseIdx == liquidPhaseIdx);
return true; //only water phase present
}
static bool isCompressible(unsigned /*phaseIdx*/)
{
//assert(0 <= phaseIdx && phaseIdx < numPhases);
// the water component decides for the liquid phase...
return H2O::liquidIsCompressible();
}
static bool isIdealGas(unsigned /*phaseIdx*/)
{
//assert(0 <= phaseIdx && phaseIdx < numPhases);
return false; // not a gas (only liquid phase present)
}
static bool isIdealMixture(unsigned /*phaseIdx*/)
{
//assert(0 <= phaseIdx && phaseIdx < numPhases);
// we assume Henry's and Rault's laws for the water phase and
// and no interaction between gas molecules of different
// components, so all phases are ideal mixtures!
return true;
}
/****************************************
* Component related static parameters
****************************************/
static const int numComponents = 2;
static const int H2OIdx = 0;
static const int N2Idx = 1;
typedef TabulatedH2O H2O;
//typedef SimpleH2O H2O;
//typedef IapwsH2O H2O;
typedef SimpleN2 N2;
static std::string_view componentName(unsigned compIdx)
{
static const std::string_view name[] = {
H2O::name(),
N2::name()
};
assert(compIdx < numComponents);
return name[compIdx];
}
static Scalar molarMass(unsigned compIdx)
{
//assert(0 <= compIdx && compIdx < numComponents);
return (compIdx == H2OIdx)
? H2O::molarMass()
: (compIdx == N2Idx)
? N2::molarMass()
: 1e30;
}
static Scalar criticalTemperature(unsigned compIdx)
{
//assert(0 <= compIdx && compIdx < numComponents);
return (compIdx == H2OIdx)
? H2O::criticalTemperature()
: (compIdx == N2Idx)
? N2::criticalTemperature()
: 1e30;
}
static Scalar criticalPressure(unsigned compIdx)
{
//assert(0 <= compIdx && compIdx < numComponents);
return (compIdx == H2OIdx)
? H2O::criticalPressure()
: (compIdx == N2Idx)
? N2::criticalPressure()
: 1e30;
}
static Scalar acentricFactor(unsigned compIdx)
{
//assert(0 <= compIdx && compIdx < numComponents);
return (compIdx == H2OIdx)
? H2O::acentricFactor()
: (compIdx == N2Idx)
? N2::acentricFactor()
: 1e30;
}
/****************************************
* thermodynamic relations
****************************************/
static void init()
{
init(/*tempMin=*/273.15,
/*tempMax=*/623.15,
/*numTemp=*/50,
/*pMin=*/0.0,
/*pMax=*/20e6,
/*numP=*/50);
}
static void init(Scalar tempMin, Scalar tempMax, unsigned nTemp,
Scalar pressMin, Scalar pressMax, unsigned nPress)
{
if (H2O::isTabulated) {
TabulatedH2O::init(tempMin, tempMax, nTemp,
pressMin, pressMax, nPress);
}
}
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));
LhsEval sumMoleFrac = 0;
for (unsigned compIdx = 0; compIdx < numComponents; ++compIdx)
sumMoleFrac += decay<LhsEval>(fluidState.moleFraction(phaseIdx, compIdx));
assert(phaseIdx == liquidPhaseIdx);
// assume ideal mixture where each molecule occupies the same volume regardless
// of whether it is water or nitrogen.
const LhsEval& clH2O = H2O::liquidDensity(T, p)/H2O::molarMass();
const auto& xlH2O = decay<LhsEval>(fluidState.moleFraction(liquidPhaseIdx, H2OIdx));
const auto& xlN2 = decay<LhsEval>(fluidState.moleFraction(liquidPhaseIdx, N2Idx));
return clH2O*(H2O::molarMass()*xlH2O + N2::molarMass()*xlN2)/sumMoleFrac;
}
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 == liquidPhaseIdx);
const auto& T = decay<LhsEval>(fluidState.temperature(phaseIdx));
const auto& p = decay<LhsEval>(fluidState.pressure(phaseIdx));
// assume pure water for the liquid phase
return H2O::liquidViscosity(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 == liquidPhaseIdx);
assert(compIdx < numComponents);
const auto& T = decay<LhsEval>(fluidState.temperature(phaseIdx));
const auto& p = decay<LhsEval>(fluidState.pressure(phaseIdx));
if (compIdx == H2OIdx)
return H2O::vaporPressure(T)/p;
return BinaryCoeff::H2O_N2::henry(T)/p;
}
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*/)
{
assert(phaseIdx == liquidPhaseIdx);
const auto& T = decay<LhsEval>(fluidState.temperature(phaseIdx));
const auto& p = decay<LhsEval>(fluidState.pressure(phaseIdx));
return BinaryCoeff::H2O_N2::liquidDiffCoeff(T, p);
}
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 == liquidPhaseIdx);
const auto& T = decay<LhsEval>(fluidState.temperature(phaseIdx));
const auto& p = decay<LhsEval>(fluidState.pressure(phaseIdx));
Valgrind::CheckDefined(T);
Valgrind::CheckDefined(p);
// TODO: way to deal with the solutes???
return H2O::liquidEnthalpy(T, p);
}
template <class FluidState, class LhsEval = typename FluidState::Scalar, class ParamCacheEval = LhsEval>
static LhsEval thermalConductivity(const FluidState& fluidState,
const ParameterCache<ParamCacheEval>& /*paramCache*/,
const unsigned phaseIdx)
{
assert(phaseIdx == liquidPhaseIdx);
const auto& T = decay<LhsEval>(fluidState.temperature(phaseIdx));
const auto& p = decay<LhsEval>(fluidState.pressure(phaseIdx));
return H2O::liquidThermalConductivity(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 == liquidPhaseIdx);
const auto& T = decay<LhsEval>(fluidState.temperature(phaseIdx));
const auto& p = decay<LhsEval>(fluidState.pressure(phaseIdx));
return H2O::liquidHeatCapacity(T, p);
}
};
} // namespace Opm
#endif
BaseFluidSystem.hpp
The base class for all fluid systems.
H2O.hpp
Material properties of pure water .
H2O_N2.hpp
Binary coefficients for water and nitrogen.
IdealGas.hpp
Relations valid for an ideal gas.
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.
Valgrind.hpp
Some templates to wrap the valgrind client request macros.
Opm::BaseFluidSystem
The base class for all fluid systems.
Definition BaseFluidSystem.hpp:43
Opm::BaseFluidSystem< Scalar, H2ON2LiquidPhaseFluidSystem< Scalar > >::Scalar
Scalar Scalar
The type used for scalar quantities.
Definition BaseFluidSystem.hpp:48
Opm::BinaryCoeff::H2O_N2::liquidDiffCoeff
static Evaluation liquidDiffCoeff(const Evaluation &temperature, const Evaluation &)
Diffusion coefficent for molecular nitrogen in liquid water.
Definition H2O_N2.hpp:102
Opm::BinaryCoeff::H2O_N2::henry
static Evaluation henry(const Evaluation &temperature)
Henry coefficent for molecular nitrogen in liquid water.
Definition H2O_N2.hpp:52
Opm::H2ON2LiquidPhaseFluidSystem
A liquid-phase-only fluid system with water and nitrogen as components.
Definition H2ON2LiquidPhaseFluidSystem.hpp:55
Opm::H2ON2LiquidPhaseFluidSystem::numComponents
static const int numComponents
Number of chemical species in the fluid system.
Definition H2ON2LiquidPhaseFluidSystem.hpp:125
Opm::H2ON2LiquidPhaseFluidSystem::N2Idx
static const int N2Idx
The index of the component for molecular nitrogen.
Definition H2ON2LiquidPhaseFluidSystem.hpp:130
Opm::H2ON2LiquidPhaseFluidSystem::phaseName
static std::string_view phaseName(unsigned phaseIdx)
Return the human readable name of a fluid phase.
Definition H2ON2LiquidPhaseFluidSystem.hpp:81
Opm::H2ON2LiquidPhaseFluidSystem::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 H2ON2LiquidPhaseFluidSystem.hpp:326
Opm::H2ON2LiquidPhaseFluidSystem::diffusionCoefficient
static LhsEval diffusionCoefficient(const FluidState &fluidState, const ParameterCache< ParamCacheEval > &, unsigned phaseIdx, unsigned)
Calculate the binary molecular diffusion coefficient for a component in a fluid phase [mol^2 * s / (k...
Definition H2ON2LiquidPhaseFluidSystem.hpp:310
Opm::H2ON2LiquidPhaseFluidSystem::criticalTemperature
static Scalar criticalTemperature(unsigned compIdx)
Critical temperature of a component [K].
Definition H2ON2LiquidPhaseFluidSystem.hpp:168
Opm::H2ON2LiquidPhaseFluidSystem::componentName
static std::string_view componentName(unsigned compIdx)
Return the human readable name of a component.
Definition H2ON2LiquidPhaseFluidSystem.hpp:141
Opm::H2ON2LiquidPhaseFluidSystem::liquidPhaseIdx
static const int liquidPhaseIdx
Index of the liquid phase.
Definition H2ON2LiquidPhaseFluidSystem.hpp:78
Opm::H2ON2LiquidPhaseFluidSystem::viscosity
static LhsEval viscosity(const FluidState &fluidState, const ParameterCache< ParamCacheEval > &, unsigned phaseIdx)
Calculate the dynamic viscosity of a fluid phase [Pa*s].
Definition H2ON2LiquidPhaseFluidSystem.hpp:277
Opm::H2ON2LiquidPhaseFluidSystem::thermalConductivity
static LhsEval thermalConductivity(const FluidState &fluidState, const ParameterCache< ParamCacheEval > &, const unsigned phaseIdx)
Thermal conductivity of a fluid phase [W/(m K)].
Definition H2ON2LiquidPhaseFluidSystem.hpp:343
Opm::H2ON2LiquidPhaseFluidSystem::fugacityCoefficient
static LhsEval fugacityCoefficient(const FluidState &fluidState, const ParameterCache< ParamCacheEval > &, unsigned phaseIdx, unsigned compIdx)
Calculate the fugacity coefficient [Pa] of an individual component in a fluid phase.
Definition H2ON2LiquidPhaseFluidSystem.hpp:292
Opm::H2ON2LiquidPhaseFluidSystem::heatCapacity
static LhsEval heatCapacity(const FluidState &fluidState, const ParameterCache< ParamCacheEval > &, unsigned phaseIdx)
Specific isobaric heat capacity of a fluid phase [J/kg].
Definition H2ON2LiquidPhaseFluidSystem.hpp:356
Opm::H2ON2LiquidPhaseFluidSystem::acentricFactor
static Scalar acentricFactor(unsigned compIdx)
The acentric factor of a component [].
Definition H2ON2LiquidPhaseFluidSystem.hpp:198
Opm::H2ON2LiquidPhaseFluidSystem::criticalPressure
static Scalar criticalPressure(unsigned compIdx)
Critical pressure of a component [Pa].
Definition H2ON2LiquidPhaseFluidSystem.hpp:183
Opm::H2ON2LiquidPhaseFluidSystem::H2O
TabulatedH2O H2O
The type of the component for pure water.
Definition H2ON2LiquidPhaseFluidSystem.hpp:133
Opm::H2ON2LiquidPhaseFluidSystem::isCompressible
static bool isCompressible(unsigned)
Returns true if and only if a fluid phase is assumed to be compressible.
Definition H2ON2LiquidPhaseFluidSystem.hpp:96
Opm::H2ON2LiquidPhaseFluidSystem::H2OIdx
static const int H2OIdx
The index of the water component.
Definition H2ON2LiquidPhaseFluidSystem.hpp:128
Opm::H2ON2LiquidPhaseFluidSystem::numPhases
static const int numPhases
Number of fluid phases in the fluid system.
Definition H2ON2LiquidPhaseFluidSystem.hpp:75
Opm::H2ON2LiquidPhaseFluidSystem::init
static void init()
Initialize the fluid system's static parameters.
Definition H2ON2LiquidPhaseFluidSystem.hpp:218
Opm::H2ON2LiquidPhaseFluidSystem::isIdealGas
static bool isIdealGas(unsigned)
Returns true if and only if a fluid phase is assumed to be an ideal gas.
Definition H2ON2LiquidPhaseFluidSystem.hpp:104
Opm::H2ON2LiquidPhaseFluidSystem::init
static void init(Scalar tempMin, Scalar tempMax, unsigned nTemp, Scalar pressMin, Scalar pressMax, unsigned nPress)
Initialize the fluid system's static parameters using problem specific temperature and pressure range...
Definition H2ON2LiquidPhaseFluidSystem.hpp:239
Opm::H2ON2LiquidPhaseFluidSystem::N2
SimpleN2 N2
The type of the component for pure molecular nitrogen.
Definition H2ON2LiquidPhaseFluidSystem.hpp:138
Opm::H2ON2LiquidPhaseFluidSystem::isIdealMixture
static bool isIdealMixture(unsigned)
Returns true if and only if a fluid phase is assumed to be an ideal mixture.
Definition H2ON2LiquidPhaseFluidSystem.hpp:111
Opm::H2ON2LiquidPhaseFluidSystem::molarMass
static Scalar molarMass(unsigned compIdx)
Return the molar mass of a component in [kg/mol].
Definition H2ON2LiquidPhaseFluidSystem.hpp:153
Opm::H2ON2LiquidPhaseFluidSystem::density
static LhsEval density(const FluidState &fluidState, const ParameterCache< ParamCacheEval > &, unsigned phaseIdx)
Calculate the density [kg/m^3] of a fluid phase.
Definition H2ON2LiquidPhaseFluidSystem.hpp:250
Opm::H2ON2LiquidPhaseFluidSystem::isLiquid
static bool isLiquid(unsigned)
Return whether a phase is liquid.
Definition H2ON2LiquidPhaseFluidSystem.hpp:89
Opm::H2O
Material properties of pure water .
Definition H2O.hpp:65
Opm::N2
Properties of pure molecular nitrogen .
Definition N2.hpp:50
Opm::N2::criticalPressure
static Scalar criticalPressure()
Returns the critical pressure of molecular nitrogen.
Definition N2.hpp:75
Opm::N2::criticalTemperature
static Scalar criticalTemperature()
Returns the critical temperature of molecular nitrogen.
Definition N2.hpp:69
Opm::N2::name
static std::string_view name()
A human readable name for nitrogen.
Definition N2.hpp:57
Opm::N2::acentricFactor
static Scalar acentricFactor()
Acentric factor of .
Definition N2.hpp:86
Opm::N2::molarMass
static Scalar molarMass()
The molar mass in of molecular nitrogen.
Definition N2.hpp:63
Opm::NullParameterCache
A parameter cache which does nothing.
Definition NullParameterCache.hpp:40
Opm::TabulatedComponent
A generic class which tabulates all thermodynamic properties of a given component.
Definition TabulatedComponent.hpp:56
Opm::TabulatedComponent::name
static std::string_view name()
A human readable name for the component.
Definition TabulatedComponent.hpp:215
Opm::TabulatedComponent::liquidHeatCapacity
static Evaluation liquidHeatCapacity(const Evaluation &temperature, const Evaluation &pressure)
Specific isobaric heat capacity of the liquid .
Definition TabulatedComponent.hpp:333
Opm::TabulatedComponent::init
static void init(Scalar tempMin, Scalar tempMax, unsigned nTemp, Scalar pressMin, Scalar pressMax, unsigned nPress)
Initialize the tables.
Definition TabulatedComponent.hpp:72
Opm::TabulatedComponent::criticalTemperature
static Scalar criticalTemperature()
Returns the critical temperature in of the component.
Definition TabulatedComponent.hpp:227
Opm::TabulatedComponent::criticalPressure
static Scalar criticalPressure()
Returns the critical pressure in of the component.
Definition TabulatedComponent.hpp:233
Opm::TabulatedComponent::molarMass
static Scalar molarMass()
The molar mass in of the component.
Definition TabulatedComponent.hpp:221
Opm::TabulatedComponent::liquidIsCompressible
static bool liquidIsCompressible()
Returns true iff the liquid phase is assumed to be compressible.
Definition TabulatedComponent.hpp:408
Opm::TabulatedComponent::liquidViscosity
static Evaluation liquidViscosity(const Evaluation &temperature, const Evaluation &pressure)
The dynamic viscosity of liquid.
Definition TabulatedComponent.hpp:478
Opm::TabulatedComponent::acentricFactor
static Scalar acentricFactor()
Returns the acentric factor of the component.
Definition TabulatedComponent.hpp:239
Opm::TabulatedComponent::liquidDensity
static Evaluation liquidDensity(const Evaluation &temperature, const Evaluation &pressure)
The density of liquid at a given pressure and temperature .
Definition TabulatedComponent.hpp:444
Opm::TabulatedComponent::vaporPressure
static Evaluation vaporPressure(const Evaluation &temperature)
The vapor pressure in of the component at a given temperature.
Definition TabulatedComponent.hpp:267
Opm::TabulatedComponent::liquidThermalConductivity
static Evaluation liquidThermalConductivity(const Evaluation &temperature, const Evaluation &pressure)
The thermal conductivity of liquid water .
Definition TabulatedComponent.hpp:512
Opm::TabulatedComponent::liquidEnthalpy
static Evaluation liquidEnthalpy(const Evaluation &temperature, const Evaluation &pressure)
Specific enthalpy of the liquid .
Definition TabulatedComponent.hpp:299
Opm
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30
Opm::H2ON2LiquidPhaseFluidSystem::ParameterCache
The type of the fluid system's parameter cache.
Definition H2ON2LiquidPhaseFluidSystem.hpp:68