Brine_CO2.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) 2012-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_BINARY_COEFF_BRINE_CO2_HPP
27 #define OPM_BINARY_COEFF_BRINE_CO2_HPP
28 
33 
34 namespace Opm {
35 namespace BinaryCoeff {
36 
41 template<class Scalar, class CO2Tables, bool verbose = true>
42 class Brine_CO2 {
43  typedef Opm::H2O<Scalar> H2O;
46  static const int liquidPhaseIdx = 0; // index of the liquid phase
47  static const int gasPhaseIdx = 1; // index of the gas phase
48 
49 public:
57  template <class Evaluation>
58  static Evaluation gasDiffCoeff(const Evaluation& temperature, const Evaluation& pressure)
59  {
60  //Diffusion coefficient of water in the CO2 phase
61  Scalar k = 1.3806504e-23; // Boltzmann constant
62  Scalar c = 4; // slip parameter, can vary between 4 (slip condition) and 6 (stick condition)
63  Scalar R_h = 1.72e-10; // hydrodynamic radius of the solute
64  const Evaluation& mu = CO2::gasViscosity(temperature, pressure); // CO2 viscosity
65  return k / (c * M_PI * R_h) * (temperature / mu);
66  }
67 
74  template <class Evaluation>
75  static Evaluation liquidDiffCoeff(const Evaluation& /*temperature*/, const Evaluation& /*pressure*/)
76  {
77  //Diffusion coefficient of CO2 in the brine phase
78  return 2e-9;
79  }
80 
98  template <class Evaluation>
99  static void calculateMoleFractions(const Evaluation& temperature,
100  const Evaluation& pg,
101  Scalar salinity,
102  const int knownPhaseIdx,
103  Evaluation& xlCO2,
104  Evaluation& ygH2O)
105  {
106  Evaluation A = computeA_(temperature, pg);
107 
108  /* salinity: conversion from mass fraction to mol fraction */
109  Scalar x_NaCl = salinityToMolFrac_(salinity);
110 
111  // if both phases are present the mole fractions in each phase can be calculate
112  // with the mutual solubility function
113  if (knownPhaseIdx < 0) {
114  Scalar molalityNaCl = moleFracToMolality_(x_NaCl); // molality of NaCl //CHANGED
115  Evaluation m0_CO2 = molalityCO2inPureWater_(temperature, pg); // molality of CO2 in pure water
116  Evaluation gammaStar = activityCoefficient_(temperature, pg, molalityNaCl);// activity coefficient of CO2 in brine
117  Evaluation m_CO2 = m0_CO2 / gammaStar; // molality of CO2 in brine
118  xlCO2 = m_CO2 / (molalityNaCl + 55.508 + m_CO2); // mole fraction of CO2 in brine
119  ygH2O = A * (1 - xlCO2 - x_NaCl); // mole fraction of water in the gas phase
120  }
121 
122  // if only liquid phase is present the mole fraction of CO2 in brine is given and
123  // and the virtual equilibrium mole fraction of water in the non-existing gas phase can be estimated
124  // with the mutual solubility function
125  if (knownPhaseIdx == liquidPhaseIdx)
126  ygH2O = A * (1 - xlCO2 - x_NaCl);
127 
128  // if only gas phase is present the mole fraction of water in the gas phase is given and
129  // and the virtual equilibrium mole fraction of CO2 in the non-existing liquid phase can be estimated
130  // with the mutual solubility function
131  if (knownPhaseIdx == gasPhaseIdx)
132  //y_H2o = fluidstate.
133  xlCO2 = 1 - x_NaCl - ygH2O / A;
134  }
135 
139  template <class Evaluation>
140  static Evaluation henry(const Evaluation& temperature)
141  { return fugacityCoefficientCO2(temperature, /*pressure=*/1e5)*1e5; }
142 
151  template <class Evaluation>
152  static Evaluation fugacityCoefficientCO2(const Evaluation& temperature, const Evaluation& pg)
153  {
154  typedef MathToolbox<Evaluation> Toolbox;
155 
156  Valgrind::CheckDefined(temperature);
158 
159  Evaluation V = 1 / (CO2::gasDensity(temperature, pg) / CO2::molarMass()) * 1.e6; // molar volume in cm^3/mol
160  Evaluation pg_bar = pg / 1.e5; // gas phase pressure in bar
161  Evaluation a_CO2 = (7.54e7 - 4.13e4 * temperature); // mixture parameter of Redlich-Kwong equation
162  Scalar b_CO2 = 27.8; // mixture parameter of Redlich-Kwong equation
163  Scalar R = IdealGas::R * 10.; // ideal gas constant with unit bar cm^3 /(K mol)
164  Evaluation lnPhiCO2;
165 
166  lnPhiCO2 = Toolbox::log(V / (V - b_CO2));
167  lnPhiCO2 += b_CO2 / (V - b_CO2);
168  lnPhiCO2 -= 2 * a_CO2 / (R * Toolbox::pow(temperature, 1.5) * b_CO2) * log((V + b_CO2) / V);
169  lnPhiCO2 +=
170  a_CO2 * b_CO2
171  / (R
172  * Toolbox::pow(temperature, 1.5)
173  * b_CO2
174  * b_CO2)
175  * (Toolbox::log((V + b_CO2) / V)
176  - b_CO2 / (V + b_CO2));
177  lnPhiCO2 -= Toolbox::log(pg_bar * V / (R * temperature));
178 
179  return Toolbox::exp(lnPhiCO2); // fugacity coefficient of CO2
180  }
181 
190  template <class Evaluation>
191  static Evaluation fugacityCoefficientH2O(const Evaluation& temperature, const Evaluation& pg)
192  {
193  typedef MathToolbox<Evaluation> Toolbox;
194 
195  const Evaluation& V = 1 / (CO2::gasDensity(temperature, pg) / CO2::molarMass()) * 1.e6; // molar volume in cm^3/mol
196  const Evaluation& pg_bar = pg / 1.e5; // gas phase pressure in bar
197  const Evaluation& a_CO2 = (7.54e7 - 4.13e4 * temperature);// mixture parameter of Redlich-Kwong equation
198  Scalar a_CO2_H2O = 7.89e7;// mixture parameter of Redlich-Kwong equation
199  Scalar b_CO2 = 27.8;// mixture parameter of Redlich-Kwong equation
200  Scalar b_H2O = 18.18;// mixture parameter of Redlich-Kwong equation
201  Scalar R = IdealGas::R * 10.; // ideal gas constant with unit bar cm^3 /(K mol)
202  Evaluation lnPhiH2O;
203 
204  lnPhiH2O =
205  Toolbox::log(V/(V - b_CO2))
206  + b_H2O/(V - b_CO2) - 2*a_CO2_H2O
207  / (R*Toolbox::pow(temperature, 1.5)*b_CO2)*Toolbox::log((V + b_CO2)/V)
208  + a_CO2*b_H2O/(R*Toolbox::pow(temperature, 1.5)*b_CO2*b_CO2)
209  *(Toolbox::log((V + b_CO2)/V) - b_CO2/(V + b_CO2))
210  - Toolbox::log(pg_bar*V/(R*temperature));
211  return Toolbox::exp(lnPhiH2O); // fugacity coefficient of H2O
212  }
213 
214 private:
220  static Scalar salinityToMolFrac_(Scalar salinity) {
221 
222  const Scalar Mw = H2O::molarMass(); /* molecular weight of water [kg/mol] */
223  const Scalar Ms = 58.8e-3; /* molecular weight of NaCl [kg/mol] */
224 
225  const Scalar X_NaCl = salinity;
226  /* salinity: conversion from mass fraction to mol fraction */
227  const Scalar x_NaCl = -Mw * X_NaCl / ((Ms - Mw) * X_NaCl - Ms);
228  return x_NaCl;
229  }
230 
236  static Scalar moleFracToMolality_(Scalar x_NaCl)
237  {
238  // conversion from mol fraction to molality (dissolved CO2 neglected)
239  return 55.508 * x_NaCl / (1 - x_NaCl);
240  }
241 
249  template <class Evaluation>
250  static Evaluation molalityCO2inPureWater_(const Evaluation& temperature, const Evaluation& pg)
251  {
252  const Evaluation& A = computeA_(temperature, pg); // according to Spycher, Pruess and Ennis-King (2003)
253  const Evaluation& B = computeB_(temperature, pg); // according to Spycher, Pruess and Ennis-King (2003)
254  const Evaluation& yH2OinGas = (1 - B) / (1. / A - B); // equilibrium mol fraction of H2O in the gas phase
255  const Evaluation& xCO2inWater = B * (1 - yH2OinGas); // equilibrium mol fraction of CO2 in the water phase
256  return (xCO2inWater * 55.508) / (1 - xCO2inWater); // CO2 molality
257  }
258 
268  template <class Evaluation>
269  static Evaluation activityCoefficient_(const Evaluation& temperature,
270  const Evaluation& pg,
271  Scalar molalityNaCl)
272  {
273  typedef MathToolbox<Evaluation> Toolbox;
274 
275  const Evaluation& lambda = computeLambda_(temperature, pg); // lambda_{CO2-Na+}
276  const Evaluation& xi = computeXi_(temperature, pg); // Xi_{CO2-Na+-Cl-}
277  const Evaluation& lnGammaStar =
278  2*molalityNaCl*lambda + xi*molalityNaCl*molalityNaCl;
279  return Toolbox::exp(lnGammaStar);
280  }
281 
290  template <class Evaluation>
291  static Evaluation computeA_(const Evaluation& temperature, const Evaluation& pg)
292  {
293  typedef MathToolbox<Evaluation> Toolbox;
294 
295  const Evaluation& deltaP = pg / 1e5 - 1; // pressure range [bar] from p0 = 1bar to pg[bar]
296  Scalar v_av_H2O = 18.1; // average partial molar volume of H2O [cm^3/mol]
297  Scalar R = IdealGas::R * 10;
298  const Evaluation& k0_H2O = equilibriumConstantH2O_(temperature); // equilibrium constant for H2O at 1 bar
299  const Evaluation& phi_H2O = fugacityCoefficientH2O(temperature, pg); // fugacity coefficient of H2O for the water-CO2 system
300  const Evaluation& pg_bar = pg / 1.e5;
301  return k0_H2O/(phi_H2O*pg_bar)*Toolbox::exp(deltaP*v_av_H2O/(R*temperature));
302  }
303 
312  template <class Evaluation>
313  static Evaluation computeB_(const Evaluation& temperature, const Evaluation& pg)
314  {
315  typedef MathToolbox<Evaluation> Toolbox;
316 
317  const Evaluation& deltaP = pg / 1e5 - 1; // pressure range [bar] from p0 = 1bar to pg[bar]
318  const Scalar v_av_CO2 = 32.6; // average partial molar volume of CO2 [cm^3/mol]
319  const Scalar R = IdealGas::R * 10;
320  const Evaluation& k0_CO2 = equilibriumConstantCO2_(temperature); // equilibrium constant for CO2 at 1 bar
321  const Evaluation& phi_CO2 = fugacityCoefficientCO2(temperature, pg); // fugacity coefficient of CO2 for the water-CO2 system
322  const Evaluation& pg_bar = pg / 1.e5;
323  return phi_CO2*pg_bar/(55.508*k0_CO2)*Toolbox::exp(-(deltaP*v_av_CO2)/(R*temperature));
324  }
325 
333  template <class Evaluation>
334  static Evaluation computeLambda_(const Evaluation& temperature, const Evaluation& pg)
335  {
336  typedef MathToolbox<Evaluation> Toolbox;
337 
338  static const Scalar c[6] =
339  { -0.411370585, 6.07632013E-4, 97.5347708, -0.0237622469, 0.0170656236, 1.41335834E-5 };
340 
341  Evaluation pg_bar = pg / 1.0E5; /* conversion from Pa to bar */
342  return
343  c[0]
344  + c[1]*temperature
345  + c[2]/temperature
346  + c[3]*pg_bar/temperature
347  + c[4]*pg_bar/(630.0 - temperature)
348  + c[5]*temperature*Toolbox::log(pg_bar);
349  }
350 
358  template <class Evaluation>
359  static Evaluation computeXi_(const Evaluation& temperature, const Evaluation& pg)
360  {
361  static const Scalar c[4] =
362  { 3.36389723E-4, -1.98298980E-5, 2.12220830E-3, -5.24873303E-3 };
363 
364  Evaluation pg_bar = pg / 1.0E5; /* conversion from Pa to bar */
365  return c[0] + c[1]*temperature + c[2]*pg_bar/temperature + c[3]*pg_bar/(630.0 - temperature);
366  }
367 
374  template <class Evaluation>
375  static Evaluation equilibriumConstantCO2_(const Evaluation& temperature)
376  {
377  typedef MathToolbox<Evaluation> Toolbox;
378 
379  Evaluation temperatureCelcius = temperature - 273.15;
380  static const Scalar c[3] = { 1.189, 1.304e-2, -5.446e-5 };
381  Evaluation logk0_CO2 = c[0] + temperatureCelcius*(c[1] + temperatureCelcius*c[2]);
382  Evaluation k0_CO2 = Toolbox::pow(10.0, logk0_CO2);
383  return k0_CO2;
384  }
385 
392  template <class Evaluation>
393  static Evaluation equilibriumConstantH2O_(const Evaluation& temperature)
394  {
395  typedef MathToolbox<Evaluation> Toolbox;
396 
397  Evaluation temperatureCelcius = temperature - 273.15;
398  static const Scalar c[4] = { -2.209, 3.097e-2, -1.098e-4, 2.048e-7 };
399  Evaluation logk0_H2O =
400  c[0] + temperatureCelcius*(c[1] + temperatureCelcius*(c[2] + temperatureCelcius*c[3]));
401  return Toolbox::pow(10.0, logk0_H2O);
402  }
403 
404 };
405 
406 } // namespace BinaryCoeff
407 } // namespace Opm
408 
409 #endif
static Evaluation liquidDiffCoeff(const Evaluation &, const Evaluation &)
Binary diffusion coefficent [m^2/s] of CO2 in the brine phase.
Definition: Brine_CO2.hpp:75
Material properties of pure water .
Definition: H2O.hpp:60
bool CheckDefined(const T &value OPM_UNUSED)
Make valgrind complain if any of the memory occupied by an object is undefined.
Definition: Valgrind.hpp:74
static Evaluation gasViscosity(Evaluation temperature, const Evaluation &pressure)
The dynamic viscosity [Pa s] of CO2.
Definition: CO2.hpp:202
Definition: MathToolbox.hpp:39
Definition: Air_Mesitylene.hpp:31
static Evaluation fugacityCoefficientH2O(const Evaluation &temperature, const Evaluation &pg)
Returns the fugacity coefficient of the H2O component in a water-CO2 mixture.
Definition: Brine_CO2.hpp:191
static Evaluation gasDensity(const Evaluation &temperature, const Evaluation &pressure)
The density of CO2 at a given pressure and temperature [kg/m^3].
Definition: CO2.hpp:190
Binary coefficients for brine and CO2.
Definition: Brine_CO2.hpp:42
A class for the CO2 fluid properties.
A class for the CO2 fluid properties.
Definition: CO2.hpp:52
static void calculateMoleFractions(const Evaluation &temperature, const Evaluation &pg, Scalar salinity, const int knownPhaseIdx, Evaluation &xlCO2, Evaluation &ygH2O)
Returns the mol (!) fraction of CO2 in the liquid phase and the mol_ (!) fraction of H2O in the gas p...
Definition: Brine_CO2.hpp:99
static Evaluation fugacityCoefficientCO2(const Evaluation &temperature, const Evaluation &pg)
Returns the fugacity coefficient of the CO2 component in a water-CO2 mixture.
Definition: Brine_CO2.hpp:152
A class for the brine fluid properties.
Material properties of pure water .
static Evaluation henry(const Evaluation &temperature)
Henry coefficent for CO2 in brine.
Definition: Brine_CO2.hpp:140
Evaluation< Scalar, VarSetTag, numVars > log(const Evaluation< Scalar, VarSetTag, numVars > &x)
Definition: Math.hpp:369
Evaluation< Scalar, VarSetTag, numVars > exp(const Evaluation< Scalar, VarSetTag, numVars > &x)
Definition: Math.hpp:295
static Evaluation gasDiffCoeff(const Evaluation &temperature, const Evaluation &pressure)
Binary diffusion coefficent [m^2/s] of water in the CO2 phase.
Definition: Brine_CO2.hpp:58
static const Scalar R
The ideal gas constant .
Definition: IdealGas.hpp:39
Relations valid for an ideal gas.
Relations valid for an ideal gas.
Definition: IdealGas.hpp:35
static Scalar molarMass()
The mass in [kg] of one mole of CO2.
Definition: CO2.hpp:67
Evaluation< Scalar, VarSetTag, numVars > pow(const Evaluation< Scalar, VarSetTag, numVars > &base, Scalar exp)
Definition: Math.hpp:312
static const Scalar molarMass()
The molar mass in of water.
Definition: H2O.hpp:79