version 3.8
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// SPDX-FileCopyrightInfo: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5// SPDX-License-Identifier: GPL-3.0-or-later
6//
13#ifndef DUMUX_PENG_ROBINSON_MIXTURE_HH
14#define DUMUX_PENG_ROBINSON_MIXTURE_HH
15
16#include "pengrobinson.hh"
17
19
20namespace Dumux {
21
27template <class Scalar, class StaticParameters>
29{
30 enum { numComponents = StaticParameters::numComponents };
32
33 // this class cannot be instantiated!
35
36 // the u and w parameters as given by the Peng-Robinson EOS
37 static const Scalar u;
38 static const Scalar w;
39
40public:
41
60 template <class FluidState, class Params>
61 static Scalar computeFugacityCoefficient(const FluidState &fs,
62 const Params &params,
63 int phaseIdx,
64 int compIdx)
65 {
66 // note that we normalize the component mole fractions, so
67 // that their sum is 100%. This increases numerical stability
68 // considerably if the fluid state is not physical.
69 Scalar Vm = params.molarVolume(phaseIdx);
70
71 // Calculate b_i / b
72 Scalar bi_b = params.bPure(phaseIdx, compIdx) / params.b(phaseIdx);
73
74 // Calculate the compressibility factor
75 Scalar RT = Constants<Scalar>::R*fs.temperature(phaseIdx);
76 Scalar p = fs.pressure(phaseIdx); // molar volume in [bar]
77 Scalar Z = p*Vm/RT; // compressibility factor
78
79 // Calculate A^* and B^* (see: Reid, p. 42)
80 Scalar Astar = params.a(phaseIdx)*p/(RT*RT);
81 Scalar Bstar = params.b(phaseIdx)*p/(RT);
82
83 // calculate delta_i (see: Reid, p. 145)
84 Scalar sumMoleFractions = 0.0;
85 for (int compJIdx = 0; compJIdx < numComponents; ++compJIdx)
86 sumMoleFractions += fs.moleFraction(phaseIdx, compJIdx);
87
88 using std::sqrt;
89 Scalar deltai = 2*sqrt(params.aPure(phaseIdx, compIdx))/params.a(phaseIdx);
90 Scalar tmp = 0;
91 for (int compJIdx = 0; compJIdx < numComponents; ++compJIdx) {
92 tmp +=
93 fs.moleFraction(phaseIdx, compJIdx)
94 / sumMoleFractions
95 * sqrt(params.aPure(phaseIdx, compJIdx))
96 * (1.0 - StaticParameters::interactionCoefficient(compIdx, compJIdx));
97 }
98 deltai *= tmp;
99
100 Scalar base =
101 (2*Z + Bstar*(u + sqrt(u*u - 4*w))) /
102 (2*Z + Bstar*(u - sqrt(u*u - 4*w)));
103 Scalar expo = Astar/(Bstar*sqrt(u*u - 4*w))*(bi_b - deltai);
104
105 using std::exp;
106 using std::max;
107 using std::min;
108 using std::pow;
109 Scalar fugCoeff =
110 exp(bi_b*(Z - 1))/max(1e-9, Z - Bstar) *
111 pow(base, expo);
112
114 // limit the fugacity coefficient to a reasonable range:
115 //
116 // on one side, we want the mole fraction to be at
117 // least 10^-3 if the fugacity is at the current pressure
118 //
119
120 fugCoeff = min(1e10, fugCoeff);
121 //
122 // on the other hand, if the mole fraction of the component is 100%, we want the
123 // fugacity to be at least 10^-3 Pa
124 //
125 fugCoeff = max(1e-10, fugCoeff);
127 using std::isfinite;
128 if (!isfinite(fugCoeff)) {
129 std::cout << "Non finite phi: " << fugCoeff << "\n";
130 }
131
132 return fugCoeff;
133 }
134
135};
136
137template<class Scalar, class StaticParameters>
138const Scalar PengRobinsonMixture<Scalar, StaticParameters>::u = 2.0;
139template<class Scalar, class StaticParameters>
140const Scalar PengRobinsonMixture<Scalar, StaticParameters>::w = -1.0;
141
142} // end namespace Dumux
143
144#endif
A central place for various physical constants occurring in some equations.
Definition: constants.hh:27
Implements the Peng-Robinson equation of state for liquids and gases.
Definition: pengrobinson.hh:48
Implements the Peng-Robinson equation of state for a mixture.
Definition: pengrobinsonmixture.hh:29
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:61
A central place for various physical constants occurring in some equations.
Definition: adapt.hh:17
Implements the Peng-Robinson equation of state for liquids and gases.