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 Components | ||
10 | * \brief A simple implementation of pure water | ||
11 | */ | ||
12 | #ifndef DUMUX_SIMPLE_H2O_HH | ||
13 | #define DUMUX_SIMPLE_H2O_HH | ||
14 | |||
15 | #include <dumux/common/parameters.hh> | ||
16 | #include <dumux/material/idealgas.hh> | ||
17 | |||
18 | #include <cmath> | ||
19 | |||
20 | #include <dumux/material/components/base.hh> | ||
21 | #include <dumux/material/components/liquid.hh> | ||
22 | #include <dumux/material/components/gas.hh> | ||
23 | |||
24 | namespace Dumux::Components { | ||
25 | |||
26 | /*! | ||
27 | * \ingroup Components | ||
28 | * \brief A simple implementation of pure water | ||
29 | * | ||
30 | * \tparam Scalar The type used for scalar values | ||
31 | */ | ||
32 | template <class Scalar> | ||
33 | class SimpleH2O | ||
34 | : public Components::Base<Scalar, SimpleH2O<Scalar> > | ||
35 | , public Components::Liquid<Scalar, SimpleH2O<Scalar> > | ||
36 | , public Components::Gas<Scalar, SimpleH2O<Scalar> > | ||
37 | { | ||
38 | using IdealGas = Dumux::IdealGas<Scalar>; | ||
39 | |||
40 | public: | ||
41 | /*! | ||
42 | * \brief A human readable name for the water. | ||
43 | */ | ||
44 | static std::string name() | ||
45 |
42/82✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 3 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 3 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.
✓ Branch 31 taken 1 times.
✗ Branch 32 not taken.
✓ Branch 34 taken 1 times.
✗ Branch 35 not taken.
✓ Branch 37 taken 1 times.
✗ Branch 38 not taken.
✓ Branch 40 taken 1 times.
✗ Branch 41 not taken.
✓ Branch 43 taken 1 times.
✗ Branch 44 not taken.
✓ Branch 46 taken 1 times.
✗ Branch 47 not taken.
✓ Branch 49 taken 1 times.
✗ Branch 50 not taken.
✓ Branch 52 taken 1 times.
✗ Branch 53 not taken.
✓ Branch 55 taken 1 times.
✗ Branch 56 not taken.
✓ Branch 58 taken 1 times.
✗ Branch 59 not taken.
✓ Branch 61 taken 1 times.
✗ Branch 62 not taken.
✓ Branch 64 taken 1 times.
✗ Branch 65 not taken.
✓ Branch 67 taken 1 times.
✗ Branch 68 not taken.
✓ Branch 70 taken 1 times.
✗ Branch 71 not taken.
✓ Branch 73 taken 1 times.
✗ Branch 74 not taken.
✓ Branch 76 taken 1 times.
✗ Branch 77 not taken.
✓ Branch 79 taken 1 times.
✗ Branch 80 not taken.
✓ Branch 82 taken 1 times.
✗ Branch 83 not taken.
✓ Branch 85 taken 1 times.
✗ Branch 86 not taken.
✓ Branch 88 taken 1 times.
✗ Branch 89 not taken.
✓ Branch 91 taken 1 times.
✗ Branch 92 not taken.
✓ Branch 94 taken 1 times.
✗ Branch 95 not taken.
✓ Branch 97 taken 1 times.
✗ Branch 98 not taken.
✓ Branch 100 taken 1 times.
✗ Branch 101 not taken.
✓ Branch 103 taken 1 times.
✗ Branch 104 not taken.
✓ Branch 106 taken 1 times.
✗ Branch 107 not taken.
✓ Branch 109 taken 1 times.
✗ Branch 110 not taken.
✓ Branch 112 taken 1 times.
✗ Branch 113 not taken.
✓ Branch 115 taken 1 times.
✗ Branch 116 not taken.
✓ Branch 118 taken 1 times.
✗ Branch 119 not taken.
|
48 | { return "SimpleH2O"; } |
46 | |||
47 | /*! | ||
48 | * \brief The molar mass in \f$\mathrm{[kg/mol]}\f$ of water. | ||
49 | */ | ||
50 | static constexpr Scalar molarMass() | ||
51 | { return 18e-3; } | ||
52 | |||
53 | /*! | ||
54 | * \brief Returns the critical temperature \f$\mathrm{[K]}\f$ of water. | ||
55 | */ | ||
56 | static Scalar criticalTemperature() | ||
57 | { return 647.096; /* [K] */ } | ||
58 | |||
59 | /*! | ||
60 | * \brief Returns the critical pressure \f$\mathrm{[Pa]}\f$ of water. | ||
61 | */ | ||
62 | static Scalar criticalPressure() | ||
63 | { return 22.064e6; /* [N/m^2] */ } | ||
64 | |||
65 | /*! | ||
66 | * \brief Returns the temperature \f$\mathrm{[K]}\f$ at water's triple point. | ||
67 | */ | ||
68 | static Scalar tripleTemperature() | ||
69 | { return 273.16; /* [K] */ } | ||
70 | |||
71 | /*! | ||
72 | * \brief Returns the pressure \f$\mathrm{[Pa]}\f$ at water's triple point. | ||
73 | */ | ||
74 | static Scalar triplePressure() | ||
75 | { return 611.657; /* [N/m^2] */ } | ||
76 | |||
77 | /*! | ||
78 | * \brief The vapor pressure in \f$\mathrm{[Pa]}\f$ of pure water | ||
79 | * at a given temperature. | ||
80 | * | ||
81 | *\param T temperature of component in \f$\mathrm{[K]}\f$ | ||
82 | * | ||
83 | * See: | ||
84 | * | ||
85 | * IAPWS: "Revised Release on the IAPWS Industrial Formulation | ||
86 | * 1997 for the Thermodynamic Properties of Water and Steam", | ||
87 | * http://www.iapws.org/relguide/IF97-Rev.pdf \cite IAPWS1997 | ||
88 | */ | ||
89 | 179227 | static Scalar vaporPressure(Scalar T) | |
90 | { | ||
91 |
1/2✓ Branch 0 taken 179227 times.
✗ Branch 1 not taken.
|
179227 | if (T > criticalTemperature()) |
92 | return criticalPressure(); | ||
93 |
2/2✓ Branch 0 taken 179226 times.
✓ Branch 1 taken 1 times.
|
179227 | if (T < tripleTemperature()) |
94 | return 0; // water is solid: We don't take sublimation into account | ||
95 | |||
96 | constexpr Scalar n[10] = { | ||
97 | 0.11670521452767e4, -0.72421316703206e6, -0.17073846940092e2, | ||
98 | 0.12020824702470e5, -0.32325550322333e7, 0.14915108613530e2, | ||
99 | -0.48232657361591e4, 0.40511340542057e6, -0.23855557567849, | ||
100 | 0.65017534844798e3 | ||
101 | }; | ||
102 | |||
103 | 179226 | const Scalar sigma = T + n[8]/(T - n[9]); | |
104 | |||
105 | 179226 | const Scalar A = (sigma + n[0])*sigma + n[1]; | |
106 | 179226 | const Scalar B = (n[2]*sigma + n[3])*sigma + n[4]; | |
107 | 179226 | const Scalar C = (n[5]*sigma + n[6])*sigma + n[7]; | |
108 | |||
109 | using std::sqrt; | ||
110 | 179226 | const Scalar term = 2.0*C/(sqrt(B*B - 4.0*A*C) - B); | |
111 | |||
112 | 179226 | return 1e6*term*term*term*term; | |
113 | } | ||
114 | |||
115 | /*! | ||
116 | * \brief Specific enthalpy of water steam \f$\mathrm{[J/kg]}\f$. | ||
117 | * | ||
118 | * \param temperature temperature of component in \f$\mathrm{[K]}\f$ | ||
119 | * \param pressure pressure of component in \f$\mathrm{[Pa]}\f$ | ||
120 | */ | ||
121 | 1132820 | static const Scalar gasEnthalpy(Scalar temperature, | |
122 | Scalar pressure) | ||
123 | { | ||
124 |
5/6✓ Branch 0 taken 8 times.
✓ Branch 1 taken 1132812 times.
✓ Branch 3 taken 7 times.
✓ Branch 4 taken 1 times.
✓ Branch 6 taken 7 times.
✗ Branch 7 not taken.
|
1132820 | static const Scalar tRef = getParam<Scalar>("SimpleH2O.ReferenceTemperature", 293.15); |
125 | 1132820 | return gasHeatCapacity(temperature, pressure)*(temperature - tRef) + vaporizationEnthalpy(); | |
126 | } | ||
127 | |||
128 | /*! | ||
129 | * \brief Specific enthalpy of liquid water \f$\mathrm{[J/kg]}\f$. | ||
130 | * | ||
131 | * \param temperature temperature of component in \f$\mathrm{[K]}\f$ | ||
132 | * \param pressure pressure of component in \f$\mathrm{[Pa]}\f$ | ||
133 | */ | ||
134 | 3720978 | static const Scalar liquidEnthalpy(Scalar temperature, | |
135 | Scalar pressure) | ||
136 | { | ||
137 |
5/6✓ Branch 0 taken 67 times.
✓ Branch 1 taken 3720911 times.
✓ Branch 3 taken 14 times.
✓ Branch 4 taken 53 times.
✓ Branch 6 taken 14 times.
✗ Branch 7 not taken.
|
3720978 | static const Scalar tRef = getParam<Scalar>("SimpleH2O.ReferenceTemperature", 293.15); |
138 | 3720978 | return liquidHeatCapacity(temperature, pressure)*(temperature - tRef) | |
139 | 3720978 | + pressure/liquidDensity(temperature, pressure); | |
140 | } | ||
141 | |||
142 | /*! | ||
143 | * \brief The vaporization enthalpy in \f$\mathrm{[J/kg]}\f$ needed to vaporize one kilogram of the liquid water to the gaseous state depending on temperature as found in: C. O. Popiel & J. Wojtkowiak (1998) Simple Formulas for Thermophysical Properties of Liquid Water for Heat Transfer Calculations (from 0°C to 150°C), DOI:10.1080/01457639808939929 | ||
144 | */ | ||
145 | 1132820 | static Scalar vaporizationEnthalpy() | |
146 | { | ||
147 | 1132820 | constexpr Scalar A = 2500.304; | |
148 | 1132820 | constexpr Scalar B = -2.2521025; | |
149 | 1132820 | constexpr Scalar C = -0.021465847; | |
150 | 1132820 | constexpr Scalar D = 3.1750136e-4 ; | |
151 | 1132820 | constexpr Scalar E = -2.8607959e-5; | |
152 | |||
153 | //tRef in °C | ||
154 |
4/6✓ Branch 0 taken 7 times.
✓ Branch 1 taken 1132813 times.
✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 7 times.
✗ Branch 7 not taken.
|
1132820 | static const Scalar tRef = getParam<Scalar>("SimpleH2O.ReferenceTemperature", 293.15) - 273.15; |
155 | |||
156 | using std::pow; | ||
157 |
3/4✓ Branch 0 taken 7 times.
✓ Branch 1 taken 1132813 times.
✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
|
1132820 | static const Scalar vaporizationEnthalpy = A + B*tRef + C*(pow(tRef, 1.5)) + D*(pow(tRef, 2.5)) + E*(pow(tRef, 3)); |
158 | 1132820 | return vaporizationEnthalpy * 1e3; // kJ/kg to J/kg | |
159 | } | ||
160 | |||
161 | |||
162 | /*! | ||
163 | * \brief Specific internal energy of steam \f$\mathrm{[J/kg]}\f$. | ||
164 | * | ||
165 | * Definition of enthalpy: \f$h= u + pv = u + p / \rho\f$. | ||
166 | * Rearranging for internal energy yields: \f$u = h - pv\f$. | ||
167 | * Exploiting the Ideal Gas assumption (\f$pv = R_{\textnormal{specific}} T\f$)gives: \f$u = h - R / M T \f$. | ||
168 | * | ||
169 | * The universal gas constant can only be used in the case of molar formulations. | ||
170 | * \param temperature temperature of component in \f$\mathrm{[K]}\f$ | ||
171 | * \param pressure pressure of component in \f$\mathrm{[Pa]}\f$ | ||
172 | */ | ||
173 | static const Scalar gasInternalEnergy(Scalar temperature, | ||
174 | Scalar pressure) | ||
175 | { | ||
176 | // 1/molarMass: conversion from [J/(mol K)] to [J/(kg K)] | ||
177 | // R*T/molarMass: pressure *spec. volume for an ideal gas | ||
178 | return gasEnthalpy(temperature, pressure) | ||
179 | - 1.0/molarMass()*IdealGas::R*temperature; | ||
180 | } | ||
181 | |||
182 | /*! | ||
183 | * \brief Specific internal energy of liquid water \f$\mathrm{[J/kg]}\f$. | ||
184 | * | ||
185 | * \param temperature temperature of component in \f$\mathrm{[K]}\f$ | ||
186 | * \param pressure pressure of component in \f$\mathrm{[Pa]}\f$ | ||
187 | */ | ||
188 | static const Scalar liquidInternalEnergy(Scalar temperature, | ||
189 | Scalar pressure) | ||
190 | { | ||
191 | return liquidEnthalpy(temperature, pressure) | ||
192 | - pressure/liquidDensity(temperature, pressure); | ||
193 | } | ||
194 | |||
195 | /*! | ||
196 | * \brief Returns true if the gas phase is assumed to be compressible | ||
197 | */ | ||
198 | static constexpr bool gasIsCompressible() | ||
199 | { return true; } | ||
200 | |||
201 | /*! | ||
202 | * \brief Returns true if the liquid phase is assumed to be compressible | ||
203 | */ | ||
204 | static constexpr bool liquidIsCompressible() | ||
205 | { return false; } | ||
206 | |||
207 | /*! | ||
208 | * \brief Returns true if the gas phase viscosity is constant | ||
209 | */ | ||
210 | static constexpr bool gasViscosityIsConstant() | ||
211 | { return true; } | ||
212 | |||
213 | /*! | ||
214 | * \brief Returns true if the liquid phase viscosity is constant | ||
215 | */ | ||
216 | static constexpr bool liquidViscosityIsConstant() | ||
217 | { return true; } | ||
218 | |||
219 | /*! | ||
220 | * \brief The density \f$\mathrm{[kg/m^3]}\f$ of steam at a given pressure and temperature. | ||
221 | * | ||
222 | * \param temperature temperature of component in \f$\mathrm{[K]}\f$ | ||
223 | * \param pressure pressure of component in \f$\mathrm{[Pa]}\f$ | ||
224 | */ | ||
225 | static Scalar gasDensity(Scalar temperature, Scalar pressure) | ||
226 | { | ||
227 | // Assume an ideal gas | ||
228 |
4/4✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 2 times.
|
2979710 | return IdealGas::density(molarMass(), temperature, pressure); |
229 | } | ||
230 | |||
231 | /*! | ||
232 | * \brief The molar density of steam in \f$\mathrm{[mol/m^3]}\f$ at a given pressure and temperature. | ||
233 | * | ||
234 | * \param temperature temperature of component in \f$\mathrm{[K]}\f$ | ||
235 | * \param pressure pressure of component in \f$\mathrm{[Pa]}\f$ | ||
236 | * | ||
237 | */ | ||
238 | static Scalar gasMolarDensity(Scalar temperature, Scalar pressure) | ||
239 | 8 | { return IdealGas::molarDensity(temperature, pressure); } | |
240 | |||
241 | /*! | ||
242 | * \brief Returns true if the gas phase is assumed to be ideal | ||
243 | */ | ||
244 | static constexpr bool gasIsIdeal() | ||
245 | { return true; } | ||
246 | |||
247 | /*! | ||
248 | * \brief The pressure of steam in \f$\mathrm{[Pa]}\f$ at a given density and temperature. | ||
249 | * | ||
250 | * \param temperature temperature of component in \f$\mathrm{[K]}\f$ | ||
251 | * \param density density of component in \f$\mathrm{[kg/m^3]}\f$ | ||
252 | */ | ||
253 | static Scalar gasPressure(Scalar temperature, Scalar density) | ||
254 | { | ||
255 | // Assume an ideal gas | ||
256 | 18 | return IdealGas::pressure(temperature, density/molarMass()); | |
257 | } | ||
258 | |||
259 | /*! | ||
260 | * \brief The density of pure water at a given pressure and temperature \f$\mathrm{[kg/m^3]}\f$. | ||
261 | * | ||
262 | * \param temperature temperature of component in \f$\mathrm{[K]}\f$ | ||
263 | * \param pressure pressure of component in \f$\mathrm{[Pa]}\f$ | ||
264 | */ | ||
265 | ✗ | static Scalar liquidDensity(Scalar temperature, Scalar pressure) | |
266 | { | ||
267 | 1440 | return 1000.0; | |
268 | } | ||
269 | |||
270 | /*! | ||
271 | * \brief The molar density of pure water in \f$\mathrm{[mol/m^3]}\f$ at a given pressure and temperature. | ||
272 | * | ||
273 | * \param temperature temperature of component in \f$\mathrm{[K]}\f$ | ||
274 | * \param pressure pressure of component in \f$\mathrm{[Pa]}\f$ | ||
275 | * | ||
276 | */ | ||
277 | ✗ | static Scalar liquidMolarDensity(Scalar temperature, Scalar pressure) | |
278 | 5471009 | { return liquidDensity(temperature, pressure)/molarMass(); } | |
279 | |||
280 | /*! | ||
281 | * \brief The pressure of water in \f$\mathrm{[Pa]}\f$ at a given density and temperature. | ||
282 | * | ||
283 | * \param temperature temperature of component in \f$\mathrm{[K]}\f$ | ||
284 | * \param density density of component in \f$\mathrm{[kg/m^3]}\f$ | ||
285 | */ | ||
286 | static Scalar liquidPressure(Scalar temperature, Scalar density) | ||
287 | { | ||
288 | DUNE_THROW(Dune::InvalidStateException, | ||
289 | "The liquid pressure is undefined for incompressible fluids"); | ||
290 | } | ||
291 | |||
292 | /*! | ||
293 | * \brief The dynamic viscosity \f$\mathrm{[Pa*s]}\f$ of steam. | ||
294 | * | ||
295 | * \param temperature temperature of component in \f$\mathrm{[K]}\f$ | ||
296 | * \param pressure pressure of component in \f$\mathrm{[Pa]}\f$ | ||
297 | */ | ||
298 | ✗ | static Scalar gasViscosity(Scalar temperature, Scalar pressure) | |
299 | { | ||
300 | ✗ | return 1e-05; | |
301 | } | ||
302 | |||
303 | /*! | ||
304 | * \brief The dynamic viscosity \f$\mathrm{[Pa*s]}\f$ of pure water. | ||
305 | * | ||
306 | * \param temperature temperature of component in \f$\mathrm{[K]}\f$ | ||
307 | * \param pressure pressure of component in \f$\mathrm{[Pa]}\f$ | ||
308 | */ | ||
309 | ✗ | static Scalar liquidViscosity(Scalar temperature, Scalar pressure) | |
310 | { | ||
311 | 1440 | return 1e-03; | |
312 | } | ||
313 | |||
314 | /*! | ||
315 | * \brief Specific isobaric heat capacity of the component \f$\mathrm{[J/(kg*K)]}\f$ as a liquid. | ||
316 | * source: http://webbook.nist.gov/cgi/fluid.cgi?ID=C7732185&Action=Page | ||
317 | * @ T= 281.15K (8°C) , p=0.1MPa) | ||
318 | * \param temperature absolute temperature in \f$\mathrm{[K]}\f$ | ||
319 | * \param pressure of the phase in \f$\mathrm{[Pa]}\f$ | ||
320 | */ | ||
321 | ✗ | static Scalar liquidHeatCapacity(Scalar temperature, Scalar pressure) | |
322 | { | ||
323 | ✗ | return 4180.0; | |
324 | } | ||
325 | |||
326 | /*! | ||
327 | * \brief Thermal conductivity \f$\mathrm{[W/(m*K)]}\f$ of water. | ||
328 | * source: http://webbook.nist.gov/cgi/fluid.cgi?ID=C7732185&Action=Page | ||
329 | * @ T= 372.76K (99.6°C) , p=0.1MPa) | ||
330 | * \param temperature absolute temperature in \f$\mathrm{[K]}\f$ | ||
331 | * \param pressure of the phase in \f$\mathrm{[Pa]}\f$ | ||
332 | */ | ||
333 | ✗ | static Scalar liquidThermalConductivity(Scalar temperature, Scalar pressure) | |
334 | { | ||
335 | ✗ | return 0.679; | |
336 | } | ||
337 | |||
338 | /*! | ||
339 | * \brief Thermal conductivity \f$\mathrm{[W/(m*K)]}\f$ of steam. | ||
340 | * source: http://webbook.nist.gov/cgi/fluid.cgi?ID=C7732185&Action=Page | ||
341 | * @ T= 372.76K (99.6°C) , p=0.1MPa) | ||
342 | * \param temperature absolute temperature in \f$\mathrm{[K]}\f$ | ||
343 | * \param pressure of the phase in \f$\mathrm{[Pa]}\f$ | ||
344 | */ | ||
345 | ✗ | static Scalar gasThermalConductivity(Scalar temperature, Scalar pressure) | |
346 | { | ||
347 | ✗ | return 0.025; | |
348 | } | ||
349 | |||
350 | /*! | ||
351 | * \brief Specific isobaric heat capacity of water steam \f$\mathrm{[J/(kg*K)]}\f$. | ||
352 | * source: http://webbook.nist.gov/cgi/fluid.cgi?ID=C7732185&Action=Page | ||
353 | * @ T= 372.76K (99.6°C) , p=0.1MPa) | ||
354 | * \param temperature temperature of component in \f$\mathrm{[K]}\f$ | ||
355 | * \param pressure pressure of component in \f$\mathrm{[Pa]}\f$ | ||
356 | */ | ||
357 | ✗ | static Scalar gasHeatCapacity(Scalar temperature, Scalar pressure) | |
358 | { | ||
359 | ✗ | return 2.08e3; | |
360 | } | ||
361 | |||
362 | }; | ||
363 | |||
364 | template <class Scalar> | ||
365 | struct IsAqueous<SimpleH2O<Scalar>> : public std::true_type {}; | ||
366 | |||
367 | } // end namespace Dumux::Components | ||
368 | |||
369 | #endif | ||
370 |