opm-common
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
137 template <class Evaluation>
138 OPM_HOST_DEVICE static Evaluation vaporPressure(const Evaluation& T)
139 { return H2O::vaporPressure(T); /* [N/m^2] */ }
140
144 template <class Evaluation>
145 OPM_HOST_DEVICE static Evaluation gasEnthalpy(const Evaluation& temperature,
146 const Evaluation& pressure)
147 { return H2O::gasEnthalpy(temperature, pressure); /* [J/kg] */ }
148
162 template <class Evaluation>
163 OPM_HOST_DEVICE static Evaluation liquidEnthalpy(const Evaluation& temperature,
164 const Evaluation& pressure,
165 const Evaluation& salinity)
166 {
167 // Numerical coefficents from Palliser and McKibbin
168 static constexpr Scalar f[] = {
169 2.63500e-1, 7.48368e-6, 1.44611e-6, -3.80860e-10
170 };
171
172 // Numerical coefficents from Michaelides for the enthalpy of brine
173 static constexpr Scalar a[4][3] = {
174 { -9633.6, -4080.0, +286.49 },
175 { +166.58, +68.577, -4.6856 },
176 { -0.90963, -0.36524, +0.249667e-1 },
177 { +0.17965e-2, +0.71924e-3, -0.4900e-4 }
178 };
179
180 const Evaluation theta = temperature - 273.15;
181
182 Evaluation S = salinity;
183 const Evaluation S_lSAT =
184 f[0]
185 + f[1]*theta
186 + f[2]*pow(theta, 2)
187 + f[3]*pow(theta, 3);
188
189 // Regularization
190 if (S > S_lSAT)
191 S = S_lSAT;
192
193 const Evaluation hw = H2O::liquidEnthalpy(temperature, pressure)/1e3; // [kJ/kg]
194
195 // From Daubert and Danner
196 const Evaluation h_NaCl =
197 (3.6710e4*temperature
198 + (6.2770e1/2)*temperature*temperature
199 - (6.6670e-2/3)*temperature*temperature*temperature
200 + (2.8000e-5/4)*pow(temperature, 4.0))/58.44e3
201 - 2.045698e+02; // [kJ/kg]
202
203 const Evaluation m = S/(1-S)/58.44e-3;
204
205 Evaluation d_h = 0;
206 for (int i = 0; i<=3; ++i) {
207 for (int j = 0; j <= 2; ++j) {
208 d_h += a[i][j] * pow(theta, i) * pow(m, j);
209 }
210 }
211
212 const Evaluation delta_h = 4.184/(1e3 + (58.44 * m))*d_h;
213
214 // Enthalpy of brine
215 const Evaluation h_ls = (1-S)*hw + S*h_NaCl + S*delta_h; // [kJ/kg]
216 return h_ls*1e3; // convert to [J/kg]
217 }
218
219
223 template <class Evaluation>
224 OPM_HOST_DEVICE static Evaluation liquidHeatCapacity(const Evaluation& temperature,
225 const Evaluation& pressure)
226 {
227 Scalar eps = scalarValue(temperature)*1e-8;
228 return (liquidEnthalpy(temperature + eps, pressure) - liquidEnthalpy(temperature, pressure))/eps;
229 }
230
234 template <class Evaluation>
235 OPM_HOST_DEVICE static Evaluation gasHeatCapacity(const Evaluation& temperature,
236 const Evaluation& pressure)
237 { return H2O::gasHeatCapacity(temperature, pressure); }
238
242 template <class Evaluation>
243 OPM_HOST_DEVICE static Evaluation gasInternalEnergy(const Evaluation& temperature,
244 const Evaluation& pressure)
245 {
246 return
247 gasEnthalpy(temperature, pressure) -
248 pressure/gasDensity(temperature, pressure);
249 }
250
254 template <class Evaluation>
255 OPM_HOST_DEVICE static Evaluation liquidInternalEnergy(const Evaluation& temperature,
256 const Evaluation& pressure)
257 {
258 return
259 liquidEnthalpy(temperature, pressure) -
260 pressure/liquidDensity(temperature, pressure);
261 }
262
266 template <class Evaluation>
267 OPM_HOST_DEVICE static Evaluation gasDensity(const Evaluation& temperature, const Evaluation& pressure)
268 { return H2O::gasDensity(temperature, pressure); }
269
282 template <class Evaluation>
283 OPM_HOST_DEVICE static Evaluation liquidDensity(const Evaluation& temperature, const Evaluation& pressure,
284 const Evaluation& salinity, bool extrapolate = false)
285 {
286 const Evaluation rhow = H2O::liquidDensity(temperature, pressure, extrapolate);
287 return liquidDensity(temperature, pressure, salinity, rhow);
288 }
289
303 template <class Evaluation>
304 OPM_HOST_DEVICE static Evaluation liquidDensity(const Evaluation& temperature,
305 const Evaluation& pressure,
306 const Evaluation& salinity,
307 const Evaluation& rhow)
308 {
309 Evaluation tempC = temperature - 273.15;
310 Evaluation pMPa = pressure/1.0E6;
311 return
312 rhow +
313 1000*salinity*(
314 0.668 +
315 0.44*salinity +
316 1.0E-6*(
317 300*pMPa -
318 2400*pMPa*salinity +
319 tempC*(
320 80.0 +
321 3*tempC -
322 3300*salinity -
323 13*pMPa +
324 47*pMPa*salinity)));
325 }
326
330 template <class Evaluation>
331 OPM_HOST_DEVICE static Evaluation gasPressure(const Evaluation& temperature, const Evaluation& density)
332 { return H2O::gasPressure(temperature, density); }
333
337 template <class Evaluation>
338 OPM_HOST_DEVICE static Evaluation liquidPressure(const Evaluation& temperature, const Evaluation& density)
339 {
340 // We use the newton method for this. For the initial value we
341 // assume the pressure to be 10% higher than the vapor
342 // pressure
343 Evaluation pressure = 1.1*vaporPressure(temperature);
344 Scalar eps = scalarValue(pressure)*1e-7;
345
346 Evaluation deltaP = pressure*2;
347 for (int i = 0;
348 i < 5
349 && std::abs(scalarValue(pressure)*1e-9) < std::abs(scalarValue(deltaP));
350 ++i)
351 {
352 const Evaluation f = liquidDensity(temperature, pressure) - density;
353
354 Evaluation df_dp = liquidDensity(temperature, pressure + eps);
355 df_dp -= liquidDensity(temperature, pressure - eps);
356 df_dp /= 2*eps;
357
358 deltaP = - f/df_dp;
359
360 pressure += deltaP;
361 }
362
363 return pressure;
364 }
365
369 template <class Evaluation>
370 OPM_HOST_DEVICE static Evaluation gasViscosity(const Evaluation& temperature, const Evaluation& pressure)
371 { return H2O::gasViscosity(temperature, pressure); }
372
384 template <class Evaluation>
385 OPM_HOST_DEVICE static Evaluation liquidViscosity(const Evaluation& temperature,
386 const Evaluation& /*pressure*/,
387 const Evaluation& salinity)
388 {
389 Evaluation T_C = temperature - 273.15;
390 if(temperature <= 275.) // regularization
391 T_C = 275.0;
392
393 Evaluation A = (0.42*Opm::pow((Opm::pow(salinity, 0.8)-0.17), 2) + 0.045)*pow(T_C, 0.8);
394 Evaluation mu_brine = 0.1 + 0.333*salinity + (1.65+91.9*salinity*salinity*salinity)*exp(-A);
395
396 return mu_brine/1000.0; // convert to [Pa s] (todo: check if correct cP->Pa s is times 10...)
397 }
398
399private:
400 //Molar mass salt (assumes pure NaCl) [kg/mol]
401 static constexpr Scalar mM_salt()
402 {
403 return 58.44e-3;
404 }
405
406};
407
408} // namespace Opm
409
410#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 liquid viscosity of the pure component.
Definition BrineDynamic.hpp:385
static OPM_HOST_DEVICE Evaluation liquidDensity(const Evaluation &temperature, const Evaluation &pressure, const Evaluation &salinity, const Evaluation &rhow)
The density of the liquid component at a given pressure in and temperature in .
Definition BrineDynamic.hpp:304
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:138
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:243
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:267
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:283
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:338
static OPM_HOST_DEVICE Evaluation gasViscosity(const Evaluation &temperature, const Evaluation &pressure)
The dynamic viscosity of steam.
Definition BrineDynamic.hpp:370
static OPM_HOST_DEVICE Evaluation liquidInternalEnergy(const Evaluation &temperature, const Evaluation &pressure)
Specific internal energy of liquid water .
Definition BrineDynamic.hpp:255
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:145
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:163
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:224
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:331
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:235
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:690
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:793
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
Scalar Brine< Scalar, H2O >::salinity
Default value for the salinity of the brine (dimensionless).
Definition Brine.hpp:391