version 3.11-dev
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
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-FileCopyrightText: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5// SPDX-License-Identifier: GPL-3.0-or-later
6//
12#ifndef DUMUX_FLUIDSYTEMS_GAS_PHASE_HH
13#define DUMUX_FLUIDSYTEMS_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::FluidSystems {
25
30template <class Scalar, class ComponentT>
32: public Base<Scalar, OnePGas<Scalar, ComponentT> >
33{
35
36 static_assert(ComponentTraits<ComponentT>::hasGasState, "The component does not implement a gas state!");
37
38public:
39 using Component = ComponentT;
41
42 static constexpr int numPhases = 1;
43 static constexpr int numComponents = 1;
44
45 static constexpr int phase0Idx = 0;
46 static constexpr int comp0Idx = 0;
47
51 static void init()
52 { }
53
54 /****************************************
55 * Fluid phase related static parameters
56 ****************************************/
62 static std::string phaseName(int phaseIdx = 0)
63 { return IOName::gaseousPhase(); }
64
70 static std::string componentName(int compIdx = 0)
71 { return Component::name(); }
72
76 static std::string name()
77 { return Component::name(); }
78
82 static constexpr bool isMiscible()
83 { return false; }
84
88 static constexpr bool isGas(int phaseIdx = 0)
89 { return true; }
90
105 static constexpr bool isIdealMixture(int phaseIdx = 0)
106 { return true; }
107
111 static constexpr bool isCompressible(int phaseIdx = 0)
112 { return Component::gasIsCompressible(); }
113
117 static constexpr bool isIdealGas(int phaseIdx = 0)
118 { return Component::gasIsIdeal(); }
119
126 static constexpr bool viscosityIsConstant(int phaseIdx)
127 { return Component::gasViscosityIsConstant(); }
128
132 static Scalar molarMass(int compIdx = 0)
133 { return Component::molarMass(); }
134
138 static Scalar criticalTemperature(int compIdx = 0)
139 { return Component::criticalTemperature(); }
140
144 static Scalar criticalPressure(int compIdx = 0)
145 { return Component::criticalPressure(); }
146
150 static Scalar tripleTemperature(int compIdx = 0)
151 { return Component::tripleTemperature(); }
152
156 static Scalar triplePressure(int compIdx = 0)
157 { return Component::triplePressure(); }
158
165 { return Component::vaporPressure(T); }
166
173 { return Component::gasDensity(temperature, pressure); }
174
177 template <class FluidState>
178 static Scalar density(const FluidState &fluidState,
179 const int phaseIdx)
180 {
181 return density(fluidState.temperature(phaseIdx),
182 fluidState.pressure(phaseIdx));
183 }
184
197 { return Component::gasMolarDensity(temperature, pressure); }
198
201 template <class FluidState>
202 static Scalar molarDensity(const FluidState &fluidState,
203 const int phaseIdx)
204 {
205 return molarDensity(fluidState.temperature(phaseIdx),
206 fluidState.pressure(phaseIdx));
207 }
208
215 { return Component::gasPressure(temperature, density); }
216
223 { return Component::gasEnthalpy(temperature, pressure); }
224
227 template <class FluidState>
228 static Scalar enthalpy(const FluidState &fluidState,
229 const int phaseIdx)
230 {
231 return enthalpy(fluidState.temperature(phaseIdx),
232 fluidState.pressure(phaseIdx));
233 }
234
241 { return Component::gasInternalEnergy(temperature, pressure); }
242
249 { return Component::gasViscosity(temperature, pressure); }
250
253 template <class FluidState>
254 static Scalar viscosity(const FluidState &fluidState,
255 const int phaseIdx)
256 {
257 return viscosity(fluidState.temperature(phaseIdx),
258 fluidState.pressure(phaseIdx));
259 }
260
263 template <class FluidState>
264 static Scalar fugacityCoefficient(const FluidState &fluidState,
265 int phaseIdx,
266 int compIdx)
267 {
268 assert(0 <= phaseIdx && phaseIdx < numPhases);
269 assert(0 <= compIdx && compIdx < numComponents);
270
271 if (phaseIdx == compIdx)
272 // We could calculate the real fugacity coefficient of
273 // the component in the fluid. Probably that's not worth
274 // the effort, since the fugacity coefficient of the other
275 // component is infinite anyway...
276 return 1.0;
277 return std::numeric_limits<Scalar>::infinity();
278 }
279
282 template <class FluidState>
283 static Scalar diffusionCoefficient(const FluidState &fluidState,
284 int phaseIdx,
285 int compIdx)
286 {
287 DUNE_THROW(Dune::InvalidStateException, "Not applicable: Diffusion coefficients");
288 }
289
292 template <class FluidState>
293 static Scalar binaryDiffusionCoefficient(const FluidState &fluidState,
294 int phaseIdx,
295 int compIIdx,
296 int compJIdx)
297
298 {
299 DUNE_THROW(Dune::InvalidStateException, "Not applicable: Binary diffusion coefficients");
300 }
301
308 { return Component::gasThermalConductivity(temperature, pressure); }
309
312 template <class FluidState>
313 static Scalar thermalConductivity(const FluidState &fluidState,
314 const int phaseIdx)
315 {
316 return thermalConductivity(fluidState.temperature(phaseIdx),
317 fluidState.pressure(phaseIdx));
318 }
319
326 { return Component::gasHeatCapacity(temperature, pressure); }
327
330 template <class FluidState>
331 static Scalar heatCapacity(const FluidState &fluidState,
332 const int phaseIdx)
333 {
334 return heatCapacity(fluidState.temperature(phaseIdx),
335 fluidState.pressure(phaseIdx));
336 }
337};
338
339} // namespace Dumux::FluidSystems
340
341#endif
Fluid system base class.
Definition: fluidsystems/base.hh:32
Scalar Scalar
export the scalar type
Definition: fluidsystems/base.hh:35
A gaseous phase consisting of a single component.
Definition: 1pgas.hh:33
static Scalar density(Scalar temperature, Scalar pressure)
The density of the component at a given pressure and temperature.
Definition: 1pgas.hh:172
static Scalar triplePressure(int compIdx=0)
Returns the pressure in at the component's triple point.
Definition: 1pgas.hh:156
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:264
static std::string componentName(int compIdx=0)
A human readable name for the component.
Definition: 1pgas.hh:70
static Scalar thermalConductivity(const FluidState &fluidState, const int phaseIdx)
Thermal conductivity of a fluid phase .
Definition: 1pgas.hh:313
static Scalar viscosity(Scalar temperature, Scalar pressure)
The dynamic viscosity of the pure component at a given pressure and temperature.
Definition: 1pgas.hh:248
static constexpr bool isGas(int phaseIdx=0)
Returns whether the fluid is gaseous.
Definition: 1pgas.hh:88
ComponentT Component
Definition: 1pgas.hh:39
static Scalar molarDensity(Scalar temperature, Scalar pressure)
The molar density of a fluid phase in .
Definition: 1pgas.hh:196
static Scalar heatCapacity(const FluidState &fluidState, const int phaseIdx)
Specific isobaric heat capacity of a fluid phase .
Definition: 1pgas.hh:331
static Scalar molarMass(int compIdx=0)
The mass in of one mole of the component.
Definition: 1pgas.hh:132
static constexpr int numPhases
Number of phases in the fluid system.
Definition: 1pgas.hh:42
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:126
static constexpr int comp0Idx
index of the only component
Definition: 1pgas.hh:46
static constexpr int numComponents
Number of components in the fluid system.
Definition: 1pgas.hh:43
static Scalar criticalPressure(int compIdx=0)
Returns the critical pressure in of the component.
Definition: 1pgas.hh:144
static Scalar tripleTemperature(int compIdx=0)
Returns the temperature in at the component's triple point.
Definition: 1pgas.hh:150
static std::string name()
A human readable name for the component.
Definition: 1pgas.hh:76
static constexpr bool isIdealGas(int phaseIdx=0)
Returns true if the fluid is assumed to be an ideal gas.
Definition: 1pgas.hh:117
static constexpr int phase0Idx
index of the only phase
Definition: 1pgas.hh:45
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:283
static const Scalar internalEnergy(Scalar temperature, Scalar pressure)
Specific internal energy of the pure component as a gas.
Definition: 1pgas.hh:240
static Scalar criticalTemperature(int compIdx=0)
Returns the critical temperature in of the component.
Definition: 1pgas.hh:138
static Scalar density(const FluidState &fluidState, const int phaseIdx)
Calculate the density of a fluid phase.
Definition: 1pgas.hh:178
static const Scalar enthalpy(Scalar temperature, Scalar pressure)
Specific enthalpy of the pure component as a gas.
Definition: 1pgas.hh:222
static Scalar molarDensity(const FluidState &fluidState, const int phaseIdx)
Calculate the molar density of a fluid phase.
Definition: 1pgas.hh:202
static std::string phaseName(int phaseIdx=0)
Return the human readable name of a fluid phase.
Definition: 1pgas.hh:62
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:105
static Scalar viscosity(const FluidState &fluidState, const int phaseIdx)
Calculate the dynamic viscosity of a fluid phase .
Definition: 1pgas.hh:254
static constexpr bool isCompressible(int phaseIdx=0)
Returns true if the fluid is assumed to be compressible.
Definition: 1pgas.hh:111
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:293
static Scalar pressure(Scalar temperature, Scalar density)
The pressure of the component at a given density and temperature.
Definition: 1pgas.hh:214
static constexpr bool isMiscible()
There is only one phase, so not mass transfer between phases can occur.
Definition: 1pgas.hh:82
static void init()
Initialize the fluid system's static parameters generically.
Definition: 1pgas.hh:51
static Scalar thermalConductivity(Scalar temperature, Scalar pressure)
Thermal conductivity of the fluid .
Definition: 1pgas.hh:307
static Scalar vaporPressure(Scalar T)
The vapor pressure in of the component at a given temperature.
Definition: 1pgas.hh:164
static Scalar heatCapacity(Scalar temperature, Scalar pressure)
Specific isobaric heat capacity of the fluid .
Definition: 1pgas.hh:325
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:228
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.
Definition: h2o.hh:901
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
Component traits, i.e. information extracted from components.
Definition: componenttraits.hh:31