opm-common
Co2BrineFluidSystem.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 
27 #ifndef OPM_CO2BRINEFLUIDSYSTEM_HH
28 #define OPM_CO2BRINEFLUIDSYSTEM_HH
29 
34 
37 
38 #include <string_view>
39 
40 namespace Opm {
47  template<class Scalar>
49  : public Opm::BaseFluidSystem<Scalar, Co2BrineFluidSystem<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 = 2;
54  static constexpr int numMisciblePhases=2;
55  static constexpr int numMiscibleComponents = 2;
56  static constexpr bool waterEnabled = false;
57  static constexpr int oilPhaseIdx = 0;
58  static constexpr int gasPhaseIdx = 1;
59  static constexpr int waterPhaseIdx = -1;
60 
61  static constexpr int Comp0Idx = 0;
62  static constexpr int Comp1Idx = 1;
63 
66 
67  template <class ValueType>
69  using ViscosityModel = typename Opm::ViscosityModels<Scalar, Co2BrineFluidSystem<Scalar>>;
70 
71  using CubicEOS = typename Opm::CubicEOS<Scalar, Co2BrineFluidSystem<Scalar>>;
72 
73 
79  static Scalar acentricFactor(unsigned compIdx)
80  {
81  switch (compIdx) {
82  case Comp0Idx: return Comp0::acentricFactor();
83  case Comp1Idx: return Comp1::acentricFactor();
84  default: throw std::runtime_error("Illegal component index for acentricFactor");
85  }
86  }
92  static Scalar criticalTemperature(unsigned compIdx)
93  {
94  switch (compIdx) {
95  case Comp0Idx: return Comp0::criticalTemperature();
96  case Comp1Idx: return Comp1::criticalTemperature();
97  default: throw std::runtime_error("Illegal component index for criticalTemperature");
98  }
99  }
105  static Scalar criticalPressure(unsigned compIdx) {
106  switch (compIdx) {
107  case Comp0Idx: return Comp0::criticalPressure();
108  case Comp1Idx: return Comp1::criticalPressure();
109  default: throw std::runtime_error("Illegal component index for criticalPressure");
110  }
111  }
117  static Scalar criticalVolume(unsigned compIdx)
118  {
119  switch (compIdx) {
120  case Comp0Idx: return Comp0::criticalVolume();
121  case Comp1Idx: return Comp1::criticalVolume();
122  default: throw std::runtime_error("Illegal component index for criticalVolume");
123  }
124  }
125 
127  static Scalar molarMass(unsigned compIdx)
128  {
129  switch (compIdx) {
130  case Comp0Idx: return Comp0::molarMass();
131  case Comp1Idx: return Comp1::molarMass();
132  default: throw std::runtime_error("Illegal component index for molarMass");
133  }
134  }
135 
140  static Scalar interactionCoefficient(unsigned /*comp1Idx*/, unsigned /*comp2Idx*/)
141  {
142  return 0.0;
143  }
144 
146  static std::string_view phaseName(unsigned phaseIdx)
147  {
148  static const std::string_view name[] = {"o", // oleic phase
149  "g"}; // gas phase
150 
151  assert(phaseIdx < 2);
152  return name[phaseIdx];
153  }
154 
156  static std::string_view componentName(unsigned compIdx)
157  {
158  static const std::string_view name[] = {
159  Comp0::name(),
160  Comp1::name(),
161  };
162 
163  assert(compIdx < 3);
164  return name[compIdx];
165  }
166 
170  template <class FluidState, class LhsEval = typename FluidState::ValueType, class ParamCacheEval = LhsEval>
171  static LhsEval density(const FluidState& fluidState,
172  const ParameterCache<ParamCacheEval>& paramCache,
173  unsigned phaseIdx)
174  {
175 
176  LhsEval dens;
177  if (phaseIdx == oilPhaseIdx || phaseIdx == gasPhaseIdx) {
178  dens = fluidState.averageMolarMass(phaseIdx) / paramCache.molarVolume(phaseIdx);
179  }
180  return dens;
181 
182  }
183 
187  template <class FluidState, class LhsEval = typename FluidState::ValueType, class ParamCacheEval = LhsEval>
188  static LhsEval viscosity(const FluidState& fluidState,
189  const ParameterCache<ParamCacheEval>& paramCache,
190  unsigned phaseIdx)
191  {
192  // Use LBC method to calculate viscosity
193  LhsEval mu;
194  mu = ViscosityModel::LBC(fluidState, paramCache, phaseIdx);
195 
196 
197  return mu;
198 
199  }
200 
202  template <class FluidState, class LhsEval = typename FluidState::ValueType, class ParamCacheEval = LhsEval>
203  static LhsEval fugacityCoefficient(const FluidState& fluidState,
204  const ParameterCache<ParamCacheEval>& paramCache,
205  unsigned phaseIdx,
206  unsigned compIdx)
207  {
208  assert(phaseIdx < numPhases);
209  assert(compIdx < numComponents);
210 
211  LhsEval phi = CubicEOS::computeFugacityCoefficient(fluidState, paramCache, phaseIdx, compIdx);
212 
213  return phi;
214  }
215 
216  };
217 }
218 #endif //OPM_CO2BRINEFLUIDSYSTEM_HH
A simplistic class representing the fluid properties.
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
Specifies the parameter cache used by the SPE-5 fluid system.
Definition: PTFlashParameterCache.hpp:49
A class for the brine fluid properties.
static Scalar molarMass()
The molar mass in of the component.
Definition: Brine.hpp:82
static Scalar acentricFactor()
Acentric factor of .
Definition: SimpleCO2.hpp:87
Definition: LBC.hpp:39
static Scalar criticalVolume(unsigned compIdx)
Critical volume of a component [m3].
Definition: Co2BrineFluidSystem.hh:117
static std::string_view name()
A human readable name for the component.
Definition: SimpleCO2.hpp:57
static Scalar criticalPressure()
Returns the critical pressure of .
Definition: SimpleCO2.hpp:75
static Scalar interactionCoefficient(unsigned, unsigned)
Returns the interaction coefficient for two components.
Definition: Co2BrineFluidSystem.hh:140
A class for the brine fluid properties.
Definition: Brine.hpp:47
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:30
Scalar molarVolume(unsigned phaseIdx) const
Returns the molar volume of a phase [m^3/mol].
Definition: PTFlashParameterCache.hpp:283
static std::string_view componentName(unsigned compIdx)
Return the human readable name of a component.
Definition: Co2BrineFluidSystem.hh:156
Definition: CubicEOS.hpp:33
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
Material properties of pure water .
static Scalar criticalTemperature()
Returns the critical temperature of .
Definition: SimpleCO2.hpp:69
static std::string_view name()
A human readable name for the component.
Definition: Brine.hpp:56
static Scalar molarMass()
The molar mass in of the component.
Definition: SimpleCO2.hpp:63
static Scalar criticalTemperature(unsigned compIdx)
Critical temperature of a component [K].
Definition: Co2BrineFluidSystem.hh:92
The base class for all fluid systems.
Definition: BaseFluidSystem.hpp:42
static Scalar acentricFactor(unsigned compIdx)
The acentric factor of a component [].
Definition: Co2BrineFluidSystem.hh:79
static Scalar criticalPressure()
Returns the critical pressure of water.
Definition: Brine.hpp:99
A two phase two component system with components co2 brine.
Definition: Co2BrineFluidSystem.hh:48
static Scalar criticalVolume()
Critical volume of [m2/kmol].
Definition: SimpleCO2.hpp:93
static std::string_view phaseName(unsigned phaseIdx)
Return the human readable name of a fluid phase.
Definition: Co2BrineFluidSystem.hh:146
static Scalar acentricFactor()
Definition: Brine.hpp:111
static Scalar criticalVolume()
Returns the critical volume of water.
Definition: Brine.hpp:105
Scalar Scalar
The type used for scalar quantities.
Definition: BaseFluidSystem.hpp:48
A simplistic class representing the fluid properties.
Definition: SimpleCO2.hpp:49
Specifies the parameter cache used by the SPE-5 fluid system.
static Scalar criticalTemperature()
Returns the critical temperature of water.
Definition: Brine.hpp:93
static Scalar criticalPressure(unsigned compIdx)
Critical pressure of a component [Pa].
Definition: Co2BrineFluidSystem.hh:105
static Scalar molarMass(unsigned compIdx)
Return the molar mass of a component in [kg/mol].
Definition: Co2BrineFluidSystem.hh:127
The base class for all fluid systems.
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