version 3.10-dev
region1.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-FileCopyrightInfo: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5// SPDX-License-Identifier: GPL-3.0-or-later
6//
17#ifndef DUMUX_IAPWS_REGION1_HH
18#define DUMUX_IAPWS_REGION1_HH
19
20#include <cmath>
21#include <iostream>
23
24namespace Dumux {
25namespace IAPWS {
36template <class Scalar>
38{
39public:
48 static void checkValidityRange(Scalar temperature, Scalar pressure,
49 const std::string& propertyName = "This property")
50 {
51 // actually this is:
52 /* 273.15 <= temperature &&
53 temperature <= 623.15 &&
54 pressure >= vaporPressure(temperature) &&
55 pressure <= 100e6 */
56 if (temperature <= 623.15 && pressure <= 100e6)
57 return;
58
59 DUNE_THROW(NumericalProblem,
60 propertyName << " of water is only implemented for temperatures below 623.15K and "
61 "pressures below 100MPa. (T=" << temperature << ", p=" << pressure << ")");
62 }
63
69 static constexpr Scalar tau(Scalar temperature)
70 { return 1386.0 / temperature; }
71
78 static constexpr Scalar dTau_dt(Scalar temperature)
79 { return - 1386.0 / (temperature*temperature); }
80
86 static constexpr Scalar pi(Scalar pressure)
87 { return pressure / 16.53e6; }
88
95 static constexpr Scalar dPi_dp(Scalar pressure)
96 { return 1.0 / 16.53e6; }
97
104 static constexpr Scalar dp_dPi(Scalar pressure)
105 { return 16.53e6; }
106
117 static Scalar gamma(Scalar temperature, Scalar pressure)
118 {
119 Scalar tau_ = tau(temperature); /* reduced temperature */
120 Scalar pi_ = pi(pressure); /* reduced pressure */
121
122 Scalar result = 0;
123 for (int i = 0; i < 34; ++i) {
124 result += n(i)*pow(7.1 - pi_, I(i))*pow(tau_ - 1.222, J(i));
125 }
126
127 return result;
128 }
129
130
142 static Scalar dGamma_dTau(Scalar temperature, Scalar pressure)
143 {
144 Scalar tau_ = tau(temperature); /* reduced temperature */
145 Scalar pi_ = pi(pressure); /* reduced pressure */
146
147 using std::pow;
148 Scalar result = 0.0;
149 for (int i = 0; i < 34; i++) {
150 result += n(i) *
151 pow(7.1 - pi_, I(i)) *
152 pow(tau_ - 1.222, J(i)-1) *
153 J(i);
154 }
155
156 return result;
157 }
158
170 static Scalar dGamma_dPi(Scalar temperature, Scalar pressure)
171 {
172 Scalar tau_ = tau(temperature); /* reduced temperature */
173 Scalar pi_ = pi(pressure); /* reduced pressure */
174
175 using std::pow;
176 Scalar result = 0.0;
177 for (int i = 0; i < 34; i++) {
178 result += -n(i) *
179 I(i) *
180 pow(7.1 - pi_, I(i) - 1) *
181 pow(tau_ - 1.222, J(i));
182 }
183
184 return result;
185 }
186
199 static Scalar ddGamma_dTaudPi(Scalar temperature, Scalar pressure)
200 {
201 Scalar tau_ = tau(temperature); /* reduced temperature */
202 Scalar pi_ = pi(pressure); /* reduced pressure */
203
204 using std::pow;
205 Scalar result = 0.0;
206 for (int i = 0; i < 34; i++) {
207 result += -n(i) *
208 I(i) *
209 J(i) *
210 pow(7.1 - pi_, I(i) - 1) *
211 pow(tau_ - 1.222, J(i) - 1);
212 }
213
214 return result;
215 }
216
229 static Scalar ddGamma_ddPi(Scalar temperature, Scalar pressure)
230 {
231 Scalar tau_ = tau(temperature); /* reduced temperature */
232 Scalar pi_ = pi(pressure); /* reduced pressure */
233
234 using std::pow;
235 Scalar result = 0.0;
236 for (int i = 0; i < 34; i++) {
237 result += n(i) *
238 I(i) *
239 (I(i) - 1) *
240 pow(7.1 - pi_, I(i) - 2) *
241 pow(tau_ - 1.222, J(i));
242 }
243
244 return result;
245 }
246
258 static Scalar ddGamma_ddTau(Scalar temperature, Scalar pressure)
259 {
260 Scalar tau_ = tau(temperature); /* reduced temperature */
261 Scalar pi_ = pi(pressure); /* reduced pressure */
262
263 using std::pow;
264 Scalar result = 0.0;
265 for (int i = 0; i < 34; i++) {
266 result += n(i) *
267 pow(7.1 - pi_, I(i)) *
268 J(i) *
269 (J(i) - 1) *
270 pow(tau_ - 1.222, J(i) - 2);
271 }
272
273 return result;
274 }
275
276private:
277 static Scalar n(int i)
278 {
279 constexpr Scalar n[34] = {
280 0.14632971213167, -0.84548187169114, -0.37563603672040e1,
281 0.33855169168385e1, -0.95791963387872, 0.15772038513228,
282 -0.16616417199501e-1, 0.81214629983568e-3, 0.28319080123804e-3,
283 -0.60706301565874e-3, -0.18990068218419e-1, -0.32529748770505e-1,
284 -0.21841717175414e-1, -0.52838357969930e-4, -0.47184321073267e-3,
285 -0.30001780793026e-3, 0.47661393906987e-4, -0.44141845330846e-5,
286 -0.72694996297594e-15,-0.31679644845054e-4, -0.28270797985312e-5,
287 -0.85205128120103e-9, -0.22425281908000e-5, -0.65171222895601e-6,
288 -0.14341729937924e-12,-0.40516996860117e-6, -0.12734301741641e-8,
289 -0.17424871230634e-9, -0.68762131295531e-18, 0.14478307828521e-19,
290 0.26335781662795e-22,-0.11947622640071e-22, 0.18228094581404e-23,
291 -0.93537087292458e-25
292 };
293 return n[i];
294 }
295
296 static short int I(int i)
297 {
298 constexpr short int I[34] = {
299 0, 0, 0,
300 0, 0, 0,
301 0, 0, 1,
302 1, 1, 1,
303 1, 1, 2,
304 2, 2, 2,
305 2, 3, 3,
306 3, 4, 4,
307 4, 5, 8,
308 8, 21, 23,
309 29, 30, 31,
310 32
311 };
312 return I[i];
313 }
314
315 static short int J(int i)
316 {
317 constexpr short int J[34] = {
318 -2, -1, 0,
319 1, 2, 3,
320 4, 5, -9,
321 -7, -1, 0,
322 1, 3, -3,
323 0, 1, 3,
324 17, -4, 0,
325 6, -5, -2,
326 10, -8, -11,
327 -6, -29, -31,
328 -38, -39, -40,
329 -41
330 };
331 return J[i];
332 }
333
334};
335
336} // end namespace IAPWS
337} // end namespace Dumux
338
339#endif
Implements the equations for region 1 of the IAPWS '97 formulation.
Definition: region1.hh:38
static Scalar dGamma_dPi(Scalar temperature, Scalar pressure)
The partial derivative of the Gibbs free energy to the normalized pressure for IAPWS region 1 (i....
Definition: region1.hh:170
static constexpr Scalar dp_dPi(Scalar pressure)
Returns the derivative of the pressure to the reduced pressure for IAPWS region 1 in .
Definition: region1.hh:104
static Scalar ddGamma_ddPi(Scalar temperature, Scalar pressure)
The second partial derivative of the Gibbs free energy to the normalized pressure for IAPWS region 1 ...
Definition: region1.hh:229
static constexpr Scalar dPi_dp(Scalar pressure)
Returns the derivative of the reduced pressure to the pressure for IAPWS region 1 in .
Definition: region1.hh:95
static constexpr Scalar tau(Scalar temperature)
Returns the reduced temperature for IAPWS region 1.
Definition: region1.hh:69
static void checkValidityRange(Scalar temperature, Scalar pressure, const std::string &propertyName="This property")
Returns true if IAPWS region 1 applies for a (temperature in , pressure in ) pair.
Definition: region1.hh:48
static constexpr Scalar dTau_dt(Scalar temperature)
Returns the derivative of the reduced temperature to the temperature for IAPWS region 1 in .
Definition: region1.hh:78
static Scalar dGamma_dTau(Scalar temperature, Scalar pressure)
The partial derivative of the Gibbs free energy to the normalized temperature for IAPWS region 1 (i....
Definition: region1.hh:142
static constexpr Scalar pi(Scalar pressure)
Returns the reduced pressure for IAPWS region 1.
Definition: region1.hh:86
static Scalar gamma(Scalar temperature, Scalar pressure)
The Gibbs free energy (dimensionless) for IAPWS region 1 (i.e. liquid)
Definition: region1.hh:117
static Scalar ddGamma_ddTau(Scalar temperature, Scalar pressure)
The second partial derivative of the Gibbs free energy to the normalized temperature for IAPWS region...
Definition: region1.hh:258
static Scalar ddGamma_dTaudPi(Scalar temperature, Scalar pressure)
The partial derivative of the Gibbs free energy to the normalized pressure and to the normalized temp...
Definition: region1.hh:199
Exception thrown if a fixable numerical problem occurs.
Definition: exceptions.hh:27
Some exceptions thrown in DuMux
std::string temperature() noexcept
I/O name of temperature for equilibrium models.
Definition: name.hh:39
std::string pressure(int phaseIdx) noexcept
I/O name of pressure for multiphase systems.
Definition: name.hh:22
Definition: adapt.hh:17