Common.hpp
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 This file is part of the Open Porous Media project (OPM).
5
6 OPM 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 2 of the License, or
9 (at your option) any later version.
10
11 OPM 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 OPM. If not, see <http://www.gnu.org/licenses/>.
18
19 Consult the COPYING file in the top-level source directory of this
20 module for the precise wording of the license and the list of
21 copyright holders.
22*/
27#ifndef OPM_IAPWS_COMMON_HPP
28#define OPM_IAPWS_COMMON_HPP
29
32
33#include <cmath>
34
35namespace Opm {
36namespace IAPWS {
37
53template <class Scalar>
54class Common
55{
56public:
58 static const Scalar molarMass;
59
61 static const Scalar Rs;
62
64 static const Scalar criticalTemperature;
65
67 static const Scalar criticalPressure;
68
70 static const Scalar criticalDensity;
71
73 static const Scalar criticalVolume;
74
76 static const Scalar criticalMolarVolume;
77
79 static const Scalar acentricFactor;
80
82 static const Scalar tripleTemperature;
83
85 static const Scalar triplePressure;
86
101 template <class Evaluation>
102 static Evaluation viscosity(const Evaluation& temperature, const Evaluation& rho)
103 {
104 Evaluation rhoBar = rho/322.0;
105 Evaluation TBar = temperature/criticalTemperature;
106
107 // muBar = muBar_1
108 const Scalar Hij[6][7] = {
109 { 5.20094e-1, 2.22531e-1,-2.81378e-1, 1.61913e-1,-3.25372e-2, 0, 0 },
110 { 8.50895e-2, 9.99115e-1,-9.06851e-1, 2.57399e-1, 0, 0, 0 },
111 { -1.08374, 1.88797 ,-7.72479e-1, 0, 0, 0, 0 },
112 { -2.89555e-1, 1.26613 ,-4.89837e-1, 0, 6.98452e-2, 0,-4.35673e-3 },
113 { 0, 0,-2.57040e-1, 0, 0, 8.72102e-3, 0 },
114 { 0, 1.20573e-1, 0, 0, 0, 0,-5.93264e-4 }
115 };
116
117 Evaluation tmp, tmp2, tmp3 = 1;
118 Evaluation muBar = 0;
119 for (int i = 0; i <= 5; ++i) {
120 tmp = 0;
121 tmp2 = 1;
122 for (int j = 0; j <= 6; ++j) {
123 tmp += Hij[i][j]*tmp2;
124 tmp2 *= (rhoBar - 1);
125 };
126 muBar += tmp3 * tmp;
127 tmp3 *= 1.0/TBar - 1;
128 };
129 muBar *= rhoBar;
130 muBar = exp(muBar);
131
132 // muBar *= muBar_0
133 muBar *= 100*sqrt(TBar);
134 const Scalar H[4] = {
135 1.67752, 2.20462, 0.6366564, -0.241605
136 };
137
138 tmp = 0, tmp2 = 1;
139 for (int i = 0; i < 4; ++i) {
140 tmp += H[i]/tmp2;
141 tmp2 *= TBar;
142 };
143 muBar /= tmp;
144
145 return 1e-6*muBar;
146 }
147
161 template <class Evaluation>
162 static Evaluation thermalConductivityIAPWS(const Evaluation& T, const Evaluation& rho)
163 {
164 static const Scalar thcond_tstar = 647.26 ;
165 static const Scalar thcond_rhostar = 317.7 ;
166 /*static const Scalar thcond_kstar = 1.0 ;*/
167
168 static const Scalar thcond_b0 = -0.397070 ;
169 static const Scalar thcond_b1 = 0.400302 ;
170 static const Scalar thcond_b2 = 1.060000 ;
171 static const Scalar thcond_B1 = -0.171587 ;
172 static const Scalar thcond_B2 = 2.392190 ;
173
174 static const Scalar thcond_c1 = 0.642857 ;
175 static const Scalar thcond_c2 = -4.11717 ;
176 static const Scalar thcond_c3 = -6.17937 ;
177 static const Scalar thcond_c4 = 0.00308976 ;
178 static const Scalar thcond_c5 = 0.0822994 ;
179 static const Scalar thcond_c6 = 10.0932 ;
180
181 static const Scalar thcond_d1 = 0.0701309 ;
182 static const Scalar thcond_d2 = 0.0118520 ;
183 static const Scalar thcond_d3 = 0.00169937 ;
184 static const Scalar thcond_d4 = -1.0200 ;
185 static const int thcond_a_count = 4;
186 static const Scalar thcond_a[thcond_a_count] = {
187 0.0102811
188 ,0.0299621
189 ,0.0156146
190 ,-0.00422464
191 };
192
193 Evaluation Tbar = T / thcond_tstar;
194 Evaluation rhobar = rho / thcond_rhostar;
195
196 /* fast implementation... minimised calls to 'pow' routine... */
197 Evaluation Troot = sqrt(Tbar);
198 Evaluation Tpow = Troot;
199 Evaluation lam = 0;
200
201 for(int k = 0; k < thcond_a_count; ++k) {
202 lam += thcond_a[k] * Tpow;
203 Tpow *= Tbar;
204 }
205
206 lam +=
207 thcond_b0 + thcond_b1
208 * rhobar + thcond_b2
209 * exp(thcond_B1 * ((rhobar + thcond_B2)*(rhobar + thcond_B2)));
210
211 Evaluation DTbar = abs(Tbar - 1) + thcond_c4;
212 Evaluation DTbarpow = pow(DTbar, 3./5);
213 Evaluation Q = 2. + thcond_c5 / DTbarpow;
214
215 Evaluation S;
216 if(Tbar >= 1)
217 S = 1. / DTbar;
218 else
219 S = thcond_c6 / DTbarpow;
220
221 Evaluation rhobar18 = pow(rhobar, 1.8);
222 Evaluation rhobarQ = pow(rhobar, Q);
223
224 lam +=
225 (thcond_d1 / pow(Tbar,10.0) + thcond_d2) * rhobar18 *
226 exp(thcond_c1 * (1 - rhobar * rhobar18))
227 + thcond_d3 * S * rhobarQ *
228 exp((Q/(1+Q))*(1 - rhobar*rhobarQ))
229 + thcond_d4 *
230 exp(thcond_c2 * pow(Troot,3.0) + thcond_c3 / pow(rhobar,5.0));
231 return /*thcond_kstar * */ lam;
232 }
233};
234
235template <class Scalar>
236const Scalar Common<Scalar>::molarMass = 18.01518e-3;
237template <class Scalar>
238const Scalar Common<Scalar>::Rs = Constants<Scalar>::R/molarMass;
239template <class Scalar>
240const Scalar Common<Scalar>::criticalTemperature = 647.096;
241template <class Scalar>
242const Scalar Common<Scalar>::criticalPressure = 22.064e6;
243template <class Scalar>
244const Scalar Common<Scalar>::criticalDensity = 322.0;
245template <class Scalar>
246const Scalar Common<Scalar>::criticalMolarVolume = molarMass/criticalDensity;
247template <class Scalar>
248const Scalar Common<Scalar>::criticalVolume = 5.595e-2;
249template <class Scalar>
250const Scalar Common<Scalar>::acentricFactor = 0.344;
251template <class Scalar>
252const Scalar Common<Scalar>::tripleTemperature = 273.16;
253template <class Scalar>
254const Scalar Common<Scalar>::triplePressure = 611.657;
255
256} // namespace IAPWS
257} // namespace Opm
258
259#endif
A traits class which provides basic mathematical functions for arbitrary scalar floating point values...
A central place for various physical constants occuring in some equations.
Definition: Constants.hpp:41
Implements relations which are common for all regions of the IAPWS '97 formulation.
Definition: Common.hpp:55
static const Scalar criticalVolume
Critical volume of water .
Definition: Common.hpp:73
static const Scalar criticalPressure
Critical pressure of water .
Definition: Common.hpp:67
static Evaluation viscosity(const Evaluation &temperature, const Evaluation &rho)
The dynamic viscosity of pure water.
Definition: Common.hpp:102
static const Scalar criticalDensity
Density of water at the critical point .
Definition: Common.hpp:70
static const Scalar criticalMolarVolume
Critical molar volume of water .
Definition: Common.hpp:76
static const Scalar criticalTemperature
Critical temperature of water .
Definition: Common.hpp:64
static Evaluation thermalConductivityIAPWS(const Evaluation &T, const Evaluation &rho)
Thermal conductivity water (IAPWS) .
Definition: Common.hpp:162
static const Scalar tripleTemperature
Triple temperature of water .
Definition: Common.hpp:82
static const Scalar triplePressure
Triple pressure of water .
Definition: Common.hpp:85
static const Scalar molarMass
The molar mass of water .
Definition: Common.hpp:58
static const Scalar acentricFactor
The acentric factor of water .
Definition: Common.hpp:79
static const Scalar Rs
Specific gas constant of water .
Definition: Common.hpp:61
Definition: Air_Mesitylene.hpp:34
Evaluation exp(const Evaluation &value)
Definition: MathToolbox.hpp:403
Evaluation sqrt(const Evaluation &value)
Definition: MathToolbox.hpp:399
Evaluation abs(const Evaluation &value)
Definition: MathToolbox.hpp:350
ReturnEval_< Evaluation1, Evaluation2 >::type pow(const Evaluation1 &base, const Evaluation2 &exp)
Definition: MathToolbox.hpp:416