version 3.8
h2oheavyoil.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//
12#ifndef DUMUX_H2O_HEAVYOIL_FLUID_SYSTEM_HH
13#define DUMUX_H2O_HEAVYOIL_FLUID_SYSTEM_HH
14
19
21
23
24#include <dumux/io/name.hh>
25
26namespace Dumux {
27namespace FluidSystems {
28
34template <class Scalar,
37 : public Base<Scalar, H2OHeavyOil<Scalar, H2OType> >
38{
40
41public:
43 using H2O = H2OType;
44
45
46 static const int numPhases = 3;
47 static const int numComponents = 2;
48
49 static const int wPhaseIdx = 0; // index of the water phase
50 static const int nPhaseIdx = 1; // index of the NAPL phase
51 static const int gPhaseIdx = 2; // index of the gas phase
52
53 static const int H2OIdx = 0;
54 static const int NAPLIdx = 1;
55
56 // export component indices to indicate the main component
57 // of the corresponding phase at atmospheric pressure 1 bar
58 // and room temperature 20°C:
59 static const int wCompIdx = H2OIdx;
60 static const int nCompIdx = NAPLIdx;
61
68 static void init()
69 {
70 init(/*tempMin=*/273.15,
71 /*tempMax=*/623.15,
72 /*numTemp=*/100,
73 /*pMin=*/0.0,
74 /*pMax=*/20e6,
75 /*numP=*/200);
76 }
77
89 static void init(Scalar tempMin, Scalar tempMax, unsigned nTemp,
90 Scalar pressMin, Scalar pressMax, unsigned nPress)
91 {
92 if (H2O::isTabulated)
93 {
94 H2O::init(tempMin, tempMax, nTemp,
95 pressMin, pressMax, nPress);
96 }
97 }
98
103 static constexpr int getMainComponent(int phaseIdx)
104 {
105 // For the gas phase, choosing a main component appears to be
106 // rather arbitrary. Motivated by the fact that the thermal conductivity
107 // of the gas phase is set to the thermal conductivity of pure water,
108 // water is chosen for now.
109 if (phaseIdx == nPhaseIdx)
110 return nCompIdx;
111 else
112 return wCompIdx;
113 }
114
118 static constexpr bool isMiscible()
119 { return true; }
120
126 static constexpr bool isGas(int phaseIdx)
127 {
128 assert(0 <= phaseIdx && phaseIdx < numPhases);
129 return phaseIdx == gPhaseIdx;
130 }
131
138 static bool isIdealGas(int phaseIdx)
139 { return phaseIdx == gPhaseIdx && H2O::gasIsIdeal() && HeavyOil::gasIsIdeal(); }
140
155 static bool isIdealMixture(int phaseIdx)
156 {
157 assert(0 <= phaseIdx && phaseIdx < numPhases);
158 // we assume Henry's and Raoult's laws for the water phase and
159 // and no interaction between gas molecules of different
160 // components, so all phases are ideal mixtures!
161 return true;
162 }
163
173 static constexpr bool isCompressible(int phaseIdx)
174 {
175 assert(0 <= phaseIdx && phaseIdx < numPhases);
176 // gases are always compressible
177 if (phaseIdx == gPhaseIdx)
178 return true;
179 else if (phaseIdx == wPhaseIdx)
180 // the water component decides for the water phase...
181 return H2O::liquidIsCompressible();
182
183 // the NAPL component decides for the napl phase...
185 }
186
190 static std::string phaseName(int phaseIdx)
191 {
192 assert(0 <= phaseIdx && phaseIdx < numPhases);
193 switch (phaseIdx)
194 {
195 case wPhaseIdx: return IOName::aqueousPhase();
196 case nPhaseIdx: return IOName::naplPhase();
197 case gPhaseIdx: return IOName::gaseousPhase();
198 }
199 DUNE_THROW(Dune::InvalidStateException, "Invalid phase index " << phaseIdx);
200 }
201
205 static std::string componentName(int compIdx)
206 {
207 switch (compIdx) {
208 case H2OIdx: return H2O::name();
209 case NAPLIdx: return HeavyOil::name();
210 };
211 DUNE_THROW(Dune::InvalidStateException, "Invalid component index " << compIdx);
212 }
213
217 static Scalar molarMass(int compIdx)
218 {
219 switch (compIdx) {
220 case H2OIdx: return H2O::molarMass();
221 case NAPLIdx: return HeavyOil::molarMass();
222 };
223 DUNE_THROW(Dune::InvalidStateException, "Invalid component index " << compIdx);
224 }
225
228 template <class FluidState>
229 static Scalar density(const FluidState &fluidState, int phaseIdx)
230 {
231 if (phaseIdx == wPhaseIdx) {
232 // See: doctoral thesis of Steffen Ochs 2007
233 // Steam injection into saturated porous media : process analysis including experimental and numerical investigations
234 // http://elib.uni-stuttgart.de/bitstream/11682/271/1/Diss_Ochs_OPUS.pdf
235
236 // This assumes each gas molecule displaces exactly one
237 // molecule in the liquid.
238
239 return H2O::liquidMolarDensity(fluidState.temperature(phaseIdx), fluidState.pressure(phaseIdx))
240 * (H2O::molarMass()*fluidState.moleFraction(wPhaseIdx, H2OIdx)
241 + HeavyOil::molarMass()*fluidState.moleFraction(wPhaseIdx, NAPLIdx));
242 }
243 else if (phaseIdx == nPhaseIdx) {
244 // assume pure NAPL for the NAPL phase
245 Scalar pressure = HeavyOil::liquidIsCompressible()?fluidState.pressure(phaseIdx):1e100;
246 return HeavyOil::liquidDensity(fluidState.temperature(phaseIdx), pressure);
247 }
248
249 assert (phaseIdx == gPhaseIdx);
250 Scalar pH2O =
251 fluidState.moleFraction(gPhaseIdx, H2OIdx) *
252 fluidState.pressure(gPhaseIdx);
253 Scalar pNAPL =
254 fluidState.moleFraction(gPhaseIdx, NAPLIdx) *
255 fluidState.pressure(gPhaseIdx);
256 return H2O::gasDensity(fluidState.temperature(phaseIdx), pH2O)
257 + HeavyOil::gasDensity(fluidState.temperature(phaseIdx), pNAPL);
258 }
259
262 template <class FluidState>
263 static Scalar molarDensity(const FluidState &fluidState, int phaseIdx)
264 {
265 Scalar temperature = fluidState.temperature(phaseIdx);
266 Scalar pressure = fluidState.pressure(phaseIdx);
267 if (phaseIdx == nPhaseIdx)
268 {
270 }
271 else if (phaseIdx == wPhaseIdx)
272 { // This assumes each gas molecule displaces exactly one
273 // molecule in the liquid.
274 return H2O::liquidMolarDensity(temperature, pressure);
275 }
276 else
277 {
278 return H2O::gasMolarDensity(temperature, fluidState.partialPressure(gPhaseIdx, H2OIdx))
279 + HeavyOil::gasMolarDensity(temperature, fluidState.partialPressure(gPhaseIdx, NAPLIdx));
280 }
281 }
282
285 template <class FluidState>
286 static Scalar viscosity(const FluidState &fluidState,
287 int phaseIdx)
288 {
289 if (phaseIdx == wPhaseIdx) {
290 // assume pure water viscosity
291 return H2O::liquidViscosity(fluidState.temperature(phaseIdx),
292 fluidState.pressure(phaseIdx));
293 }
294 else if (phaseIdx == nPhaseIdx) {
295 // assume pure NAPL viscosity
296 return HeavyOil::liquidViscosity(fluidState.temperature(phaseIdx),
297 fluidState.pressure(phaseIdx));
298 }
299
300 assert (phaseIdx == gPhaseIdx);
301
302 /* Wilke method. See:
303 *
304 * See: R. Reid, et al.: The Properties of Gases and Liquids,
305 * 4th edition, McGraw-Hill, 1987, 407-410
306 * 5th edition, McGraw-Hill, 20001, p. 9.21/22
307 *
308 * in this case, we use a simplified version in order to avoid
309 * computationally costly evaluation of sqrt and pow functions and
310 * divisions
311 * -- compare e.g. with Promo Class p. 32/33
312 */
313 const Scalar mu[numComponents] = {
314 h2oGasViscosityInMixture(fluidState.temperature(phaseIdx), fluidState.pressure(phaseIdx)),
315 HeavyOil::gasViscosity(fluidState.temperature(phaseIdx), HeavyOil::vaporPressure(fluidState.temperature(phaseIdx)))
316 };
317
318 return mu[H2OIdx]*fluidState.moleFraction(gPhaseIdx, H2OIdx)
319 + mu[NAPLIdx]*fluidState.moleFraction(gPhaseIdx, NAPLIdx);
320 }
321
337 template <class FluidState>
338 static Scalar binaryDiffusionCoefficient(const FluidState &fluidState,
339 int phaseIdx,
340 int compIIdx,
341 int compJIdx)
342
343 {
344 const Scalar T = fluidState.temperature(phaseIdx);
345 const Scalar p = fluidState.pressure(phaseIdx);
346
347 // liquid phase
348 if (phaseIdx == wPhaseIdx)
350
351 // gas phase
352 else if (phaseIdx == gPhaseIdx)
354 else
355 DUNE_THROW(Dune::InvalidStateException,
356 "Non-existent binary diffusion coefficient for phase index "
357 << phaseIdx);
358 }
359
369 template <class FluidState>
370 static Scalar diffusionCoefficient(const FluidState &fluidState, int phaseIdx)
371 {
372 // liquid phase
373 if (phaseIdx == wPhaseIdx)
374 return binaryDiffusionCoefficient(fluidState, phaseIdx, H2OIdx, NAPLIdx);
375 // gas phase
376 else if (phaseIdx == gPhaseIdx)
377 return binaryDiffusionCoefficient(fluidState, phaseIdx, NAPLIdx, H2OIdx);
378 else
379 DUNE_THROW(Dune::InvalidStateException,
380 "Non-existent diffusion coefficient for phase index "<< phaseIdx);
381 }
382
389 template <class FluidState>
390 static Scalar henryCoefficient(const FluidState &fluidState,
391 int phaseIdx,
392 int compIdx)
393 {
394 assert(0 <= phaseIdx && phaseIdx < numPhases);
395 assert(0 <= compIdx && compIdx < numComponents);
396
397 const Scalar T = fluidState.temperature(phaseIdx);
398
399 if (compIdx == NAPLIdx && phaseIdx == wPhaseIdx)
401
402 else if (phaseIdx == nPhaseIdx && compIdx == H2OIdx)
404
405 else
406 DUNE_THROW(Dune::InvalidStateException, "non-existent henry coefficient for phase index " << phaseIdx
407 << " and component index " << compIdx);
408 }
409
416 template <class FluidState>
417 static Scalar partialPressureGas(const FluidState &fluidState, int phaseIdx,
418 int compIdx)
419 {
420 assert(0 <= compIdx && compIdx < numComponents);
421
422 const Scalar T = fluidState.temperature(phaseIdx);
423 if (compIdx == NAPLIdx)
424 return HeavyOil::vaporPressure(T);
425 else if (compIdx == H2OIdx)
426 return H2O::vaporPressure(T);
427 else
428 DUNE_THROW(Dune::InvalidStateException, "non-existent component index " << compIdx);
429 }
430
437 template <class FluidState>
438 static Scalar inverseVaporPressureCurve(const FluidState &fluidState,
439 int phaseIdx,
440 int compIdx)
441 {
442 assert(0 <= compIdx && compIdx < numComponents);
443
444 const Scalar pressure = fluidState.pressure(phaseIdx);
445 if (compIdx == NAPLIdx)
447 else if (compIdx == H2OIdx)
448 return H2O::vaporTemperature(pressure);
449 else
450 DUNE_THROW(Dune::InvalidStateException, "non-existent component index " << compIdx);
451 }
452
463 template <class FluidState>
464 static Scalar enthalpy(const FluidState &fluidState,
465 int phaseIdx)
466 {
467 if (phaseIdx == wPhaseIdx) {
468 return H2O::liquidEnthalpy(fluidState.temperature(phaseIdx), fluidState.pressure(phaseIdx));
469 }
470 else if (phaseIdx == nPhaseIdx) {
471 return HeavyOil::liquidEnthalpy(fluidState.temperature(phaseIdx), fluidState.pressure(phaseIdx));
472 }
473 else if (phaseIdx == gPhaseIdx) { // gas phase enthalpy depends strongly on composition
474 Scalar hgc = HeavyOil::gasEnthalpy(fluidState.temperature(phaseIdx),
475 fluidState.pressure(phaseIdx));
476 Scalar hgw = H2O::gasEnthalpy(fluidState.temperature(phaseIdx),
477 fluidState.pressure(phaseIdx));
478
479 Scalar result = 0;
480 result += hgw * fluidState.massFraction(gPhaseIdx, H2OIdx);
481 result += hgc * fluidState.massFraction(gPhaseIdx, NAPLIdx);
482
483 return result;
484 }
485 DUNE_THROW(Dune::InvalidStateException, "Invalid phase index " << phaseIdx);
486 }
487
494 template <class FluidState>
495 static Scalar componentEnthalpy(const FluidState& fluidState, int phaseIdx, int componentIdx)
496 {
497 const Scalar T = fluidState.temperature(phaseIdx);
498 const Scalar p = fluidState.pressure(phaseIdx);
499
500 if (phaseIdx == wPhaseIdx)
501 {
502 if (componentIdx == H2OIdx)
503 return H2O::liquidEnthalpy(T, p);
504 else if (componentIdx == NAPLIdx)
505 DUNE_THROW(Dune::NotImplemented, "The component enthalpy for NAPL in water is not implemented.");
506 DUNE_THROW(Dune::InvalidStateException, "Invalid component index " << componentIdx);
507 }
508 else if (phaseIdx == nPhaseIdx)
509 {
510 if (componentIdx == H2OIdx)
511 DUNE_THROW(Dune::NotImplemented, "The component enthalpy for water in NAPL is not implemented.");
512 else if (componentIdx == NAPLIdx)
513 return HeavyOil::liquidEnthalpy(T, p);
514 DUNE_THROW(Dune::InvalidStateException, "Invalid component index " << componentIdx);
515 }
516 else if (phaseIdx == gPhaseIdx)
517 {
518 if (componentIdx == H2OIdx)
519 return H2O::gasEnthalpy(T, p);
520 else if (componentIdx == NAPLIdx)
521 return HeavyOil::gasEnthalpy(T, p);
522 DUNE_THROW(Dune::InvalidStateException, "Invalid component index " << componentIdx);
523 }
524 DUNE_THROW(Dune::InvalidStateException, "Invalid phase index " << phaseIdx);
525 }
526
529 template <class FluidState>
530 static Scalar heatCapacity(const FluidState &fluidState,
531 int phaseIdx)
532 {
533 DUNE_THROW(Dune::NotImplemented, "FluidSystems::H2ONAPL::heatCapacity()");
534 }
535
545 template <class FluidState>
546 static Scalar thermalConductivity(const FluidState &fluidState,
547 int phaseIdx)
548 {
549 const Scalar temperature = fluidState.temperature(phaseIdx) ;
550 const Scalar pressure = fluidState.pressure(phaseIdx);
551 if (phaseIdx == wPhaseIdx)
552 {
553 return H2O::liquidThermalConductivity(temperature, pressure);
554 }
555 else if (phaseIdx == nPhaseIdx)
556 {
558 }
559 else if (phaseIdx == gPhaseIdx)
560 {
561 return H2O::gasThermalConductivity(temperature, pressure);
562 }
563 DUNE_THROW(Dune::InvalidStateException, "Invalid phase index " << phaseIdx);
564 }
565
566};
567} // end namespace FluidSystems
568} // end namespace Dumux
569
570#endif
static Scalar liquidDiffCoeff(Scalar temperature, Scalar pressure)
Diffusion coefficient [m^2/s] for heavy oil in liquid water.
Definition: h2o_heavyoil.hh:78
static Scalar gasDiffCoeff(Scalar temperature, Scalar pressure)
Binary diffusion coefficient [m^2/s] for molecular water and heavy oil.
Definition: h2o_heavyoil.hh:65
static Scalar henryOilInWater(Scalar temperature)
Henry coefficient for heavy oil in liquid water.
Definition: h2o_heavyoil.hh:35
static Scalar henryWaterInOil(Scalar temperature)
Henry coefficient for water in liquid heavy oil.
Definition: h2o_heavyoil.hh:50
Properties of the component heavyoil.
Definition: heavyoil.hh:38
static Scalar liquidViscosity(Scalar temperature, Scalar pressure)
The dynamic viscosity of pure heavyoil.
Definition: heavyoil.hh:422
static constexpr Scalar molarMass()
The molar mass in of heavyoil.
Definition: heavyoil.hh:51
static Scalar vaporPressure(Scalar temperature)
The saturation vapor pressure in of.
Definition: heavyoil.hh:219
static constexpr bool gasIsIdeal()
Returns true if the gas phase is assumed to be ideal.
Definition: heavyoil.hh:378
static Scalar liquidMolarDensity(Scalar temperature, Scalar pressure)
The molar density of pure heavyoil in at a given pressure and temperature.
Definition: heavyoil.hh:366
static Scalar gasMolarDensity(Scalar temperature, Scalar pressure)
The molar density of pure heavyoil in , depending on pressure and temperature.
Definition: heavyoil.hh:339
static Scalar gasViscosity(Scalar temperature, Scalar pressure)
The dynamic viscosity of heavyoil vapor.
Definition: heavyoil.hh:393
static Scalar vaporTemperature(Scalar pressure)
Definition: heavyoil.hh:231
static Scalar liquidThermalConductivity(Scalar temperature, Scalar pressure)
Thermal conductivity of heavy oil.
Definition: heavyoil.hh:463
static Scalar gasDensity(Scalar temperature, Scalar pressure)
The (ideal) gas density of heavyoil vapor at a given temperature and pressure .
Definition: heavyoil.hh:328
static constexpr bool liquidIsCompressible()
Returns true if the liquid phase is assumed to be compressible.
Definition: heavyoil.hh:384
static Scalar liquidEnthalpy(const Scalar temperature, const Scalar pressure)
Specific enthalpy of liquid heavyoil .
Definition: heavyoil.hh:249
static std::string name()
A human readable name for heavyoil.
Definition: heavyoil.hh:45
static Scalar gasEnthalpy(Scalar temperature, Scalar pressure)
Specific enthalpy of heavyoil vapor .
Definition: heavyoil.hh:317
static Scalar liquidDensity(Scalar temperature, Scalar pressure)
The density of pure heavyoil at a given pressure and temperature .
Definition: heavyoil.hh:348
Tabulates all thermodynamic properties of a given component.
Definition: tabulatedcomponent.hh:672
Fluid system base class.
Definition: fluidsystems/base.hh:33
A compositional fluid system with water and heavy oil components in both the liquid and the gas phase...
Definition: h2oheavyoil.hh:38
static Scalar henryCoefficient(const FluidState &fluidState, int phaseIdx, int compIdx)
Henry coefficients of a component in a phase.
Definition: h2oheavyoil.hh:390
static constexpr bool isCompressible(int phaseIdx)
Returns true if and only if a fluid phase is assumed to be compressible.
Definition: h2oheavyoil.hh:173
static const int gPhaseIdx
Definition: h2oheavyoil.hh:51
static std::string componentName(int compIdx)
Return the human readable name of a component (used in indices)
Definition: h2oheavyoil.hh:205
static const int wCompIdx
Definition: h2oheavyoil.hh:59
static Scalar molarDensity(const FluidState &fluidState, int phaseIdx)
Calculate the molar density of a fluid phase.
Definition: h2oheavyoil.hh:263
static bool isIdealMixture(int phaseIdx)
Returns true if and only if a fluid phase is assumed to be an ideal mixture.
Definition: h2oheavyoil.hh:155
static const int numPhases
Definition: h2oheavyoil.hh:46
static constexpr bool isMiscible()
Returns whether the fluids are miscible.
Definition: h2oheavyoil.hh:118
static Scalar viscosity(const FluidState &fluidState, int phaseIdx)
Calculate the dynamic viscosity of a fluid phase .
Definition: h2oheavyoil.hh:286
static Scalar enthalpy(const FluidState &fluidState, int phaseIdx)
Given all mole fractions in a phase, return the specific phase enthalpy .
Definition: h2oheavyoil.hh:464
static const int H2OIdx
Definition: h2oheavyoil.hh:53
static Scalar partialPressureGas(const FluidState &fluidState, int phaseIdx, int compIdx)
Partial pressures in the gas phase, taken from saturation vapor pressures.
Definition: h2oheavyoil.hh:417
static Scalar componentEnthalpy(const FluidState &fluidState, int phaseIdx, int componentIdx)
Returns the specific enthalpy of a component in a specific phase.
Definition: h2oheavyoil.hh:495
static const int nPhaseIdx
Definition: h2oheavyoil.hh:50
static Scalar thermalConductivity(const FluidState &fluidState, int phaseIdx)
Thermal conductivity of a fluid phase .
Definition: h2oheavyoil.hh:546
H2OType H2O
Definition: h2oheavyoil.hh:43
static std::string phaseName(int phaseIdx)
Return the human readable name of a phase (used in indices)
Definition: h2oheavyoil.hh:190
static const int numComponents
Definition: h2oheavyoil.hh:47
static constexpr int getMainComponent(int phaseIdx)
Get the main component of a given phase.
Definition: h2oheavyoil.hh:103
static constexpr bool isGas(int phaseIdx)
Return whether a phase is gaseous.
Definition: h2oheavyoil.hh:126
static const int NAPLIdx
Definition: h2oheavyoil.hh:54
static Scalar molarMass(int compIdx)
Return the molar mass of a component in [kg/mol].
Definition: h2oheavyoil.hh:217
static void init(Scalar tempMin, Scalar tempMax, unsigned nTemp, Scalar pressMin, Scalar pressMax, unsigned nPress)
Initialize the fluid system's static parameters using problem specific temperature and pressure range...
Definition: h2oheavyoil.hh:89
static Scalar density(const FluidState &fluidState, int phaseIdx)
Calculate the density of a fluid phase.
Definition: h2oheavyoil.hh:229
static Scalar inverseVaporPressureCurve(const FluidState &fluidState, int phaseIdx, int compIdx)
Inverse vapor pressures, taken from inverse saturation vapor pressures.
Definition: h2oheavyoil.hh:438
static const int nCompIdx
Definition: h2oheavyoil.hh:60
static bool isIdealGas(int phaseIdx)
Returns true if and only if a fluid phase is assumed to be an ideal gas.
Definition: h2oheavyoil.hh:138
static Scalar diffusionCoefficient(const FluidState &fluidState, int phaseIdx)
Calculate the molecular diffusion coefficient for a component in a fluid phase .
Definition: h2oheavyoil.hh:370
static const int wPhaseIdx
Definition: h2oheavyoil.hh:49
static Scalar binaryDiffusionCoefficient(const FluidState &fluidState, int phaseIdx, int compIIdx, int compJIdx)
Given a phase's composition, temperature and pressure, return the binary diffusion coefficient for c...
Definition: h2oheavyoil.hh:338
static void init()
Initialize the fluid system's static parameters generically.
Definition: h2oheavyoil.hh:68
static Scalar heatCapacity(const FluidState &fluidState, int phaseIdx)
Specific isobaric heat capacity of a fluid phase .
Definition: h2oheavyoil.hh:530
Fluid system base class.
Material properties of pure water .
Binary coefficients for water and heavy oil.
Properties of the component heavyoil.
Relations valid for an ideal gas.
A collection of input/output field names for common physical quantities.
Scalar h2oGasViscosityInMixture(Scalar temperature, Scalar pressure)
The dynamic viscosity of steam in a gas mixture.
Definition: h2o.hh:961
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
std::string pressure(int phaseIdx) noexcept
I/O name of pressure for multiphase systems.
Definition: name.hh:22
Definition: adapt.hh:17
Tabulates all thermodynamic properties of a given untabulated chemical species.