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
34#include <opm/common/OpmLog/OpmLog.hpp>
35
38
39#include <cmath>
40
41namespace Opm {
42
61template <class Scalar>
62class SimpleHuDuanH2O : public Component<Scalar, SimpleHuDuanH2O<Scalar>>
63{
66
67 static constexpr Scalar R = Constants<Scalar>::R / 18e-3; // specific gas constant of water
68
69public:
73 static const char* name()
74 { return "H2O"; }
75
79 static bool gasIsCompressible()
80 { return true; }
81
86 { return false; }
87
91 static bool gasIsIdeal()
92 { return true; }
93
97 static Scalar molarMass()
98 { return 18e-3; }
99
103 static Scalar criticalTemperature()
104 { return 647.096; /* [K] */ }
105
109 static Scalar criticalPressure()
110 { return 22.064e6; /* [N/m^2] */ }
111
115 static Scalar tripleTemperature()
116 { return 273.16; /* [K] */ }
117
121 static Scalar triplePressure()
122 { return 611.657; /* [N/m^2] */ }
123
136 template <class Evaluation>
137 static Evaluation vaporPressure(const Evaluation& T)
138 {
139 if (T > criticalTemperature())
140 return criticalPressure();
141 if (T < tripleTemperature())
142 return 0; // water is solid: We don't take sublimation into account
143
144 static constexpr Scalar n[10] = {
145 0.11670521452767e4, -0.72421316703206e6, -0.17073846940092e2,
146 0.12020824702470e5, -0.32325550322333e7, 0.14915108613530e2,
147 -0.48232657361591e4, 0.40511340542057e6, -0.23855557567849,
148 0.65017534844798e3
149 };
150
151 Evaluation sigma = T + n[8]/(T - n[9]);
152
153 Evaluation A = (sigma + n[0])*sigma + n[1];
154 Evaluation B = (n[2]*sigma + n[3])*sigma + n[4];
155 Evaluation C = (n[5]*sigma + n[6])*sigma + n[7];
156
157 Evaluation tmp = 2.0*C/(sqrt(B*B - 4.0*A*C) - B);
158 tmp *= tmp;
159 tmp *= tmp;
160
161 return 1e6*tmp;
162 }
163
170 template <class Evaluation>
171 static Evaluation gasEnthalpy(const Evaluation& temperature,
172 const Evaluation& /*pressure*/)
173 { return 1.976e3*temperature + 40.65e3/molarMass(); }
174
175
179 template <class Evaluation>
180 static Evaluation gasHeatCapacity(const Evaluation&,
181 const Evaluation&)
182 { return 1.976e3; }
183
190 template <class Evaluation>
191 static Evaluation liquidEnthalpy(const Evaluation& temperature,
192 const Evaluation& /*pressure*/)
193 { return 4180*temperature; }
194
198 template <class Evaluation>
199 static Evaluation liquidHeatCapacity(const Evaluation&,
200 const Evaluation&)
201 { return 4.184e3; }
202
216 template <class Evaluation>
217 static Evaluation gasInternalEnergy(const Evaluation& temperature,
218 const Evaluation& pressure)
219 {
220 return
221 gasEnthalpy(temperature, pressure) -
222 1/molarMass()* // conversion from [J/(mol K)] to [J/(kg K)]
223 IdealGas::R*temperature; // = pressure *spec. volume for an ideal gas
224 }
225
232 template <class Evaluation>
233 static Evaluation liquidInternalEnergy(const Evaluation& temperature,
234 const Evaluation& pressure)
235 {
236 return
237 liquidEnthalpy(temperature, pressure) -
238 pressure/liquidDensity(temperature, pressure);
239 }
240
247 template <class Evaluation>
248 static Evaluation liquidThermalConductivity(const Evaluation& /*temperature*/,
249 const Evaluation& /*pressure*/)
250 {
251 return 0.578078; // conductivity of liquid water [W / (m K ) ] IAPWS evaluated at p=.1 MPa, T=8°C
252 }
253
260 template <class Evaluation>
261 static Evaluation gasThermalConductivity(const Evaluation& /*temperature*/,
262 const Evaluation& /*pressure*/)
263 {
264 return 0.028224; // conductivity of steam [W / (m K ) ] IAPWS evaluated at p=.1 MPa, T=8°C
265 }
266
273 template <class Evaluation>
274 static Evaluation gasDensity(const Evaluation& temperature, const Evaluation& pressure)
275 {
276 // Assume an ideal gas
277 return molarMass()*IdealGas::molarDensity(temperature, pressure);
278 }
279
286 template <class Evaluation>
287 static Evaluation gasPressure(const Evaluation& temperature, const Evaluation& density)
288 {
289 // Assume an ideal gas
290 return IdealGas::pressure(temperature, density/molarMass());
291 }
292
301 template <class Evaluation>
302 static Evaluation liquidDensity(const Evaluation& temperature, const Evaluation& pressure,
303 bool extrapolate)
304 {
305 return liquidDensity_(temperature, pressure, extrapolate);
306 }
307
314 template <class Evaluation>
315 static Evaluation liquidPressure(const Evaluation& /*temperature*/, const Evaluation& /*density*/)
316 {
317 throw std::logic_error("The liquid pressure is undefined for incompressible fluids");
318 }
319
327 template <class Evaluation>
328 static Evaluation gasViscosity(const Evaluation& /*temperature*/,
329 const Evaluation& /*pressure*/)
330 {
331 return 1e-05;
332 }
333
342 template <class Evaluation>
343 static Evaluation liquidViscosity(const Evaluation& temperature, const Evaluation& pressure,
344 bool extrapolate)
345 {
346 if (temperature > 570) {
347 const std::string msg =
348 "Viscosity of water based on Hu et al is too "
349 "different from IAPWS for T above 570K and (T = " +
350 std::to_string(getValue(temperature)) + ")";
351 if (extrapolate)
352 {
353 OpmLog::warning(msg);
354 }
355 else
356 throw NumericalProblem(msg);
357 }
358
359 const Evaluation rho = liquidDensity(temperature, pressure, extrapolate);
360 return Common::viscosity(temperature, rho);
361 }
362
363private:
364
373 template <class Evaluation>
374 static Evaluation liquidDensity_(const Evaluation& T, const Evaluation& pressure, bool extrapolate) {
375 // Hu, Duan, Zhu and Chou: PVTx properties of the CO2-H2O and CO2-H2O-NaCl
376 // systems below 647 K: Assessment of experimental data and
377 // thermodynamics models, Chemical Geology, 2007.
378 if (T > 647 || pressure > 100e6) {
379 const std::string msg =
380 "Density of water is only implemented for temperatures "
381 "below 647K and pressures below 100MPa. (T = " +
382 std::to_string(getValue(T)) + ", p=" +
383 std::to_string(getValue(pressure)) + ")";
384 if (extrapolate)
385 {
386 OpmLog::warning(msg);
387 }
388 else
389 throw NumericalProblem(msg);
390 }
391
392 Evaluation p = pressure / 1e6; // to MPa
393 Scalar Mw = molarMass() * 1e3; //kg/kmol
394
395 static constexpr Scalar k0[5] = { 3.27225e-07, -4.20950e-04, 2.32594e-01, -4.16920e+01, 5.71292e+03 };
396 static constexpr Scalar k1[5] = { -2.32306e-10, 2.91138e-07, -1.49662e-04, 3.59860e-02, -3.55071 };
397 static constexpr Scalar k2[3] = { 2.57241e-14, -1.24336e-11, 5.42707e-07 };
398 static constexpr Scalar k3[3] = { -4.42028e-18, 2.10007e-15, -8.11491e-11 };
399 Evaluation k0_eval = 1e-3 * (((k0[0]*T + k0[1])*T + k0[2])*T + k0[3] + k0[4]/T);
400 Evaluation k1_eval = 1e-2 * (((k1[0]*T + k1[1])*T + k1[2])*T + k1[3] + k1[4]/T);
401 Evaluation k2_eval = 1e-1 * ((k2[0]*T + k2[1])*T*T + k2[2]);
402 Evaluation k3_eval = (k3[0]*T + k3[1])*T*T + k3[2];
403
404 // molar volum (m³/kmol):
405 Evaluation vw = ((k3_eval*p + k2_eval)*p + k1_eval)*p + k0_eval;
406
407 // density kg/m3
408 return Mw / vw;
409
410 }
411
412};
413
414} // namespace Opm
415
416#endif
Provides the OPM specific exception classes.
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:40
A simple version of pure water with density from Hu et al.
Definition: SimpleHuDuanH2O.hpp:63
static Evaluation gasThermalConductivity(const Evaluation &, const Evaluation &)
Specific heat conductivity of steam .
Definition: SimpleHuDuanH2O.hpp:261
static Scalar tripleTemperature()
Returns the temperature at water's triple point.
Definition: SimpleHuDuanH2O.hpp:115
static Evaluation gasDensity(const Evaluation &temperature, const Evaluation &pressure)
The density of steam at a given pressure and temperature.
Definition: SimpleHuDuanH2O.hpp:274
static Evaluation gasPressure(const Evaluation &temperature, const Evaluation &density)
The pressure of steam in at a given density and temperature.
Definition: SimpleHuDuanH2O.hpp:287
static Evaluation vaporPressure(const Evaluation &T)
The vapor pressure in of pure water at a given temperature.
Definition: SimpleHuDuanH2O.hpp:137
static Evaluation liquidHeatCapacity(const Evaluation &, const Evaluation &)
Specific isobaric heat capacity of the component [J/kg] as a liquid.
Definition: SimpleHuDuanH2O.hpp:199
static Evaluation liquidEnthalpy(const Evaluation &temperature, const Evaluation &)
Specific enthalpy of liquid water .
Definition: SimpleHuDuanH2O.hpp:191
static Evaluation liquidViscosity(const Evaluation &temperature, const Evaluation &pressure, bool extrapolate)
The dynamic viscosity of pure water.
Definition: SimpleHuDuanH2O.hpp:343
static Scalar criticalPressure()
Returns the critical pressure of water.
Definition: SimpleHuDuanH2O.hpp:109
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:302
static Evaluation liquidPressure(const Evaluation &, const Evaluation &)
The pressure of water in at a given density and temperature.
Definition: SimpleHuDuanH2O.hpp:315
static bool gasIsIdeal()
Returns true iff the gas phase is assumed to be ideal.
Definition: SimpleHuDuanH2O.hpp:91
static Evaluation liquidThermalConductivity(const Evaluation &, const Evaluation &)
Specific heat conductivity of liquid water .
Definition: SimpleHuDuanH2O.hpp:248
static bool gasIsCompressible()
Returns true iff the gas phase is assumed to be compressible.
Definition: SimpleHuDuanH2O.hpp:79
static Scalar criticalTemperature()
Returns the critical temperature of water.
Definition: SimpleHuDuanH2O.hpp:103
static bool liquidIsCompressible()
Returns true iff the liquid phase is assumed to be compressible.
Definition: SimpleHuDuanH2O.hpp:85
static Evaluation liquidInternalEnergy(const Evaluation &temperature, const Evaluation &pressure)
Specific internal energy of liquid water .
Definition: SimpleHuDuanH2O.hpp:233
static Scalar molarMass()
The molar mass in of water.
Definition: SimpleHuDuanH2O.hpp:97
static Evaluation gasViscosity(const Evaluation &, const Evaluation &)
The dynamic viscosity of steam.
Definition: SimpleHuDuanH2O.hpp:328
static Evaluation gasEnthalpy(const Evaluation &temperature, const Evaluation &)
Specific enthalpy of water steam .
Definition: SimpleHuDuanH2O.hpp:171
static Evaluation gasInternalEnergy(const Evaluation &temperature, const Evaluation &pressure)
Specific internal energy of steam .
Definition: SimpleHuDuanH2O.hpp:217
static Evaluation gasHeatCapacity(const Evaluation &, const Evaluation &)
Specific isobaric heat capacity of the component [J/kg] as a gas.
Definition: SimpleHuDuanH2O.hpp:180
static const char * name()
A human readable name for the water.
Definition: SimpleHuDuanH2O.hpp:73
static Scalar triplePressure()
Returns the pressure at water's triple point.
Definition: SimpleHuDuanH2O.hpp:121
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:30