3.2-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
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 * See the file COPYING for full copying permissions. *
5 * *
6 * This program is free software: you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation, either version 3 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
18 *****************************************************************************/
29#ifndef DUMUX_IAPWS_REGION1_HH
30#define DUMUX_IAPWS_REGION1_HH
31
32#include <cmath>
33#include <iostream>
35
36namespace Dumux {
37namespace IAPWS {
48template <class Scalar>
50{
51public:
60 static void checkValidityRange(Scalar temperature, Scalar pressure,
61 const std::string& propertyName = "This property")
62 {
63 // actually this is:
64 /* 273.15 <= temperature &&
65 temperature <= 623.15 &&
66 pressure >= vaporPressure(temperature) &&
67 pressure <= 100e6 */
68 if (temperature <= 623.15 && pressure <= 100e6)
69 return;
70
71 DUNE_THROW(NumericalProblem,
72 propertyName << " of water is only implemented for temperatures below 623.15K and "
73 "pressures below 100MPa. (T=" << temperature << ", p=" << pressure << ")");
74 }
75
81 static constexpr Scalar tau(Scalar temperature)
82 { return 1386.0 / temperature; }
83
90 static constexpr Scalar dTau_dt(Scalar temperature)
91 { return - 1386.0 / (temperature*temperature); }
92
98 static constexpr Scalar pi(Scalar pressure)
99 { return pressure / 16.53e6; }
100
107 static constexpr Scalar dPi_dp(Scalar pressure)
108 { return 1.0 / 16.53e6; }
109
116 static constexpr Scalar dp_dPi(Scalar pressure)
117 { return 16.53e6; }
118
129 static Scalar gamma(Scalar temperature, Scalar pressure)
130 {
131 Scalar tau_ = tau(temperature); /* reduced temperature */
132 Scalar pi_ = pi(pressure); /* reduced pressure */
133
134 Scalar result = 0;
135 for (int i = 0; i < 34; ++i) {
136 result += n(i)*pow(7.1 - pi_, I(i))*pow(tau_ - 1.222, J(i));
137 }
138
139 return result;
140 }
141
142
154 static Scalar dGamma_dTau(Scalar temperature, Scalar pressure)
155 {
156 Scalar tau_ = tau(temperature); /* reduced temperature */
157 Scalar pi_ = pi(pressure); /* reduced pressure */
158
159 using std::pow;
160 Scalar result = 0.0;
161 for (int i = 0; i < 34; i++) {
162 result += n(i) *
163 pow(7.1 - pi_, I(i)) *
164 pow(tau_ - 1.222, J(i)-1) *
165 J(i);
166 }
167
168 return result;
169 }
170
182 static Scalar dGamma_dPi(Scalar temperature, Scalar pressure)
183 {
184 Scalar tau_ = tau(temperature); /* reduced temperature */
185 Scalar pi_ = pi(pressure); /* reduced pressure */
186
187 using std::pow;
188 Scalar result = 0.0;
189 for (int i = 0; i < 34; i++) {
190 result += -n(i) *
191 I(i) *
192 pow(7.1 - pi_, I(i) - 1) *
193 pow(tau_ - 1.222, J(i));
194 }
195
196 return result;
197 }
198
211 static Scalar ddGamma_dTaudPi(Scalar temperature, Scalar pressure)
212 {
213 Scalar tau_ = tau(temperature); /* reduced temperature */
214 Scalar pi_ = pi(pressure); /* reduced pressure */
215
216 using std::pow;
217 Scalar result = 0.0;
218 for (int i = 0; i < 34; i++) {
219 result += -n(i) *
220 I(i) *
221 J(i) *
222 pow(7.1 - pi_, I(i) - 1) *
223 pow(tau_ - 1.222, J(i) - 1);
224 }
225
226 return result;
227 }
228
241 static Scalar ddGamma_ddPi(Scalar temperature, Scalar pressure)
242 {
243 Scalar tau_ = tau(temperature); /* reduced temperature */
244 Scalar pi_ = pi(pressure); /* reduced pressure */
245
246 using std::pow;
247 Scalar result = 0.0;
248 for (int i = 0; i < 34; i++) {
249 result += n(i) *
250 I(i) *
251 (I(i) - 1) *
252 pow(7.1 - pi_, I(i) - 2) *
253 pow(tau_ - 1.222, J(i));
254 }
255
256 return result;
257 }
258
270 static Scalar ddGamma_ddTau(Scalar temperature, Scalar pressure)
271 {
272 Scalar tau_ = tau(temperature); /* reduced temperature */
273 Scalar pi_ = pi(pressure); /* reduced pressure */
274
275 using std::pow;
276 Scalar result = 0.0;
277 for (int i = 0; i < 34; i++) {
278 result += n(i) *
279 pow(7.1 - pi_, I(i)) *
280 J(i) *
281 (J(i) - 1) *
282 pow(tau_ - 1.222, J(i) - 2);
283 }
284
285 return result;
286 }
287
288private:
289 static Scalar n(int i)
290 {
291 constexpr Scalar n[34] = {
292 0.14632971213167, -0.84548187169114, -0.37563603672040e1,
293 0.33855169168385e1, -0.95791963387872, 0.15772038513228,
294 -0.16616417199501e-1, 0.81214629983568e-3, 0.28319080123804e-3,
295 -0.60706301565874e-3, -0.18990068218419e-1, -0.32529748770505e-1,
296 -0.21841717175414e-1, -0.52838357969930e-4, -0.47184321073267e-3,
297 -0.30001780793026e-3, 0.47661393906987e-4, -0.44141845330846e-5,
298 -0.72694996297594e-15,-0.31679644845054e-4, -0.28270797985312e-5,
299 -0.85205128120103e-9, -0.22425281908000e-5, -0.65171222895601e-6,
300 -0.14341729937924e-12,-0.40516996860117e-6, -0.12734301741641e-8,
301 -0.17424871230634e-9, -0.68762131295531e-18, 0.14478307828521e-19,
302 0.26335781662795e-22,-0.11947622640071e-22, 0.18228094581404e-23,
303 -0.93537087292458e-25
304 };
305 return n[i];
306 }
307
308 static short int I(int i)
309 {
310 constexpr short int I[34] = {
311 0, 0, 0,
312 0, 0, 0,
313 0, 0, 1,
314 1, 1, 1,
315 1, 1, 2,
316 2, 2, 2,
317 2, 3, 3,
318 3, 4, 4,
319 4, 5, 8,
320 8, 21, 23,
321 29, 30, 31,
322 32
323 };
324 return I[i];
325 }
326
327 static short int J(int i)
328 {
329 constexpr short int J[34] = {
330 -2, -1, 0,
331 1, 2, 3,
332 4, 5, -9,
333 -7, -1, 0,
334 1, 3, -3,
335 0, 1, 3,
336 17, -4, 0,
337 6, -5, -2,
338 10, -8, -11,
339 -6, -29, -31,
340 -38, -39, -40,
341 -41
342 };
343 return J[i];
344 }
345
346};
347
348} // end namespace IAPWS
349} // end namespace Dumux
350
351#endif
Some exceptions thrown in DuMux
Definition: adapt.hh:29
std::string temperature() noexcept
I/O name of temperature for equilibrium models.
Definition: name.hh:51
std::string pressure(int phaseIdx) noexcept
I/O name of pressure for multiphase systems.
Definition: name.hh:34
Exception thrown if a fixable numerical problem occurs.
Definition: exceptions.hh:39
Implements the equations for region 1 of the IAPWS '97 formulation.
Definition: region1.hh:50
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:182
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:116
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:241
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:107
static constexpr Scalar tau(Scalar temperature)
Returns the reduced temperature for IAPWS region 1.
Definition: region1.hh:81
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:60
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:90
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:154
static constexpr Scalar pi(Scalar pressure)
Returns the reduced pressure for IAPWS region 1.
Definition: region1.hh:98
static Scalar gamma(Scalar temperature, Scalar pressure)
The Gibbs free energy (dimensionless) for IAPWS region 1 (i.e. liquid)
Definition: region1.hh:129
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:270
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:211