version 3.8
common.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//
18#ifndef DUMUX_IAPWS_COMMON_HH
19#define DUMUX_IAPWS_COMMON_HH
20
21#include <cmath>
22#include <iostream>
23
24#include <dune/common/math.hh>
25
27
28namespace Dumux::IAPWS {
29
43template <class Scalar>
44class Common
45{
46public:
48 static constexpr Scalar molarMass = 18.01518e-3;
49
51 static constexpr Scalar Rs = Constants<Scalar>::R / molarMass;
52
54 static constexpr Scalar criticalTemperature = 647.096;
55
57 static constexpr Scalar criticalPressure = 22.064e6;
58
60 static constexpr Scalar criticalMolarVolume = molarMass / 322.0;
61
63 static constexpr Scalar acentricFactor = 0.344;
64
66 static constexpr Scalar criticalDensity = 322;
67
69 static constexpr Scalar tripleTemperature = 273.16;
70
72 static constexpr Scalar triplePressure = 611.657;
73
88 static Scalar viscosity(Scalar temperature, Scalar rho)
89 {
90 const Scalar rhoBar = rho/322.0;
91 const Scalar TBar = temperature/criticalTemperature;
92
93 // muBar = muBar_1
94 constexpr Scalar Hij[6][7] = {
95 { 5.20094e-1, 2.22531e-1,-2.81378e-1, 1.61913e-1,-3.25372e-2, 0, 0 },
96 { 8.50895e-2, 9.99115e-1,-9.06851e-1, 2.57399e-1, 0, 0, 0 },
97 {-1.08374 , 1.88797 ,-7.72479e-1, 0, 0, 0, 0 },
98 {-2.89555e-1, 1.26613 ,-4.89837e-1, 0, 6.98452e-2, 0,-4.35673e-3 },
99 { 0, 0,-2.57040e-1, 0, 0, 8.72102e-3, 0 },
100 { 0, 1.20573e-1, 0, 0, 0, 0,-5.93264e-4 }
101 };
102
103 Scalar tmp, tmp2, tmp3 = 1;
104 Scalar muBar = 0;
105 for (int i = 0; i <= 5; ++i) {
106 tmp = 0;
107 tmp2 = 1;
108 for (int j = 0; j <= 6; ++j) {
109 tmp += Hij[i][j]*tmp2;
110 tmp2 *= (rhoBar - 1);
111 }
112 muBar += tmp3 * tmp;
113 tmp3 *= 1.0/TBar - 1;
114 }
115 using std::exp;
116 muBar *= rhoBar;
117 muBar = exp(muBar);
118
119 // muBar *= muBar_0
120 using std::sqrt;
121 muBar *= 100*sqrt(TBar);
122 constexpr Scalar H[4] = {
123 1.67752, 2.20462, 0.6366564, -0.241605
124 };
125
126 tmp = 0, tmp2 = 1;
127 for (int i = 0; i < 4; ++i) {
128 tmp += H[i]/tmp2;
129 tmp2 *= TBar;
130 }
131 muBar /= tmp;
132
133 return 1e-6*muBar;
134 }
135
149 static Scalar thermalConductivityIAPWS(const Scalar T, const Scalar rho)
150 {
151 constexpr Scalar thcond_tstar = 647.26 ;
152 constexpr Scalar thcond_rhostar = 317.7 ;
153 /*static constexpr Scalar thcond_kstar = 1.0 ;*/
154
155 constexpr Scalar thcond_b0 = -0.397070 ;
156 constexpr Scalar thcond_b1 = 0.400302 ;
157 constexpr Scalar thcond_b2 = 1.060000 ;
158 constexpr Scalar thcond_B1 = -0.171587 ;
159 constexpr Scalar thcond_B2 = 2.392190 ;
160
161 constexpr Scalar thcond_c1 = 0.642857 ;
162 constexpr Scalar thcond_c2 = -4.11717 ;
163 constexpr Scalar thcond_c3 = -6.17937 ;
164 constexpr Scalar thcond_c4 = 0.00308976 ;
165 constexpr Scalar thcond_c5 = 0.0822994 ;
166 constexpr Scalar thcond_c6 = 10.0932 ;
167
168 constexpr Scalar thcond_d1 = 0.0701309 ;
169 constexpr Scalar thcond_d2 = 0.0118520 ;
170 constexpr Scalar thcond_d3 = 0.00169937 ;
171 constexpr Scalar thcond_d4 = -1.0200 ;
172 constexpr unsigned int thcond_a_count = 4;
173 constexpr Scalar thcond_a[thcond_a_count] = {
174 0.0102811
175 ,0.0299621
176 ,0.0156146
177 ,-0.00422464
178 };
179
180 const Scalar Tbar = T / thcond_tstar;
181 const Scalar rhobar = rho / thcond_rhostar;
182
183 /* fast implementation... minimised calls to 'pow' routine... */
184 using std::sqrt;
185 const Scalar Troot = sqrt(Tbar);
186 Scalar Tpow = Troot;
187 Scalar lam = 0;
188
189 for(unsigned int k = 0; k < thcond_a_count; ++k) {
190 lam += thcond_a[k] * Tpow;
191 Tpow *= Tbar;
192 }
193
194 using std::exp;
195 lam += thcond_b0 + thcond_b1
196 * rhobar + thcond_b2
197 * exp(thcond_B1 * ((rhobar + thcond_B2)*(rhobar + thcond_B2)));
198
199 using std::abs;
200 using std::pow;
201 using Dune::power;
202 const Scalar DTbar = abs(Tbar - 1) + thcond_c4;
203 const Scalar DTbarpow = pow(DTbar, 3./5);
204 const Scalar Q = 2. + thcond_c5 / DTbarpow;
205 const Scalar S = (Tbar >= 1) ? 1. / DTbar : thcond_c6 / DTbarpow;
206
207 const Scalar rhobar18 = pow(rhobar, 1.8);
208 const Scalar rhobarQ = pow(rhobar, Q);
209
210 lam +=
211 (thcond_d1 / power(Tbar,10) + thcond_d2) * rhobar18 *
212 exp(thcond_c1 * (1 - rhobar * rhobar18))
213 + thcond_d3 * S * rhobarQ *
214 exp((Q/(1+Q))*(1 - rhobar*rhobarQ))
215 + thcond_d4 *
216 exp(thcond_c2 * power(Troot,3) + thcond_c3 / power(rhobar,5));
217 return /*thcond_kstar * */ lam;
218 }
219};
220
221} // end namespace Dumux::IAPWS
222
223#endif
A central place for various physical constants occurring in some equations.
Definition: constants.hh:27
Implements relations which are common for all regions of the IAPWS '97 formulation.
Definition: common.hh:45
static constexpr Scalar criticalMolarVolume
Critical molar volume of water .
Definition: common.hh:60
static constexpr Scalar Rs
Specific gas constant of water .
Definition: common.hh:51
static constexpr Scalar triplePressure
Triple pressure of water .
Definition: common.hh:72
static constexpr Scalar molarMass
The molar mass of water .
Definition: common.hh:48
static Scalar viscosity(Scalar temperature, Scalar rho)
The dynamic viscosity of pure water.
Definition: common.hh:88
static constexpr Scalar acentricFactor
The acentric factor of water .
Definition: common.hh:63
static constexpr Scalar criticalTemperature
Critical temperature of water .
Definition: common.hh:54
static constexpr Scalar criticalDensity
Density of water at the critical point .
Definition: common.hh:66
static constexpr Scalar tripleTemperature
Triple temperature of water .
Definition: common.hh:69
static constexpr Scalar criticalPressure
Critical pressure of water .
Definition: common.hh:57
static Scalar thermalConductivityIAPWS(const Scalar T, const Scalar rho)
Thermal conductivity water (IAPWS) .
Definition: common.hh:149
A central place for various physical constants occurring in some equations.
Definition: common.hh:28
std::string temperature() noexcept
I/O name of temperature for equilibrium models.
Definition: name.hh:39