3.5-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
pengrobinsonmixture.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 *****************************************************************************/
25#ifndef DUMUX_PENG_ROBINSON_MIXTURE_HH
26#define DUMUX_PENG_ROBINSON_MIXTURE_HH
27
28#include "pengrobinson.hh"
29
31
32namespace Dumux {
33
39template <class Scalar, class StaticParameters>
41{
42 enum { numComponents = StaticParameters::numComponents };
44
45 // this class cannot be instantiated!
47
48 // the u and w parameters as given by the Peng-Robinson EOS
49 static const Scalar u;
50 static const Scalar w;
51
52public:
53
72 template <class FluidState, class Params>
73 static Scalar computeFugacityCoefficient(const FluidState &fs,
74 const Params &params,
75 int phaseIdx,
76 int compIdx)
77 {
78 // note that we normalize the component mole fractions, so
79 // that their sum is 100%. This increases numerical stability
80 // considerably if the fluid state is not physical.
81 Scalar Vm = params.molarVolume(phaseIdx);
82
83 // Calculate b_i / b
84 Scalar bi_b = params.bPure(phaseIdx, compIdx) / params.b(phaseIdx);
85
86 // Calculate the compressibility factor
87 Scalar RT = Constants<Scalar>::R*fs.temperature(phaseIdx);
88 Scalar p = fs.pressure(phaseIdx); // molar volume in [bar]
89 Scalar Z = p*Vm/RT; // compressibility factor
90
91 // Calculate A^* and B^* (see: Reid, p. 42)
92 Scalar Astar = params.a(phaseIdx)*p/(RT*RT);
93 Scalar Bstar = params.b(phaseIdx)*p/(RT);
94
95 // calculate delta_i (see: Reid, p. 145)
96 Scalar sumMoleFractions = 0.0;
97 for (int compJIdx = 0; compJIdx < numComponents; ++compJIdx)
98 sumMoleFractions += fs.moleFraction(phaseIdx, compJIdx);
99
100 using std::sqrt;
101 Scalar deltai = 2*sqrt(params.aPure(phaseIdx, compIdx))/params.a(phaseIdx);
102 Scalar tmp = 0;
103 for (int compJIdx = 0; compJIdx < numComponents; ++compJIdx) {
104 tmp +=
105 fs.moleFraction(phaseIdx, compJIdx)
106 / sumMoleFractions
107 * sqrt(params.aPure(phaseIdx, compJIdx))
108 * (1.0 - StaticParameters::interactionCoefficient(compIdx, compJIdx));
109 }
110 deltai *= tmp;
111
112 Scalar base =
113 (2*Z + Bstar*(u + sqrt(u*u - 4*w))) /
114 (2*Z + Bstar*(u - sqrt(u*u - 4*w)));
115 Scalar expo = Astar/(Bstar*sqrt(u*u - 4*w))*(bi_b - deltai);
116
117 using std::exp;
118 using std::max;
119 using std::min;
120 using std::pow;
121 Scalar fugCoeff =
122 exp(bi_b*(Z - 1))/max(1e-9, Z - Bstar) *
123 pow(base, expo);
124
126 // limit the fugacity coefficient to a reasonable range:
127 //
128 // on one side, we want the mole fraction to be at
129 // least 10^-3 if the fugacity is at the current pressure
130 //
131
132 fugCoeff = min(1e10, fugCoeff);
133 //
134 // on the other hand, if the mole fraction of the component is 100%, we want the
135 // fugacity to be at least 10^-3 Pa
136 //
137 fugCoeff = max(1e-10, fugCoeff);
139 using std::isfinite;
140 if (!isfinite(fugCoeff)) {
141 std::cout << "Non finite phi: " << fugCoeff << "\n";
142 }
143
144 return fugCoeff;
145 }
146
147};
148
149template<class Scalar, class StaticParameters>
150const Scalar PengRobinsonMixture<Scalar, StaticParameters>::u = 2.0;
151template<class Scalar, class StaticParameters>
152const Scalar PengRobinsonMixture<Scalar, StaticParameters>::w = -1.0;
153
154} // end namespace Dumux
155
156#endif
Implements the Peng-Robinson equation of state for liquids and gases.
A central place for various physical constants occuring in some equations.
Definition: adapt.hh:29
A central place for various physical constants occuring in some equations.
Definition: constants.hh:39
Implements the Peng-Robinson equation of state for liquids and gases.
Definition: pengrobinson.hh:60
Implements the Peng-Robinson equation of state for a mixture.
Definition: pengrobinsonmixture.hh:41
static Scalar computeFugacityCoefficient(const FluidState &fs, const Params &params, int phaseIdx, int compIdx)
Returns the fugacity coefficient of an individual component in the phase.
Definition: pengrobinsonmixture.hh:73