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  Copyright (C) 2009-2013 by Andreas Lauser
5 
6  This file is part of the Open Porous Media project (OPM).
7 
8  OPM is free software: you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation, either version 2 of the License, or
11  (at your option) any later version.
12 
13  OPM is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with OPM. If not, see <http://www.gnu.org/licenses/>.
20 */
26 #ifndef OPM_BRINE_HPP
27 #define OPM_BRINE_HPP
28 
31 
32 namespace Opm {
33 
42 template <class Scalar, class H2O>
43 class Brine : public Component<Scalar, Brine<Scalar, H2O> >
44 {
45 public:
47  static Scalar salinity;
48 
52  static const char *name()
53  { return "Brine"; }
54 
58  static bool gasIsIdeal()
59  { return H2O::gasIsIdeal(); }
60 
64  static bool gasIsCompressible()
65  { return H2O::gasIsCompressible(); }
66 
70  static bool liquidIsCompressible()
71  { return H2O::liquidIsCompressible(); }
72 
78  static Scalar molarMass()
79  {
80  const Scalar M1 = H2O::molarMass();
81  const Scalar M2 = 58e-3; // molar mass of NaCl [kg/mol]
82  const Scalar X2 = salinity; // mass fraction of salt in brine
83  return M1*M2/(M2 + X2*(M1 - M2));
84  }
85 
90  { return H2O::criticalTemperature(); /* [K] */ }
91 
96  { return H2O::criticalPressure(); /* [N/m^2] */ }
97 
102  { return H2O::tripleTemperature(); /* [K] */ }
103 
108  { return H2O::triplePressure(); /* [N/m^2] */ }
109 
113  template <class Evaluation>
114  static Evaluation vaporPressure(const Evaluation& T)
115  { return H2O::vaporPressure(T); /* [N/m^2] */ }
116 
120  template <class Evaluation>
121  static Evaluation gasEnthalpy(const Evaluation& temperature,
122  const Evaluation& pressure)
123  { return H2O::gasEnthalpy(temperature, pressure); /* [J/kg] */ }
124 
133  template <class Evaluation>
134  static Evaluation liquidEnthalpy(const Evaluation& temperature,
135  const Evaluation& pressure)
136  {
137  typedef MathToolbox<Evaluation> Toolbox;
138 
139  // Numerical coefficents from Palliser and McKibbin
140  static const Scalar f[] = {
141  2.63500e-1, 7.48368e-6, 1.44611e-6, -3.80860e-10
142  };
143 
144  // Numerical coefficents from Michaelides for the enthalpy of brine
145  static const Scalar a[4][3] = {
146  { -9633.6, -4080.0, +286.49 },
147  { +166.58, +68.577, -4.6856 },
148  { -0.90963, -0.36524, +0.249667e-1 },
149  { +0.17965e-2, +0.71924e-3, -0.4900e-4 }
150  };
151 
152  Evaluation theta = temperature - 273.15;
153 
154  Scalar S = salinity;
155  Scalar S_lSAT =
156  f[0]
157  + f[1]*Toolbox::value(theta)
158  + f[2]*std::pow(Toolbox::value(theta), 2)
159  + f[3]*std::pow(Toolbox::value(theta), 3);
160 
161  // Regularization
162  if (S > S_lSAT)
163  S = S_lSAT;
164 
165  Evaluation hw = H2O::liquidEnthalpy(temperature, pressure)/1e3; // [kJ/kg]
166 
167  // From Daubert and Danner
168  Evaluation h_NaCl =
169  (3.6710e4*temperature
170  + (6.2770e1/2)*temperature*temperature
171  - (6.6670e-2/3)*temperature*temperature*temperature
172  + (2.8000e-5/4)*std::pow(temperature,4))/58.44e3
173  - 2.045698e+02; // [kJ/kg]
174 
175  Scalar m = S/(1-S)/58.44e-3;
176 
177  Evaluation d_h = 0;
178  for (int i = 0; i<=3; ++i) {
179  for (int j = 0; j <= 2; ++j) {
180  d_h += a[i][j] * std::pow(theta, i) * std::pow(m, j);
181  }
182  }
183 
184  Evaluation delta_h = 4.184/(1e3 + (58.44 * m))*d_h;
185 
186  // Enthalpy of brine
187  Evaluation h_ls = (1-S)*hw + S*h_NaCl + S*delta_h; // [kJ/kg]
188  return h_ls*1e3; // convert to [J/kg]
189  }
190 
191 
195  template <class Evaluation>
196  static Evaluation liquidHeatCapacity(const Evaluation& temperature,
197  const Evaluation& pressure)
198  {
199  Scalar eps = temperature*1e-8;
200  return (liquidEnthalpy(temperature + eps, pressure) - liquidEnthalpy(temperature, pressure))/eps;
201  }
202 
206  template <class Evaluation>
207  static Evaluation gasHeatCapacity(const Evaluation& temperature,
208  const Evaluation& pressure)
209  { return H2O::gasHeatCapacity(temperature, pressure); }
210 
214  template <class Evaluation>
215  static Evaluation gasInternalEnergy(const Evaluation& temperature,
216  const Evaluation& pressure)
217  {
218  return
219  gasEnthalpy(temperature, pressure) -
220  pressure/gasDensity(temperature, pressure);
221  }
222 
226  template <class Evaluation>
227  static Evaluation liquidInternalEnergy(const Evaluation& temperature,
228  const Evaluation& pressure)
229  {
230  return
231  liquidEnthalpy(temperature, pressure) -
232  pressure/liquidDensity(temperature, pressure);
233  }
234 
238  template <class Evaluation>
239  static Evaluation gasDensity(const Evaluation& temperature, const Evaluation& pressure)
240  { return H2O::gasDensity(temperature, pressure); }
241 
249  template <class Evaluation>
250  static Evaluation liquidDensity(const Evaluation& temperature, const Evaluation& pressure)
251  {
252  Evaluation tempC = temperature - 273.15;
253  Evaluation pMPa = pressure/1.0E6;
254 
255  const Evaluation rhow = H2O::liquidDensity(temperature, pressure);
256  return
257  rhow +
258  1000*salinity*(
259  0.668 +
260  0.44*salinity +
261  1.0E-6*(
262  300*pMPa -
263  2400*pMPa*salinity +
264  tempC*(
265  80.0 -
266  3*tempC -
267  3300*salinity -
268  13*pMPa +
269  47*pMPa*salinity)));
270  }
271 
275  template <class Evaluation>
276  static Evaluation gasPressure(const Evaluation& temperature, const Evaluation& density)
277  { return H2O::gasPressure(temperature, density); }
278 
282  template <class Evaluation>
283  static Evaluation liquidPressure(const Evaluation& temperature, const Evaluation& density)
284  {
285  typedef MathToolbox<Evaluation> Toolbox;
286 
287  // We use the newton method for this. For the initial value we
288  // assume the pressure to be 10% higher than the vapor
289  // pressure
290  Evaluation pressure = 1.1*vaporPressure(temperature);
291  Scalar eps = Toolbox::value(pressure)*1e-7;
292 
293  Evaluation deltaP = pressure*2;
294  for (int i = 0;
295  i < 5
296  && std::abs(Toolbox::value(pressure)*1e-9) < std::abs(Toolbox::value(deltaP));
297  ++i)
298  {
299  const Evaluation& f = liquidDensity(temperature, pressure) - density;
300 
301  Evaluation df_dp = liquidDensity(temperature, pressure + eps);
302  df_dp -= liquidDensity(temperature, pressure - eps);
303  df_dp /= 2*eps;
304 
305  deltaP = - f/df_dp;
306 
307  pressure += deltaP;
308  }
309 
310  return pressure;
311  }
312 
316  template <class Evaluation>
317  static Evaluation gasViscosity(const Evaluation& temperature, const Evaluation& pressure)
318  { return H2O::gasViscosity(temperature, pressure); }
319 
328  template <class Evaluation>
329  static Evaluation liquidViscosity(const Evaluation& temperature, const Evaluation& /*pressure*/)
330  {
331  typedef MathToolbox<Evaluation> Toolbox;
332 
333  Evaluation T_C = temperature - 273.15;
334  if(temperature <= 275.) // regularization
335  T_C = Toolbox::createConstant(275.0);
336 
337  Evaluation A = (0.42*std::pow((std::pow(salinity, 0.8)-0.17), 2) + 0.045)*Toolbox::pow(T_C, 0.8);
338  Evaluation mu_brine = 0.1 + 0.333*salinity + (1.65+91.9*salinity*salinity*salinity)*Toolbox::exp(-A);
339 
340  return mu_brine/1000.0; // convert to [Pa s] (todo: check if correct cP->Pa s is times 10...)
341  }
342 };
343 
347 template <class Scalar, class H2O>
348 Scalar Brine<Scalar, H2O>::salinity = 0.1; // also needs to be adapted in CO2 solubility table!
349 
350 } // namespace Opm
351 
352 #endif
Abstract base class of a pure chemical species.
Definition: Component.hpp:42
static Scalar molarMass()
The molar mass in of the component.
Definition: Brine.hpp:78
Definition: MathToolbox.hpp:39
static Evaluation vaporPressure(Evaluation temperature)
The vapor pressure in of pure water at a given temperature.
Definition: H2O.hpp:131
Definition: Air_Mesitylene.hpp:31
static bool gasIsCompressible()
Returns true iff the gas phase is assumed to be compressible.
Definition: H2O.hpp:534
Scalar Scalar
Definition: Component.hpp:45
static Evaluation gasEnthalpy(const Evaluation &temperature, const Evaluation &pressure)
Specific enthalpy of the pure component in gas.
Definition: Brine.hpp:121
A class for the brine fluid properties.
Definition: Brine.hpp:43
static const Scalar triplePressure()
Returns the pressure at water's triple point.
Definition: H2O.hpp:115
static Evaluation gasDensity(const Evaluation &temperature, const Evaluation &pressure)
The density of steam in at a given pressure and temperature.
Definition: H2O.hpp:556
static const Scalar tripleTemperature()
Returns the temperature at water's triple point.
Definition: H2O.hpp:109
static Evaluation gasPressure(const Evaluation &temperature, const Evaluation &density)
The pressure of steam in at a given density and temperature.
Definition: Brine.hpp:276
static bool gasIsIdeal()
Returns true iff the gas phase is assumed to be ideal.
Definition: Brine.hpp:58
static Evaluation gasHeatCapacity(const Evaluation &temperature, const Evaluation &pressure)
Specific isobaric heat capacity of water steam .
Definition: Brine.hpp:207
static bool gasIsCompressible()
Returns true iff the gas phase is assumed to be compressible.
Definition: Brine.hpp:64
static Evaluation gasViscosity(const Evaluation &temperature, const Evaluation &pressure)
The dynamic viscosity of steam.
Definition: Brine.hpp:317
static Evaluation gasPressure(const Evaluation &temperature, Scalar density)
The pressure of steam in at a given density and temperature.
Definition: H2O.hpp:639
Evaluation< Scalar, VarSetTag, numVars > exp(const Evaluation< Scalar, VarSetTag, numVars > &x)
Definition: Math.hpp:295
static Evaluation liquidDensity(const Evaluation &temperature, const Evaluation &pressure)
The density of pure water in at a given pressure and temperature.
Definition: H2O.hpp:685
static bool gasIsIdeal()
Returns true iff the gas phase is assumed to be ideal.
Definition: H2O.hpp:623
static bool liquidIsCompressible()
Returns true iff the liquid phase is assumed to be compressible.
Definition: H2O.hpp:540
static Evaluation liquidDensity(const Evaluation &temperature, const Evaluation &pressure)
The density of the liquid component at a given pressure in and temperature in . ...
Definition: Brine.hpp:250
static Evaluation liquidPressure(const Evaluation &temperature, const Evaluation &density)
The pressure of liquid water in at a given density and temperature.
Definition: Brine.hpp:283
static Evaluation vaporPressure(const Evaluation &T)
The vapor pressure in of pure water at a given temperature.
Definition: Brine.hpp:114
Evaluation< Scalar, VarSetTag, numVars > abs(const Evaluation< Scalar, VarSetTag, numVars > &)
Definition: Math.hpp:41
static Evaluation gasHeatCapacity(const Evaluation &temperature, const Evaluation &pressure)
Specific isobaric heat capacity of water steam .
Definition: H2O.hpp:273
static Evaluation liquidViscosity(const Evaluation &temperature, const Evaluation &)
The dynamic viscosity of pure water.
Definition: Brine.hpp:329
static Scalar triplePressure()
Returns the pressure at water's triple point.
Definition: Brine.hpp:107
static const char * name()
A human readable name for the component.
Definition: Brine.hpp:52
static Evaluation gasInternalEnergy(const Evaluation &temperature, const Evaluation &pressure)
Specific internal energy of steam and water vapor .
Definition: Brine.hpp:215
static Evaluation liquidEnthalpy(const Evaluation &temperature, const Evaluation &pressure)
Specific enthalpy of liquid water .
Definition: H2O.hpp:229
static const Scalar criticalPressure()
Returns the critical pressure of water.
Definition: H2O.hpp:97
static const Scalar criticalTemperature()
Returns the critical temperature of water.
Definition: H2O.hpp:91
static Evaluation gasDensity(const Evaluation &temperature, const Evaluation &pressure)
The density of steam in at a given pressure and temperature.
Definition: Brine.hpp:239
static Evaluation gasViscosity(const Evaluation &temperature, const Evaluation &pressure)
The dynamic viscosity of steam.
Definition: H2O.hpp:790
Abstract base class of a pure chemical species.
Evaluation< Scalar, VarSetTag, numVars > pow(const Evaluation< Scalar, VarSetTag, numVars > &base, Scalar exp)
Definition: Math.hpp:312
static Evaluation liquidHeatCapacity(const Evaluation &temperature, const Evaluation &pressure)
Specific isobaric heat capacity of liquid water .
Definition: Brine.hpp:196
static Evaluation gasEnthalpy(const Evaluation &temperature, const Evaluation &pressure)
Specific enthalpy of water steam .
Definition: H2O.hpp:176
static Scalar salinity
The mass fraction of salt assumed to be in the brine.
Definition: Brine.hpp:47
static Scalar tripleTemperature()
Returns the temperature at water's triple point.
Definition: Brine.hpp:101
static Evaluation liquidEnthalpy(const Evaluation &temperature, const Evaluation &pressure)
Specific enthalpy of the pure component in liquid.
Definition: Brine.hpp:134
static Scalar criticalTemperature()
Returns the critical temperature of water.
Definition: Brine.hpp:89
static Evaluation liquidInternalEnergy(const Evaluation &temperature, const Evaluation &pressure)
Specific internal energy of liquid water .
Definition: Brine.hpp:227
static Scalar criticalPressure()
Returns the critical pressure of water.
Definition: Brine.hpp:95
static bool liquidIsCompressible()
Returns true iff the liquid phase is assumed to be compressible.
Definition: Brine.hpp:70
static const Scalar molarMass()
The molar mass in of water.
Definition: H2O.hpp:79
A traits class which provides basic mathematical functions for arbitrary scalar floating point values...