opm-common
BaseFluidSystem.hpp
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  This file is part of the Open Porous Media project (OPM).
5 
6  OPM is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 2 of the License, or
9  (at your option) any later version.
10 
11  OPM is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with OPM. If not, see <http://www.gnu.org/licenses/>.
18 
19  Consult the COPYING file in the top-level source directory of this
20  module for the precise wording of the license and the list of
21  copyright holders.
22 */
27 #ifndef OPM_BASE_FLUID_SYSTEM_HPP
28 #define OPM_BASE_FLUID_SYSTEM_HPP
29 
30 #include <opm/common/utility/DemangledType.hpp>
31 
32 #include <stdexcept>
33 #include <string_view>
34 
35 namespace Opm {
36 
41 template <class ScalarT, class Implementation>
43 {
44 public:
48  typedef ScalarT Scalar;
49 
57  template <class Evaluation>
58  struct ParameterCache {
59  ParameterCache() = delete; // derived fluid systems must specify this class!
60  };
61 
63  static const int numComponents = -1000;
64 
66  static const int numPhases = -2000;
67 
73  static std::string_view phaseName(unsigned /*phaseIdx*/)
74  {
75  throw std::runtime_error(not_implemented("phaseName"));
76  }
77 
83  static bool isLiquid(unsigned /*phaseIdx*/)
84  {
85  throw std::runtime_error(not_implemented("isLiquid"));
86  }
87 
102  static bool isIdealMixture(unsigned /*phaseIdx*/)
103  {
104  throw std::runtime_error(not_implemented("isIdealMixture"));
105  }
106 
116  static bool isCompressible(unsigned /*phaseIdx*/)
117  {
118  throw std::runtime_error(not_implemented("isCompressible"));
119  }
120 
127  static bool isIdealGas(unsigned /*phaseIdx*/)
128  {
129  throw std::runtime_error(not_implemented("isIdealGas"));
130  }
131 
137  static std::string_view componentName(unsigned /*compIdx*/)
138  {
139  throw std::runtime_error(not_implemented("componentName"));
140  }
141 
147  static Scalar molarMass(unsigned /*compIdx*/)
148  {
149  throw std::runtime_error(not_implemented("molarMass"));
150  }
151 
157  static Scalar acentricFactor(unsigned /*compIdx*/)
158  {
159  throw std::runtime_error(not_implemented("acentricFactor"));
160  }
161 
165  static void init()
166  { }
167 
174  template <class FluidState, class LhsEval = typename FluidState::ValueType, class ParamCache>
175  static LhsEval density(const FluidState& /*fluidState*/,
176  const ParamCache& /*paramCache*/,
177  unsigned /*phaseIdx*/)
178  {
179  throw std::runtime_error(not_implemented("density"));
180  }
181 
196  template <class FluidState, class LhsEval = typename FluidState::ValueType, class ParamCache>
197  static LhsEval fugacityCoefficient(const FluidState& /*fluidState*/,
198  ParamCache& /*paramCache*/,
199  unsigned /*phaseIdx*/,
200  unsigned /*compIdx*/)
201  {
202  throw std::runtime_error(not_implemented("fugacityCoefficient"));
203  }
204 
211  template <class FluidState, class LhsEval = typename FluidState::ValueType, class ParamCache>
212  static LhsEval viscosity(const FluidState& /*fluidState*/,
213  ParamCache& /*paramCache*/,
214  unsigned /*phaseIdx*/)
215  {
216  throw std::runtime_error(not_implemented("viscosity"));
217  }
218 
236  template <class FluidState, class LhsEval = typename FluidState::ValueType, class ParamCache>
237  static LhsEval diffusionCoefficient(const FluidState& /*fluidState*/,
238  ParamCache& /*paramCache*/,
239  unsigned /*phaseIdx*/,
240  unsigned /*compIdx*/)
241  {
242  throw std::runtime_error(not_implemented("diffusionCoefficient"));
243  }
244 
252  template <class FluidState, class LhsEval = typename FluidState::ValueType, class ParamCache>
253  static LhsEval enthalpy(const FluidState& /*fluidState*/,
254  ParamCache& /*paramCache*/,
255  unsigned /*phaseIdx*/)
256  {
257  throw std::runtime_error(not_implemented("enthalpy"));
258  }
259 
266  template <class FluidState, class LhsEval = typename FluidState::ValueType, class ParamCache>
267  static LhsEval thermalConductivity(const FluidState& /*fluidState*/,
268  ParamCache& /*paramCache*/,
269  unsigned /*phaseIdx*/)
270  {
271  throw std::runtime_error(not_implemented("thermalConductivity"));
272  }
273 
280  template <class FluidState, class LhsEval = typename FluidState::ValueType, class ParamCache>
281  static LhsEval heatCapacity(const FluidState& /*fluidState*/,
282  ParamCache& /*paramCache*/,
283  unsigned /*phaseIdx*/)
284  {
285  throw std::runtime_error(not_implemented("heatCapacity"));
286  }
287 
288 
290  static bool phaseIsActive(unsigned /*phaseIdx*/)
291  {
292  return true;
293  }
294 
295 private:
296  static std::string not_implemented(const std::string_view method)
297  {
298  return "Not implemented: The fluid system '" +
299  getDemangledType<Implementation>() +
300  "' does not provide a " + method.data() + "() method!";
301  }
302 };
303 
304 } // namespace Opm
305 
306 #endif
static LhsEval diffusionCoefficient(const FluidState &, ParamCache &, unsigned, unsigned)
Calculate the binary molecular diffusion coefficient for a component in a fluid phase [mol^2 * s / (k...
Definition: BaseFluidSystem.hpp:237
static bool isIdealMixture(unsigned)
Returns true if and only if a fluid phase is assumed to be an ideal mixture.
Definition: BaseFluidSystem.hpp:102
static bool phaseIsActive(unsigned)
Returns whether a fluid phase is active.
Definition: BaseFluidSystem.hpp:290
static const int numComponents
Number of chemical species in the fluid system.
Definition: BaseFluidSystem.hpp:63
static const int numPhases
Number of fluid phases in the fluid system.
Definition: BaseFluidSystem.hpp:66
static void init()
Initialize the fluid system&#39;s static parameters.
Definition: BaseFluidSystem.hpp:165
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:30
static bool isIdealGas(unsigned)
Returns true if and only if a fluid phase is assumed to be an ideal gas.
Definition: BaseFluidSystem.hpp:127
static LhsEval thermalConductivity(const FluidState &, ParamCache &, unsigned)
Thermal conductivity of a fluid phase [W/(m K)].
Definition: BaseFluidSystem.hpp:267
The type of the fluid system&#39;s parameter cache.
Definition: BaseFluidSystem.hpp:58
static LhsEval enthalpy(const FluidState &, ParamCache &, unsigned)
Given a phase&#39;s composition, temperature, pressure and density, calculate its specific enthalpy [J/kg...
Definition: BaseFluidSystem.hpp:253
static LhsEval viscosity(const FluidState &, ParamCache &, unsigned)
Calculate the dynamic viscosity of a fluid phase [Pa*s].
Definition: BaseFluidSystem.hpp:212
static LhsEval density(const FluidState &, const ParamCache &, unsigned)
Calculate the density [kg/m^3] of a fluid phase.
Definition: BaseFluidSystem.hpp:175
The base class for all fluid systems.
Definition: BaseFluidSystem.hpp:42
static std::string_view phaseName(unsigned)
Return the human readable name of a fluid phase.
Definition: BaseFluidSystem.hpp:73
static Scalar molarMass(unsigned)
Return the molar mass of a component in [kg/mol].
Definition: BaseFluidSystem.hpp:147
ScalarT Scalar
The type used for scalar quantities.
Definition: BaseFluidSystem.hpp:48
static bool isLiquid(unsigned)
Return whether a phase is liquid.
Definition: BaseFluidSystem.hpp:83
static LhsEval heatCapacity(const FluidState &, ParamCache &, unsigned)
Specific isobaric heat capacity of a fluid phase [J/kg].
Definition: BaseFluidSystem.hpp:281
static LhsEval fugacityCoefficient(const FluidState &, ParamCache &, unsigned, unsigned)
Calculate the fugacity coefficient [Pa] of an individual component in a fluid phase.
Definition: BaseFluidSystem.hpp:197
static bool isCompressible(unsigned)
Returns true if and only if a fluid phase is assumed to be compressible.
Definition: BaseFluidSystem.hpp:116
static std::string_view componentName(unsigned)
Return the human readable name of a component.
Definition: BaseFluidSystem.hpp:137
static Scalar acentricFactor(unsigned)
Return the acetntric factor of a component.
Definition: BaseFluidSystem.hpp:157