opm-common
Brine.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_BRINE_HPP
29 #define OPM_BRINE_HPP
30 
33 
34 #include <string_view>
35 
36 namespace Opm {
37 
46 template <class Scalar, class H2O>
47 class Brine : public Component<Scalar, Brine<Scalar, H2O> >
48 {
49 public:
51  static Scalar salinity;
52 
56  static std::string_view name()
57  { return "Brine"; }
58 
62  static bool gasIsIdeal()
63  { return H2O::gasIsIdeal(); }
64 
68  static bool gasIsCompressible()
69  { return H2O::gasIsCompressible(); }
70 
74  static bool liquidIsCompressible()
75  { return H2O::liquidIsCompressible(); }
76 
82  static Scalar molarMass()
83  {
84  const Scalar M1 = H2O::molarMass();
85  constexpr Scalar M2 = 58e-3; // molar mass of NaCl [kg/mol]
86  const Scalar X2 = salinity; // mass fraction of salt in brine
87  return M1*M2/(M2 + X2*(M1 - M2));
88  }
89 
93  static Scalar criticalTemperature()
94  { return H2O::criticalTemperature(); /* [K] */ }
95 
99  static Scalar criticalPressure()
100  { return H2O::criticalPressure(); /* [N/m^2] */ }
101 
105  static Scalar criticalVolume()
106  { return H2O::criticalVolume(); /* [m3/kmol] */ }
107 
111  static Scalar acentricFactor()
112  { return H2O::acentricFactor(); }
113 
117  static Scalar tripleTemperature()
118  { return H2O::tripleTemperature(); /* [K] */ }
119 
123  static Scalar triplePressure()
124  { return H2O::triplePressure(); /* [N/m^2] */ }
125 
138  template <class Evaluation>
139  static Evaluation vaporPressure(const Evaluation& T)
140  { return H2O::vaporPressure(T); /* [N/m^2] */ }
141 
145  template <class Evaluation>
146  static Evaluation gasEnthalpy(const Evaluation& temperature,
147  const Evaluation& pressure)
148  { return H2O::gasEnthalpy(temperature, pressure); /* [J/kg] */ }
149 
158  template <class Evaluation>
159  static Evaluation liquidEnthalpy(const Evaluation& temperature,
160  const Evaluation& pressure)
161  {
162  // Numerical coefficents from Palliser and McKibbin
163  static constexpr Scalar f[] = {
164  2.63500e-1, 7.48368e-6, 1.44611e-6, -3.80860e-10
165  };
166 
167  // Numerical coefficents from Michaelides for the enthalpy of brine
168  static constexpr Scalar a[4][3] = {
169  { -9633.6, -4080.0, +286.49 },
170  { +166.58, +68.577, -4.6856 },
171  { -0.90963, -0.36524, +0.249667e-1 },
172  { +0.17965e-2, +0.71924e-3, -0.4900e-4 }
173  };
174 
175  const Evaluation theta = temperature - 273.15;
176 
177  Evaluation S = salinity;
178  const Evaluation S_lSAT =
179  f[0]
180  + f[1]*theta
181  + f[2]*pow(theta, 2)
182  + f[3]*pow(theta, 3);
183 
184  // Regularization
185  if (S > S_lSAT)
186  S = S_lSAT;
187 
188  const Evaluation hw = H2O::liquidEnthalpy(temperature, pressure)/1e3; // [kJ/kg]
189 
190  // From Daubert and Danner
191  const Evaluation h_NaCl =
192  (3.6710e4*temperature
193  + (6.2770e1/2)*temperature*temperature
194  - (6.6670e-2/3)*temperature*temperature*temperature
195  + (2.8000e-5/4)*pow(temperature, 4.0))/58.44e3
196  - 2.045698e+02; // [kJ/kg]
197 
198  const Evaluation m = S/(1-S)/58.44e-3;
199 
200  Evaluation d_h = 0;
201  for (int i = 0; i<=3; ++i) {
202  for (int j = 0; j <= 2; ++j) {
203  d_h += a[i][j] * pow(theta, i) * pow(m, j);
204  }
205  }
206 
207  const Evaluation delta_h = 4.184/(1e3 + (58.44 * m))*d_h;
208 
209  // Enthalpy of brine
210  const Evaluation h_ls = (1-S)*hw + S*h_NaCl + S*delta_h; // [kJ/kg]
211  return h_ls*1e3; // convert to [J/kg]
212  }
213 
214 
218  template <class Evaluation>
219  static Evaluation liquidHeatCapacity(const Evaluation& temperature,
220  const Evaluation& pressure)
221  {
222  Scalar eps = scalarValue(temperature)*1e-8;
223  return (liquidEnthalpy(temperature + eps, pressure) - liquidEnthalpy(temperature, pressure))/eps;
224  }
225 
229  template <class Evaluation>
230  static Evaluation gasHeatCapacity(const Evaluation& temperature,
231  const Evaluation& pressure)
232  { return H2O::gasHeatCapacity(temperature, pressure); }
233 
237  template <class Evaluation>
238  static Evaluation gasInternalEnergy(const Evaluation& temperature,
239  const Evaluation& pressure)
240  {
241  return
242  gasEnthalpy(temperature, pressure) -
243  pressure/gasDensity(temperature, pressure);
244  }
245 
249  template <class Evaluation>
250  static Evaluation liquidInternalEnergy(const Evaluation& temperature,
251  const Evaluation& pressure)
252  {
253  return
254  liquidEnthalpy(temperature, pressure) -
255  pressure/liquidDensity(temperature, pressure);
256  }
257 
261  template <class Evaluation>
262  static Evaluation gasDensity(const Evaluation& temperature, const Evaluation& pressure)
263  { return H2O::gasDensity(temperature, pressure); }
264 
276  template <class Evaluation>
277  static Evaluation liquidDensity(const Evaluation& temperature,
278  const Evaluation& pressure, bool extrapolate = false)
279  {
280  const Evaluation rhow = H2O::liquidDensity(temperature, pressure, extrapolate);
281  return liquidDensity(temperature, pressure, rhow);
282  }
283 
296  template <class Evaluation>
297  static Evaluation liquidDensity(const Evaluation& temperature,
298  const Evaluation& pressure,
299  const Evaluation& rhow)
300  {
301  Evaluation tempC = temperature - 273.15;
302  Evaluation pMPa = pressure/1.0E6;
303  return
304  rhow +
305  1000*salinity*(
306  0.668 +
307  0.44*salinity +
308  1.0E-6*(
309  300*pMPa -
310  2400*pMPa*salinity +
311  tempC*(
312  80.0 +
313  3*tempC -
314  3300*salinity -
315  13*pMPa +
316  47*pMPa*salinity)));
317  }
318 
322  template <class Evaluation>
323  static Evaluation gasPressure(const Evaluation& temperature, const Evaluation& density)
324  { return H2O::gasPressure(temperature, density); }
325 
329  template <class Evaluation>
330  static Evaluation liquidPressure(const Evaluation& temperature, const Evaluation& density)
331  {
332  // We use the newton method for this. For the initial value we
333  // assume the pressure to be 10% higher than the vapor
334  // pressure
335  Evaluation pressure = 1.1*vaporPressure(temperature);
336  Scalar eps = scalarValue(pressure)*1e-7;
337 
338  Evaluation deltaP = pressure*2;
339  for (int i = 0;
340  i < 5
341  && std::abs(scalarValue(pressure)*1e-9) < std::abs(scalarValue(deltaP));
342  ++i)
343  {
344  const Evaluation f = liquidDensity(temperature, pressure) - density;
345 
346  Evaluation df_dp = liquidDensity(temperature, pressure + eps);
347  df_dp -= liquidDensity(temperature, pressure - eps);
348  df_dp /= 2*eps;
349 
350  deltaP = - f/df_dp;
351 
352  pressure += deltaP;
353  }
354 
355  return pressure;
356  }
357 
361  template <class Evaluation>
362  static Evaluation gasViscosity(const Evaluation& temperature, const Evaluation& pressure)
363  { return H2O::gasViscosity(temperature, pressure); }
364 
373  template <class Evaluation>
374  static Evaluation liquidViscosity(const Evaluation& temperature, const Evaluation& /*pressure*/)
375  {
376  Evaluation T_C = temperature - 273.15;
377  if(temperature <= 275.) // regularization
378  T_C = 275.0;
379 
380  Evaluation A = (0.42*std::pow((std::pow(salinity, 0.8)-0.17), 2) + 0.045)*pow(T_C, 0.8);
381  Evaluation mu_brine = 0.1 + 0.333*salinity + (1.65+91.9*salinity*salinity*salinity)*exp(-A);
382 
383  return mu_brine/1000.0; // convert to [Pa s] (todo: check if correct cP->Pa s is times 10...)
384  }
385 };
386 
390 template <class Scalar, class H2O>
391 Scalar Brine<Scalar, H2O>::salinity = 0.1; // also needs to be adapted in CO2 solubility table!
392 
393 } // namespace Opm
394 
395 #endif
static bool gasIsIdeal()
Returns true iff the gas phase is assumed to be ideal.
Definition: H2O.hpp:629
A traits class which provides basic mathematical functions for arbitrary scalar floating point values...
static const Scalar tripleTemperature()
Returns the temperature at water&#39;s triple point.
Definition: H2O.hpp:121
static Evaluation liquidHeatCapacity(const Evaluation &temperature, const Evaluation &pressure)
Specific isobaric heat capacity of liquid water .
Definition: Brine.hpp:219
Abstract base class of a pure chemical species.
Definition: Component.hpp:43
static Evaluation liquidInternalEnergy(const Evaluation &temperature, const Evaluation &pressure)
Specific internal energy of liquid water .
Definition: Brine.hpp:250
static Scalar molarMass()
The molar mass in of the component.
Definition: Brine.hpp:82
static bool liquidIsCompressible()
Returns true iff the liquid phase is assumed to be compressible.
Definition: H2O.hpp:548
static Evaluation gasViscosity(const Evaluation &temperature, const Evaluation &pressure)
The dynamic viscosity of steam.
Definition: H2O.hpp:793
static Evaluation gasInternalEnergy(const Evaluation &temperature, const Evaluation &pressure)
Specific internal energy of steam and water vapor .
Definition: Brine.hpp:238
static bool gasIsIdeal()
Returns true iff the gas phase is assumed to be ideal.
Definition: Brine.hpp:62
static const Scalar acentricFactor()
The acentric factor of water.
Definition: H2O.hpp:91
static bool gasIsCompressible()
Returns true iff the gas phase is assumed to be compressible.
Definition: H2O.hpp:542
static Scalar triplePressure()
Returns the pressure at water&#39;s triple point.
Definition: Brine.hpp:123
static Evaluation liquidDensity(const Evaluation &temperature, const Evaluation &pressure, bool extrapolate=false)
The density of the liquid component at a given pressure in and temperature in . ...
Definition: Brine.hpp:277
static Evaluation liquidDensity(const Evaluation &temperature, const Evaluation &pressure, const Evaluation &rhow)
The density of the liquid component at a given pressure in and temperature in . ...
Definition: Brine.hpp:297
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 Scalar tripleTemperature()
Returns the temperature at water&#39;s triple point.
Definition: Brine.hpp:117
static Evaluation liquidEnthalpy(const Evaluation &temperature, const Evaluation &pressure)
Specific enthalpy of liquid water .
Definition: H2O.hpp:239
A class for the brine fluid properties.
Definition: Brine.hpp:47
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:30
static bool liquidIsCompressible()
Returns true iff the liquid phase is assumed to be compressible.
Definition: Brine.hpp:74
static Scalar salinity
The mass fraction of salt assumed to be in the brine.
Definition: Brine.hpp:51
static Evaluation gasViscosity(const Evaluation &temperature, const Evaluation &pressure)
The dynamic viscosity of steam.
Definition: Brine.hpp:362
static Evaluation liquidPressure(const Evaluation &temperature, const Evaluation &density)
The pressure of liquid water in at a given density and temperature.
Definition: Brine.hpp:330
Abstract base class of a pure chemical species.
static std::string_view name()
A human readable name for the component.
Definition: Brine.hpp:56
static const Scalar criticalVolume()
Returns the critical volume of water.
Definition: H2O.hpp:109
static Evaluation gasHeatCapacity(const Evaluation &temperature, const Evaluation &pressure)
Specific isobaric heat capacity of water steam .
Definition: Brine.hpp:230
static const Scalar criticalTemperature()
Returns the critical temperature of water.
Definition: H2O.hpp:97
static Evaluation gasHeatCapacity(const Evaluation &temperature, const Evaluation &pressure)
Specific isobaric heat capacity of water steam .
Definition: H2O.hpp:281
static Evaluation vaporPressure(const Evaluation &T)
The vapor pressure in of pure water at a given temperature.
Definition: Brine.hpp:139
static Evaluation vaporPressure(Evaluation temperature)
The vapor pressure in of pure water at a given temperature.
Definition: H2O.hpp:143
static Evaluation gasEnthalpy(const Evaluation &temperature, const Evaluation &pressure)
Specific enthalpy of water steam .
Definition: H2O.hpp:188
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 Evaluation gasPressure(const Evaluation &temperature, const Evaluation &density)
The pressure of steam in at a given density and temperature.
Definition: Brine.hpp:323
static Evaluation gasEnthalpy(const Evaluation &temperature, const Evaluation &pressure)
Specific enthalpy of the pure component in gas.
Definition: Brine.hpp:146
static Scalar criticalPressure()
Returns the critical pressure of water.
Definition: Brine.hpp:99
static bool gasIsCompressible()
Returns true iff the gas phase is assumed to be compressible.
Definition: Brine.hpp:68
static Evaluation liquidEnthalpy(const Evaluation &temperature, const Evaluation &pressure)
Specific enthalpy of the pure component in liquid.
Definition: Brine.hpp:159
static Evaluation gasPressure(const Evaluation &temperature, Scalar density)
The pressure of steam in at a given density and temperature.
Definition: H2O.hpp:645
static const Scalar molarMass()
The molar mass in of water.
Definition: H2O.hpp:85
static Scalar acentricFactor()
Definition: Brine.hpp:111
static Scalar criticalVolume()
Returns the critical volume of water.
Definition: Brine.hpp:105
static const Scalar triplePressure()
Returns the pressure at water&#39;s triple point.
Definition: H2O.hpp:127
static const Scalar criticalPressure()
Returns the critical pressure of water.
Definition: H2O.hpp:103
static Evaluation gasDensity(const Evaluation &temperature, const Evaluation &pressure)
The density of steam in at a given pressure and temperature.
Definition: Brine.hpp:262
static Scalar criticalTemperature()
Returns the critical temperature of water.
Definition: Brine.hpp:93
static Evaluation liquidViscosity(const Evaluation &temperature, const Evaluation &)
The dynamic viscosity of pure water.
Definition: Brine.hpp:374