3.3.0
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
brine_co2.hh
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 * See the file COPYING for full copying permissions. *
5 * *
6 * This program 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 3 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program 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 this program. If not, see <http://www.gnu.org/licenses/>. *
18 *****************************************************************************/
24#ifndef DUMUX_BINARY_COEFF_BRINE_CO2_HH
25#define DUMUX_BINARY_COEFF_BRINE_CO2_HH
26
27#include <dune/common/math.hh>
28
34
35namespace Dumux::BinaryCoeff {
36
41template<class Scalar, class CO2Tables, bool verbose = true>
42class Brine_CO2 {
46 static constexpr int lPhaseIdx = 0; // index of the liquid phase
47 static constexpr int gPhaseIdx = 1; // index of the gas phase
48
49public:
57 static Scalar gasDiffCoeff(Scalar temperature, Scalar pressure)
58 {
59 static const bool hasGasDiffCoeff = hasParam("BinaryCoefficients.GasDiffCoeff");
60 if (!hasGasDiffCoeff) //in case one might set that user-specific as e.g. in dumux-lecture/mm/convectivemixing
61 {
62 //Diffusion coefficient of water in the CO2 phase
63 constexpr Scalar PI = 3.141593;
64 constexpr Scalar k = 1.3806504e-23; // Boltzmann constant
65 constexpr Scalar c = 4; // slip parameter, can vary between 4 (slip condition) and 6 (stick condition)
66 constexpr Scalar R_h = 1.72e-10; // hydrodynamic radius of the solute
67 const Scalar mu = CO2::gasViscosity(temperature, pressure); // CO2 viscosity
68 return k / (c * PI * R_h) * (temperature / mu);
69 }
70 else
71 {
72 static const Scalar D = getParam<Scalar>("BinaryCoefficients.GasDiffCoeff");
73 return D;
74 }
75 }
76
83 static Scalar liquidDiffCoeff(Scalar temperature, Scalar pressure)
84 {
85 //Diffusion coefficient of CO2 in the brine phase
86 static const bool hasLiquidDiffCoeff = hasParam("BinaryCoefficients.LiquidDiffCoeff");
87 if (!hasLiquidDiffCoeff) //in case one might set that user-specific as e.g. in dumux-lecture/mm/convectivemixing
88 return 2e-9;
89 else
90 {
91 const Scalar D = getParam<Scalar>("BinaryCoefficients.LiquidDiffCoeff");
92 return D;
93 }
94 }
95
113 static void calculateMoleFractions(const Scalar temperature,
114 const Scalar pg,
115 const Scalar salinity,
116 const int knownPhaseIdx,
117 Scalar &xlCO2,
118 Scalar &ygH2O)
119 {
120
121 const Scalar A = computeA_(temperature, pg);
122
123 /* salinity: conversion from mass fraction to mol fraction */
124 const Scalar x_NaCl = salinityToMoleFrac_(salinity);
125
126 // if both phases are present the mole fractions in each phase can be calculate
127 // with the mutual solubility function
128 if (knownPhaseIdx < 0)
129 {
130 const Scalar molalityNaCl = molFracToMolality_(x_NaCl); // molality of NaCl //CHANGED
131 const Scalar m0_CO2 = molalityCO2inPureWater_(temperature, pg); // molality of CO2 in pure water
132 const Scalar gammaStar = activityCoefficient_(temperature, pg, molalityNaCl);// activity coefficient of CO2 in brine
133 const Scalar m_CO2 = m0_CO2 / gammaStar; // molality of CO2 in brine
134 xlCO2 = m_CO2 / (molalityNaCl + 55.508 + m_CO2); // mole fraction of CO2 in brine
135 ygH2O = A * (1 - xlCO2 - x_NaCl); // mole fraction of water in the gas phase
136 }
137
138 // if only liquid phase is present the mole fraction of CO2 in brine is given and
139 // and the virtual equilibrium mole fraction of water in the non-existing gas phase can be estimated
140 // with the mutual solubility function
141 if (knownPhaseIdx == lPhaseIdx)
142 ygH2O = A * (1 - xlCO2 - x_NaCl);
143
144 // if only gas phase is present the mole fraction of water in the gas phase is given and
145 // and the virtual equilibrium mole fraction of CO2 in the non-existing liquid phase can be estimated
146 // with the mutual solubility function
147 if (knownPhaseIdx == gPhaseIdx)
148 xlCO2 = 1 - x_NaCl - ygH2O / A;
149 }
150
158 static Scalar fugacityCoefficientCO2(Scalar T, Scalar pg)
159 {
160 const Scalar V = 1 / (CO2::gasDensity(T, pg) / CO2::molarMass()) * 1.e6; // molar volume in cm^3/mol
161 const Scalar pg_bar = pg / 1.e5; // gas phase pressure in bar
162 const Scalar a_CO2 = (7.54e7 - 4.13e4 * T); // mixture parameter of Redlich-Kwong equation
163 constexpr Scalar b_CO2 = 27.8; // mixture parameter of Redlich-Kwong equation
164 constexpr Scalar R = IdealGas::R * 10.; // ideal gas constant with unit bar cm^3 /(K mol)
165
166 using std::log;
167 using std::exp;
168 using std::pow;
169 const Scalar lnPhiCO2 = log(V / (V - b_CO2)) + b_CO2 / (V - b_CO2) - 2 * a_CO2 / (R
170 * pow(T, 1.5) * b_CO2) * log((V + b_CO2) / V) + a_CO2 * b_CO2
171 / (R * pow(T, 1.5) * b_CO2 * b_CO2) * (log((V + b_CO2) / V)
172 - b_CO2 / (V + b_CO2)) - log(pg_bar * V / (R * T));
173
174 return exp(lnPhiCO2); // fugacity coefficient of CO2
175 }
176
184 static Scalar fugacityCoefficientH2O(Scalar T, Scalar pg)
185 {
186 const Scalar V = 1 / (CO2::gasDensity(T, pg) / CO2::molarMass()) * 1.e6; // molar volume in cm^3/mol
187 const Scalar pg_bar = pg / 1.e5; // gas phase pressure in bar
188 const Scalar a_CO2 = (7.54e7 - 4.13e4 * T);// mixture parameter of Redlich-Kwong equation
189 constexpr Scalar a_CO2_H2O = 7.89e7;// mixture parameter of Redlich-Kwong equation
190 constexpr Scalar b_CO2 = 27.8;// mixture parameter of Redlich-Kwong equation
191 constexpr Scalar b_H2O = 18.18;// mixture parameter of Redlich-Kwong equation
192 constexpr Scalar R = IdealGas::R * 10.; // ideal gas constant with unit bar cm^3 /(K mol)
193
194 using std::log;
195 using std::pow;
196 using std::exp;
197 const Scalar lnPhiH2O = log(V / (V - b_CO2)) + b_H2O / (V - b_CO2) - 2 * a_CO2_H2O
198 / (R * pow(T, 1.5) * b_CO2) * log((V + b_CO2) / V) + a_CO2
199 * b_H2O / (R * pow(T, 1.5) * b_CO2 * b_CO2) * (log((V + b_CO2)
200 / V) - b_CO2 / (V + b_CO2)) - log(pg_bar * V / (R * T));
201
202 return exp(lnPhiH2O); // fugacity coefficient of H2O
203 }
204
205private:
210 static Scalar salinityToMoleFrac_(Scalar salinity)
211 {
212 constexpr Scalar Mw = H2O::molarMass(); // molecular weight of water [kg/mol]
213 constexpr Scalar Ms = 58.8e-3; // molecular weight of NaCl [kg/mol]
214
215 const Scalar X_NaCl = salinity;
216 // salinity: conversion from mass fraction to mol fraction
217 const Scalar x_NaCl = -Mw * X_NaCl / ((Ms - Mw) * X_NaCl - Ms);
218 return x_NaCl;
219 }
220
227 static Scalar molFracToMolality_(Scalar x_NaCl)
228 {
229 // conversion from mol fraction to molality (dissolved CO2 neglected)
230 return 55.508 * x_NaCl / (1 - x_NaCl);
231 }
232
240 static Scalar molalityCO2inPureWater_(Scalar temperature, Scalar pg)
241 {
242 const Scalar A = computeA_(temperature, pg); // according to Spycher, Pruess and Ennis-King (2003)
243 const Scalar B = computeB_(temperature, pg); // according to Spycher, Pruess and Ennis-King (2003)
244 const Scalar yH2OinGas = (1 - B) / (1. / A - B); // equilibrium mol fraction of H2O in the gas phase
245 const Scalar xCO2inWater = B * (1 - yH2OinGas); // equilibrium mol fraction of CO2 in the water phase
246 return (xCO2inWater * 55.508) / (1 - xCO2inWater); // CO2 molality
247 }
248
258 static Scalar activityCoefficient_(Scalar temperature, Scalar pg, Scalar molalityNaCl)
259 {
260 const Scalar lambda = computeLambda_(temperature, pg); // lambda_{CO2-Na+}
261 const Scalar xi = computeXi_(temperature, pg); // Xi_{CO2-Na+-Cl-}
262 const Scalar lnGammaStar = 2 * lambda * molalityNaCl + xi * molalityNaCl
263 * molalityNaCl;
264 using std::exp;
265 return exp(lnGammaStar); // molal activity coefficient of CO2 in brine
266 }
267
276 static Scalar computeA_(Scalar T, Scalar pg)
277 {
278 const Scalar deltaP = pg / 1e5 - 1; // pressure range [bar] from p0 = 1bar to pg[bar]
279 const Scalar v_av_H2O = 18.1; // average partial molar volume of H2O [cm^3/mol]
280 constexpr Scalar R = IdealGas::R * 10;
281 const Scalar k0_H2O = equilibriumConstantH2O_(T); // equilibrium constant for H2O at 1 bar
282 const Scalar phi_H2O = fugacityCoefficientH2O(T, pg); // fugacity coefficient of H2O for the water-CO2 system
283 const Scalar pg_bar = pg / 1.e5;
284 using std::exp;
285 return k0_H2O / (phi_H2O * pg_bar) * exp(deltaP * v_av_H2O / (R * T));
286 }
287
296 static Scalar computeB_(Scalar T, Scalar pg)
297 {
298 const Scalar deltaP = pg / 1e5 - 1; // pressure range [bar] from p0 = 1bar to pg[bar]
299 constexpr Scalar v_av_CO2 = 32.6; // average partial molar volume of CO2 [cm^3/mol]
300 constexpr Scalar R = IdealGas::R * 10;
301 const Scalar k0_CO2 = equilibriumConstantCO2_(T); // equilibrium constant for CO2 at 1 bar
302 const Scalar phi_CO2 = fugacityCoefficientCO2(T, pg); // fugacity coefficient of CO2 for the water-CO2 system
303 const Scalar pg_bar = pg / 1.e5;
304 using std::exp;
305 return phi_CO2 * pg_bar / (55.508 * k0_CO2) * exp(-(deltaP
306 * v_av_CO2) / (R * T));
307 }
308
316 static Scalar computeLambda_(Scalar T, Scalar pg)
317 {
318 constexpr Scalar c[6] = { -0.411370585, 6.07632013E-4, 97.5347708,
319 -0.0237622469, 0.0170656236, 1.41335834E-5 };
320
321 using std::log;
322 const Scalar pg_bar = pg / 1.0E5; /* conversion from Pa to bar */
323 return c[0] + c[1] * T + c[2] / T + c[3] * pg_bar / T + c[4] * pg_bar
324 / (630.0 - T) + c[5] * T * log(pg_bar);
325 }
326
334 static Scalar computeXi_(Scalar T, Scalar pg)
335 {
336 constexpr Scalar c[4] = { 3.36389723E-4, -1.98298980E-5,
337 2.12220830E-3, -5.24873303E-3 };
338
339 Scalar pg_bar = pg / 1.0E5; /* conversion from Pa to bar */
340 return c[0] + c[1] * T + c[2] * pg_bar / T + c[3] * pg_bar / (630.0 - T);
341 }
342
349 static Scalar equilibriumConstantCO2_(Scalar T)
350 {
351 const Scalar TinC = T - 273.15; //temperature in °C
352 constexpr Scalar c[3] = { 1.189, 1.304e-2, -5.446e-5 };
353 const Scalar logk0_CO2 = c[0] + c[1] * TinC + c[2] * TinC * TinC;
354 using std::pow;
355 return pow(10, logk0_CO2);
356 }
357
364 static Scalar equilibriumConstantH2O_(Scalar T)
365 {
366 const Scalar TinC = T - 273.15; //temperature in °C
367 constexpr Scalar c[4] = { -2.209, 3.097e-2, -1.098e-4, 2.048e-7 };
368 const Scalar logk0_H2O = c[0] + c[1] * TinC + c[2] * TinC * TinC + c[3]
369 * TinC * TinC * TinC;
370 using std::pow;
371 return pow(10, logk0_H2O);
372 }
373};
374
381template<class Scalar, class CO2Tables, bool verbose = true>
383{
388
389public:
398 static Scalar moleFracCO2InBrine(Scalar temperature, Scalar pg, Scalar rhoCO2)
399 {
400 // regularisations:
401 if (pg > 2.5e8) {
402 pg = 2.5e8;
403 }
404 if (pg < 2.e5) {
405 pg = 2.e5;
406 }
407 if (temperature < 275.) {
408 temperature = 275;
409 }
410 if (temperature > 600.) {
411 temperature = 600;
412 }
413
414 const Scalar Mw = H2O::molarMass(); /* molecular weight of water [kg/mol] */
415 const Scalar Ms = 58.8e-3; /* molecular weight of NaCl [kg/mol] */
416
417 const Scalar X_NaCl = Brine::salinity();
418 /* salinity: conversion from mass fraction to mole fraction */
419 const Scalar x_NaCl = -Mw * X_NaCl / ((Ms - Mw) * X_NaCl - Ms);
420
421 // salinity: conversion from mole fraction to molality
422 const Scalar mol_NaCl = -55.56 * x_NaCl / (x_NaCl - 1);
423
424 const Scalar A = computeA_(temperature, pg); /* mu_{CO2}^{l(0)}/RT */
425 const Scalar B = computeB_(temperature, pg); /* lambda_{CO2-Na+} */
426 const Scalar C = computeC_(temperature, pg); /* Xi_{CO2-Na+-Cl-} */
427 const Scalar pgCO2 = partialPressureCO2_(temperature, pg);
428 const Scalar phiCO2 = fugacityCoeffCO2_(temperature, pgCO2, rhoCO2);
429
430 using std::log;
431 using Dune::power;
432 const Scalar exponent = A - log(phiCO2) + 2*B*mol_NaCl + C*power(mol_NaCl,2);
433
434 using std::exp;
435 const Scalar mol_CO2w = pgCO2 / (1e5 * exp(exponent)); /* paper: equation (6) */
436
437 const Scalar x_CO2w = mol_CO2w / (mol_CO2w + 55.56); /* conversion: molality to mole fraction */
438 //Scalar X_CO2w = x_CO2w*MCO2/(x_CO2w*MCO2 + (1-x_CO2w)*Mw); /* conversion: mole fraction to mass fraction */
439
440 return x_CO2w;
441 }
442
443private:
449 static Scalar computeA_(Scalar T, Scalar pg)
450 {
451 static const Scalar c[10] = {
452 28.9447706,
453 -0.0354581768,
454 -4770.67077,
455 1.02782768E-5,
456 33.8126098,
457 9.04037140E-3,
458 -1.14934031E-3,
459 -0.307405726,
460 -0.0907301486,
461 9.32713393E-4,
462 };
463
464 const Scalar pg_bar = pg / 1.0E5; /* conversion from Pa to bar */
465 const Scalar Tr = 630.0 - T;
466
467 using std::log;
468 return
469 c[0] +
470 c[1]*T +
471 c[2]/T +
472 c[3]*T*T +
473 c[4]/Tr +
474 c[5]*pg_bar +
475 c[6]*pg_bar*log(T) +
476 c[7]*pg_bar/T +
477 c[8]*pg_bar/Tr +
478 c[9]*pg_bar*pg_bar/(Tr*Tr);
479 }
480
487 static Scalar computeB_(Scalar T, Scalar pg)
488 {
489 const Scalar c1 = -0.411370585;
490 const Scalar c2 = 6.07632013E-4;
491 const Scalar c3 = 97.5347708;
492 const Scalar c8 = -0.0237622469;
493 const Scalar c9 = 0.0170656236;
494 const Scalar c11 = 1.41335834E-5;
495
496 const Scalar pg_bar = pg / 1.0E5; /* conversion from Pa to bar */
497
498 using std::log;
499 return
500 c1 +
501 c2*T +
502 c3/T +
503 c8*pg_bar/T +
504 c9*pg_bar/(630.0-T) +
505 c11*T*log(pg_bar);
506 }
507
514 static Scalar computeC_(Scalar T, Scalar pg)
515 {
516 const Scalar c1 = 3.36389723E-4;
517 const Scalar c2 = -1.98298980E-5;
518 const Scalar c8 = 2.12220830E-3;
519 const Scalar c9 = -5.24873303E-3;
520
521 const Scalar pg_bar = pg / 1.0E5; /* conversion from Pa to bar */
522
523 return
524 c1 +
525 c2*T +
526 c8*pg_bar/T +
527 c9*pg_bar/(630.0-T);
528 }
529
540 static Scalar partialPressureCO2_(Scalar temperature, Scalar pg)
541 {
543 }
544
552 static Scalar fugacityCoeffCO2_(Scalar temperature,
553 Scalar pg,
554 Scalar rhoCO2)
555 {
556 static const Scalar a[15] = {
557 8.99288497E-2,
558 -4.94783127E-1,
559 4.77922245E-2,
560 1.03808883E-2,
561 -2.82516861E-2,
562 9.49887563E-2,
563 5.20600880E-4,
564 -2.93540971E-4,
565 -1.77265112E-3,
566 -2.51101973E-5,
567 8.93353441E-5,
568 7.88998563E-5,
569 -1.66727022E-2,
570 1.3980,
571 2.96000000E-2
572 };
573
574 // reduced temperature
575 const Scalar Tr = temperature / CO2::criticalTemperature();
576 // reduced pressure
577 const Scalar pr = pg / CO2::criticalPressure();
578
579 // reduced molar volume. ATTENTION: Vc is _NOT_ the critical
580 // molar volume of CO2. See the reference!
582 const Scalar Vr =
583 // molar volume of CO2 at (temperature, pg)
584 CO2::molarMass() / rhoCO2
585 *
586 // "pseudo-critical" molar volume
587 1.0 / Vc;
588
589 // the Z coefficient
590 const Scalar Z = pr * Vr / Tr;
591
592 const Scalar A = a[0] + a[1] / (Tr * Tr) + a[2] / (Tr * Tr * Tr);
593 const Scalar B = a[3] + a[4] / (Tr * Tr) + a[5] / (Tr * Tr * Tr);
594 const Scalar C = a[6] + a[7] / (Tr * Tr) + a[8] / (Tr * Tr * Tr);
595 const Scalar D = a[9] + a[10] / (Tr * Tr) + a[11] / (Tr * Tr * Tr);
596
597 using std::log;
598 using std::exp;
599 const Scalar lnphiCO2 =
600 Z - 1 -
601 log(Z) +
602 A/Vr +
603 B/(2*Vr*Vr) +
604 C/(4*Vr*Vr*Vr*Vr) +
605 D/(5*Vr*Vr*Vr*Vr*Vr)
606 +
607 a[12]/(2*Tr*Tr*Tr*a[14])*
608 (
609 a[13] + 1 -
610 ( a[13] + 1 +
611 a[14]/(Vr*Vr)
612 )*exp(-a[14]/(Vr*Vr)));
613
614 return exp(lnphiCO2);
615 }
616
617};
618
619} // end namespace Dumux::BinaryCoeff
620
621#endif
The infrastructure to retrieve run-time parameters from Dune::ParameterTrees.
A class for the CO2 fluid properties.
Material properties of pure water .
Relations valid for an ideal gas.
bool hasParam(const std::string &param)
Check whether a key exists in the parameter tree.
Definition: parameters.hh:382
std::string temperature() noexcept
I/O name of temperature for equilibrium models.
Definition: name.hh:51
std::string pressure(int phaseIdx) noexcept
I/O name of pressure for multiphase systems.
Definition: name.hh:34
Definition: air_mesitylene.hh:31
Binary coefficients for brine and CO2.
Definition: brine_co2.hh:42
static Scalar fugacityCoefficientCO2(Scalar T, Scalar pg)
Returns the fugacity coefficient of the CO2 component in a water-CO2 mixture (given in Spycher,...
Definition: brine_co2.hh:158
static Scalar fugacityCoefficientH2O(Scalar T, Scalar pg)
Returns the fugacity coefficient of the H2O component in a water-CO2 mixture (given in Spycher,...
Definition: brine_co2.hh:184
static void calculateMoleFractions(const Scalar temperature, const Scalar pg, const Scalar salinity, const int knownPhaseIdx, Scalar &xlCO2, Scalar &ygH2O)
Returns the mol (!) fraction of CO2 in the liquid phase and the mol (!) fraction of H2O in the gas ph...
Definition: brine_co2.hh:113
static Scalar liquidDiffCoeff(Scalar temperature, Scalar pressure)
Binary diffusion coefficient of CO2 in the brine phase.
Definition: brine_co2.hh:83
static Scalar gasDiffCoeff(Scalar temperature, Scalar pressure)
Binary diffusion coefficient of water in the CO2 phase.
Definition: brine_co2.hh:57
Old version of binary coefficients for CO2 and brine. Calculates molfraction of CO2 in brine accordin...
Definition: brine_co2.hh:383
static Scalar moleFracCO2InBrine(Scalar temperature, Scalar pg, Scalar rhoCO2)
Returns the mole (!) fraction of CO2 in the liquid phase at a given temperature, pressure and density...
Definition: brine_co2.hh:398
A class for the brine fluid properties.
Definition: components/brine.hh:56
static Scalar salinity()
Return the constant salinity.
Definition: components/brine.hh:73
static Scalar vaporPressure(Scalar temperature)
The vapor pressure in of pure brine at a given temperature. Here, it is assumed to be equal to that ...
Definition: components/brine.hh:120
A class for the CO2 fluid properties.
Definition: co2.hh:57
static constexpr Scalar molarMass()
The mass in of one mole of CO2.
Definition: co2.hh:72
static Scalar gasDensity(Scalar temperature, Scalar pressure)
The density of CO2 at a given pressure and temperature .
Definition: co2.hh:226
static Scalar criticalTemperature()
Returns the critical temperature of CO2.
Definition: co2.hh:78
static Scalar gasViscosity(Scalar temperature, Scalar pressure)
The dynamic viscosity of CO2. Equations given in: - Vesovic et al., 1990.
Definition: co2.hh:327
static Scalar criticalPressure()
Returns the critical pressure of CO2.
Definition: co2.hh:84
Material properties of pure water .
Definition: h2o.hh:60
static constexpr Scalar molarMass()
The molar mass in of water.
Definition: h2o.hh:80
Relations valid for an ideal gas.
Definition: idealgas.hh:37
static constexpr Scalar R
The ideal gas constant .
Definition: idealgas.hh:40
A class for the brine fluid properties,.