Co2BrineFluidSystem.hh
Go to the documentation of this file.
1// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 // vi: set et ts=4 sw=4 sts=4:
3 /*
4 Copyright 2022 SINTEF Digital, Mathematics and Cybernetics.
5
6 This file is part of the Open Porous Media project (OPM).
7
8 OPM is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 2 of the License, or
11 (at your option) any later version.
12
13 OPM is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with OPM. If not, see <http://www.gnu.org/licenses/>.
20
21 Consult the COPYING file in the top-level source directory of this
22 module for the precise wording of the license and the list of
23 copyright holders.
24 */
25
26
27#ifndef OPM_CO2BRINEFLUIDSYSTEM_HH
28#define OPM_CO2BRINEFLUIDSYSTEM_HH
29
34
37//#include <opm/material/viscositymodels/LBC.hpp>
38
39namespace Opm {
46 template<class Scalar>
48 : public Opm::BaseFluidSystem<Scalar, Co2BrineFluidSystem<Scalar> > {
49 public:
50 // TODO: I do not think these should be constant in fluidsystem, will try to make it non-constant later
51 static constexpr int numPhases=2;
52 static constexpr int numComponents = 2;
53 static constexpr int numMisciblePhases=2;
54 static constexpr int numMiscibleComponents = 2;
55 static constexpr int oilPhaseIdx = 0;
56 static constexpr int gasPhaseIdx = 1;
57
58 static constexpr int Comp0Idx = 0;
59 static constexpr int Comp1Idx = 1;
60
63
64 template <class ValueType>
67 //using ViscosityModel = typename Opm::ViscosityModels<Scalar, Co2BrineFluidSystem<Scalar>>;
68
70
71
77 static Scalar acentricFactor(unsigned compIdx)
78 {
79 switch (compIdx) {
80 case Comp0Idx: return Comp0::acentricFactor();
81 case Comp1Idx: return Comp1::acentricFactor();
82 default: throw std::runtime_error("Illegal component index for acentricFactor");
83 }
84 }
90 static Scalar criticalTemperature(unsigned compIdx)
91 {
92 switch (compIdx) {
95 default: throw std::runtime_error("Illegal component index for criticalTemperature");
96 }
97 }
103 static Scalar criticalPressure(unsigned compIdx) {
104 switch (compIdx) {
105 case Comp0Idx: return Comp0::criticalPressure();
106 case Comp1Idx: return Comp1::criticalPressure();
107 default: throw std::runtime_error("Illegal component index for criticalPressure");
108 }
109 }
115 static Scalar criticalVolume(unsigned compIdx)
116 {
117 switch (compIdx) {
118 case Comp0Idx: return Comp0::criticalVolume();
119 case Comp1Idx: return Comp1::criticalVolume();
120 default: throw std::runtime_error("Illegal component index for criticalVolume");
121 }
122 }
123
125 static Scalar molarMass(unsigned compIdx)
126 {
127 switch (compIdx) {
128 case Comp0Idx: return Comp0::molarMass();
129 case Comp1Idx: return Comp1::molarMass();
130 default: throw std::runtime_error("Illegal component index for molarMass");
131 }
132 }
133
138 static Scalar interactionCoefficient(unsigned /*comp1Idx*/, unsigned /*comp2Idx*/)
139 {
140 return 0.0;
141 }
142
144 static const char* phaseName(unsigned phaseIdx)
145 {
146 static const char* name[] = {"o", // oleic phase
147 "g"}; // gas phase
148
149 assert(0 <= phaseIdx && phaseIdx < 2);
150 return name[phaseIdx];
151 }
152
154 static const char* componentName(unsigned compIdx)
155 {
156 static const char* name[] = {
157 Comp0::name(),
158 Comp1::name(),
159 };
160
161 assert(0 <= compIdx && compIdx < 3);
162 return name[compIdx];
163 }
164
168 template <class FluidState, class LhsEval = typename FluidState::Scalar, class ParamCacheEval = LhsEval>
169 static LhsEval density(const FluidState& fluidState,
170 const ParameterCache<ParamCacheEval>& paramCache,
171 unsigned phaseIdx)
172 {
173
174 LhsEval dens;
175 if (phaseIdx == oilPhaseIdx || phaseIdx == gasPhaseIdx) {
176 dens = fluidState.averageMolarMass(phaseIdx) / paramCache.molarVolume(phaseIdx);
177 }
178 return dens;
179
180 }
181
185 template <class FluidState, class LhsEval = typename FluidState::Scalar, class ParamCacheEval = LhsEval>
186 static LhsEval viscosity(const FluidState& fluidState,
187 const ParameterCache<ParamCacheEval>& paramCache,
188 unsigned phaseIdx)
189 {
190 // Use LBC method to calculate viscosity
191 LhsEval mu;
192 mu = ViscosityModel::LBC(fluidState, paramCache, phaseIdx);
193
194
195 return mu;
196
197 }
198
200 template <class FluidState, class LhsEval = typename FluidState::Scalar, class ParamCacheEval = LhsEval>
201 static LhsEval fugacityCoefficient(const FluidState& fluidState,
202 const ParameterCache<ParamCacheEval>& paramCache,
203 unsigned phaseIdx,
204 unsigned compIdx)
205 {
206 assert(phaseIdx < numPhases);
207 assert(compIdx < numComponents);
208
209 LhsEval phi = PengRobinsonMixture::computeFugacityCoefficient(fluidState, paramCache, phaseIdx, compIdx);
210
211 return phi;
212 }
213
214 };
215}
216#endif //OPM_CO2BRINEFLUIDSYSTEM_HH
The base class for all fluid systems.
Definition: BaseFluidSystem.hpp:44
Scalar Scalar
The type used for scalar quantities.
Definition: BaseFluidSystem.hpp:49
A class for the brine fluid properties.
Definition: Brine.hpp:46
static Scalar molarMass()
The molar mass in of the component.
Definition: Brine.hpp:80
static Scalar criticalVolume()
Returns the critical volume of water.
Definition: Brine.hpp:103
static Scalar criticalPressure()
Returns the critical pressure of water.
Definition: Brine.hpp:97
static const char * name()
A human readable name for the component.
Definition: Brine.hpp:54
static Scalar criticalTemperature()
Returns the critical temperature of water.
Definition: Brine.hpp:91
static Scalar acentricFactor()
Definition: Brine.hpp:109
A two phase two component system, co2 brine.
Definition: Co2BrineFluidSystem.hh:48
static const char * componentName(unsigned compIdx)
Return the human readable name of a component.
Definition: Co2BrineFluidSystem.hh:154
static Scalar criticalVolume(unsigned compIdx)
Critical volume of a component [m3].
Definition: Co2BrineFluidSystem.hh:115
static Scalar acentricFactor(unsigned compIdx)
The acentric factor of a component [].
Definition: Co2BrineFluidSystem.hh:77
static constexpr int gasPhaseIdx
Definition: Co2BrineFluidSystem.hh:56
static constexpr int numComponents
Definition: Co2BrineFluidSystem.hh:52
static constexpr int numPhases
Definition: Co2BrineFluidSystem.hh:51
static Scalar molarMass(unsigned compIdx)
Return the molar mass of a component in [kg/mol].
Definition: Co2BrineFluidSystem.hh:125
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:186
static constexpr int Comp0Idx
Definition: Co2BrineFluidSystem.hh:58
static constexpr int numMisciblePhases
Definition: Co2BrineFluidSystem.hh:53
typename Opm::ViscosityModels< Scalar, Co2BrineFluidSystem< Scalar > > ViscosityModel
Definition: Co2BrineFluidSystem.hh:66
static constexpr int Comp1Idx
Definition: Co2BrineFluidSystem.hh:59
static Scalar criticalPressure(unsigned compIdx)
Critical pressure of a component [Pa].
Definition: Co2BrineFluidSystem.hh:103
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:169
static constexpr int oilPhaseIdx
Definition: Co2BrineFluidSystem.hh:55
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:201
static constexpr int numMiscibleComponents
Definition: Co2BrineFluidSystem.hh:54
typename Opm::PengRobinsonMixture< Scalar, Co2BrineFluidSystem< Scalar > > PengRobinsonMixture
Definition: Co2BrineFluidSystem.hh:69
static const char * phaseName(unsigned phaseIdx)
Return the human readable name of a fluid phase.
Definition: Co2BrineFluidSystem.hh:144
static Scalar criticalTemperature(unsigned compIdx)
Critical temperature of a component [K].
Definition: Co2BrineFluidSystem.hh:90
static Scalar interactionCoefficient(unsigned, unsigned)
Returns the interaction coefficient for two components.
Definition: Co2BrineFluidSystem.hh:138
Specifies the parameter cache used by the SPE-5 fluid system.
Definition: PTFlashParameterCache.hpp:48
Scalar molarVolume(unsigned phaseIdx) const
Returns the molar volume of a phase [m^3/mol].
Definition: PTFlashParameterCache.hpp:199
Implements the Peng-Robinson equation of state for a mixture.
Definition: PengRobinsonMixture.hpp:41
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:89
A simplistic class representing the fluid properties.
Definition: SimpleCO2.hpp:51
static Scalar criticalVolume()
Critical volume of [m2/kmol].
Definition: SimpleCO2.hpp:94
static const char * name()
A human readable name for the component.
Definition: SimpleCO2.hpp:58
static Scalar criticalTemperature()
Returns the critical temperature of .
Definition: SimpleCO2.hpp:70
static Scalar acentricFactor()
Acentric factor of .
Definition: SimpleCO2.hpp:88
static Scalar criticalPressure()
Returns the critical pressure of .
Definition: SimpleCO2.hpp:76
static Scalar molarMass()
The molar mass in of the component.
Definition: SimpleCO2.hpp:64
Definition: LBC.hpp:40
Definition: Air_Mesitylene.hpp:34