Loading...
Searching...
No Matches
ThreeComponentFluidSystem.hh
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*
Copyright 2022 SINTEF Digital, Mathematics and Cybernetics.
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_THREECOMPONENTFLUIDSYSTEM_HH
#define OPM_THREECOMPONENTFLUIDSYSTEM_HH
#include <opm/material/eos/PengRobinsonMixture.hpp>
#include <opm/material/fluidsystems/BaseFluidSystem.hpp>
#include <opm/material/components/SimpleCO2.hpp>
#include <opm/material/components/C10.hpp>
#include <opm/material/components/C1.hpp>
#include <string_view>
// TODO: this is something else need to check
#include <opm/material/fluidsystems/PTFlashParameterCache.hpp>
#include <opm/material/viscositymodels/LBC.hpp>
namespace Opm {
template<class Scalar>
class ThreeComponentFluidSystem
: public Opm::BaseFluidSystem<Scalar, ThreeComponentFluidSystem<Scalar> > {
public:
// TODO: I do not think these should be constant in fluidsystem, will try to make it non-constant later
static constexpr int numPhases=2;
static constexpr int numComponents = 3;
static constexpr int numMisciblePhases=2;
static constexpr int numMiscibleComponents = 3;
// TODO: phase location should be more general
static constexpr int oilPhaseIdx = 0;
static constexpr int gasPhaseIdx = 1;
static constexpr int Comp0Idx = 0;
static constexpr int Comp1Idx = 1;
static constexpr int Comp2Idx = 2;
// TODO: needs to be more general
using Comp0 = SimpleCO2<Scalar>;
using Comp1 = C1<Scalar>;
using Comp2 = C10<Scalar>;
template <class ValueType>
using ParameterCache = PTFlashParameterCache<ValueType, ThreeComponentFluidSystem<Scalar>>;
using ViscosityModel = ViscosityModels<Scalar, ThreeComponentFluidSystem<Scalar>>;
using PengRobinsonMixture = ::Opm::PengRobinsonMixture<Scalar, ThreeComponentFluidSystem<Scalar>>;
static Scalar acentricFactor(unsigned compIdx)
{
switch (compIdx) {
case Comp0Idx: return Comp0::acentricFactor();
case Comp1Idx: return Comp1::acentricFactor();
case Comp2Idx: return Comp2::acentricFactor();
default: throw std::runtime_error("Illegal component index for acentricFactor");
}
}
static Scalar criticalTemperature(unsigned compIdx)
{
switch (compIdx) {
case Comp0Idx: return Comp0::criticalTemperature();
case Comp1Idx: return Comp1::criticalTemperature();
case Comp2Idx: return Comp2::criticalTemperature();
default: throw std::runtime_error("Illegal component index for criticalTemperature");
}
}
static Scalar criticalPressure(unsigned compIdx) {
switch (compIdx) {
case Comp0Idx: return Comp0::criticalPressure();
case Comp1Idx: return Comp1::criticalPressure();
case Comp2Idx: return Comp2::criticalPressure();
default: throw std::runtime_error("Illegal component index for criticalPressure");
}
}
static Scalar criticalVolume(unsigned compIdx)
{
switch (compIdx) {
case Comp0Idx: return Comp0::criticalVolume();
case Comp1Idx: return Comp1::criticalVolume();
case Comp2Idx: return Comp2::criticalVolume();
default: throw std::runtime_error("Illegal component index for criticalVolume");
}
}
static Scalar molarMass(unsigned compIdx)
{
switch (compIdx) {
case Comp0Idx: return Comp0::molarMass();
case Comp1Idx: return Comp1::molarMass();
case Comp2Idx: return Comp2::molarMass();
default: throw std::runtime_error("Illegal component index for molarMass");
}
}
static Scalar interactionCoefficient(unsigned /*comp1Idx*/, unsigned /*comp2Idx*/)
{
return 0.0;
}
static std::string_view phaseName(unsigned phaseIdx)
{
static const std::string_view name[] = {"o", // oleic phase
"g"}; // gas phase
assert(phaseIdx < 2);
return name[phaseIdx];
}
static std::string_view componentName(unsigned compIdx)
{
static const std::string_view name[] = {
Comp0::name(),
Comp1::name(),
Comp2::name(),
};
assert(compIdx < 3);
return name[compIdx];
}
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 == oilPhaseIdx || phaseIdx == gasPhaseIdx); // This is a oil + gas only two-phase system
return decay<LhsEval>(fluidState.averageMolarMass(phaseIdx) / paramCache.molarVolume(phaseIdx));
}
template <class FluidState, class LhsEval = typename FluidState::Scalar, class ParamCacheEval = LhsEval>
static LhsEval viscosity(const FluidState& fluidState,
const ParameterCache<ParamCacheEval>& paramCache,
unsigned phaseIdx)
{
// Use LBC method to calculate viscosity
return decay<LhsEval>(ViscosityModel::LBC(fluidState, paramCache, phaseIdx));
}
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);
return decay<LhsEval>(PengRobinsonMixture::computeFugacityCoefficient(fluidState, paramCache, phaseIdx, compIdx));
}
static bool isCompressible([[maybe_unused]] unsigned phaseIdx)
{
assert(phaseIdx < numPhases);
return true;
}
static bool isIdealMixture([[maybe_unused]] unsigned phaseIdx)
{
assert(phaseIdx < numPhases);
return false;
}
static bool isLiquid(unsigned phaseIdx)
{
assert(phaseIdx < numPhases);
return (phaseIdx == 0);
}
static bool isIdealGas(unsigned phaseIdx)
{
assert(phaseIdx < numPhases);
return (phaseIdx == 1);
}
};
}
#endif //OPM_THREECOMPONENTFLUIDSYSTEM_HH
BaseFluidSystem.hpp
The base class for all fluid systems.
C10.hpp
Properties of pure molecular n-Decane .
C1.hpp
Properties of pure molecular methane .
LBC.hpp
PTFlashParameterCache.hpp
Specifies the parameter cache used by the SPE-5 fluid system.
PengRobinsonMixture.hpp
Implements the Peng-Robinson equation of state for a mixture.
SimpleCO2.hpp
A simplistic class representing the fluid properties.
Opm::BaseFluidSystem
The base class for all fluid systems.
Definition BaseFluidSystem.hpp:43
Opm::BaseFluidSystem< Scalar, ThreeComponentFluidSystem< Scalar > >::Scalar
Scalar Scalar
The type used for scalar quantities.
Definition BaseFluidSystem.hpp:48
Opm::C10
Properties of pure molecular n-Decane .
Definition C10.hpp:50
Opm::C10::criticalVolume
static Scalar criticalVolume()
Critical volume of [m3/kmol].
Definition C10.hpp:81
Opm::C10::name
static std::string_view name()
A human readable name for NDecane.
Definition C10.hpp:57
Opm::C10::criticalPressure
static Scalar criticalPressure()
Returns the critical pressure of molecular n-Decane.
Definition C10.hpp:75
Opm::C10::criticalTemperature
static Scalar criticalTemperature()
Returns the critical temperature of molecular n-Decane.
Definition C10.hpp:69
Opm::C10::molarMass
static Scalar molarMass()
The molar mass in of molecular n-Decane.
Definition C10.hpp:63
Opm::C10::acentricFactor
static Scalar acentricFactor()
Acentric factor of .
Definition C10.hpp:86
Opm::C1
Properties of pure molecular methane .
Definition C1.hpp:51
Opm::C1::criticalPressure
static Scalar criticalPressure()
Returns the critical pressure of molecular methane.
Definition C1.hpp:76
Opm::C1::molarMass
static Scalar molarMass()
The molar mass in of molecular methane.
Definition C1.hpp:64
Opm::C1::criticalTemperature
static Scalar criticalTemperature()
Returns the critical temperature of molecular methane.
Definition C1.hpp:70
Opm::C1::acentricFactor
static Scalar acentricFactor()
Acentric factor of .
Definition C1.hpp:87
Opm::C1::criticalVolume
static Scalar criticalVolume()
Critical volume of [m3/kmol].
Definition C1.hpp:82
Opm::C1::name
static std::string_view name()
A human readable name for NDecane.
Definition C1.hpp:58
Opm::PTFlashParameterCache
Specifies the parameter cache used by the SPE-5 fluid system.
Definition PTFlashParameterCache.hpp:48
Opm::PTFlashParameterCache::molarVolume
Scalar molarVolume(unsigned phaseIdx) const
Returns the molar volume of a phase [m^3/mol].
Definition PTFlashParameterCache.hpp:210
Opm::PengRobinsonMixture
Implements the Peng-Robinson equation of state for a mixture.
Definition PengRobinsonMixture.hpp:41
Opm::PengRobinsonMixture::computeFugacityCoefficient
static LhsEval computeFugacityCoefficient(const FluidState &fs, const Params &params, unsigned phaseIdx, unsigned compIdx)
Returns the fugacity coefficient of an individual component in the phase.
Definition PengRobinsonMixture.hpp:74
Opm::SimpleCO2
A simplistic class representing the fluid properties.
Definition SimpleCO2.hpp:50
Opm::SimpleCO2::criticalVolume
static Scalar criticalVolume()
Critical volume of [m2/kmol].
Definition SimpleCO2.hpp:93
Opm::SimpleCO2::criticalTemperature
static Scalar criticalTemperature()
Returns the critical temperature of .
Definition SimpleCO2.hpp:69
Opm::SimpleCO2::acentricFactor
static Scalar acentricFactor()
Acentric factor of .
Definition SimpleCO2.hpp:87
Opm::SimpleCO2::criticalPressure
static Scalar criticalPressure()
Returns the critical pressure of .
Definition SimpleCO2.hpp:75
Opm::SimpleCO2::name
static std::string_view name()
A human readable name for the component.
Definition SimpleCO2.hpp:57
Opm::SimpleCO2::molarMass
static Scalar molarMass()
The molar mass in of the component.
Definition SimpleCO2.hpp:63
Opm::ThreeComponentFluidSystem
A two phase three component fluid system with components CO2, Methane and NDekan.
Definition ThreeComponentFluidSystem.hh:52
Opm::ThreeComponentFluidSystem::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 ThreeComponentFluidSystem.hh:200
Opm::ThreeComponentFluidSystem::density
static LhsEval density(const FluidState &fluidState, const ParameterCache< ParamCacheEval > &paramCache, unsigned phaseIdx)
Calculate the density [kg/m^3] of a fluid phase.
Definition ThreeComponentFluidSystem.hh:180
Opm::ThreeComponentFluidSystem::criticalPressure
static Scalar criticalPressure(unsigned compIdx)
Critical pressure of a component [Pa].
Definition ThreeComponentFluidSystem.hh:110
Opm::ThreeComponentFluidSystem::componentName
static std::string_view componentName(unsigned compIdx)
Return the human readable name of a component.
Definition ThreeComponentFluidSystem.hh:164
Opm::ThreeComponentFluidSystem::criticalTemperature
static Scalar criticalTemperature(unsigned compIdx)
Critical temperature of a component [K].
Definition ThreeComponentFluidSystem.hh:96
Opm::ThreeComponentFluidSystem::isIdealMixture
static bool isIdealMixture(unsigned phaseIdx)
Returns true if and only if a fluid phase is assumed to be an ideal mixture.
Definition ThreeComponentFluidSystem.hh:220
Opm::ThreeComponentFluidSystem::phaseName
static std::string_view phaseName(unsigned phaseIdx)
Return the human readable name of a fluid phase.
Definition ThreeComponentFluidSystem.hh:154
Opm::ThreeComponentFluidSystem::molarMass
static Scalar molarMass(unsigned compIdx)
Return the molar mass of a component in [kg/mol].
Definition ThreeComponentFluidSystem.hh:134
Opm::ThreeComponentFluidSystem::acentricFactor
static Scalar acentricFactor(unsigned compIdx)
The acentric factor of a component [].
Definition ThreeComponentFluidSystem.hh:82
Opm::ThreeComponentFluidSystem::isCompressible
static bool isCompressible(unsigned phaseIdx)
Returns true if and only if a fluid phase is assumed to be compressible.
Definition ThreeComponentFluidSystem.hh:212
Opm::ThreeComponentFluidSystem::isIdealGas
static bool isIdealGas(unsigned phaseIdx)
Returns true if and only if a fluid phase is assumed to be an ideal gas.
Definition ThreeComponentFluidSystem.hh:236
Opm::ThreeComponentFluidSystem::interactionCoefficient
static Scalar interactionCoefficient(unsigned, unsigned)
Returns the interaction coefficient for two components.
Definition ThreeComponentFluidSystem.hh:148
Opm::ThreeComponentFluidSystem::isLiquid
static bool isLiquid(unsigned phaseIdx)
Return whether a phase is liquid.
Definition ThreeComponentFluidSystem.hh:228
Opm::ThreeComponentFluidSystem::viscosity
static LhsEval viscosity(const FluidState &fluidState, const ParameterCache< ParamCacheEval > &paramCache, unsigned phaseIdx)
Calculate the dynamic viscosity of a fluid phase [Pa*s].
Definition ThreeComponentFluidSystem.hh:190
Opm::ThreeComponentFluidSystem::criticalVolume
static Scalar criticalVolume(unsigned compIdx)
Critical volume of a component [m3].
Definition ThreeComponentFluidSystem.hh:123
Opm::ViscosityModels
Definition LBC.hpp:40
Opm
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30