Loading...
Searching...
No Matches
Spe5FluidSystem.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_SPE5_FLUID_SYSTEM_HPP
#define OPM_SPE5_FLUID_SYSTEM_HPP
#include "BaseFluidSystem.hpp"
#include "Spe5ParameterCache.hpp"
#include <opm/material/Constants.hpp>
#include <opm/material/eos/PengRobinsonMixture.hpp>
#include <opm/material/common/Spline.hpp>
#include <string_view>
namespace Opm {
template <class Scalar>
class Spe5FluidSystem
: public BaseFluidSystem<Scalar, Spe5FluidSystem<Scalar> >
{
typedef Spe5FluidSystem<Scalar> ThisType;
typedef typename ::Opm::PengRobinsonMixture<Scalar, ThisType> PengRobinsonMixture;
typedef typename ::Opm::PengRobinson<Scalar> PengRobinson;
static const Scalar R;
public:
template <class Evaluation>
struct ParameterCache : public Spe5ParameterCache<Evaluation, ThisType>
{};
/****************************************
* Fluid phase parameters
****************************************/
static const int numPhases = 3;
static const int gasPhaseIdx = 0;
static const int waterPhaseIdx = 1;
static const int oilPhaseIdx = 2;
typedef ::Opm::H2O<Scalar> H2O;
static std::string_view phaseName(unsigned phaseIdx)
{
static const std::string_view name[] = {
"gas",
"water",
"oil",
};
assert(phaseIdx < numPhases);
return name[phaseIdx];
}
static bool isLiquid(unsigned phaseIdx)
{
//assert(0 <= phaseIdx && phaseIdx < numPhases);
return phaseIdx != gasPhaseIdx;
}
static bool isCompressible(unsigned /*phaseIdx*/)
{
//assert(0 <= phaseIdx && phaseIdx < numPhases);
return true;
}
static bool isIdealGas(unsigned /*phaseIdx*/)
{
//assert(0 <= phaseIdx && phaseIdx < numPhases);
return false; // gas is not ideal here!
}
static bool isIdealMixture(unsigned phaseIdx)
{
// always use the reference oil for the fugacity coefficents,
// so they cannot be dependent on composition and they the
// phases thus always an ideal mixture
return phaseIdx == waterPhaseIdx;
}
/****************************************
* Component related parameters
****************************************/
static const int numComponents = 7;
static const int H2OIdx = 0;
static const int C1Idx = 1;
static const int C3Idx = 2;
static const int C6Idx = 3;
static const int C10Idx = 4;
static const int C15Idx = 5;
static const int C20Idx = 6;
static std::string_view componentName(unsigned compIdx)
{
static const std::string_view name[] = {
H2O::name(),
"C1",
"C3",
"C6",
"C10",
"C15",
"C20"
};
assert(compIdx < numComponents);
return name[compIdx];
}
static Scalar molarMass(unsigned compIdx)
{
return
(compIdx == H2OIdx)
? H2O::molarMass()
: (compIdx == C1Idx)
? 16.04e-3
: (compIdx == C3Idx)
? 44.10e-3
: (compIdx == C6Idx)
? 86.18e-3
: (compIdx == C10Idx)
? 142.29e-3
: (compIdx == C15Idx)
? 206.00e-3
: (compIdx == C20Idx)
? 282.00e-3
: 1e30;
}
static Scalar criticalTemperature(unsigned compIdx)
{
return
(compIdx == H2OIdx)
? H2O::criticalTemperature()
: (compIdx == C1Idx)
? 343.0*5/9
: (compIdx == C3Idx)
? 665.7*5/9
: (compIdx == C6Idx)
? 913.4*5/9
: (compIdx == C10Idx)
? 1111.8*5/9
: (compIdx == C15Idx)
? 1270.0*5/9
: (compIdx == C20Idx)
? 1380.0*5/9
: 1e30;
}
static Scalar criticalPressure(unsigned compIdx)
{
return
(compIdx == H2OIdx)
? H2O::criticalPressure()
: (compIdx == C1Idx)
? 667.8 * 6894.7573
: (compIdx == C3Idx)
? 616.3 * 6894.7573
: (compIdx == C6Idx)
? 436.9 * 6894.7573
: (compIdx == C10Idx)
? 304.0 * 6894.7573
: (compIdx == C15Idx)
? 200.0 * 6894.7573
: (compIdx == C20Idx)
? 162.0 * 6894.7573
: 1e30;
}
static Scalar criticalMolarVolume(unsigned compIdx)
{
return
(compIdx == H2OIdx)
? H2O::criticalMolarVolume()
: (compIdx == C1Idx)
? 0.290*R*criticalTemperature(C1Idx)/criticalPressure(C1Idx)
: (compIdx == C3Idx)
? 0.277*R*criticalTemperature(C3Idx)/criticalPressure(C3Idx)
: (compIdx == C6Idx)
? 0.264*R*criticalTemperature(C6Idx)/criticalPressure(C6Idx)
: (compIdx == C10Idx)
? 0.257*R*criticalTemperature(C10Idx)/criticalPressure(C10Idx)
: (compIdx == C15Idx)
? 0.245*R*criticalTemperature(C15Idx)/criticalPressure(C15Idx)
: (compIdx == C20Idx)
? 0.235*R*criticalTemperature(C20Idx)/criticalPressure(C20Idx)
: 1e30;
}
static Scalar acentricFactor(unsigned compIdx)
{
return
(compIdx == H2OIdx)
? H2O::acentricFactor()
: (compIdx == C1Idx)
? 0.0130
: (compIdx == C3Idx)
? 0.1524
: (compIdx == C6Idx)
? 0.3007
: (compIdx == C10Idx)
? 0.4885
: (compIdx == C15Idx)
? 0.6500
: (compIdx == C20Idx)
? 0.8500
: 1e30;
}
static Scalar interactionCoefficient(unsigned comp1Idx, unsigned comp2Idx)
{
unsigned i = std::min(comp1Idx, comp2Idx);
unsigned j = std::max(comp1Idx, comp2Idx);
if (i == C1Idx && (j == C15Idx || j == C20Idx))
return 0.05;
else if (i == C3Idx && (j == C15Idx || j == C20Idx))
return 0.005;
return 0;
}
/****************************************
* Methods which compute stuff
****************************************/
static void init(Scalar minT = 273.15,
Scalar maxT = 373.15,
Scalar minP = 1e4,
Scalar maxP = 100e6)
{
PengRobinsonParamsMixture<Scalar, ThisType, gasPhaseIdx, /*useSpe5=*/true> prParams;
// find envelopes of the 'a' and 'b' parameters for the range
// minT <= T <= maxT and minP <= p <= maxP. For
// this we take advantage of the fact that 'a' and 'b' for
// mixtures is just a convex combination of the attractive and
// repulsive parameters of the pure components
Scalar minA = 1e30, maxA = -1e30;
Scalar minB = 1e30, maxB = -1e30;
prParams.updatePure(minT, minP);
for (unsigned compIdx = 0; compIdx < numComponents; ++compIdx) {
minA = std::min(prParams.pureParams(compIdx).a(), minA);
maxA = std::max(prParams.pureParams(compIdx).a(), maxA);
minB = std::min(prParams.pureParams(compIdx).b(), minB);
maxB = std::max(prParams.pureParams(compIdx).b(), maxB);
};
prParams.updatePure(maxT, minP);
for (unsigned compIdx = 0; compIdx < numComponents; ++compIdx) {
minA = std::min(prParams.pureParams(compIdx).a(), minA);
maxA = std::max(prParams.pureParams(compIdx).a(), maxA);
minB = std::min(prParams.pureParams(compIdx).b(), minB);
maxB = std::max(prParams.pureParams(compIdx).b(), maxB);
};
prParams.updatePure(minT, maxP);
for (unsigned compIdx = 0; compIdx < numComponents; ++compIdx) {
minA = std::min(prParams.pureParams(compIdx).a(), minA);
maxA = std::max(prParams.pureParams(compIdx).a(), maxA);
minB = std::min(prParams.pureParams(compIdx).b(), minB);
maxB = std::max(prParams.pureParams(compIdx).b(), maxB);
};
prParams.updatePure(maxT, maxP);
for (unsigned compIdx = 0; compIdx < numComponents; ++compIdx) {
minA = std::min(prParams.pureParams(compIdx).a(), minA);
maxA = std::max(prParams.pureParams(compIdx).a(), maxA);
minB = std::min(prParams.pureParams(compIdx).b(), minB);
maxB = std::max(prParams.pureParams(compIdx).b(), maxB);
};
PengRobinson::init(/*aMin=*/minA, /*aMax=*/maxA, /*na=*/100,
/*bMin=*/minB, /*bMax=*/maxB, /*nb=*/200);
}
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);
return 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)
{
assert(phaseIdx <= numPhases);
if (phaseIdx == gasPhaseIdx) {
// given by SPE-5 in table on page 64. we use a constant
// viscosity, though...
return 0.0170e-2 * 0.1;
}
else if (phaseIdx == waterPhaseIdx)
// given by SPE-5: 0.7 centi-Poise = 0.0007 Pa s
return 0.7e-2 * 0.1;
else {
assert(phaseIdx == oilPhaseIdx);
// given by SPE-5 in table on page 64. we use a constant
// viscosity, though...
return 0.208e-2 * 0.1;
}
}
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 == oilPhaseIdx || phaseIdx == gasPhaseIdx)
return PengRobinsonMixture::computeFugacityCoefficient(fluidState,
paramCache,
phaseIdx,
compIdx);
else {
assert(phaseIdx == waterPhaseIdx);
return
henryCoeffWater_(compIdx, fluidState.temperature(waterPhaseIdx))
/ fluidState.pressure(waterPhaseIdx);
}
}
protected:
template <class LhsEval>
static LhsEval henryCoeffWater_(unsigned compIdx, const LhsEval& temperature)
{
// use henry's law for the solutes and the vapor pressure for
// the solvent.
switch (compIdx) {
case H2OIdx: return H2O::vaporPressure(temperature);
// the values of the Henry constant for the solutes have
// are faked so far...
case C1Idx: return 5.57601e+09;
case C3Idx: return 1e10;
case C6Idx: return 1e10;
case C10Idx: return 1e10;
case C15Idx: return 1e10;
case C20Idx: return 1e10;
default: throw std::logic_error("Unknown component index "+std::to_string(compIdx));
}
}
};
template <class Scalar>
const Scalar Spe5FluidSystem<Scalar>::R = Constants<Scalar>::R;
} // namespace Opm
#endif
BaseFluidSystem.hpp
The base class for all fluid systems.
Constants.hpp
PengRobinsonMixture.hpp
Implements the Peng-Robinson equation of state for a mixture.
Spe5ParameterCache.hpp
Specifies the parameter cache used by the SPE-5 fluid system.
Spline.hpp
Class implementing cubic splines.
Opm::BaseFluidSystem
The base class for all fluid systems.
Definition BaseFluidSystem.hpp:43
Opm::BaseFluidSystem< Scalar, Spe5FluidSystem< Scalar > >::Scalar
Scalar Scalar
Definition BaseFluidSystem.hpp:48
Opm::Constants::R
static constexpr Scalar R
The ideal gas constant [J/(mol K)].
Definition Constants.hpp:45
Opm::H2O::criticalTemperature
static const Scalar criticalTemperature()
Returns the critical temperature of water.
Definition H2O.hpp:97
Opm::H2O::name
static std::string_view name()
A human readable name for the water.
Definition H2O.hpp:79
Opm::H2O::vaporPressure
static Evaluation vaporPressure(Evaluation temperature)
The vapor pressure in of pure water at a given temperature.
Definition H2O.hpp:143
Opm::H2O::criticalMolarVolume
static const Scalar criticalMolarVolume()
Returns the molar volume of water at the critical point.
Definition H2O.hpp:115
Opm::H2O::acentricFactor
static const Scalar acentricFactor()
The acentric factor of water.
Definition H2O.hpp:91
Opm::H2O::criticalPressure
static const Scalar criticalPressure()
Returns the critical pressure of water.
Definition H2O.hpp:103
Opm::H2O::molarMass
static const Scalar molarMass()
The molar mass in of water.
Definition H2O.hpp:85
Opm::PengRobinsonMixture< Scalar, ThisType >::computeFugacityCoefficient
static LhsEval computeFugacityCoefficient(const FluidState &fs, const Params &params, unsigned phaseIdx, unsigned compIdx)
Definition PengRobinsonMixture.hpp:74
Opm::PengRobinsonParamsMixture
The mixing rule for the oil and the gas phases of the SPE5 problem.
Definition PengRobinsonParamsMixture.hpp:60
Opm::PengRobinsonParamsMixture::updatePure
void updatePure(const FluidState &fluidState)
Update Peng-Robinson parameters for the pure components.
Definition PengRobinsonParamsMixture.hpp:82
Opm::PengRobinsonParamsMixture::pureParams
const PureParams & pureParams(unsigned compIdx) const
Return the Peng-Robinson parameters of a pure substance,.
Definition PengRobinsonParamsMixture.hpp:201
Opm::PengRobinsonParams::a
Scalar a() const
Returns the attractive parameter 'a' of the Peng-Robinson fluid.
Definition PengRobinsonParams.hpp:50
Opm::PengRobinsonParams::b
Scalar b() const
Returns the repulsive parameter 'b' of the Peng-Robinson fluid.
Definition PengRobinsonParams.hpp:57
Opm::Spe5FluidSystem
The fluid system for the oil, gas and water phases of the SPE5 problem.
Definition Spe5FluidSystem.hpp:59
Opm::Spe5FluidSystem::oilPhaseIdx
static const int oilPhaseIdx
Index of the oil phase.
Definition Spe5FluidSystem.hpp:85
Opm::Spe5FluidSystem::isIdealMixture
static bool isIdealMixture(unsigned phaseIdx)
Returns true if and only if a fluid phase is assumed to be an ideal mixture.
Definition Spe5FluidSystem.hpp:129
Opm::Spe5FluidSystem::H2OIdx
static const int H2OIdx
Index of the water component.
Definition Spe5FluidSystem.hpp:144
Opm::Spe5FluidSystem::numComponents
static const int numComponents
Number of chemical species in the fluid system.
Definition Spe5FluidSystem.hpp:142
Opm::Spe5FluidSystem::C15Idx
static const int C15Idx
Index of the C15 component.
Definition Spe5FluidSystem.hpp:149
Opm::Spe5FluidSystem::numPhases
static const int numPhases
Number of fluid phases in the fluid system.
Definition Spe5FluidSystem.hpp:78
Opm::Spe5FluidSystem::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 Spe5FluidSystem.hpp:399
Opm::Spe5FluidSystem::criticalPressure
static Scalar criticalPressure(unsigned compIdx)
Critical pressure of a component [Pa].
Definition Spe5FluidSystem.hpp:216
Opm::Spe5FluidSystem::density
static LhsEval density(const FluidState &fluidState, const ParameterCache< ParamCacheEval > &paramCache, unsigned phaseIdx)
Calculate the density [kg/m^3] of a fluid phase.
Definition Spe5FluidSystem.hpp:364
Opm::Spe5FluidSystem::criticalTemperature
static Scalar criticalTemperature(unsigned compIdx)
Critical temperature of a component [K].
Definition Spe5FluidSystem.hpp:193
Opm::Spe5FluidSystem::criticalMolarVolume
static Scalar criticalMolarVolume(unsigned compIdx)
Molar volume of a component at the critical point [m^3/mol].
Definition Spe5FluidSystem.hpp:239
Opm::Spe5FluidSystem::acentricFactor
static Scalar acentricFactor(unsigned compIdx)
The acentric factor of a component [].
Definition Spe5FluidSystem.hpp:262
Opm::Spe5FluidSystem::viscosity
static LhsEval viscosity(const FluidState &, const ParameterCache< ParamCacheEval > &, unsigned phaseIdx)
Calculate the dynamic viscosity of a fluid phase [Pa*s].
Definition Spe5FluidSystem.hpp:375
Opm::Spe5FluidSystem::init
static void init(Scalar minT=273.15, Scalar maxT=373.15, Scalar minP=1e4, Scalar maxP=100e6)
Initialize the fluid system's static parameters.
Definition Spe5FluidSystem.hpp:310
Opm::Spe5FluidSystem::C1Idx
static const int C1Idx
Index of the C1 component.
Definition Spe5FluidSystem.hpp:145
Opm::Spe5FluidSystem::isCompressible
static bool isCompressible(unsigned)
Returns true if and only if a fluid phase is assumed to be compressible.
Definition Spe5FluidSystem.hpp:115
Opm::Spe5FluidSystem::C20Idx
static const int C20Idx
Index of the C20 component.
Definition Spe5FluidSystem.hpp:150
Opm::Spe5FluidSystem::C6Idx
static const int C6Idx
Index of the C6 component.
Definition Spe5FluidSystem.hpp:147
Opm::Spe5FluidSystem::C10Idx
static const int C10Idx
Index of the C10 component.
Definition Spe5FluidSystem.hpp:148
Opm::Spe5FluidSystem::interactionCoefficient
static Scalar interactionCoefficient(unsigned comp1Idx, unsigned comp2Idx)
Returns the interaction coefficient for two components.
Definition Spe5FluidSystem.hpp:287
Opm::Spe5FluidSystem::waterPhaseIdx
static const int waterPhaseIdx
Index of the water phase.
Definition Spe5FluidSystem.hpp:83
Opm::Spe5FluidSystem::molarMass
static Scalar molarMass(unsigned compIdx)
Return the molar mass of a component in [kg/mol].
Definition Spe5FluidSystem.hpp:170
Opm::Spe5FluidSystem::H2O
::Opm::H2O< Scalar > H2O
The component for pure water to be used.
Definition Spe5FluidSystem.hpp:88
Opm::Spe5FluidSystem::C3Idx
static const int C3Idx
Index of the C3 component.
Definition Spe5FluidSystem.hpp:146
Opm::Spe5FluidSystem::isLiquid
static bool isLiquid(unsigned phaseIdx)
Return whether a phase is liquid.
Definition Spe5FluidSystem.hpp:104
Opm::Spe5FluidSystem::gasPhaseIdx
static const int gasPhaseIdx
Index of the gas phase.
Definition Spe5FluidSystem.hpp:81
Opm::Spe5FluidSystem::componentName
static std::string_view componentName(unsigned compIdx)
Return the human readable name of a component.
Definition Spe5FluidSystem.hpp:153
Opm::Spe5FluidSystem::phaseName
static std::string_view phaseName(unsigned phaseIdx)
Return the human readable name of a fluid phase.
Definition Spe5FluidSystem.hpp:91
Opm::Spe5FluidSystem::isIdealGas
static bool isIdealGas(unsigned)
Returns true if and only if a fluid phase is assumed to be an ideal gas.
Definition Spe5FluidSystem.hpp:122
Opm::Spe5ParameterCache::molarVolume
Scalar molarVolume(unsigned phaseIdx) const
Returns the molar volume of a phase [m^3/mol].
Definition Spe5ParameterCache.hpp:222
Opm
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30
Opm::Spe5FluidSystem::ParameterCache
The type of the fluid system's parameter cache.
Definition Spe5FluidSystem.hpp:71