Line | Branch | Exec | Source |
---|---|---|---|
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 | // | ||
7 | /*! | ||
8 | * \file | ||
9 | * \ingroup FluidSystems | ||
10 | * \brief @copybrief Dumux::FluidSystems::OnePGas | ||
11 | */ | ||
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 | |||
20 | #include <dumux/material/fluidsystems/base.hh> | ||
21 | #include <dumux/material/components/componenttraits.hh> | ||
22 | #include <dumux/io/name.hh> | ||
23 | |||
24 | namespace Dumux::FluidSystems { | ||
25 | |||
26 | /*! | ||
27 | * \ingroup FluidSystems | ||
28 | * \brief A gaseous phase consisting of a single component | ||
29 | */ | ||
30 | template <class Scalar, class ComponentT> | ||
31 | class OnePGas | ||
32 | : public Base<Scalar, OnePGas<Scalar, ComponentT> > | ||
33 | { | ||
34 | using ThisType = OnePGas<Scalar, ComponentT>; | ||
35 | |||
36 | static_assert(ComponentTraits<ComponentT>::hasGasState, "The component does not implement a gas state!"); | ||
37 | |||
38 | public: | ||
39 | using Component = ComponentT; | ||
40 | using ParameterCache = NullParameterCache; | ||
41 | |||
42 | static constexpr int numPhases = 1; //!< Number of phases in the fluid system | ||
43 | static constexpr int numComponents = 1; //!< Number of components in the fluid system | ||
44 | |||
45 | static constexpr int phase0Idx = 0; //!< index of the only phase | ||
46 | static constexpr int comp0Idx = 0; //!< index of the only component | ||
47 | |||
48 | /*! | ||
49 | * \brief Initialize the fluid system's static parameters generically | ||
50 | */ | ||
51 |
1/2✓ Branch 1 taken 15 times.
✗ Branch 2 not taken.
|
15 | static void init() |
52 | { } | ||
53 | |||
54 | /**************************************** | ||
55 | * Fluid phase related static parameters | ||
56 | ****************************************/ | ||
57 | /*! | ||
58 | * \brief Return the human readable name of a fluid phase | ||
59 | * | ||
60 | * \param phaseIdx The index of the fluid phase to consider | ||
61 | */ | ||
62 | 638 | static std::string phaseName(int phaseIdx = 0) | |
63 | { return IOName::gaseousPhase(); } | ||
64 | |||
65 | /*! | ||
66 | * \brief A human readable name for the component. | ||
67 | * | ||
68 | * \param compIdx The index of the component to consider | ||
69 | */ | ||
70 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | static std::string componentName(int compIdx = 0) |
71 | { return Component::name(); } | ||
72 | |||
73 | /*! | ||
74 | * \brief A human readable name for the component. | ||
75 | */ | ||
76 | 4 | static std::string name() | |
77 | 4 | { return Component::name(); } | |
78 | |||
79 | /*! | ||
80 | * \brief There is only one phase, so not mass transfer between phases can occur | ||
81 | */ | ||
82 | static constexpr bool isMiscible() | ||
83 | { return false; } | ||
84 | |||
85 | /*! | ||
86 | * \brief Returns whether the fluid is gaseous | ||
87 | */ | ||
88 | static constexpr bool isGas(int phaseIdx = 0) | ||
89 | { return true; } | ||
90 | |||
91 | /*! | ||
92 | * \brief Returns true if and only if a fluid phase is assumed to | ||
93 | * be an ideal mixture. | ||
94 | * | ||
95 | * We define an ideal mixture as a fluid phase where the fugacity | ||
96 | * coefficients of all components times the pressure of the phase | ||
97 | * are independent on the fluid composition. This assumption is true | ||
98 | * if only a single component is involved. If you are unsure what | ||
99 | * this function should return, it is safe to return false. The | ||
100 | * only damage done will be (slightly) increased computation times | ||
101 | * in some cases. | ||
102 | * | ||
103 | * \param phaseIdx The index of the fluid phase to consider | ||
104 | */ | ||
105 | static constexpr bool isIdealMixture(int phaseIdx = 0) | ||
106 | { return true; } | ||
107 | |||
108 | /*! | ||
109 | * \brief Returns true if the fluid is assumed to be compressible | ||
110 | */ | ||
111 | static constexpr bool isCompressible(int phaseIdx = 0) | ||
112 | { return Component::gasIsCompressible(); } | ||
113 | |||
114 | /*! | ||
115 | * \brief Returns true if the fluid is assumed to be an ideal gas | ||
116 | */ | ||
117 | static constexpr bool isIdealGas(int phaseIdx = 0) | ||
118 | { return Component::gasIsIdeal(); } | ||
119 | |||
120 | /*! | ||
121 | * \brief Returns true if and only if a fluid phase is assumed to | ||
122 | * have a constant viscosity. | ||
123 | * | ||
124 | * \param phaseIdx The index of the fluid phase to consider | ||
125 | */ | ||
126 | static constexpr bool viscosityIsConstant(int phaseIdx) | ||
127 | { return Component::gasViscosityIsConstant(); } | ||
128 | |||
129 | /*! | ||
130 | * \brief The mass in \f$\mathrm{[kg]}\f$ of one mole of the component. | ||
131 | */ | ||
132 | static Scalar molarMass(int compIdx = 0) | ||
133 | { return Component::molarMass(); } | ||
134 | |||
135 | /*! | ||
136 | * \brief Returns the critical temperature in \f$\mathrm{[K]}\f$ of the component | ||
137 | */ | ||
138 | static Scalar criticalTemperature(int compIdx = 0) | ||
139 | { return Component::criticalTemperature(); } | ||
140 | |||
141 | /*! | ||
142 | * \brief Returns the critical pressure in \f$\mathrm{[Pa]}\f$ of the component | ||
143 | */ | ||
144 | static Scalar criticalPressure(int compIdx = 0) | ||
145 | { return Component::criticalPressure(); } | ||
146 | |||
147 | /*! | ||
148 | * \brief Returns the temperature in \f$\mathrm{[K]}\f$ at the component's triple point. | ||
149 | */ | ||
150 | static Scalar tripleTemperature(int compIdx = 0) | ||
151 | { return Component::tripleTemperature(); } | ||
152 | |||
153 | /*! | ||
154 | * \brief Returns the pressure in \f$\mathrm{[Pa]}\f$ at the component's triple point. | ||
155 | */ | ||
156 | static Scalar triplePressure(int compIdx = 0) | ||
157 | { return Component::triplePressure(); } | ||
158 | |||
159 | /*! | ||
160 | * \brief The vapor pressure in \f$\mathrm{[Pa]}\f$ of the component at a given | ||
161 | * temperature. | ||
162 | * \param T temperature \f$\mathrm{[K]}\f$ | ||
163 | */ | ||
164 | static Scalar vaporPressure(Scalar T) | ||
165 | { return Component::vaporPressure(T); } | ||
166 | |||
167 | /*! | ||
168 | * \brief The density \f$\mathrm{[kg/m^3]}\f$ of the component at a given pressure and temperature. | ||
169 | * \param temperature The given temperature \f$\mathrm{[K]}\f$ | ||
170 | * \param pressure The given pressure \f$\mathrm{[Pa]}\f$ | ||
171 | */ | ||
172 | 75120325 | static Scalar density(Scalar temperature, Scalar pressure) | |
173 | 75120325 | { return Component::gasDensity(temperature, pressure); } | |
174 | |||
175 | using Base<Scalar, ThisType>::density; | ||
176 | //! \copydoc Base<Scalar,ThisType>::density(const FluidState&,int) | ||
177 | template <class FluidState> | ||
178 | 62992540 | static Scalar density(const FluidState &fluidState, | |
179 | const int phaseIdx) | ||
180 | { | ||
181 | 62992540 | return density(fluidState.temperature(phaseIdx), | |
182 | 1 | fluidState.pressure(phaseIdx)); | |
183 | } | ||
184 | |||
185 | /*! | ||
186 | * \brief The molar density \f$\rho_{mol,\alpha}\f$ | ||
187 | * of a fluid phase \f$\alpha\f$ in \f$\mathrm{[mol/m^3]}\f$ | ||
188 | * | ||
189 | * The molar density is defined by the | ||
190 | * mass density \f$\rho_\alpha\f$ and the component molar mass \f$M_\alpha\f$: | ||
191 | * | ||
192 | * \f[\rho_{mol,\alpha} = \frac{\rho_\alpha}{M_\alpha} \;.\f] | ||
193 | * \param temperature The temperature at which to evaluate the molar density | ||
194 | * \param pressure The pressure at which to evaluate the molar density | ||
195 | */ | ||
196 | 4 | static Scalar molarDensity(Scalar temperature, Scalar pressure) | |
197 | 4 | { return Component::gasMolarDensity(temperature, pressure); } | |
198 | |||
199 | using Base<Scalar, ThisType>::molarDensity; | ||
200 | //! \copydoc Base<Scalar,ThisType>::molarDensity(const FluidState&,int) | ||
201 | template <class FluidState> | ||
202 | 1 | static Scalar molarDensity(const FluidState &fluidState, | |
203 | const int phaseIdx) | ||
204 | { | ||
205 | 1 | return molarDensity(fluidState.temperature(phaseIdx), | |
206 | 1 | fluidState.pressure(phaseIdx)); | |
207 | } | ||
208 | |||
209 | /*! | ||
210 | * \brief The pressure \f$\mathrm{[Pa]}\f$ of the component at a given density and temperature. | ||
211 | * \param temperature The given temperature \f$\mathrm{[K]}\f$ | ||
212 | * \param density The given density \f$\mathrm{[kg/m^3]}\f$ | ||
213 | */ | ||
214 | static Scalar pressure(Scalar temperature, Scalar density) | ||
215 | { return Component::gasPressure(temperature, density); } | ||
216 | |||
217 | /*! | ||
218 | * \brief Specific enthalpy \f$\mathrm{[J/kg]}\f$ of the pure component as a gas. | ||
219 | * \param temperature The given temperature \f$\mathrm{[K]}\f$ | ||
220 | * \param pressure The given pressure \f$\mathrm{[Pa]}\f$ | ||
221 | */ | ||
222 | 24863936 | static const Scalar enthalpy(Scalar temperature, Scalar pressure) | |
223 | 24863936 | { return Component::gasEnthalpy(temperature, pressure); } | |
224 | |||
225 | using Base<Scalar, ThisType>::enthalpy; | ||
226 | //! \copydoc Base<Scalar,ThisType>::enthalpy(const FluidState&,int) | ||
227 | template <class FluidState> | ||
228 | 24863933 | static Scalar enthalpy(const FluidState &fluidState, | |
229 | const int phaseIdx) | ||
230 | { | ||
231 | 24863933 | return enthalpy(fluidState.temperature(phaseIdx), | |
232 | 1 | fluidState.pressure(phaseIdx)); | |
233 | } | ||
234 | |||
235 | /*! | ||
236 | * \brief Specific internal energy \f$\mathrm{[J/kg]}\f$ of the pure component as a gas. | ||
237 | * \param temperature The given temperature \f$\mathrm{[K]}\f$ | ||
238 | * \param pressure The given pressure \f$\mathrm{[Pa]}\f$ | ||
239 | */ | ||
240 | static const Scalar internalEnergy(Scalar temperature, Scalar pressure) | ||
241 | { return Component::gasInternalEnergy(temperature, pressure); } | ||
242 | |||
243 | /*! | ||
244 | * \brief The dynamic viscosity \f$\mathrm{[Pa s]}\f$ of the pure component at a given pressure and temperature. | ||
245 | * \param temperature The given temperature \f$\mathrm{[K]}\f$ | ||
246 | * \param pressure The given pressure \f$\mathrm{[Pa]}\f$ | ||
247 | */ | ||
248 | 67997382 | static Scalar viscosity(Scalar temperature, Scalar pressure) | |
249 | 67997381 | { return Component::gasViscosity(temperature, pressure); } | |
250 | |||
251 | using Base<Scalar, ThisType>::viscosity; | ||
252 | //! \copydoc Base<Scalar,ThisType>::viscosity(const FluidState&,int) | ||
253 | template <class FluidState> | ||
254 | 62992540 | static Scalar viscosity(const FluidState &fluidState, | |
255 | const int phaseIdx) | ||
256 | { | ||
257 |
1/2✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
|
62992540 | return viscosity(fluidState.temperature(phaseIdx), |
258 | 1 | fluidState.pressure(phaseIdx)); | |
259 | } | ||
260 | |||
261 | using Base<Scalar, ThisType>::fugacityCoefficient; | ||
262 | //! \copydoc Base<Scalar,ThisType>::fugacityCoefficient(const FluidState&,int,int) | ||
263 | template <class FluidState> | ||
264 | 1 | static Scalar fugacityCoefficient(const FluidState &fluidState, | |
265 | int phaseIdx, | ||
266 | int compIdx) | ||
267 | { | ||
268 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | assert(0 <= phaseIdx && phaseIdx < numPhases); |
269 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | 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 | |||
280 | using Base<Scalar, ThisType>::diffusionCoefficient; | ||
281 | //! \copydoc Base<Scalar,ThisType>::diffusionCoefficient(const FluidState&,int,int) | ||
282 | template <class FluidState> | ||
283 | 1 | static Scalar diffusionCoefficient(const FluidState &fluidState, | |
284 | int phaseIdx, | ||
285 | int compIdx) | ||
286 | { | ||
287 |
10/20✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 1 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 1 times.
✗ Branch 26 not taken.
✓ Branch 28 taken 1 times.
✗ Branch 29 not taken.
|
4 | DUNE_THROW(Dune::InvalidStateException, "Not applicable: Diffusion coefficients"); |
288 | } | ||
289 | |||
290 | using Base<Scalar, ThisType>::binaryDiffusionCoefficient; | ||
291 | //! \copydoc Base<Scalar,ThisType>::binaryDiffusionCoefficient(const FluidState&,int,int,int) | ||
292 | template <class FluidState> | ||
293 | 1 | static Scalar binaryDiffusionCoefficient(const FluidState &fluidState, | |
294 | int phaseIdx, | ||
295 | int compIIdx, | ||
296 | int compJIdx) | ||
297 | |||
298 | { | ||
299 |
10/20✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 1 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
✓ Branch 19 taken 1 times.
✗ Branch 20 not taken.
✓ Branch 22 taken 1 times.
✗ Branch 23 not taken.
✓ Branch 25 taken 1 times.
✗ Branch 26 not taken.
✓ Branch 28 taken 1 times.
✗ Branch 29 not taken.
|
4 | DUNE_THROW(Dune::InvalidStateException, "Not applicable: Binary diffusion coefficients"); |
300 | } | ||
301 | |||
302 | /*! | ||
303 | * \brief Thermal conductivity of the fluid \f$\mathrm{[W/(m K)]}\f$. | ||
304 | * \param temperature The given temperature \f$\mathrm{[K]}\f$ | ||
305 | * \param pressure The given pressure \f$\mathrm{[Pa]}\f$ | ||
306 | */ | ||
307 | 4 | static Scalar thermalConductivity(Scalar temperature, Scalar pressure) | |
308 | 4 | { return Component::gasThermalConductivity(temperature, pressure); } | |
309 | |||
310 | using Base<Scalar, ThisType>::thermalConductivity; | ||
311 | //! \copydoc Base<Scalar,ThisType>::thermalConductivity(const FluidState&,int) | ||
312 | template <class FluidState> | ||
313 | 1 | static Scalar thermalConductivity(const FluidState &fluidState, | |
314 | const int phaseIdx) | ||
315 | { | ||
316 | 1 | return thermalConductivity(fluidState.temperature(phaseIdx), | |
317 | 1 | fluidState.pressure(phaseIdx)); | |
318 | } | ||
319 | |||
320 | /*! | ||
321 | * \brief Specific isobaric heat capacity of the fluid \f$\mathrm{[J/(kg K)]}\f$. | ||
322 | * \param temperature The given temperature \f$\mathrm{[K]}\f$ | ||
323 | * \param pressure The given pressure \f$\mathrm{[Pa]}\f$ | ||
324 | */ | ||
325 | 24863936 | static Scalar heatCapacity(Scalar temperature, Scalar pressure) | |
326 | 24863936 | { return Component::gasHeatCapacity(temperature, pressure); } | |
327 | |||
328 | using Base<Scalar, ThisType>::heatCapacity; | ||
329 | //! \copydoc Base<Scalar,ThisType>::heatCapacity(const FluidState&,int) | ||
330 | template <class FluidState> | ||
331 | 24863933 | static Scalar heatCapacity(const FluidState &fluidState, | |
332 | const int phaseIdx) | ||
333 | { | ||
334 | 24863933 | return heatCapacity(fluidState.temperature(phaseIdx), | |
335 | 1 | fluidState.pressure(phaseIdx)); | |
336 | } | ||
337 | }; | ||
338 | |||
339 | } // namespace Dumux::FluidSystems | ||
340 | |||
341 | #endif | ||
342 |