My Project
Loading...
Searching...
No Matches
BrineDynamic.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*/
28#ifndef OPM_BRINEDYNAMIC_HPP
29#define OPM_BRINEDYNAMIC_HPP
30
33#include <opm/common/utility/gpuDecorators.hpp>
34
35#include <string_view>
36
37namespace Opm {
38
47template <class Scalar, class H2O>
48class BrineDynamic : public Component<Scalar, BrineDynamic<Scalar, H2O> >
49{
50public:
51
55 static std::string_view name()
56 { return "Brine"; }
57
61 OPM_HOST_DEVICE static bool gasIsIdeal()
62 { return H2O::gasIsIdeal(); }
63
67 OPM_HOST_DEVICE static bool gasIsCompressible()
68 { return H2O::gasIsCompressible(); }
69
73 OPM_HOST_DEVICE static bool liquidIsCompressible()
74 { return H2O::liquidIsCompressible(); }
75
81 template <class Evaluation>
82 OPM_HOST_DEVICE static Evaluation molarMass(const Evaluation& salinity)
83 {
84 const Scalar M1 = H2O::molarMass();
85 const Evaluation X2 = salinity; // mass fraction of salt in brine
86 return M1*mM_salt()/(mM_salt() + X2*(M1 - mM_salt()));
87 }
88
92 OPM_HOST_DEVICE static Scalar criticalTemperature()
93 { return H2O::criticalTemperature(); /* [K] */ }
94
98 OPM_HOST_DEVICE static Scalar criticalPressure()
99 { return H2O::criticalPressure(); /* [N/m^2] */ }
100
104 OPM_HOST_DEVICE static Scalar criticalVolume()
105 { return H2O::criticalVolume(); /* [m3/kmol] */ }
106
110 OPM_HOST_DEVICE static Scalar acentricFactor()
111 { return H2O::acentricFactor(); }
112
116 OPM_HOST_DEVICE static Scalar tripleTemperature()
117 { return H2O::tripleTemperature(); /* [K] */ }
118
122 OPM_HOST_DEVICE static Scalar triplePressure()
123 { return H2O::triplePressure(); /* [N/m^2] */ }
124
128 template <class Evaluation>
129 OPM_HOST_DEVICE static Evaluation vaporPressure(const Evaluation& T)
130 { return H2O::vaporPressure(T); /* [N/m^2] */ }
131
135 template <class Evaluation>
136 OPM_HOST_DEVICE static Evaluation gasEnthalpy(const Evaluation& temperature,
137 const Evaluation& pressure)
138 { return H2O::gasEnthalpy(temperature, pressure); /* [J/kg] */ }
139
148 template <class Evaluation>
149 OPM_HOST_DEVICE static Evaluation liquidEnthalpy(const Evaluation& temperature,
150 const Evaluation& pressure,
151 const Evaluation& salinity)
152 {
153 // Numerical coefficents from Palliser and McKibbin
154 static constexpr Scalar f[] = {
155 2.63500e-1, 7.48368e-6, 1.44611e-6, -3.80860e-10
156 };
157
158 // Numerical coefficents from Michaelides for the enthalpy of brine
159 static constexpr Scalar a[4][3] = {
160 { -9633.6, -4080.0, +286.49 },
161 { +166.58, +68.577, -4.6856 },
162 { -0.90963, -0.36524, +0.249667e-1 },
163 { +0.17965e-2, +0.71924e-3, -0.4900e-4 }
164 };
165
166 const Evaluation theta = temperature - 273.15;
167
168 Evaluation S = salinity;
169 const Evaluation S_lSAT =
170 f[0]
171 + f[1]*theta
172 + f[2]*pow(theta, 2)
173 + f[3]*pow(theta, 3);
174
175 // Regularization
176 if (S > S_lSAT)
177 S = S_lSAT;
178
179 const Evaluation hw = H2O::liquidEnthalpy(temperature, pressure)/1e3; // [kJ/kg]
180
181 // From Daubert and Danner
182 const Evaluation h_NaCl =
183 (3.6710e4*temperature
184 + (6.2770e1/2)*temperature*temperature
185 - (6.6670e-2/3)*temperature*temperature*temperature
186 + (2.8000e-5/4)*pow(temperature, 4.0))/58.44e3
187 - 2.045698e+02; // [kJ/kg]
188
189 const Evaluation m = S/(1-S)/58.44e-3;
190
191 Evaluation d_h = 0;
192 for (int i = 0; i<=3; ++i) {
193 for (int j = 0; j <= 2; ++j) {
194 d_h += a[i][j] * pow(theta, i) * pow(m, j);
195 }
196 }
197
198 const Evaluation delta_h = 4.184/(1e3 + (58.44 * m))*d_h;
199
200 // Enthalpy of brine
201 const Evaluation h_ls = (1-S)*hw + S*h_NaCl + S*delta_h; // [kJ/kg]
202 return h_ls*1e3; // convert to [J/kg]
203 }
204
205
209 template <class Evaluation>
210 OPM_HOST_DEVICE static Evaluation liquidHeatCapacity(const Evaluation& temperature,
211 const Evaluation& pressure)
212 {
213 Scalar eps = scalarValue(temperature)*1e-8;
214 return (liquidEnthalpy(temperature + eps, pressure) - liquidEnthalpy(temperature, pressure))/eps;
215 }
216
220 template <class Evaluation>
221 OPM_HOST_DEVICE static Evaluation gasHeatCapacity(const Evaluation& temperature,
222 const Evaluation& pressure)
223 { return H2O::gasHeatCapacity(temperature, pressure); }
224
228 template <class Evaluation>
229 OPM_HOST_DEVICE static Evaluation gasInternalEnergy(const Evaluation& temperature,
230 const Evaluation& pressure)
231 {
232 return
233 gasEnthalpy(temperature, pressure) -
234 pressure/gasDensity(temperature, pressure);
235 }
236
240 template <class Evaluation>
241 OPM_HOST_DEVICE static Evaluation liquidInternalEnergy(const Evaluation& temperature,
242 const Evaluation& pressure)
243 {
244 return
245 liquidEnthalpy(temperature, pressure) -
246 pressure/liquidDensity(temperature, pressure);
247 }
248
252 template <class Evaluation>
253 OPM_HOST_DEVICE static Evaluation gasDensity(const Evaluation& temperature, const Evaluation& pressure)
254 { return H2O::gasDensity(temperature, pressure); }
255
263 template <class Evaluation>
264 OPM_HOST_DEVICE static Evaluation liquidDensity(const Evaluation& temperature, const Evaluation& pressure, const Evaluation& salinity, bool extrapolate = false)
265 {
266 Evaluation tempC = temperature - 273.15;
267 Evaluation pMPa = pressure/1.0E6;
268
269 const Evaluation rhow = H2O::liquidDensity(temperature, pressure, extrapolate);
270 return
271 rhow +
272 1000*salinity*(
273 0.668 +
274 0.44*salinity +
275 1.0E-6*(
276 300*pMPa -
277 2400*pMPa*salinity +
278 tempC*(
279 80.0 +
280 3*tempC -
281 3300*salinity -
282 13*pMPa +
283 47*pMPa*salinity)));
284 }
285
289 template <class Evaluation>
290 OPM_HOST_DEVICE static Evaluation gasPressure(const Evaluation& temperature, const Evaluation& density)
291 { return H2O::gasPressure(temperature, density); }
292
296 template <class Evaluation>
297 OPM_HOST_DEVICE static Evaluation liquidPressure(const Evaluation& temperature, const Evaluation& density)
298 {
299 // We use the newton method for this. For the initial value we
300 // assume the pressure to be 10% higher than the vapor
301 // pressure
302 Evaluation pressure = 1.1*vaporPressure(temperature);
303 Scalar eps = scalarValue(pressure)*1e-7;
304
305 Evaluation deltaP = pressure*2;
306 for (int i = 0;
307 i < 5
308 && std::abs(scalarValue(pressure)*1e-9) < std::abs(scalarValue(deltaP));
309 ++i)
310 {
311 const Evaluation f = liquidDensity(temperature, pressure) - density;
312
313 Evaluation df_dp = liquidDensity(temperature, pressure + eps);
314 df_dp -= liquidDensity(temperature, pressure - eps);
315 df_dp /= 2*eps;
316
317 deltaP = - f/df_dp;
318
319 pressure += deltaP;
320 }
321
322 return pressure;
323 }
324
328 template <class Evaluation>
329 OPM_HOST_DEVICE static Evaluation gasViscosity(const Evaluation& temperature, const Evaluation& pressure)
330 { return H2O::gasViscosity(temperature, pressure); }
331
340 template <class Evaluation>
341 OPM_HOST_DEVICE static Evaluation liquidViscosity(const Evaluation& temperature, const Evaluation& /*pressure*/, const Evaluation& salinity)
342 {
343 Evaluation T_C = temperature - 273.15;
344 if(temperature <= 275.) // regularization
345 T_C = 275.0;
346
347 Evaluation A = (0.42*Opm::pow((Opm::pow(salinity, 0.8)-0.17), 2) + 0.045)*pow(T_C, 0.8);
348 Evaluation mu_brine = 0.1 + 0.333*salinity + (1.65+91.9*salinity*salinity*salinity)*exp(-A);
349
350 return mu_brine/1000.0; // convert to [Pa s] (todo: check if correct cP->Pa s is times 10...)
351 }
352private:
353 //Molar mass salt (assumes pure NaCl) [kg/mol]
354 static constexpr Scalar mM_salt()
355 {
356 return 58.44e-3;
357 }
358
359};
360
361} // namespace Opm
362
363#endif
Abstract base class of a pure chemical species.
A traits class which provides basic mathematical functions for arbitrary scalar floating point values...
A class for the brine fluid properties.
Definition BrineDynamic.hpp:49
static OPM_HOST_DEVICE Scalar criticalTemperature()
Returns the critical temperature of water.
Definition BrineDynamic.hpp:92
static OPM_HOST_DEVICE Evaluation liquidViscosity(const Evaluation &temperature, const Evaluation &, const Evaluation &salinity)
The dynamic viscosity of pure water.
Definition BrineDynamic.hpp:341
static OPM_HOST_DEVICE bool liquidIsCompressible()
Returns true iff the liquid phase is assumed to be compressible.
Definition BrineDynamic.hpp:73
static OPM_HOST_DEVICE Evaluation vaporPressure(const Evaluation &T)
The vapor pressure in of pure water at a given temperature.
Definition BrineDynamic.hpp:129
static std::string_view name()
A human readable name for the component.
Definition BrineDynamic.hpp:55
static OPM_HOST_DEVICE Evaluation gasInternalEnergy(const Evaluation &temperature, const Evaluation &pressure)
Specific internal energy of steam and water vapor .
Definition BrineDynamic.hpp:229
static OPM_HOST_DEVICE Evaluation molarMass(const Evaluation &salinity)
The molar mass in of the component.
Definition BrineDynamic.hpp:82
static OPM_HOST_DEVICE Evaluation gasDensity(const Evaluation &temperature, const Evaluation &pressure)
The density of steam in at a given pressure and temperature.
Definition BrineDynamic.hpp:253
static OPM_HOST_DEVICE Evaluation liquidDensity(const Evaluation &temperature, const Evaluation &pressure, const Evaluation &salinity, bool extrapolate=false)
The density of the liquid component at a given pressure in and temperature in .
Definition BrineDynamic.hpp:264
static OPM_HOST_DEVICE Evaluation liquidPressure(const Evaluation &temperature, const Evaluation &density)
The pressure of liquid water in at a given density and temperature.
Definition BrineDynamic.hpp:297
static OPM_HOST_DEVICE Evaluation gasViscosity(const Evaluation &temperature, const Evaluation &pressure)
The dynamic viscosity of steam.
Definition BrineDynamic.hpp:329
static OPM_HOST_DEVICE Evaluation liquidInternalEnergy(const Evaluation &temperature, const Evaluation &pressure)
Specific internal energy of liquid water .
Definition BrineDynamic.hpp:241
static OPM_HOST_DEVICE bool gasIsCompressible()
Returns true iff the gas phase is assumed to be compressible.
Definition BrineDynamic.hpp:67
static OPM_HOST_DEVICE Evaluation gasEnthalpy(const Evaluation &temperature, const Evaluation &pressure)
Specific enthalpy of the pure component in gas.
Definition BrineDynamic.hpp:136
static OPM_HOST_DEVICE Scalar criticalPressure()
Returns the critical pressure of water.
Definition BrineDynamic.hpp:98
static OPM_HOST_DEVICE Evaluation liquidEnthalpy(const Evaluation &temperature, const Evaluation &pressure, const Evaluation &salinity)
Specific enthalpy of the pure component in liquid.
Definition BrineDynamic.hpp:149
static OPM_HOST_DEVICE Scalar criticalVolume()
Returns the critical volume of water.
Definition BrineDynamic.hpp:104
static OPM_HOST_DEVICE Evaluation liquidHeatCapacity(const Evaluation &temperature, const Evaluation &pressure)
Specific isobaric heat capacity of liquid water .
Definition BrineDynamic.hpp:210
static OPM_HOST_DEVICE Scalar acentricFactor()
Definition BrineDynamic.hpp:110
static OPM_HOST_DEVICE Evaluation gasPressure(const Evaluation &temperature, const Evaluation &density)
The pressure of steam in at a given density and temperature.
Definition BrineDynamic.hpp:290
static OPM_HOST_DEVICE Scalar tripleTemperature()
Returns the temperature at water's triple point.
Definition BrineDynamic.hpp:116
static OPM_HOST_DEVICE Evaluation gasHeatCapacity(const Evaluation &temperature, const Evaluation &pressure)
Specific isobaric heat capacity of water steam .
Definition BrineDynamic.hpp:221
static OPM_HOST_DEVICE bool gasIsIdeal()
Returns true iff the gas phase is assumed to be ideal.
Definition BrineDynamic.hpp:61
static OPM_HOST_DEVICE Scalar triplePressure()
Returns the pressure at water's triple point.
Definition BrineDynamic.hpp:122
Abstract base class of a pure chemical species.
Definition Component.hpp:44
static Evaluation liquidDensity(const Evaluation &temperature, const Evaluation &pressure, bool extrapolate=false)
The density of pure water in at a given pressure and temperature.
Definition H2O.hpp:689
static const Scalar criticalTemperature()
Returns the critical temperature of water.
Definition H2O.hpp:97
static Evaluation gasDensity(const Evaluation &temperature, const Evaluation &pressure)
The density of steam in at a given pressure and temperature.
Definition H2O.hpp:564
static bool gasIsCompressible()
Returns true iff the gas phase is assumed to be compressible.
Definition H2O.hpp:542
static Evaluation gasPressure(const Evaluation &temperature, Scalar density)
The pressure of steam in at a given density and temperature.
Definition H2O.hpp:645
static Evaluation vaporPressure(Evaluation temperature)
The vapor pressure in of pure water at a given temperature.
Definition H2O.hpp:143
static Evaluation gasViscosity(const Evaluation &temperature, const Evaluation &pressure)
The dynamic viscosity of steam.
Definition H2O.hpp:792
static Evaluation gasHeatCapacity(const Evaluation &temperature, const Evaluation &pressure)
Specific isobaric heat capacity of water steam .
Definition H2O.hpp:281
static Evaluation liquidEnthalpy(const Evaluation &temperature, const Evaluation &pressure)
Specific enthalpy of liquid water .
Definition H2O.hpp:239
static const Scalar acentricFactor()
The acentric factor of water.
Definition H2O.hpp:91
static bool gasIsIdeal()
Returns true iff the gas phase is assumed to be ideal.
Definition H2O.hpp:629
static const Scalar criticalPressure()
Returns the critical pressure of water.
Definition H2O.hpp:103
static const Scalar molarMass()
The molar mass in of water.
Definition H2O.hpp:85
static bool liquidIsCompressible()
Returns true iff the liquid phase is assumed to be compressible.
Definition H2O.hpp:548
static Evaluation gasEnthalpy(const Evaluation &temperature, const Evaluation &pressure)
Specific enthalpy of water steam .
Definition H2O.hpp:188
static const Scalar tripleTemperature()
Returns the temperature at water's triple point.
Definition H2O.hpp:121
static const Scalar triplePressure()
Returns the pressure at water's triple point.
Definition H2O.hpp:127
static const Scalar criticalVolume()
Returns the critical volume of water.
Definition H2O.hpp:109
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30