Loading...
Searching...
No Matches
Co2BrineFluidSystem.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_CO2BRINEFLUIDSYSTEM_HH
#define OPM_CO2BRINEFLUIDSYSTEM_HH
#include <opm/material/fluidsystems/BaseFluidSystem.hpp>
#include <opm/material/components/SimpleCO2.hpp>
#include <opm/material/components/H2O.hpp>
#include <opm/material/components/Brine.hpp>
#include <opm/material/fluidsystems/PTFlashParameterCache.hpp>
#include <opm/material/viscositymodels/LBC.hpp>
#include <string_view>
namespace Opm {
template<class Scalar>
class Co2BrineFluidSystem
: public Opm::BaseFluidSystem<Scalar, Co2BrineFluidSystem<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 = 2;
static constexpr int numMisciblePhases=2;
static constexpr int numMiscibleComponents = 2;
static constexpr bool waterEnabled = false;
static constexpr int oilPhaseIdx = 0;
static constexpr int gasPhaseIdx = 1;
static constexpr int waterPhaseIdx = -1;
static constexpr int Comp0Idx = 0;
static constexpr int Comp1Idx = 1;
using Comp0 = Opm::SimpleCO2<Scalar>;
using Comp1 = Opm::Brine<Scalar, Opm::H2O<Scalar>>;
template <class ValueType>
using ParameterCache = Opm::PTFlashParameterCache<ValueType, Co2BrineFluidSystem<Scalar>>;
using ViscosityModel = typename Opm::ViscosityModels<Scalar, Co2BrineFluidSystem<Scalar>>;
using CubicEOS = typename Opm::CubicEOS<Scalar, Co2BrineFluidSystem<Scalar>>;
static Scalar acentricFactor(unsigned compIdx)
{
switch (compIdx) {
case Comp0Idx: return Comp0::acentricFactor();
case Comp1Idx: return Comp1::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();
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();
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();
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();
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(),
};
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)
{
LhsEval dens;
if (phaseIdx == oilPhaseIdx || phaseIdx == gasPhaseIdx) {
dens = fluidState.averageMolarMass(phaseIdx) / paramCache.molarVolume(phaseIdx);
}
return dens;
}
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
LhsEval mu;
mu = ViscosityModel::LBC(fluidState, paramCache, phaseIdx);
return mu;
}
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);
LhsEval phi = CubicEOS::computeFugacityCoefficient(fluidState, paramCache, phaseIdx, compIdx);
return phi;
}
};
}
#endif //OPM_CO2BRINEFLUIDSYSTEM_HH
BaseFluidSystem.hpp
The base class for all fluid systems.
Brine.hpp
A class for the brine fluid properties.
H2O.hpp
Material properties of pure water .
LBC.hpp
PTFlashParameterCache.hpp
Specifies the parameter cache used by the SPE-5 fluid system.
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, Co2BrineFluidSystem< Scalar > >::Scalar
Scalar Scalar
Definition BaseFluidSystem.hpp:48
Opm::Brine
A class for the brine fluid properties.
Definition Brine.hpp:48
Opm::Brine< Scalar, Opm::H2O< Scalar > >::molarMass
static Scalar molarMass()
Definition Brine.hpp:82
Opm::Brine< Scalar, Opm::H2O< Scalar > >::criticalVolume
static Scalar criticalVolume()
Definition Brine.hpp:105
Opm::Brine< Scalar, Opm::H2O< Scalar > >::criticalPressure
static Scalar criticalPressure()
Definition Brine.hpp:99
Opm::Brine< Scalar, Opm::H2O< Scalar > >::name
static std::string_view name()
Definition Brine.hpp:56
Opm::Brine< Scalar, Opm::H2O< Scalar > >::criticalTemperature
static Scalar criticalTemperature()
Definition Brine.hpp:93
Opm::Brine< Scalar, Opm::H2O< Scalar > >::acentricFactor
static Scalar acentricFactor()
Definition Brine.hpp:111
Opm::Co2BrineFluidSystem
A two phase two component system with components co2 brine.
Definition Co2BrineFluidSystem.hh:49
Opm::Co2BrineFluidSystem::criticalVolume
static Scalar criticalVolume(unsigned compIdx)
Critical volume of a component [m3].
Definition Co2BrineFluidSystem.hh:117
Opm::Co2BrineFluidSystem::acentricFactor
static Scalar acentricFactor(unsigned compIdx)
The acentric factor of a component [].
Definition Co2BrineFluidSystem.hh:79
Opm::Co2BrineFluidSystem::molarMass
static Scalar molarMass(unsigned compIdx)
Return the molar mass of a component in [kg/mol].
Definition Co2BrineFluidSystem.hh:127
Opm::Co2BrineFluidSystem::viscosity
static LhsEval viscosity(const FluidState &fluidState, const ParameterCache< ParamCacheEval > &paramCache, unsigned phaseIdx)
Calculate the dynamic viscosity of a fluid phase [Pa*s].
Definition Co2BrineFluidSystem.hh:188
Opm::Co2BrineFluidSystem::componentName
static std::string_view componentName(unsigned compIdx)
Return the human readable name of a component.
Definition Co2BrineFluidSystem.hh:156
Opm::Co2BrineFluidSystem::criticalPressure
static Scalar criticalPressure(unsigned compIdx)
Critical pressure of a component [Pa].
Definition Co2BrineFluidSystem.hh:105
Opm::Co2BrineFluidSystem::density
static LhsEval density(const FluidState &fluidState, const ParameterCache< ParamCacheEval > &paramCache, unsigned phaseIdx)
Calculate the density [kg/m^3] of a fluid phase.
Definition Co2BrineFluidSystem.hh:171
Opm::Co2BrineFluidSystem::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 Co2BrineFluidSystem.hh:203
Opm::Co2BrineFluidSystem::criticalTemperature
static Scalar criticalTemperature(unsigned compIdx)
Critical temperature of a component [K].
Definition Co2BrineFluidSystem.hh:92
Opm::Co2BrineFluidSystem::interactionCoefficient
static Scalar interactionCoefficient(unsigned, unsigned)
Returns the interaction coefficient for two components.
Definition Co2BrineFluidSystem.hh:140
Opm::Co2BrineFluidSystem::phaseName
static std::string_view phaseName(unsigned phaseIdx)
Return the human readable name of a fluid phase.
Definition Co2BrineFluidSystem.hh:146
Opm::CubicEOS
Definition CubicEOS.hpp:34
Opm::PTFlashParameterCache
Specifies the parameter cache used by the SPE-5 fluid system.
Definition PTFlashParameterCache.hpp:51
Opm::PTFlashParameterCache::molarVolume
Scalar molarVolume(unsigned phaseIdx) const
Returns the molar volume of a phase [m^3/mol].
Definition PTFlashParameterCache.hpp:283
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::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