My Project
ThreeComponentFluidSystem.hh
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 #ifndef OPM_THREECOMPONENTFLUIDSYSTEM_HH
27 #define OPM_THREECOMPONENTFLUIDSYSTEM_HH
28 
33 
34 
35 // TODO: this is something else need to check
38 
39 namespace Opm {
47  template<class Scalar>
49  : public Opm::BaseFluidSystem<Scalar, ThreeComponentFluidSystem<Scalar> > {
50  public:
51  // TODO: I do not think these should be constant in fluidsystem, will try to make it non-constant later
52  static constexpr int numPhases=2;
53  static constexpr int numComponents = 3;
54  static constexpr int numMisciblePhases=2;
55  static constexpr int numMiscibleComponents = 3;
56  // TODO: phase location should be more general
57  static constexpr int oilPhaseIdx = 0;
58  static constexpr int gasPhaseIdx = 1;
59 
60  static constexpr int Comp0Idx = 0;
61  static constexpr int Comp1Idx = 1;
62  static constexpr int Comp2Idx = 2;
63 
64  // TODO: needs to be more general
66  using Comp1 = Opm::C1<Scalar>;
67  using Comp2 = Opm::C10<Scalar>;
68 
69  template <class ValueType>
72  using PengRobinsonMixture = typename Opm::PengRobinsonMixture<Scalar, ThreeComponentFluidSystem<Scalar>>;
73 
79  static Scalar acentricFactor(unsigned compIdx)
80  {
81  switch (compIdx) {
82  case Comp0Idx: return Comp0::acentricFactor();
83  case Comp1Idx: return Comp1::acentricFactor();
84  case Comp2Idx: return Comp2::acentricFactor();
85  default: throw std::runtime_error("Illegal component index for acentricFactor");
86  }
87  }
93  static Scalar criticalTemperature(unsigned compIdx)
94  {
95  switch (compIdx) {
96  case Comp0Idx: return Comp0::criticalTemperature();
97  case Comp1Idx: return Comp1::criticalTemperature();
98  case Comp2Idx: return Comp2::criticalTemperature();
99  default: throw std::runtime_error("Illegal component index for criticalTemperature");
100  }
101  }
107  static Scalar criticalPressure(unsigned compIdx) {
108  switch (compIdx) {
109  case Comp0Idx: return Comp0::criticalPressure();
110  case Comp1Idx: return Comp1::criticalPressure();
111  case Comp2Idx: return Comp2::criticalPressure();
112  default: throw std::runtime_error("Illegal component index for criticalPressure");
113  }
114  }
120  static Scalar criticalVolume(unsigned compIdx)
121  {
122  switch (compIdx) {
123  case Comp0Idx: return Comp0::criticalVolume();
124  case Comp1Idx: return Comp1::criticalVolume();
125  case Comp2Idx: return Comp2::criticalVolume();
126  default: throw std::runtime_error("Illegal component index for criticalVolume");
127  }
128  }
129 
131  static Scalar molarMass(unsigned compIdx)
132  {
133  switch (compIdx) {
134  case Comp0Idx: return Comp0::molarMass();
135  case Comp1Idx: return Comp1::molarMass();
136  case Comp2Idx: return Comp2::molarMass();
137  default: throw std::runtime_error("Illegal component index for molarMass");
138  }
139  }
140 
145  static Scalar interactionCoefficient(unsigned /*comp1Idx*/, unsigned /*comp2Idx*/)
146  {
147  return 0.0;
148  }
149 
151  static const char* phaseName(unsigned phaseIdx)
152  {
153  static const char* name[] = {"o", // oleic phase
154  "g"}; // gas phase
155 
156  assert(0 <= phaseIdx && phaseIdx < 2);
157  return name[phaseIdx];
158  }
159 
161  static const char* componentName(unsigned compIdx)
162  {
163  static const char* name[] = {
164  Comp0::name(),
165  Comp1::name(),
166  Comp2::name(),
167  };
168 
169  assert(0 <= compIdx && compIdx < 3);
170  return name[compIdx];
171  }
172 
176  template <class FluidState, class LhsEval = typename FluidState::Scalar, class ParamCacheEval = LhsEval>
177  static LhsEval density(const FluidState& fluidState,
178  const ParameterCache<ParamCacheEval>& paramCache,
179  unsigned phaseIdx)
180  {
181 
182  LhsEval dens;
183  if (phaseIdx == oilPhaseIdx || phaseIdx == gasPhaseIdx) {
184  dens = fluidState.averageMolarMass(phaseIdx) / paramCache.molarVolume(phaseIdx);
185  }
186  return dens;
187 
188  }
189 
191  template <class FluidState, class LhsEval = typename FluidState::Scalar, class ParamCacheEval = LhsEval>
192  static LhsEval viscosity(const FluidState& fluidState,
193  const ParameterCache<ParamCacheEval>& paramCache,
194  unsigned phaseIdx)
195  {
196  // Use LBC method to calculate viscosity
197  LhsEval mu;
198  mu = ViscosityModel::LBC(fluidState, paramCache, phaseIdx);
199 
200  }
201 
203  template <class FluidState, class LhsEval = typename FluidState::Scalar, class ParamCacheEval = LhsEval>
204  static LhsEval fugacityCoefficient(const FluidState& fluidState,
205  const ParameterCache<ParamCacheEval>& paramCache,
206  unsigned phaseIdx,
207  unsigned compIdx)
208  {
209  assert(phaseIdx < numPhases);
210  assert(compIdx < numComponents);
211 
212  LhsEval phi = PengRobinsonMixture::computeFugacityCoefficient(fluidState, paramCache, phaseIdx, compIdx);
213  return phi;
214  }
215 
216  };
217 }
218 #endif //OPM_THREECOMPONENTFLUIDSYSTEM_HH
The base class for all fluid systems.
Properties of pure molecular n-Decane .
Properties of pure molecular methane .
Specifies the parameter cache used by the SPE-5 fluid system.
A simplistic class representing the fluid properties.
The base class for all fluid systems.
Definition: BaseFluidSystem.hpp:44
Scalar Scalar
The type used for scalar quantities.
Definition: BaseFluidSystem.hpp:49
Properties of pure molecular n-Decane .
Definition: C10.hpp:49
static Scalar criticalVolume()
Critical volume of [m2/kmol].
Definition: C10.hpp:80
static const char * name()
A human readable name for NDecane.
Definition: C10.hpp:56
static Scalar criticalPressure()
Returns the critical pressure of molecular n-Decane.
Definition: C10.hpp:74
static Scalar criticalTemperature()
Returns the critical temperature of molecular n-Decane.
Definition: C10.hpp:68
static Scalar molarMass()
The molar mass in of molecular n-Decane.
Definition: C10.hpp:62
static Scalar acentricFactor()
Acentric factor of .
Definition: C10.hpp:85
Properties of pure molecular methane .
Definition: C1.hpp:49
static Scalar criticalPressure()
Returns the critical pressure of molecular methane.
Definition: C1.hpp:74
static Scalar molarMass()
The molar mass in of molecular methane.
Definition: C1.hpp:62
static Scalar criticalTemperature()
Returns the critical temperature of molecular methane.
Definition: C1.hpp:68
static const char * name()
A human readable name for NDecane.
Definition: C1.hpp:56
static Scalar acentricFactor()
Acentric factor of .
Definition: C1.hpp:85
static Scalar criticalVolume()
Critical volume of [m2/kmol].
Definition: C1.hpp:80
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
A two phase three component fluid system with components CO2, Methane and NDekan.
Definition: ThreeComponentFluidSystem.hh:49
static const char * componentName(unsigned compIdx)
Return the human readable name of a component.
Definition: ThreeComponentFluidSystem.hh:161
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:204
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:177
static Scalar criticalPressure(unsigned compIdx)
Critical pressure of a component [Pa].
Definition: ThreeComponentFluidSystem.hh:107
static const char * phaseName(unsigned phaseIdx)
Return the human readable name of a fluid phase.
Definition: ThreeComponentFluidSystem.hh:151
static Scalar criticalTemperature(unsigned compIdx)
Critical temperature of a component [K].
Definition: ThreeComponentFluidSystem.hh:93
static Scalar molarMass(unsigned compIdx)
Return the molar mass of a component in [kg/mol].
Definition: ThreeComponentFluidSystem.hh:131
static Scalar acentricFactor(unsigned compIdx)
The acentric factor of a component [].
Definition: ThreeComponentFluidSystem.hh:79
static Scalar interactionCoefficient(unsigned, unsigned)
Returns the interaction coefficient for two components.
Definition: ThreeComponentFluidSystem.hh:145
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:192
static Scalar criticalVolume(unsigned compIdx)
Critical volume of a component [m3].
Definition: ThreeComponentFluidSystem.hh:120
Definition: LBC.hpp:40