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  Copyright (C) 2010-2013 by Andreas Lauser
5  Copyright (C) 2012 by Philipp Nuske
6  Copyright (C) 2010 by Felix Bode
7 
8  This file is part of the Open Porous Media project (OPM).
9 
10  OPM is free software: you can redistribute it and/or modify
11  it under the terms of the GNU General Public License as published by
12  the Free Software Foundation, either version 2 of the License, or
13  (at your option) any later version.
14 
15  OPM is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with OPM. If not, see <http://www.gnu.org/licenses/>.
22 */
27 #ifndef OPM_IAPWS_COMMON_HPP
28 #define OPM_IAPWS_COMMON_HPP
29 
32 
33 #include <cmath>
34 
35 namespace Opm {
36 namespace IAPWS {
37 
53 template <class Scalar>
54 class Common
55 {
56 public:
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 criticalMolarVolume;
74 
76  static const Scalar acentricFactor;
77 
79  static const Scalar tripleTemperature;
80 
82  static const Scalar triplePressure;
83 
98  template <class Evaluation>
99  static Evaluation viscosity(const Evaluation& temperature, const Evaluation& rho)
100  {
101  typedef MathToolbox<Evaluation> Toolbox;
102 
103  Evaluation rhoBar = rho/322.0;
104  Evaluation TBar = temperature/criticalTemperature;
105 
106  // muBar = muBar_1
107  const Scalar Hij[6][7] = {
108  { 5.20094e-1, 2.22531e-1,-2.81378e-1, 1.61913e-1,-3.25372e-2, 0, 0 },
109  { 8.50895e-2, 9.99115e-1,-9.06851e-1, 2.57399e-1, 0, 0, 0 },
110  { -1.08374, 1.88797 ,-7.72479e-1, 0, 0, 0, 0 },
111  { -2.89555e-1, 1.26613 ,-4.89837e-1, 0, 6.98452e-2, 0,-4.35673e-3 },
112  { 0, 0,-2.57040e-1, 0, 0, 8.72102e-3, 0 },
113  { 0, 1.20573e-1, 0, 0, 0, 0,-5.93264e-4 }
114  };
115 
116  Evaluation tmp, tmp2, tmp3 = 1;
117  Evaluation muBar = 0;
118  for (int i = 0; i <= 5; ++i) {
119  tmp = 0;
120  tmp2 = 1;
121  for (int j = 0; j <= 6; ++j) {
122  tmp += Hij[i][j]*tmp2;
123  tmp2 *= (rhoBar - 1);
124  };
125  muBar += tmp3 * tmp;
126  tmp3 *= 1.0/TBar - 1;
127  };
128  muBar *= rhoBar;
129  muBar = Toolbox::exp(muBar);
130 
131  // muBar *= muBar_0
132  muBar *= 100*Toolbox::sqrt(TBar);
133  const Scalar H[4] = {
134  1.67752, 2.20462, 0.6366564, -0.241605
135  };
136 
137  tmp = 0, tmp2 = 1;
138  for (int i = 0; i < 4; ++i) {
139  tmp += H[i]/tmp2;
140  tmp2 *= TBar;
141  };
142  muBar /= tmp;
143 
144  return 1e-6*muBar;
145  }
146 
160  template <class Evaluation>
161  static Evaluation thermalConductivityIAPWS(const Evaluation& T, const Evaluation& rho)
162  {
163  typedef MathToolbox<Evaluation> Toolbox;
164 
165  static const Scalar thcond_tstar = 647.26 ;
166  static const Scalar thcond_rhostar = 317.7 ;
167  /*static const Scalar thcond_kstar = 1.0 ;*/
168 
169  static const Scalar thcond_b0 = -0.397070 ;
170  static const Scalar thcond_b1 = 0.400302 ;
171  static const Scalar thcond_b2 = 1.060000 ;
172  static const Scalar thcond_B1 = -0.171587 ;
173  static const Scalar thcond_B2 = 2.392190 ;
174 
175  static const Scalar thcond_c1 = 0.642857 ;
176  static const Scalar thcond_c2 = -4.11717 ;
177  static const Scalar thcond_c3 = -6.17937 ;
178  static const Scalar thcond_c4 = 0.00308976 ;
179  static const Scalar thcond_c5 = 0.0822994 ;
180  static const Scalar thcond_c6 = 10.0932 ;
181 
182  static const Scalar thcond_d1 = 0.0701309 ;
183  static const Scalar thcond_d2 = 0.0118520 ;
184  static const Scalar thcond_d3 = 0.00169937 ;
185  static const Scalar thcond_d4 = -1.0200 ;
186  static const int thcond_a_count = 4;
187  static const Scalar thcond_a[thcond_a_count] = {
188  0.0102811
189  ,0.0299621
190  ,0.0156146
191  ,-0.00422464
192  };
193 
194  Evaluation Tbar = T / thcond_tstar;
195  Evaluation rhobar = rho / thcond_rhostar;
196 
197  /* fast implementation... minimised calls to 'pow' routine... */
198  Evaluation Troot = Toolbox::sqrt(Tbar);
199  Evaluation Tpow = Troot;
200  Evaluation lam = 0;
201 
202  for(int k = 0; k < thcond_a_count; ++k) {
203  lam += thcond_a[k] * Tpow;
204  Tpow *= Tbar;
205  }
206 
207  lam +=
208  thcond_b0 + thcond_b1
209  * rhobar + thcond_b2
210  * Toolbox::exp(thcond_B1 * ((rhobar + thcond_B2)*(rhobar + thcond_B2)));
211 
212  Evaluation DTbar = Toolbox::abs(Tbar - 1) + thcond_c4;
213  Evaluation DTbarpow = Toolbox::pow(DTbar, 3./5);
214  Evaluation Q = 2. + thcond_c5 / DTbarpow;
215 
216  Evaluation S;
217  if(Tbar >= 1)
218  S = 1. / DTbar;
219  else
220  S = thcond_c6 / DTbarpow;
221 
222  Evaluation rhobar18 = Toolbox::pow(rhobar, 1.8);
223  Evaluation rhobarQ = Toolbox::pow(rhobar, Q);
224 
225  lam +=
226  (thcond_d1 / Toolbox::pow(Tbar,10.0) + thcond_d2) * rhobar18 *
227  Toolbox::exp(thcond_c1 * (1 - rhobar * rhobar18))
228  + thcond_d3 * S * rhobarQ *
229  Toolbox::exp((Q/(1+Q))*(1 - rhobar*rhobarQ))
230  + thcond_d4 *
231  Toolbox::exp(thcond_c2 * Toolbox::pow(Troot,3.0) + thcond_c3 / Toolbox::pow(rhobar,5.0));
232  return /*thcond_kstar * */ lam;
233  }
234 };
235 
236 template <class Scalar>
237 const Scalar Common<Scalar>::molarMass = 18.01518e-3;
238 template <class Scalar>
239 const Scalar Common<Scalar>::Rs = Opm::Constants<Scalar>::R/molarMass;
240 template <class Scalar>
241 const Scalar Common<Scalar>::criticalTemperature = 647.096;
242 template <class Scalar>
243 const Scalar Common<Scalar>::criticalPressure = 22.064e6;
244 template <class Scalar>
245 const Scalar Common<Scalar>::criticalDensity = 322.0;
246 template <class Scalar>
247 const Scalar Common<Scalar>::criticalMolarVolume = molarMass/criticalDensity;
248 template <class Scalar>
249 const Scalar Common<Scalar>::acentricFactor = 0.344;
250 template <class Scalar>
251 const Scalar Common<Scalar>::tripleTemperature = 273.16;
252 template <class Scalar>
253 const Scalar Common<Scalar>::triplePressure = 611.657;
254 
255 } // namespace IAPWS
256 } // namespace Opm
257 
258 #endif
Definition: MathToolbox.hpp:39
Definition: Air_Mesitylene.hpp:31
static Evaluation thermalConductivityIAPWS(const Evaluation &T, const Evaluation &rho)
Thermal conductivity water (IAPWS) .
Definition: Common.hpp:161
Evaluation< Scalar, VarSetTag, numVars > sqrt(const Evaluation< Scalar, VarSetTag, numVars > &x)
Definition: Math.hpp:278
A central place for various physical constants occuring in some equations.
Evaluation< Scalar, VarSetTag, numVars > exp(const Evaluation< Scalar, VarSetTag, numVars > &x)
Definition: Math.hpp:295
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:73
Evaluation< Scalar, VarSetTag, numVars > abs(const Evaluation< Scalar, VarSetTag, numVars > &)
Definition: Math.hpp:41
static const Scalar Rs
Specific gas constant of water .
Definition: Common.hpp:61
static const Scalar tripleTemperature
Triple temperature of water .
Definition: Common.hpp:79
Implements relations which are common for all regions of the IAPWS '97 formulation.
Definition: Common.hpp:54
Evaluation< Scalar, VarSetTag, numVars > pow(const Evaluation< Scalar, VarSetTag, numVars > &base, Scalar exp)
Definition: Math.hpp:312
static const Scalar molarMass
The molar mass of water .
Definition: Common.hpp:58
static const Scalar criticalPressure
Critical pressure of water .
Definition: Common.hpp:67
static const Scalar criticalTemperature
Critical temperature of water .
Definition: Common.hpp:64
static const Scalar triplePressure
Triple pressure of water .
Definition: Common.hpp:82
static Evaluation viscosity(const Evaluation &temperature, const Evaluation &rho)
The dynamic viscosity of pure water.
Definition: Common.hpp:99
A central place for various physical constants occuring in some equations.
Definition: Constants.hpp:39
static const Scalar acentricFactor
The acentric factor of water .
Definition: Common.hpp:76
A traits class which provides basic mathematical functions for arbitrary scalar floating point values...