My Project
SimpleHuDuanH2O.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_SIMPLE_HU_DUAN_H2O_HPP
28 #define OPM_SIMPLE_HU_DUAN_H2O_HPP
29 
30 #include "Component.hpp"
31 #include "iapws/Common.hpp"
32 
33 
35 
38 
39 #if HAVE_OPM_COMMON
40 #include <opm/common/OpmLog/OpmLog.hpp>
41 #else
42 #include <iostream>
43 #endif
44 
45 #include <cmath>
46 #include <sstream>
47 
48 namespace Opm {
49 
68 template <class Scalar>
69 class SimpleHuDuanH2O : public Component<Scalar, SimpleHuDuanH2O<Scalar>>
70 {
73 
74  static constexpr Scalar R = Constants<Scalar>::R / 18e-3; // specific gas constant of water
75 
76 public:
80  static const char* name()
81  { return "H2O"; }
82 
86  static bool gasIsCompressible()
87  { return true; }
88 
92  static bool liquidIsCompressible()
93  { return false; }
94 
98  static bool gasIsIdeal()
99  { return true; }
100 
104  static Scalar molarMass()
105  { return 18e-3; }
106 
110  static Scalar criticalTemperature()
111  { return 647.096; /* [K] */ }
112 
116  static Scalar criticalPressure()
117  { return 22.064e6; /* [N/m^2] */ }
118 
122  static Scalar tripleTemperature()
123  { return 273.16; /* [K] */ }
124 
128  static Scalar triplePressure()
129  { return 611.657; /* [N/m^2] */ }
130 
143  template <class Evaluation>
144  static Evaluation vaporPressure(const Evaluation& T)
145  {
146  if (T > criticalTemperature())
147  return criticalPressure();
148  if (T < tripleTemperature())
149  return 0; // water is solid: We don't take sublimation into account
150 
151  static constexpr Scalar n[10] = {
152  0.11670521452767e4, -0.72421316703206e6, -0.17073846940092e2,
153  0.12020824702470e5, -0.32325550322333e7, 0.14915108613530e2,
154  -0.48232657361591e4, 0.40511340542057e6, -0.23855557567849,
155  0.65017534844798e3
156  };
157 
158  Evaluation sigma = T + n[8]/(T - n[9]);
159 
160  Evaluation A = (sigma + n[0])*sigma + n[1];
161  Evaluation B = (n[2]*sigma + n[3])*sigma + n[4];
162  Evaluation C = (n[5]*sigma + n[6])*sigma + n[7];
163 
164  Evaluation tmp = 2.0*C/(sqrt(B*B - 4.0*A*C) - B);
165  tmp *= tmp;
166  tmp *= tmp;
167 
168  return 1e6*tmp;
169  }
170 
177  template <class Evaluation>
178  static Evaluation gasEnthalpy(const Evaluation& temperature,
179  const Evaluation& /*pressure*/)
180  { return 1.976e3*temperature + 40.65e3/molarMass(); }
181 
182 
186  template <class Evaluation>
187  static Evaluation gasHeatCapacity(const Evaluation&,
188  const Evaluation&)
189  { return 1.976e3; }
190 
197  template <class Evaluation>
198  static Evaluation liquidEnthalpy(const Evaluation& temperature,
199  const Evaluation& /*pressure*/)
200  { return 4180*temperature; }
201 
205  template <class Evaluation>
206  static Evaluation liquidHeatCapacity(const Evaluation&,
207  const Evaluation&)
208  { return 4.184e3; }
209 
223  template <class Evaluation>
224  static Evaluation gasInternalEnergy(const Evaluation& temperature,
225  const Evaluation& pressure)
226  {
227  return
228  gasEnthalpy(temperature, pressure) -
229  1/molarMass()* // conversion from [J/(mol K)] to [J/(kg K)]
230  IdealGas::R*temperature; // = pressure *spec. volume for an ideal gas
231  }
232 
239  template <class Evaluation>
240  static Evaluation liquidInternalEnergy(const Evaluation& temperature,
241  const Evaluation& pressure)
242  {
243  return
244  liquidEnthalpy(temperature, pressure) -
245  pressure/liquidDensity(temperature, pressure);
246  }
247 
254  template <class Evaluation>
255  static Evaluation liquidThermalConductivity(const Evaluation& /*temperature*/,
256  const Evaluation& /*pressure*/)
257  {
258  return 0.578078; // conductivity of liquid water [W / (m K ) ] IAPWS evaluated at p=.1 MPa, T=8°C
259  }
260 
267  template <class Evaluation>
268  static Evaluation gasThermalConductivity(const Evaluation& /*temperature*/,
269  const Evaluation& /*pressure*/)
270  {
271  return 0.028224; // conductivity of steam [W / (m K ) ] IAPWS evaluated at p=.1 MPa, T=8°C
272  }
273 
280  template <class Evaluation>
281  static Evaluation gasDensity(const Evaluation& temperature, const Evaluation& pressure)
282  {
283  // Assume an ideal gas
284  return molarMass()*IdealGas::molarDensity(temperature, pressure);
285  }
286 
293  template <class Evaluation>
294  static Evaluation gasPressure(const Evaluation& temperature, const Evaluation& density)
295  {
296  // Assume an ideal gas
297  return IdealGas::pressure(temperature, density/molarMass());
298  }
299 
308  template <class Evaluation>
309  static Evaluation liquidDensity(const Evaluation& temperature, const Evaluation& pressure,
310  bool extrapolate)
311  {
312  return liquidDensity_(temperature, pressure, extrapolate);
313  }
314 
321  template <class Evaluation>
322  static Evaluation liquidPressure(const Evaluation& /*temperature*/, const Evaluation& /*density*/)
323  {
324  throw std::logic_error("The liquid pressure is undefined for incompressible fluids");
325  }
326 
334  template <class Evaluation>
335  static Evaluation gasViscosity(const Evaluation& /*temperature*/,
336  const Evaluation& /*pressure*/)
337  {
338  return 1e-05;
339  }
340 
349  template <class Evaluation>
350  static Evaluation liquidViscosity(const Evaluation& temperature, const Evaluation& pressure,
351  bool extrapolate)
352  {
353  if (temperature > 570) {
354  std::ostringstream oss;
355  oss << "Viscosity of water based on Hu et al is too different from IAPWS for T above 570K and "
356  << "(T = " << temperature << ")";
357  if(extrapolate)
358  {
359 #if HAVE_OPM_COMMON
360  OpmLog::warning(oss.str());
361 #else
362  std::cerr << "warning: "<< oss.str() <<std::endl;
363 #endif
364  }
365  else
366  throw NumericalIssue(oss.str());
367  }
368 
369  const Evaluation rho = liquidDensity(temperature, pressure, extrapolate);
370  return Common::viscosity(temperature, rho);
371  }
372 
373 private:
374 
383  template <class Evaluation>
384  static Evaluation liquidDensity_(const Evaluation& T, const Evaluation& pressure, bool extrapolate) {
385  // Hu, Duan, Zhu and Chou: PVTx properties of the CO2-H2O and CO2-H2O-NaCl
386  // systems below 647 K: Assessment of experimental data and
387  // thermodynamics models, Chemical Geology, 2007.
388  if (T > 647 || pressure > 100e6) {
389  std::ostringstream oss;
390  oss << "Density of water is only implemented for temperatures below 647K and "
391  << "pressures below 100MPa. (T = " << T << ", p=" << pressure;
392  if(extrapolate)
393  {
394 #if HAVE_OPM_COMMON
395  OpmLog::warning(oss.str());
396 #else
397  std::cerr << "warning: "<< oss.str() <<std::endl;
398 #endif
399  }
400  else
401  throw NumericalIssue(oss.str());
402  }
403 
404  Evaluation p = pressure / 1e6; // to MPa
405  Scalar Mw = molarMass() * 1e3; //kg/kmol
406 
407  static constexpr Scalar k0[5] = { 3.27225e-07, -4.20950e-04, 2.32594e-01, -4.16920e+01, 5.71292e+03 };
408  static constexpr Scalar k1[5] = { -2.32306e-10, 2.91138e-07, -1.49662e-04, 3.59860e-02, -3.55071 };
409  static constexpr Scalar k2[3] = { 2.57241e-14, -1.24336e-11, 5.42707e-07 };
410  static constexpr Scalar k3[3] = { -4.42028e-18, 2.10007e-15, -8.11491e-11 };
411  Evaluation k0_eval = 1e-3 * (((k0[0]*T + k0[1])*T + k0[2])*T + k0[3] + k0[4]/T);
412  Evaluation k1_eval = 1e-2 * (((k1[0]*T + k1[1])*T + k1[2])*T + k1[3] + k1[4]/T);
413  Evaluation k2_eval = 1e-1 * ((k2[0]*T + k2[1])*T*T + k2[2]);
414  Evaluation k3_eval = (k3[0]*T + k3[1])*T*T + k3[2];
415 
416  // molar volum (m³/kmol):
417  Evaluation vw = ((k3_eval*p + k2_eval)*p + k1_eval)*p + k0_eval;
418 
419  // density kg/m3
420  return Mw / vw;
421 
422  }
423 
424 };
425 
426 } // namespace Opm
427 
428 #endif
Implements relations which are common for all regions of the IAPWS '97 formulation.
Abstract base class of a pure chemical species.
Provides the opm-material specific exception classes.
Relations valid for an ideal gas.
A traits class which provides basic mathematical functions for arbitrary scalar floating point values...
Abstract base class of a pure chemical species.
Definition: Component.hpp:42
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 Evaluation viscosity(const Evaluation &temperature, const Evaluation &rho)
The dynamic viscosity of pure water.
Definition: Common.hpp:102
Relations valid for an ideal gas.
Definition: IdealGas.hpp:38
static const Scalar R
The ideal gas constant .
Definition: IdealGas.hpp:41
static Evaluation pressure(const Evaluation &temperature, const Evaluation &rhoMolar)
The pressure of the gas in , depending on the molar density and temperature.
Definition: IdealGas.hpp:58
static Evaluation molarDensity(const Evaluation &temperature, const Evaluation &pressure)
The molar density of the gas , depending on pressure and temperature.
Definition: IdealGas.hpp:67
Definition: Exceptions.hpp:46
A simple version of pure water with density from Hu et al.
Definition: SimpleHuDuanH2O.hpp:70
static Evaluation gasThermalConductivity(const Evaluation &, const Evaluation &)
Specific heat conductivity of steam .
Definition: SimpleHuDuanH2O.hpp:268
static Scalar tripleTemperature()
Returns the temperature at water's triple point.
Definition: SimpleHuDuanH2O.hpp:122
static Evaluation gasDensity(const Evaluation &temperature, const Evaluation &pressure)
The density of steam at a given pressure and temperature.
Definition: SimpleHuDuanH2O.hpp:281
static Evaluation gasPressure(const Evaluation &temperature, const Evaluation &density)
The pressure of steam in at a given density and temperature.
Definition: SimpleHuDuanH2O.hpp:294
static Evaluation vaporPressure(const Evaluation &T)
The vapor pressure in of pure water at a given temperature.
Definition: SimpleHuDuanH2O.hpp:144
static Evaluation liquidHeatCapacity(const Evaluation &, const Evaluation &)
Specific isobaric heat capacity of the component [J/kg] as a liquid.
Definition: SimpleHuDuanH2O.hpp:206
static Evaluation liquidEnthalpy(const Evaluation &temperature, const Evaluation &)
Specific enthalpy of liquid water .
Definition: SimpleHuDuanH2O.hpp:198
static Evaluation liquidViscosity(const Evaluation &temperature, const Evaluation &pressure, bool extrapolate)
The dynamic viscosity of pure water.
Definition: SimpleHuDuanH2O.hpp:350
static Scalar criticalPressure()
Returns the critical pressure of water.
Definition: SimpleHuDuanH2O.hpp:116
static Evaluation liquidDensity(const Evaluation &temperature, const Evaluation &pressure, bool extrapolate)
The density of pure water at a given pressure and temperature .
Definition: SimpleHuDuanH2O.hpp:309
static Evaluation liquidPressure(const Evaluation &, const Evaluation &)
The pressure of water in at a given density and temperature.
Definition: SimpleHuDuanH2O.hpp:322
static bool gasIsIdeal()
Returns true iff the gas phase is assumed to be ideal.
Definition: SimpleHuDuanH2O.hpp:98
static const char * name()
A human readable name for the water.
Definition: SimpleHuDuanH2O.hpp:80
static Evaluation liquidThermalConductivity(const Evaluation &, const Evaluation &)
Specific heat conductivity of liquid water .
Definition: SimpleHuDuanH2O.hpp:255
static bool gasIsCompressible()
Returns true iff the gas phase is assumed to be compressible.
Definition: SimpleHuDuanH2O.hpp:86
static Scalar criticalTemperature()
Returns the critical temperature of water.
Definition: SimpleHuDuanH2O.hpp:110
static bool liquidIsCompressible()
Returns true iff the liquid phase is assumed to be compressible.
Definition: SimpleHuDuanH2O.hpp:92
static Evaluation liquidInternalEnergy(const Evaluation &temperature, const Evaluation &pressure)
Specific internal energy of liquid water .
Definition: SimpleHuDuanH2O.hpp:240
static Scalar molarMass()
The molar mass in of water.
Definition: SimpleHuDuanH2O.hpp:104
static Evaluation gasViscosity(const Evaluation &, const Evaluation &)
The dynamic viscosity of steam.
Definition: SimpleHuDuanH2O.hpp:335
static Evaluation gasEnthalpy(const Evaluation &temperature, const Evaluation &)
Specific enthalpy of water steam .
Definition: SimpleHuDuanH2O.hpp:178
static Evaluation gasInternalEnergy(const Evaluation &temperature, const Evaluation &pressure)
Specific internal energy of steam .
Definition: SimpleHuDuanH2O.hpp:224
static Evaluation gasHeatCapacity(const Evaluation &, const Evaluation &)
Specific isobaric heat capacity of the component [J/kg] as a gas.
Definition: SimpleHuDuanH2O.hpp:187
static Scalar triplePressure()
Returns the pressure at water's triple point.
Definition: SimpleHuDuanH2O.hpp:128