3.4
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
pengrobinsonparamsmixture.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 *****************************************************************************/
35#ifndef DUMUX_PENG_ROBINSON_PARAMS_MIXTURE_HH
36#define DUMUX_PENG_ROBINSON_PARAMS_MIXTURE_HH
37
38#include <algorithm>
40
41#include "pengrobinsonparams.hh"
42
43namespace Dumux {
44
60template <class Scalar, class FluidSystem, int phaseIdx, bool useSpe5Relations=false>
62 : public PengRobinsonParams<Scalar>
63{
64 enum { numComponents = FluidSystem::numComponents };
65
66 // Peng-Robinson parameters for pure substances
68
69public:
75 template <class FluidState>
76 void updatePure(const FluidState &fluidState)
77 {
78 updatePure(fluidState.temperature(phaseIdx),
79 fluidState.pressure(phaseIdx));
80 }
81
88 void updatePure(Scalar temperature, Scalar pressure)
89 {
90 // Calculate the Peng-Robinson parameters of the pure
91 // components
92 //
93 // See: R. Reid, et al.: The Properties of Gases and Liquids,
94 // 4th edition, McGraw-Hill, 1987, p. 43
95 for (int i = 0; i < numComponents; ++i) {
96 Scalar pc = FluidSystem::criticalPressure(i);
97 Scalar omega = FluidSystem::acentricFactor(i);
98 Scalar Tr = temperature/FluidSystem::criticalTemperature(i);
99 Scalar RTc = Constants<Scalar>::R*FluidSystem::criticalTemperature(i);
100
101 Scalar f_omega;
102
103 if (useSpe5Relations) {
104 if (omega < 0.49) f_omega = 0.37464 + omega*(1.54226 + omega*(-0.26992));
105 else f_omega = 0.379642 + omega*(1.48503 + omega*(-0.164423 + omega*0.016666));
106 }
107 else
108 f_omega = 0.37464 + omega*(1.54226 - omega*0.26992);
109
110 using std::sqrt;
111 Scalar tmp = 1 + f_omega*(1 - sqrt(Tr));
112 tmp = tmp*tmp;
113
114 Scalar a = 0.4572355*RTc*RTc/pc * tmp;
115 Scalar b = 0.0777961 * RTc / pc;
116 using std::isfinite;
117 assert(isfinite(a));
118 assert(isfinite(b));
119
120 this->pureParams_[i].setA(a);
121 this->pureParams_[i].setB(b);
122 }
123
124 updateACache_();
125 }
126
135 template <class FluidState>
136 void updateMix(const FluidState &fs)
137 {
138 Scalar sumx = 0.0;
139 for (int compIdx = 0; compIdx < numComponents; ++compIdx)
140 sumx += fs.moleFraction(phaseIdx, compIdx);
141 using std::max;
142 sumx = max(1e-10, sumx);
143
144 // Calculate the Peng-Robinson parameters of the mixture
145 //
146 // See: R. Reid, et al.: The Properties of Gases and Liquids,
147 // 4th edition, McGraw-Hill, 1987, p. 82
148 Scalar a = 0;
149 Scalar b = 0;
150 for (int compIIdx = 0; compIIdx < numComponents; ++compIIdx) {
151 Scalar xi = fs.moleFraction(phaseIdx, compIIdx) / sumx;
152 using::std::isfinite;
153 for (int compJIdx = 0; compJIdx < numComponents; ++compJIdx) {
154 Scalar xj = fs.moleFraction(phaseIdx, compJIdx) / sumx;
155
156 // mixing rule from Reid, page 82
157 a += xi * xj * aCache_[compIIdx][compJIdx];
158
159 assert(isfinite(a));
160 }
161
162 // mixing rule from Reid, page 82
163 b += xi * this->pureParams_[compIIdx].b();
164 assert(isfinite(b));
165 }
166
167 this->setA(a);
168 this->setB(b);
169 }
170
181 template <class FluidState>
182 void updateSingleMoleFraction(const FluidState &fs,
183 int compIdx)
184 {
185 updateMix(fs);
186 }
187
192 const PureParams &pureParams(int compIdx) const
193 { return pureParams_[compIdx]; }
194
199 const PureParams &operator[](int compIdx) const
200 {
201 assert(0 <= compIdx && compIdx < numComponents);
202 return pureParams_[compIdx];
203 }
204
205protected:
206 PureParams pureParams_[numComponents];
207
208private:
209 void updateACache_()
210 {
211 for (int compIIdx = 0; compIIdx < numComponents; ++ compIIdx) {
212 for (int compJIdx = 0; compJIdx < numComponents; ++ compJIdx) {
213 // interaction coefficient as given in SPE5
214 Scalar Psi = FluidSystem::interactionCoefficient(compIIdx, compJIdx);
215 using std::sqrt;
216 aCache_[compIIdx][compJIdx] =
217 sqrt(this->pureParams_[compIIdx].a()
218 * this->pureParams_[compJIdx].a())
219 * (1 - Psi);
220 }
221 }
222 }
223
224 Scalar aCache_[numComponents][numComponents];
225};
226
227} // end namespace
228
229#endif
Base class for Peng-Robinson parameters of a single-component fluid or a mixture.
A central place for various physical constants occuring in some equations.
Definition: adapt.hh:29
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
A central place for various physical constants occuring in some equations.
Definition: constants.hh:39
Stores and provides access to the Peng-Robinson parameters.
Definition: pengrobinsonparams.hh:44
void setA(Scalar value)
Set the attractive parameter 'a' of the Peng-Robinson fluid.
Definition: pengrobinsonparams.hh:66
Scalar a() const
Returns the attractive parameter 'a' of the Peng-Robinson fluid.
Definition: pengrobinsonparams.hh:50
void setB(Scalar value)
Set the repulsive parameter 'b' of the Peng-Robinson fluid.
Definition: pengrobinsonparams.hh:74
Scalar b() const
Returns the repulsive parameter 'b' of the Peng-Robinson fluid.
Definition: pengrobinsonparams.hh:58
The mixing rule for the oil and the gas phases of the SPE5 problem.
Definition: pengrobinsonparamsmixture.hh:63
const PureParams & operator[](int compIdx) const
Returns the Peng-Robinson parameters for a pure component.
Definition: pengrobinsonparamsmixture.hh:199
void updateMix(const FluidState &fs)
Calculates the "a" and "b" Peng-Robinson parameters for the mixture.
Definition: pengrobinsonparamsmixture.hh:136
PureParams pureParams_[numComponents]
Definition: pengrobinsonparamsmixture.hh:206
const PureParams & pureParams(int compIdx) const
Return the Peng-Robinson parameters of a pure substance,.
Definition: pengrobinsonparamsmixture.hh:192
void updateSingleMoleFraction(const FluidState &fs, int compIdx)
Calculates the "a" and "b" Peng-Robinson parameters for the mixture provided that only a single mole ...
Definition: pengrobinsonparamsmixture.hh:182
void updatePure(Scalar temperature, Scalar pressure)
Peng-Robinson parameters for the pure components.
Definition: pengrobinsonparamsmixture.hh:88
void updatePure(const FluidState &fluidState)
Update Peng-Robinson parameters for the pure components.
Definition: pengrobinsonparamsmixture.hh:76