version 3.8
1pgas.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// SPDX-FileCopyrightInfo: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5// SPDX-License-Identifier: GPL-3.0-or-later
6//
12#ifndef DUMUX_GAS_PHASE_HH
13#define DUMUX_GAS_PHASE_HH
14
15#include <cassert>
16#include <limits>
17
18#include <dune/common/exceptions.hh>
19
22#include <dumux/io/name.hh>
23
24namespace Dumux {
25namespace FluidSystems {
26
31template <class Scalar, class ComponentT>
33: public Base<Scalar, OnePGas<Scalar, ComponentT> >
34{
36
37 static_assert(ComponentTraits<ComponentT>::hasGasState, "The component does not implement a gas state!");
38
39public:
40 using Component = ComponentT;
42
43 static constexpr int numPhases = 1;
44 static constexpr int numComponents = 1;
45
46 static constexpr int phase0Idx = 0;
47 static constexpr int comp0Idx = 0;
48
52 static void init()
53 { }
54
55 /****************************************
56 * Fluid phase related static parameters
57 ****************************************/
63 static std::string phaseName(int phaseIdx = 0)
64 { return IOName::gaseousPhase(); }
65
71 static std::string componentName(int compIdx = 0)
72 { return Component::name(); }
73
77 static std::string name()
78 { return Component::name(); }
79
83 static constexpr bool isMiscible()
84 { return false; }
85
89 static constexpr bool isGas(int phaseIdx = 0)
90 { return true; }
91
106 static constexpr bool isIdealMixture(int phaseIdx = 0)
107 { return true; }
108
112 static constexpr bool isCompressible(int phaseIdx = 0)
113 { return Component::gasIsCompressible(); }
114
118 static constexpr bool isIdealGas(int phaseIdx = 0)
119 { return Component::gasIsIdeal(); }
120
127 static constexpr bool viscosityIsConstant(int phaseIdx)
128 { return Component::gasViscosityIsConstant(); }
129
133 static Scalar molarMass(int compIdx = 0)
134 { return Component::molarMass(); }
135
139 static Scalar criticalTemperature(int compIdx = 0)
140 { return Component::criticalTemperature(); }
141
145 static Scalar criticalPressure(int compIdx = 0)
146 { return Component::criticalPressure(); }
147
151 static Scalar tripleTemperature(int compIdx = 0)
152 { return Component::tripleTemperature(); }
153
157 static Scalar triplePressure(int compIdx = 0)
158 { return Component::triplePressure(); }
159
166 { return Component::vaporPressure(T); }
167
174 { return Component::gasDensity(temperature, pressure); }
175
178 template <class FluidState>
179 static Scalar density(const FluidState &fluidState,
180 const int phaseIdx)
181 {
182 return density(fluidState.temperature(phaseIdx),
183 fluidState.pressure(phaseIdx));
184 }
185
198 { return Component::gasMolarDensity(temperature, pressure); }
199
202 template <class FluidState>
203 static Scalar molarDensity(const FluidState &fluidState,
204 const int phaseIdx)
205 {
206 return molarDensity(fluidState.temperature(phaseIdx),
207 fluidState.pressure(phaseIdx));
208 }
209
216 { return Component::gasPressure(temperature, density); }
217
224 { return Component::gasEnthalpy(temperature, pressure); }
225
228 template <class FluidState>
229 static Scalar enthalpy(const FluidState &fluidState,
230 const int phaseIdx)
231 {
232 return enthalpy(fluidState.temperature(phaseIdx),
233 fluidState.pressure(phaseIdx));
234 }
235
242 { return Component::gasInternalEnergy(temperature, pressure); }
243
250 { return Component::gasViscosity(temperature, pressure); }
251
254 template <class FluidState>
255 static Scalar viscosity(const FluidState &fluidState,
256 const int phaseIdx)
257 {
258 return viscosity(fluidState.temperature(phaseIdx),
259 fluidState.pressure(phaseIdx));
260 }
261
264 template <class FluidState>
265 static Scalar fugacityCoefficient(const FluidState &fluidState,
266 int phaseIdx,
267 int compIdx)
268 {
269 assert(0 <= phaseIdx && phaseIdx < numPhases);
270 assert(0 <= compIdx && compIdx < numComponents);
271
272 if (phaseIdx == compIdx)
273 // We could calculate the real fugacity coefficient of
274 // the component in the fluid. Probably that's not worth
275 // the effort, since the fugacity coefficient of the other
276 // component is infinite anyway...
277 return 1.0;
278 return std::numeric_limits<Scalar>::infinity();
279 }
280
283 template <class FluidState>
284 static Scalar diffusionCoefficient(const FluidState &fluidState,
285 int phaseIdx,
286 int compIdx)
287 {
288 DUNE_THROW(Dune::InvalidStateException, "Not applicable: Diffusion coefficients");
289 }
290
293 template <class FluidState>
294 static Scalar binaryDiffusionCoefficient(const FluidState &fluidState,
295 int phaseIdx,
296 int compIIdx,
297 int compJIdx)
298
299 {
300 DUNE_THROW(Dune::InvalidStateException, "Not applicable: Binary diffusion coefficients");
301 }
302
309 { return Component::gasThermalConductivity(temperature, pressure); }
310
313 template <class FluidState>
314 static Scalar thermalConductivity(const FluidState &fluidState,
315 const int phaseIdx)
316 {
317 return thermalConductivity(fluidState.temperature(phaseIdx),
318 fluidState.pressure(phaseIdx));
319 }
320
327 { return Component::gasHeatCapacity(temperature, pressure); }
328
331 template <class FluidState>
332 static Scalar heatCapacity(const FluidState &fluidState,
333 const int phaseIdx)
334 {
335 return heatCapacity(fluidState.temperature(phaseIdx),
336 fluidState.pressure(phaseIdx));
337 }
338};
339
340} // namespace FluidSystems
341} // namespace
342
343#endif
Fluid system base class.
Definition: fluidsystems/base.hh:33
Scalar Scalar
export the scalar type
Definition: fluidsystems/base.hh:36
A gaseous phase consisting of a single component.
Definition: 1pgas.hh:34
static Scalar density(Scalar temperature, Scalar pressure)
The density of the component at a given pressure and temperature.
Definition: 1pgas.hh:173
static Scalar triplePressure(int compIdx=0)
Returns the pressure in at the component's triple point.
Definition: 1pgas.hh:157
static Scalar fugacityCoefficient(const FluidState &fluidState, int phaseIdx, int compIdx)
Calculate the fugacity coefficient of an individual component in a fluid phase.
Definition: 1pgas.hh:265
static std::string componentName(int compIdx=0)
A human readable name for the component.
Definition: 1pgas.hh:71
static Scalar thermalConductivity(const FluidState &fluidState, const int phaseIdx)
Thermal conductivity of a fluid phase .
Definition: 1pgas.hh:314
static Scalar viscosity(Scalar temperature, Scalar pressure)
The dynamic viscosity of the pure component at a given pressure and temperature.
Definition: 1pgas.hh:249
static constexpr bool isGas(int phaseIdx=0)
Returns whether the fluid is gaseous.
Definition: 1pgas.hh:89
ComponentT Component
Definition: 1pgas.hh:40
static Scalar molarDensity(Scalar temperature, Scalar pressure)
The molar density of a fluid phase in .
Definition: 1pgas.hh:197
static Scalar heatCapacity(const FluidState &fluidState, const int phaseIdx)
Specific isobaric heat capacity of a fluid phase .
Definition: 1pgas.hh:332
static Scalar molarMass(int compIdx=0)
The mass in of one mole of the component.
Definition: 1pgas.hh:133
static constexpr int numPhases
Number of phases in the fluid system.
Definition: 1pgas.hh:43
static constexpr bool viscosityIsConstant(int phaseIdx)
Returns true if and only if a fluid phase is assumed to have a constant viscosity.
Definition: 1pgas.hh:127
static constexpr int comp0Idx
index of the only component
Definition: 1pgas.hh:47
static constexpr int numComponents
Number of components in the fluid system.
Definition: 1pgas.hh:44
static Scalar criticalPressure(int compIdx=0)
Returns the critical pressure in of the component.
Definition: 1pgas.hh:145
static Scalar tripleTemperature(int compIdx=0)
Returns the temperature in at the component's triple point.
Definition: 1pgas.hh:151
static std::string name()
A human readable name for the component.
Definition: 1pgas.hh:77
static constexpr bool isIdealGas(int phaseIdx=0)
Returns true if the fluid is assumed to be an ideal gas.
Definition: 1pgas.hh:118
static constexpr int phase0Idx
index of the only phase
Definition: 1pgas.hh:46
static Scalar diffusionCoefficient(const FluidState &fluidState, int phaseIdx, int compIdx)
Calculate the binary molecular diffusion coefficient for a component in a fluid phase .
Definition: 1pgas.hh:284
static const Scalar internalEnergy(Scalar temperature, Scalar pressure)
Specific internal energy of the pure component as a gas.
Definition: 1pgas.hh:241
static Scalar criticalTemperature(int compIdx=0)
Returns the critical temperature in of the component.
Definition: 1pgas.hh:139
static Scalar density(const FluidState &fluidState, const int phaseIdx)
Calculate the density of a fluid phase.
Definition: 1pgas.hh:179
static const Scalar enthalpy(Scalar temperature, Scalar pressure)
Specific enthalpy of the pure component as a gas.
Definition: 1pgas.hh:223
static Scalar molarDensity(const FluidState &fluidState, const int phaseIdx)
Calculate the molar density of a fluid phase.
Definition: 1pgas.hh:203
static std::string phaseName(int phaseIdx=0)
Return the human readable name of a fluid phase.
Definition: 1pgas.hh:63
static constexpr bool isIdealMixture(int phaseIdx=0)
Returns true if and only if a fluid phase is assumed to be an ideal mixture.
Definition: 1pgas.hh:106
static Scalar viscosity(const FluidState &fluidState, const int phaseIdx)
Calculate the dynamic viscosity of a fluid phase .
Definition: 1pgas.hh:255
static constexpr bool isCompressible(int phaseIdx=0)
Returns true if the fluid is assumed to be compressible.
Definition: 1pgas.hh:112
static Scalar binaryDiffusionCoefficient(const FluidState &fluidState, int phaseIdx, int compIIdx, int compJIdx)
Given a phase's composition, temperature and pressure, return the binary diffusion coefficient for c...
Definition: 1pgas.hh:294
static Scalar pressure(Scalar temperature, Scalar density)
The pressure of the component at a given density and temperature.
Definition: 1pgas.hh:215
static constexpr bool isMiscible()
There is only one phase, so not mass transfer between phases can occur.
Definition: 1pgas.hh:83
static void init()
Initialize the fluid system's static parameters generically.
Definition: 1pgas.hh:52
static Scalar thermalConductivity(Scalar temperature, Scalar pressure)
Thermal conductivity of the fluid .
Definition: 1pgas.hh:308
static Scalar vaporPressure(Scalar T)
The vapor pressure in of the component at a given temperature.
Definition: 1pgas.hh:165
static Scalar heatCapacity(Scalar temperature, Scalar pressure)
Specific isobaric heat capacity of the fluid .
Definition: 1pgas.hh:326
static Scalar enthalpy(const FluidState &fluidState, const int phaseIdx)
Given a phase's composition, temperature, pressure and density, calculate its specific enthalpy .
Definition: 1pgas.hh:229
The a parameter cache which does nothing.
Definition: nullparametercache.hh:22
Component traits, i.e. information extracted from components.
Fluid system base class.
A collection of input/output field names for common physical quantities.
std::string temperature() noexcept
I/O name of temperature for equilibrium models.
Definition: name.hh:39
std::string gaseousPhase() noexcept
I/O name of gaseous phase.
Definition: name.hh:111
Definition: adapt.hh:17
Component traits, i.e. information extracted from components.
Definition: componenttraits.hh:31