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  Copyright (C) 2009-2013 by Andreas Lauser
5  Copyright (C) 2012 by Philipp Nuske
6  Copyright (C) 2012 by Klaus Mosthaf
7 
8  This file is part of the Open Porous Media project (OPM).
9 
10  OPM is free software: you can redistribute it and/or modify
11  it under the terms of the GNU General Public License as published by
12  the Free Software Foundation, either version 2 of the License, or
13  (at your option) any later version.
14 
15  OPM is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with OPM. If not, see <http://www.gnu.org/licenses/>.
22 */
27 #ifndef OPM_BASE_FLUID_SYSTEM_HPP
28 #define OPM_BASE_FLUID_SYSTEM_HPP
29 
30 #include "NullParameterCache.hpp"
31 
32 #include <opm/common/Exceptions.hpp>
33 #include <opm/common/ErrorMacros.hpp>
35 
36 namespace Opm {
37 
42 template <class Scalar, class Implementation>
44 {
45 public:
55 
57  static const int numComponents = -1000;
58 
60  static const int numPhases = -2000;
61 
67  static char *phaseName(unsigned /*phaseIdx*/)
68  {
69  OPM_THROW(std::runtime_error,
70  "Not implemented: The fluid system '" << Opm::className<Implementation>() << "' does not provide a phaseName() method!");
71  }
72 
78  static bool isLiquid(unsigned /*phaseIdx*/)
79  {
80  OPM_THROW(std::runtime_error,
81  "Not implemented: The fluid system '" << Opm::className<Implementation>() << "' does not provide a isLiquid() method!");
82  }
83 
98  static bool isIdealMixture(unsigned /*phaseIdx*/)
99  {
100  OPM_THROW(std::runtime_error,
101  "Not implemented: The fluid system '" << Opm::className<Implementation>() << "' does not provide a isIdealMixture() method!");
102  }
103 
113  static bool isCompressible(unsigned /*phaseIdx*/)
114  {
115  OPM_THROW(std::runtime_error,
116  "Not implemented: The fluid system '" << Opm::className<Implementation>() << "' does not provide a isCompressible() method!");
117  }
118 
125  static bool isIdealGas(unsigned /*phaseIdx*/)
126  {
127  OPM_THROW(std::runtime_error,
128  "Not implemented: The fluid system '" << Opm::className<Implementation>() << "' does not provide a isIdealGas() method!");
129  }
130 
136  static const char *componentName(unsigned /*compIdx*/)
137  {
138  OPM_THROW(std::runtime_error,
139  "Not implemented: The fluid system '" << Opm::className<Implementation>() << "' does not provide a componentName() method!");
140  }
141 
147  static Scalar molarMass(unsigned /*compIdx*/)
148  {
149  OPM_THROW(std::runtime_error,
150  "Not implemented: The fluid system '" << Opm::className<Implementation>() << "' does not provide a molarMass() method!");
151  }
152 
156  static void init()
157  { }
158 
165  template <class FluidState, class LhsEval = typename FluidState::Scalar, class ParameterCache = NullParameterCache>
166  static LhsEval density(const FluidState &/*fluidState*/,
167  const ParameterCache &/*paramCache*/,
168  unsigned /*phaseIdx*/)
169  {
170  OPM_THROW(std::runtime_error,
171  "Not implemented: The fluid system '" << Opm::className<Implementation>() << "' does not provide a density() method!");
172  }
173 
188  template <class FluidState, class LhsEval = typename FluidState::Scalar, class ParameterCache = NullParameterCache>
189  static LhsEval fugacityCoefficient(const FluidState &/*fluidState*/,
190  const ParameterCache &/*paramCache*/,
191  unsigned /*phaseIdx*/,
192  unsigned /*compIdx*/)
193  {
194  OPM_THROW(std::runtime_error, "Not implemented: The fluid system '" << Opm::className<Implementation>() << "' does not provide a fugacityCoefficient() method!");
195  }
196 
203  template <class FluidState, class LhsEval = typename FluidState::Scalar, class ParameterCache = NullParameterCache>
204  static LhsEval viscosity(const FluidState &/*fluidState*/,
205  const ParameterCache &/*paramCache*/,
206  unsigned /*phaseIdx*/)
207  {
208  OPM_THROW(std::runtime_error, "Not implemented: The fluid system '" << Opm::className<Implementation>() << "' does not provide a viscosity() method!");
209  }
210 
228  template <class FluidState, class LhsEval = typename FluidState::Scalar, class ParameterCache = NullParameterCache>
229  static LhsEval diffusionCoefficient(const FluidState &/*fluidState*/,
230  const ParameterCache &/*paramCache*/,
231  unsigned /*phaseIdx*/,
232  unsigned /*compIdx*/)
233  {
234  OPM_THROW(std::runtime_error, "Not implemented: The fluid system '" << Opm::className<Implementation>() << "' does not provide a diffusionCoefficient() method!");
235  }
236 
244  template <class FluidState, class LhsEval = typename FluidState::Scalar, class ParameterCache = NullParameterCache>
245  static LhsEval enthalpy(const FluidState &/*fluidState*/,
246  const ParameterCache &/*paramCache*/,
247  unsigned /*phaseIdx*/)
248  {
249  OPM_THROW(std::runtime_error, "Not implemented: The fluid system '" << Opm::className<Implementation>() << "' does not provide an enthalpy() method!");
250  }
251 
258  template <class FluidState, class LhsEval = typename FluidState::Scalar, class ParameterCache = NullParameterCache>
259  static LhsEval thermalConductivity(const FluidState &/*fluidState*/,
260  const ParameterCache &/*paramCache*/,
261  unsigned /*phaseIdx*/)
262  {
263  OPM_THROW(std::runtime_error, "Not implemented: The fluid system '" << Opm::className<Implementation>() << "' does not provide a thermalConductivity() method!");
264  }
265 
272  template <class FluidState, class LhsEval = typename FluidState::Scalar, class ParameterCache = NullParameterCache>
273  static LhsEval heatCapacity(const FluidState &/*fluidState*/,
274  const ParameterCache &/*paramCache*/,
275  unsigned /*phaseIdx*/)
276  {
277  OPM_THROW(std::runtime_error, "Not implemented: The fluid system '" << Opm::className<Implementation>() << "' does not provide a heatCapacity() method!");
278  }
279 };
280 
281 } // namespace Opm
282 
283 #endif
static LhsEval diffusionCoefficient(const FluidState &, const ParameterCache &, unsigned, unsigned)
Calculate the binary molecular diffusion coefficient for a component in a fluid phase [mol^2 * s / (k...
Definition: BaseFluidSystem.hpp:229
static char * phaseName(unsigned)
Return the human readable name of a fluid phase.
Definition: BaseFluidSystem.hpp:67
static bool isLiquid(unsigned)
Return whether a phase is liquid.
Definition: BaseFluidSystem.hpp:78
Definition: Air_Mesitylene.hpp:31
A parameter cache which does nothing.
static LhsEval heatCapacity(const FluidState &, const ParameterCache &, unsigned)
Specific isobaric heat capacity of a fluid phase [J/kg].
Definition: BaseFluidSystem.hpp:273
static LhsEval viscosity(const FluidState &, const ParameterCache &, unsigned)
Calculate the dynamic viscosity of a fluid phase [Pa*s].
Definition: BaseFluidSystem.hpp:204
static LhsEval fugacityCoefficient(const FluidState &, const ParameterCache &, unsigned, unsigned)
Calculate the fugacity coefficient [Pa] of an individual component in a fluid phase.
Definition: BaseFluidSystem.hpp:189
The base class for all fluid systems.
Definition: BaseFluidSystem.hpp:43
A parameter cache which does nothing.
Definition: NullParameterCache.hpp:36
static const char * componentName(unsigned)
Return the human readable name of a component.
Definition: BaseFluidSystem.hpp:136
static LhsEval density(const FluidState &, const ParameterCache &, unsigned)
Calculate the density [kg/m^3] of a fluid phase.
Definition: BaseFluidSystem.hpp:166
static bool isIdealGas(unsigned)
Returns true if and only if a fluid phase is assumed to be an ideal gas.
Definition: BaseFluidSystem.hpp:125
static bool isCompressible(unsigned)
Returns true if and only if a fluid phase is assumed to be compressible.
Definition: BaseFluidSystem.hpp:113
static LhsEval thermalConductivity(const FluidState &, const ParameterCache &, unsigned)
Thermal conductivity of a fluid phase [W/(m K)].
Definition: BaseFluidSystem.hpp:259
static void init()
Initialize the fluid system's static parameters.
Definition: BaseFluidSystem.hpp:156
static LhsEval enthalpy(const FluidState &, const ParameterCache &, unsigned)
Given a phase's composition, temperature, pressure and density, calculate its specific enthalpy [J/kg...
Definition: BaseFluidSystem.hpp:245
static Scalar molarMass(unsigned)
Return the molar mass of a component in [kg/mol].
Definition: BaseFluidSystem.hpp:147
A free function to provide the demangled class name of a given object or type as a string...
static const int numPhases
Number of fluid phases in the fluid system.
Definition: BaseFluidSystem.hpp:60
static bool isIdealMixture(unsigned)
Returns true if and only if a fluid phase is assumed to be an ideal mixture.
Definition: BaseFluidSystem.hpp:98
static const int numComponents
Number of chemical species in the fluid system.
Definition: BaseFluidSystem.hpp:57
NullParameterCache ParameterCache
The type of the fluid system's parameter cache.
Definition: BaseFluidSystem.hpp:54