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