GCC Code Coverage Report


Directory: ../../../builds/dumux-repositories/
File: dumux/dumux/material/fluidsystems/1pliquid.hh
Date: 2025-04-12 19:19:20
Exec Total Coverage
Lines: 42 42 100.0%
Functions: 9 9 100.0%
Branches: 32 64 50.0%

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::OnePLiquid
11 */
12 #ifndef DUMUX_FLUIDSYSTEMS_LIQUID_PHASE_HH
13 #define DUMUX_FLUIDSYSTEMS_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::FluidSystems {
25
26 /*!
27 * \ingroup FluidSystems
28 * \brief A liquid phase consisting of a single component
29 */
30 template <class Scalar, class ComponentT>
31 class OnePLiquid
32 : public Base<Scalar, OnePLiquid<Scalar, ComponentT> >
33 {
34 using ThisType = OnePLiquid<Scalar, ComponentT>;
35
36 static_assert(ComponentTraits<ComponentT>::hasLiquidState, "The component does not implement a liquid 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 6 times.
✗ Branch 2 not taken.
6 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 392 static std::string phaseName(int phaseIdx = 0)
63 { return IOName::liquidPhase(); }
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 7 static std::string name()
77 7 { 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 a liquid
87 */
88 static constexpr bool isGas(int phaseIdx = 0)
89 { return false; }
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::liquidIsCompressible(); }
113
114 /*!
115 * \brief Returns true if the fluid viscosity is constant
116 */
117 static constexpr bool viscosityIsConstant(int phaseIdx = 0)
118 { return Component::liquidViscosityIsConstant(); }
119
120 /*!
121 * \brief Returns true if the fluid is assumed to be an ideal gas
122 */
123 static constexpr bool isIdealGas(int phaseIdx = 0)
124 { return false; /* we're a liquid! */ }
125
126 /*!
127 * \brief The mass in \f$\mathrm{[kg]}\f$ of one mole of the component.
128 */
129 static Scalar molarMass(int compIdx = 0)
130 { return Component::molarMass(); }
131
132 /*!
133 * \brief Returns the critical temperature \f$\mathrm{[K]}\f$ of the component
134 */
135 static Scalar criticalTemperature(int compIdx = 0)
136 { return Component::criticalTemperature(); }
137
138 /*!
139 * \brief Returns the critical pressure \f$\mathrm{[Pa]}\f$ of the component
140 */
141 static Scalar criticalPressure(int compIdx = 0)
142 { return Component::criticalPressure(); }
143
144 /*!
145 * \brief Returns the temperature \f$\mathrm{[K]}\f$ at the component's triple point.
146 */
147 static Scalar tripleTemperature(int compIdx = 0)
148 { return Component::tripleTemperature(); }
149
150 /*!
151 * \brief Returns the pressure \f$\mathrm{[Pa]}\f$ at the component's triple point.
152 */
153 static Scalar triplePressure(int compIdx = 0)
154 { return Component::triplePressure(); }
155
156 /*!
157 * \brief The vapor pressure in \f$\mathrm{[Pa]}\f$ of the component at a given
158 * temperature.
159 */
160 static Scalar vaporPressure(Scalar T)
161 { return Component::vaporPressure(T); }
162
163 /*!
164 * \brief The density \f$\mathrm{[kg/m^3]}\f$ of the component at a given pressure and temperature.
165 */
166 58206612 static Scalar density(Scalar temperature, Scalar pressure)
167 58457871 { return Component::liquidDensity(temperature, pressure); }
168
169 using Base<Scalar, ThisType>::density;
170 //! \copydoc Base<Scalar,ThisType>::density(const FluidState&,int)
171 template <class FluidState>
172 54453843 static Scalar density(const FluidState &fluidState,
173 const int phaseIdx)
174 {
175
2/4
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 7 times.
✗ Branch 6 not taken.
54452199 return density(fluidState.temperature(phaseIdx),
176 1 fluidState.pressure(phaseIdx));
177 }
178
179 using Base<Scalar, ThisType>::molarDensity;
180 //! \copydoc Base<Scalar,ThisType>::molarDensity(const FluidState&,int)
181 template <class FluidState>
182 1 static Scalar molarDensity(const FluidState &fluidState, const int phaseIdx)
183 {
184 1 return molarDensity(fluidState.temperature(phaseIdx),
185 1 fluidState.pressure(phaseIdx));
186 }
187
188 /*!
189 * \brief The density \f$\mathrm{[kg/m^3]}\f$ of the component at a given pressure and temperature.
190 * \param temperature The temperature at which to evaluate the molar density
191 * \param pressure The pressure at which to evaluate the molar density
192 */
193 8 static Scalar molarDensity(Scalar temperature, Scalar pressure)
194 7 { return Component::liquidMolarDensity(temperature, pressure); }
195
196 /*!
197 * \brief The pressure \f$\mathrm{[Pa]}\f$ of the component at a given density and temperature.
198 * \param temperature The temperature at which to evaluate the pressure
199 * \param density The density at which to evaluate the pressure
200 */
201 static Scalar pressure(Scalar temperature, Scalar density)
202 { return Component::liquidPressure(temperature, density); }
203
204 /*!
205 * \brief Specific enthalpy \f$\mathrm{[J/kg]}\f$ the pure component as a liquid.
206 * \param temperature The temperature at which to evaluate the enthalpy
207 * \param pressure The pressure at which to evaluate the enthalpy
208 */
209 10006064 static const Scalar enthalpy(Scalar temperature, Scalar pressure)
210
2/4
✓ Branch 1 taken 38840 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 57 times.
✗ Branch 6 not taken.
10006063 { return Component::liquidEnthalpy(temperature, pressure); }
211
212 using Base<Scalar, ThisType>::enthalpy;
213 //! \copydoc Base<Scalar,ThisType>::enthalpy(const FluidState&,int)
214 template <class FluidState>
215 9967160 static Scalar enthalpy(const FluidState &fluidState,
216 const int phaseIdx)
217 {
218
2/4
✓ Branch 4 taken 3800 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 3800 times.
✗ Branch 8 not taken.
9967160 return enthalpy(fluidState.temperature(phaseIdx),
219 1 fluidState.pressure(phaseIdx));
220 }
221
222 /*!
223 * \brief Specific internal energy \f$\mathrm{[J/kg]}\f$ the pure component as a liquid.
224 * \param temperature The temperature at which to evaluate the internal energy
225 * \param pressure The pressure at which to evaluate the internal energy
226 */
227 static const Scalar internalEnergy(Scalar temperature, Scalar pressure)
228 { return Component::liquidInternalEnergy(temperature, pressure); }
229
230 /*!
231 * \brief The dynamic liquid viscosity \f$\mathrm{[N/m^3*s]}\f$ of the pure component.
232 * \param temperature The temperature at which to evaluate the viscosity
233 * \param pressure The pressure at which to evaluate the viscosity
234 */
235
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
58457864 static Scalar viscosity(Scalar temperature, Scalar pressure)
236 58457857 { return Component::liquidViscosity(temperature, pressure); }
237
238 using Base<Scalar, ThisType>::viscosity;
239 //! \copydoc Base<Scalar,ThisType>::viscosity(const FluidState&,int)
240 template <class FluidState>
241 1 static Scalar viscosity(const FluidState &fluidState,
242 const int phaseIdx)
243 {
244 54452185 return viscosity(fluidState.temperature(phaseIdx),
245 1 fluidState.pressure(phaseIdx));
246 }
247
248 using Base<Scalar, ThisType>::fugacityCoefficient;
249 //! \copydoc Base<Scalar,ThisType>::fugacityCoefficient(const FluidState&,int,int)
250 template <class FluidState>
251 1 static Scalar fugacityCoefficient(const FluidState &fluidState,
252 int phaseIdx,
253 int compIdx)
254 {
255
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 assert(0 <= phaseIdx && phaseIdx < numPhases);
256
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 assert(0 <= compIdx && compIdx < numComponents);
257
258 if (phaseIdx == compIdx)
259 // We could calculate the real fugacity coefficient of
260 // the component in the fluid. Probably that's not worth
261 // the effort, since the fugacity coefficient of the other
262 // component is infinite anyway...
263 return 1.0;
264 return std::numeric_limits<Scalar>::infinity();
265 }
266
267 using Base<Scalar, ThisType>::diffusionCoefficient;
268 //! \copydoc Base<Scalar,ThisType>::diffusionCoefficient(const FluidState&,int,int)
269 template <class FluidState>
270 1 static Scalar diffusionCoefficient(const FluidState &fluidState,
271 int phaseIdx,
272 int compIdx)
273 {
274
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");
275 }
276
277 using Base<Scalar, ThisType>::binaryDiffusionCoefficient;
278 //! \copydoc Base<Scalar,ThisType>::binaryDiffusionCoefficient(const FluidState&,int,int,int)
279 template <class FluidState>
280 1 static Scalar binaryDiffusionCoefficient(const FluidState &fluidState,
281 int phaseIdx,
282 int compIIdx,
283 int compJIdx)
284 {
285
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");
286 }
287
288 /*!
289 * \brief Thermal conductivity of the fluid \f$\mathrm{[W/(m K)]}\f$.
290 * \param temperature The temperature at which to evaluate the thermal conductivity
291 * \param pressure The pressure at which to evaluate the thermal conductivity
292 */
293 7675253 static Scalar thermalConductivity(Scalar temperature, Scalar pressure)
294 7651431 { return Component::liquidThermalConductivity(temperature, pressure); }
295
296 using Base<Scalar, ThisType>::thermalConductivity;
297 //! \copydoc Base<Scalar,ThisType>::thermalConductivity(const FluidState&,int)
298 template <class FluidState>
299 7651425 static Scalar thermalConductivity(const FluidState &fluidState,
300 const int phaseIdx)
301 {
302
1/2
✓ Branch 3 taken 660 times.
✗ Branch 4 not taken.
7651425 return thermalConductivity(fluidState.temperature(phaseIdx),
303 1 fluidState.pressure(phaseIdx));
304 }
305
306 /*!
307 * \brief Specific isobaric heat capacity of the fluid \f$\mathrm{[J/(kg K)]}\f$.
308 * \param temperature The temperature at which to evaluate the heat capacity
309 * \param pressure The pressure at which to evaluate the heat capacity
310 */
311 8 static Scalar heatCapacity(Scalar temperature, Scalar pressure)
312 7 { return Component::liquidHeatCapacity(temperature, pressure); }
313
314 using Base<Scalar, ThisType>::heatCapacity;
315 //! \copydoc Base<Scalar,ThisType>::heatCapacity(const FluidState&,int)
316 template <class FluidState>
317 1 static Scalar heatCapacity(const FluidState &fluidState,
318 const int phaseIdx)
319 {
320 1 return heatCapacity(fluidState.temperature(phaseIdx),
321 1 fluidState.pressure(phaseIdx));
322 }
323 };
324
325 } // namespace Dumux::FluidSystems
326
327 #endif
328