version 3.11-dev
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
spe5.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-FileCopyrightText: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5// SPDX-License-Identifier: GPL-3.0-or-later
6//
12#ifndef DUMUX_SPE5_FLUID_SYSTEM_HH
13#define DUMUX_SPE5_FLUID_SYSTEM_HH
14
15#include "spe5parametercache.hh"
16
19#include <dumux/io/name.hh>
20
21namespace Dumux::FluidSystems {
22
42template <class Scalar>
43class Spe5
44{
46
49
50public:
52
53 /****************************************
54 * Fluid phase parameters
55 ****************************************/
56
58 static const int numPhases = 3;
59
61 static const int gPhaseIdx = 0;
63 static const int wPhaseIdx = 1;
65 static const int oPhaseIdx = 2;
66
69
74 static std::string phaseName(int phaseIdx)
75 {
76 assert(0 <= phaseIdx && phaseIdx < numPhases);
77 switch (phaseIdx)
78 {
79 case gPhaseIdx: return IOName::gaseousPhase();
80 case wPhaseIdx: return IOName::aqueousPhase();
81 case oPhaseIdx: return IOName::naplPhase();
82 }
83 DUNE_THROW(Dune::InvalidStateException, "Invalid phase index " << phaseIdx);
84 }
85
89 static constexpr bool isMiscible()
90 { return true; }
91
96 static constexpr bool isGas(int phaseIdx)
97 {
98 assert(0 <= phaseIdx && phaseIdx < numPhases);
99 return phaseIdx == gPhaseIdx;
100 }
101
108 static constexpr bool isCompressible(int phaseIdx)
109 {
110 assert(0 <= phaseIdx && phaseIdx < numPhases);
111 return true;
112 }
113
127 static bool isIdealMixture(int phaseIdx)
128 {
129 // always use the reference oil for the fugacity coefficients,
130 // so they cannot be dependent on composition and they the
131 // phases thus always an ideal mixture
132 return phaseIdx == wPhaseIdx;
133 }
134
141 static bool isIdealGas(int phaseIdx)
142 {
143 assert(0 <= phaseIdx && phaseIdx < numPhases);
144 return false; // gas is not ideal here!
145 }
146
147 /****************************************
148 * Component related parameters
149 ****************************************/
150
152 static const int numComponents = 7;
153
154 static const int H2OIdx = 0;
155 static const int C1Idx = 1;
156 static const int C3Idx = 2;
157 static const int C6Idx = 3;
158 static const int C10Idx = 4;
159 static const int C15Idx = 5;
160 static const int C20Idx = 6;
161
166 static std::string componentName(int compIdx)
167 {
168 static std::string name[] = {
169 H2O::name(),
170 std::string("C1"),
171 std::string("C3"),
172 std::string("C6"),
173 std::string("C10"),
174 std::string("C15"),
175 std::string("C20")
176 };
177
178 assert(0 <= compIdx && compIdx < numComponents);
179 return name[compIdx];
180 }
181
186 static Scalar molarMass(int compIdx)
187 {
188 static const Scalar M[] = {
190 16.04e-3, // C1
191 44.10e-3, // C3
192 86.18e-3, // C6
193 142.29e-3, // C10
194 206.00e-3, // C15
195 282.00e-3 // C20
196 };
197
198 assert(0 <= compIdx && compIdx < numComponents);
199 return M[compIdx];
200 }
201
206 static Scalar criticalTemperature(int compIdx)
207 {
208 static const Scalar Tcrit[] = {
210 343.0*5/9, // C1
211 665.7*5/9, // C3
212 913.4*5/9, // C6
213 1111.8*5/9, // C10
214 1270.0*5/9, // C15
215 1380.0*5/9 // C20
216 };
217
218 assert(0 <= compIdx && compIdx < numComponents);
219 return Tcrit[compIdx];
220 }
221
226 static Scalar criticalPressure(int compIdx)
227 {
228 static const Scalar pcrit[] = {
229 H2O::criticalPressure(), // H2O
230 667.8 * 6894.7573, // C1
231 616.3 * 6894.7573, // C3
232 436.9 * 6894.7573, // C6
233 304.0 * 6894.7573, // C10
234 200.0 * 6894.7573, // C15
235 162.0 * 6894.7573 // C20
236 };
237
238 assert(0 <= compIdx && compIdx < numComponents);
239 return pcrit[compIdx];
240 }
241
246 static Scalar criticalMolarVolume(int compIdx)
247 {
248 static const Scalar R = 8.314472;
249 static const Scalar vcrit[] = {
251 0.290*R*criticalTemperature(1)/criticalPressure(1), // C1
252 0.277*R*criticalTemperature(2)/criticalPressure(2), // C3
253 0.264*R*criticalTemperature(3)/criticalPressure(3), // C6
254 0.257*R*criticalTemperature(4)/criticalPressure(4), // C10
255 0.245*R*criticalTemperature(5)/criticalPressure(5), // C15
256 0.235*R*criticalTemperature(6)/criticalPressure(6) // C20
257 };
258
259 assert(0 <= compIdx && compIdx < numComponents);
260 return vcrit[compIdx];
261 }
262
267 static Scalar acentricFactor(int compIdx)
268 {
269 static const Scalar accFac[] = {
270 0.344, // H2O (from Reid, et al.)
271 0.0130, // C1
272 0.1524, // C3
273 0.3007, // C6
274 0.4885, // C10
275 0.6500, // C15
276 0.8500 // C20
277 };
278
279 assert(0 <= compIdx && compIdx < numComponents);
280 return accFac[compIdx];
281 }
282
290 static Scalar interactionCoefficient(int comp1Idx, int comp2Idx)
291 {
292 using std::min;
293 using std::max;
294 int i = min(comp1Idx, comp2Idx);
295 int j = max(comp1Idx, comp2Idx);
296 if (i == C1Idx && (j == C15Idx || j == C20Idx))
297 return 0.05;
298 else if (i == C3Idx && (j == C15Idx || j == C20Idx))
299 return 0.005;
300 return 0;
301 }
302
303 /****************************************
304 * Methods which compute stuff
305 ****************************************/
306
310 static void init()
311 {
312 PengRobinsonParamsMixture<Scalar, ThisType, gPhaseIdx, /*useSpe5=*/true> prParams;
313
314 // find envelopes of the 'a' and 'b' parameters for the range
315 // 273.15K <= T <= 373.15K and 10e3 Pa <= p <= 100e6 Pa. For
316 // this we take advantage of the fact that 'a' and 'b' for
317 // mixtures is just a convex combination of the attractive and
318 // repulsive parameters of the pure components
319 Scalar minT = 273.15, maxT = 373.15;
320 Scalar minP = 1e4, maxP = 100e6;
321
322 Scalar minA = 1e100, maxA = -1e100;
323 Scalar minB = 1e100, maxB = -1e100;
324
325 prParams.updatePure(minT, minP);
326 using std::min;
327 using std::max;
328 for (int compIdx = 0; compIdx < numComponents; ++compIdx) {
329 minA = min(prParams.pureParams(compIdx).a(), minA);
330 maxA = max(prParams.pureParams(compIdx).a(), maxA);
331 minB = min(prParams.pureParams(compIdx).b(), minB);
332 maxB = max(prParams.pureParams(compIdx).b(), maxB);
333 }
334
335 prParams.updatePure(maxT, minP);
336 for (int compIdx = 0; compIdx < numComponents; ++compIdx) {
337 minA = min(prParams.pureParams(compIdx).a(), minA);
338 maxA = max(prParams.pureParams(compIdx).a(), maxA);
339 minB = min(prParams.pureParams(compIdx).b(), minB);
340 maxB = max(prParams.pureParams(compIdx).b(), maxB);
341 }
342
343 prParams.updatePure(minT, maxP);
344 for (int compIdx = 0; compIdx < numComponents; ++compIdx) {
345 minA = min(prParams.pureParams(compIdx).a(), minA);
346 maxA = max(prParams.pureParams(compIdx).a(), maxA);
347 minB = min(prParams.pureParams(compIdx).b(), minB);
348 maxB = max(prParams.pureParams(compIdx).b(), maxB);
349 }
350
351 prParams.updatePure(maxT, maxP);
352 for (int compIdx = 0; compIdx < numComponents; ++compIdx) {
353 minA = min(prParams.pureParams(compIdx).a(), minA);
354 maxA = max(prParams.pureParams(compIdx).a(), maxA);
355 minB = min(prParams.pureParams(compIdx).b(), minB);
356 maxB = max(prParams.pureParams(compIdx).b(), maxB);
357 }
358
359 PengRobinson::init(/*aMin=*/minA, /*aMax=*/maxA, /*na=*/100,
360 /*bMin=*/minB, /*bMax=*/maxB, /*nb=*/200);
361 }
362
371 template <class FluidState>
372 static Scalar density(const FluidState &fluidState,
373 const ParameterCache &paramCache,
374 int phaseIdx)
375 {
376 assert(0 <= phaseIdx && phaseIdx < numPhases);
377
378 return fluidState.averageMolarMass(phaseIdx)/paramCache.molarVolume(phaseIdx);
379 }
380
390 template <class FluidState>
391 static Scalar molarDensity(const FluidState &fluidState, const ParameterCache &paramCache, int phaseIdx)
392 {
393 return 1.0/paramCache.molarVolume(phaseIdx);
394 }
395
402 template <class FluidState>
403 static Scalar viscosity(const FluidState &fs,
404 const ParameterCache &paramCache,
405 int phaseIdx)
406 {
407 assert(0 <= phaseIdx && phaseIdx <= numPhases);
408
409 if (phaseIdx == gPhaseIdx) {
410 // given by SPE-5 in table on page 64. we use a constant
411 // viscosity, though...
412 return 0.0170e-2 * 0.1;
413 }
414 else if (phaseIdx == wPhaseIdx)
415 // given by SPE-5: 0.7 centi-Poise = 0.0007 Pa s
416 return 0.7e-2 * 0.1;
417 else {
418 assert(phaseIdx == oPhaseIdx);
419 // given by SPE-5 in table on page 64. we use a constant
420 // viscosity, though...
421 return 0.208e-2 * 0.1;
422 }
423 }
424
440 template <class FluidState>
441 static Scalar fugacityCoefficient(const FluidState &fs,
442 const ParameterCache &paramCache,
443 int phaseIdx,
444 int compIdx)
445 {
446 assert(0 <= phaseIdx && phaseIdx <= numPhases);
447 assert(0 <= compIdx && compIdx <= numComponents);
448
449 if (phaseIdx == oPhaseIdx || phaseIdx == gPhaseIdx)
451 paramCache,
452 phaseIdx,
453 compIdx);
454 else {
455 assert(phaseIdx == wPhaseIdx);
456 return henryCoeffWater_(compIdx, fs.temperature(wPhaseIdx))
457 / fs.pressure(wPhaseIdx);
458 }
459 }
460
461
485 template <class FluidState>
486 static Scalar diffusionCoefficient(const FluidState &fs,
487 const ParameterCache &paramCache,
488 int phaseIdx,
489 int compIdx)
490 { DUNE_THROW(Dune::NotImplemented, "Diffusion coefficients"); }
491
503 template <class FluidState>
504 static Scalar binaryDiffusionCoefficient(const FluidState &fluidState,
505 const ParameterCache &paramCache,
506 int phaseIdx,
507 int compIIdx,
508 int compJIdx)
509 { DUNE_THROW(Dune::NotImplemented, "Binary diffusion coefficients"); }
510
518 template <class FluidState>
519 static Scalar enthalpy(const FluidState &fs,
520 const ParameterCache &paramCache,
521 int phaseIdx)
522 { DUNE_THROW(Dune::NotImplemented, "Enthalpies"); }
523
531 template <class FluidState>
532 static Scalar thermalConductivity(const FluidState &fluidState,
533 const ParameterCache &paramCache,
534 int phaseIdx)
535 { DUNE_THROW(Dune::NotImplemented, "Thermal conductivities"); }
536
544 template <class FluidState>
545 static Scalar heatCapacity(const FluidState &fluidState,
546 const ParameterCache &paramCache,
547 int phaseIdx)
548 { DUNE_THROW(Dune::NotImplemented, "Heat capacities"); }
549
550
551private:
552 static Scalar henryCoeffWater_(int compIdx, Scalar temperature)
553 {
554 // use henry's law for the solutes and the vapor pressure for
555 // the solvent.
556 switch (compIdx) {
558
559 // the values of the Henry constant for the solutes have
560 // are faked so far...
561 case C1Idx: return 5.57601e+09;
562 case C3Idx: return 1e10;
563 case C6Idx: return 1e10;
564 case C10Idx: return 1e10;
565 case C15Idx: return 1e10;
566 case C20Idx: return 1e10;
567 default: DUNE_THROW(Dune::InvalidStateException, "Unknown component index " << compIdx);
568 }
569 }
570};
571
572} // end namespace Dumux::FluidSystems
573
574#endif
Material properties of pure water .
Definition: h2o.hh:48
static Scalar vaporPressure(Scalar T)
The vapor pressure in of pure water at a given temperature.
Definition: h2o.hh:118
static constexpr Scalar criticalTemperature()
Returns the critical temperature of water.
Definition: h2o.hh:80
static std::string name()
A human readable name for the water.
Definition: h2o.hh:62
static constexpr Scalar molarMass()
The molar mass in of water.
Definition: h2o.hh:68
static constexpr Scalar criticalPressure()
Returns the critical pressure of water.
Definition: h2o.hh:86
static constexpr Scalar criticalMolarVolume()
Returns the molar volume of water at the critical point.
Definition: h2o.hh:92
The fluid system for the SPE-5 benchmark problem.
Definition: spe5.hh:44
static Scalar molarDensity(const FluidState &fluidState, const ParameterCache &paramCache, int phaseIdx)
The molar density of a fluid phase in .
Definition: spe5.hh:391
static bool isIdealMixture(int phaseIdx)
Returns true if and only if a fluid phase is assumed to be an ideal mixture.
Definition: spe5.hh:127
static Scalar criticalTemperature(int compIdx)
Critical temperature of a component .
Definition: spe5.hh:206
static const int C15Idx
Definition: spe5.hh:159
static Scalar binaryDiffusionCoefficient(const FluidState &fluidState, const ParameterCache &paramCache, int phaseIdx, int compIIdx, int compJIdx)
Given a phase's composition, temperature and pressure, return the binary diffusion coefficient for c...
Definition: spe5.hh:504
static Scalar heatCapacity(const FluidState &fluidState, const ParameterCache &paramCache, int phaseIdx)
Given a phase's composition, temperature and pressure, calculate its heat capacity .
Definition: spe5.hh:545
static const int C3Idx
Definition: spe5.hh:156
static Scalar fugacityCoefficient(const FluidState &fs, const ParameterCache &paramCache, int phaseIdx, int compIdx)
Calculate the fugacity coefficient of an individual component in a fluid phase.
Definition: spe5.hh:441
static Scalar thermalConductivity(const FluidState &fluidState, const ParameterCache &paramCache, int phaseIdx)
Given a phase's composition, temperature and pressure, calculate its thermal conductivity .
Definition: spe5.hh:532
static const int H2OIdx
Definition: spe5.hh:154
static std::string componentName(int compIdx)
Return the human readable name of a component.
Definition: spe5.hh:166
static Scalar diffusionCoefficient(const FluidState &fs, const ParameterCache &paramCache, int phaseIdx, int compIdx)
Calculate the binary molecular diffusion coefficient for a component in a fluid phase .
Definition: spe5.hh:486
static const int C6Idx
Definition: spe5.hh:157
static const int C20Idx
Definition: spe5.hh:160
static Scalar molarMass(int compIdx)
Return the molar mass of a component in .
Definition: spe5.hh:186
static constexpr bool isMiscible()
Returns whether the fluids are miscible.
Definition: spe5.hh:89
static bool isIdealGas(int phaseIdx)
Returns true if and only if a fluid phase is assumed to be an ideal gas.
Definition: spe5.hh:141
static const int C1Idx
Definition: spe5.hh:155
static const int numComponents
Number of components in the fluid system.
Definition: spe5.hh:152
static const int oPhaseIdx
Index of the oil phase.
Definition: spe5.hh:65
static Scalar density(const FluidState &fluidState, const ParameterCache &paramCache, int phaseIdx)
Calculate the density of a fluid phase.
Definition: spe5.hh:372
static const int C10Idx
Definition: spe5.hh:158
static Scalar acentricFactor(int compIdx)
The acentric factor of a component .
Definition: spe5.hh:267
static const int gPhaseIdx
Index of the gas phase.
Definition: spe5.hh:61
static Scalar viscosity(const FluidState &fs, const ParameterCache &paramCache, int phaseIdx)
Calculate the dynamic viscosity of a fluid phase .
Definition: spe5.hh:403
static void init()
Initialize the fluid system's static parameters.
Definition: spe5.hh:310
static Scalar interactionCoefficient(int comp1Idx, int comp2Idx)
Returns the interaction coefficient for two components.
Definition: spe5.hh:290
static const int numPhases
Number of phases in the fluid system.
Definition: spe5.hh:58
static std::string phaseName(int phaseIdx)
Return the human readable name of a fluid phase.
Definition: spe5.hh:74
static const int wPhaseIdx
Index of the water phase.
Definition: spe5.hh:63
static constexpr bool isGas(int phaseIdx)
Return whether a phase is gaseous.
Definition: spe5.hh:96
static Scalar criticalPressure(int compIdx)
Critical pressure of a component .
Definition: spe5.hh:226
static Scalar criticalMolarVolume(int compIdx)
Molar volume of a component at the critical point .
Definition: spe5.hh:246
static Scalar enthalpy(const FluidState &fs, const ParameterCache &paramCache, int phaseIdx)
Given a phase's composition, temperature and pressure, calculate its specific enthalpy .
Definition: spe5.hh:519
static constexpr bool isCompressible(int phaseIdx)
Return whether a phase is compressible.
Definition: spe5.hh:108
Implements the Peng-Robinson equation of state for liquids and gases.
Definition: pengrobinson.hh:48
static void init(Scalar aMin, Scalar aMax, int na, Scalar bMin, Scalar bMax, int nb)
Definition: pengrobinson.hh:53
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
Scalar a() const
Returns the attractive parameter 'a' of the Peng-Robinson fluid.
Definition: pengrobinsonparams.hh:38
Scalar b() const
Returns the repulsive parameter 'b' of the Peng-Robinson fluid.
Definition: pengrobinsonparams.hh:46
The mixing rule for the oil and the gas phases of the SPE5 problem.
Definition: pengrobinsonparamsmixture.hh:51
const PureParams & pureParams(int compIdx) const
Return the Peng-Robinson parameters of a pure substance,.
Definition: pengrobinsonparamsmixture.hh:180
void updatePure(const FluidState &fluidState)
Update Peng-Robinson parameters for the pure components.
Definition: pengrobinsonparamsmixture.hh:64
Specifies the parameters required by the SPE5 problem which are despondent on the thermodynamic state...
Definition: spe5parametercache.hh:33
Scalar molarVolume(int phaseIdx) const
Returns the molar volume of a phase .
Definition: spe5parametercache.hh:186
A collection of input/output field names for common physical quantities.
Definition: h2o.hh:901
std::string temperature() noexcept
I/O name of temperature for equilibrium models.
Definition: name.hh:39
std::string gaseousPhase() noexcept
I/O name of gaseous phase.
Definition: name.hh:111
std::string naplPhase() noexcept
I/O name of napl phase.
Definition: name.hh:119
std::string aqueousPhase() noexcept
I/O name of aqueous phase.
Definition: name.hh:115
Implements the Peng-Robinson equation of state for a mixture.
Specifies the parameters required by the SPE5 problem which are despondent on the thermodynamic state...
Provides 3rd order polynomial splines.