3.2-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
2pimmiscible.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 *****************************************************************************/
24#ifndef DUMUX_2P_IMMISCIBLE_FLUID_SYSTEM_HH
25#define DUMUX_2P_IMMISCIBLE_FLUID_SYSTEM_HH
26
27#include <limits>
28#include <cassert>
29
30#include <dune/common/exceptions.hh>
31
36#include <dumux/io/name.hh>
37
38#include "base.hh"
39
40namespace Dumux {
41namespace FluidSystems {
42
56template <class Scalar, class Fluid0, class Fluid1>
58: public Base<Scalar, TwoPImmiscible<Scalar, Fluid0, Fluid1> >
59{
60 static_assert((Fluid0::numPhases == 1), "Fluid0 has more than one phase");
61 static_assert((Fluid1::numPhases == 1), "Fluid1 has more than one phase");
62 static_assert((Fluid0::numComponents == 1), "Fluid0 has more than one component");
63 static_assert((Fluid1::numComponents == 1), "Fluid1 has more than one component");
64 // two gaseous phases at once do not make sense physically! (but two liquids are fine)
65 static_assert(!Fluid0::isGas() || !Fluid1::isGas(), "One phase has to be a liquid!");
66
69
70public:
71 static constexpr int numPhases = 2;
72 static constexpr int numComponents = 2;
73
74 static constexpr int phase0Idx = 0;
75 static constexpr int phase1Idx = 1;
76 static constexpr int comp0Idx = 0;
77 static constexpr int comp1Idx = 1;
78
79 /****************************************
80 * Fluid phase related static parameters
81 ****************************************/
86 static std::string phaseName(int phaseIdx)
87 {
88 assert(0 <= phaseIdx && phaseIdx < numPhases);
89
90 if (!Fluid0::isGas() && !Fluid1::isGas())
91 {
94
95 if (name0 != name1)
96 return (phaseIdx == phase0Idx) ? name0 : name1;
97 else
98 return (phaseIdx == phase0Idx) ? name0 + "_0" : name1 + "_1";
99 }
100 else
101 {
102 if (phaseIdx == phase0Idx)
103 return Fluid0::isGas() ? IOName::gaseousPhase() : IOName::liquidPhase();
104 else
105 return Fluid1::isGas() ? IOName::gaseousPhase() : IOName::liquidPhase();
106 }
107 }
108
112 static constexpr bool isMiscible()
113 { return false; }
114
119 static constexpr bool isGas(int phaseIdx)
120 {
121 assert(0 <= phaseIdx && phaseIdx < numPhases);
122
123 if (phaseIdx == phase0Idx)
124 return Fluid0::isGas();
125 return Fluid1::isGas();
126 }
127
141 static bool isIdealMixture(int phaseIdx)
142 {
143 assert(0 <= phaseIdx && phaseIdx < numPhases);
144
145 // we assume immisibility
146 return true;
147 }
148
155 static constexpr bool isIdealGas(int phaseIdx)
156 {
157 assert(0 <= phaseIdx && phaseIdx < numPhases);
158
159 // let the fluids decide
160 if (phaseIdx == phase0Idx)
161 return Fluid0::isIdealGas();
162 return Fluid1::isIdealGas();
163 }
164
174 static constexpr bool isCompressible(int phaseIdx)
175 {
176 assert(0 <= phaseIdx && phaseIdx < numPhases);
177
178 // let the fluids decide
179 if (phaseIdx == phase0Idx)
180 return Fluid0::isCompressible();
181 return Fluid1::isCompressible();
182 }
183
189 static constexpr bool viscosityIsConstant(int phaseIdx)
190 {
191 assert(0 <= phaseIdx && phaseIdx < numPhases);
192
193 // let the fluids decide
194 if (phaseIdx == phase0Idx)
195 return Fluid0::viscosityIsConstant();
196 return Fluid1::viscosityIsConstant();
197 }
198
205 static bool isIdealFluid1(int phaseIdx)
206 {
207 assert(0 <= phaseIdx && phaseIdx < numPhases);
208
209 // let the fluids decide
210 if (phaseIdx == phase0Idx)
211 return Fluid0::isIdealFluid1();
212 return Fluid1::isIdealFluid1();
213 }
214
215 /****************************************
216 * Component related static parameters
217 ****************************************/
223 static std::string componentName(int compIdx)
224 {
225 assert(0 <= compIdx && compIdx < numComponents);
226
227 if (compIdx == comp0Idx)
228 return Fluid0::name();
229 return Fluid1::name();
230 }
231
236 static Scalar molarMass(int compIdx)
237 {
238 assert(0 <= compIdx && compIdx < numComponents);
239
240 if (compIdx == comp0Idx)
241 return Fluid0::molarMass();
242 return Fluid1::molarMass();
243 }
244
249 static Scalar criticalTemperature(int compIdx)
250 {
251 assert(0 <= compIdx && compIdx < numComponents);
252
253 if (compIdx == comp0Idx)
254 return Fluid0::criticalTemperature();
255 return Fluid1::criticalTemperature();
256 }
257
262 static Scalar criticalPressure(int compIdx)
263 {
264 assert(0 <= compIdx && compIdx < numComponents);
265
266 if (compIdx == comp0Idx)
267 return Fluid0::criticalPressure();
268 return Fluid1::criticalPressure();
269 }
270
275 static Scalar acentricFactor(int compIdx)
276 {
277 assert(0 <= compIdx && compIdx < numComponents);
278
279 if (compIdx == comp0Idx)
280 return Fluid0::acentricFactor();
281 return Fluid1::acentricFactor();
282 }
283
284 /****************************************
285 * thermodynamic relations
286 ****************************************/
287
291 static void init()
292 {
293 // initialize with some default values
294 init(/*tempMin=*/273.15, /*tempMax=*/623.15, /*numTemp=*/100,
295 /*pMin=*/-10.0, /*pMax=*/20e6, /*numP=*/200);
296 }
297
309 static void init(Scalar tempMin, Scalar tempMax, std::size_t nTemp,
310 Scalar pressMin, Scalar pressMax, std::size_t nPress)
311 {
312 if (Fluid0::Component::isTabulated)
313 Fluid0::Component::init(tempMin, tempMax, nTemp, pressMin, pressMax, nPress);
314
315 if (Fluid1::Component::isTabulated)
316 Fluid1::Component::init(tempMin, tempMax, nTemp, pressMin, pressMax, nPress);
317 }
318
319 using Base::density;
324 template <class FluidState>
325 static Scalar density(const FluidState &fluidState,
326 int phaseIdx)
327 {
328 assert(0 <= phaseIdx && phaseIdx < numPhases);
329
330 Scalar temperature = fluidState.temperature(phaseIdx);
331 Scalar pressure = fluidState.pressure(phaseIdx);
332 if (phaseIdx == phase0Idx)
335 }
336
337 using Base::molarDensity;
347 template <class FluidState>
348 static Scalar molarDensity(const FluidState &fluidState, int phaseIdx)
349 {
350 Scalar temperature = fluidState.temperature(phaseIdx);
351 Scalar pressure = fluidState.pressure(phaseIdx);
352 if (phaseIdx == phase0Idx)
355 }
356
357 using Base::viscosity;
363 template <class FluidState>
364 static Scalar viscosity(const FluidState &fluidState,
365 int phaseIdx)
366 {
367 assert(0 <= phaseIdx && phaseIdx < numPhases);
368
369 Scalar temperature = fluidState.temperature(phaseIdx);
370 Scalar pressure = fluidState.pressure(phaseIdx);
371 if (phaseIdx == phase0Idx)
374 }
375
393 template <class FluidState>
394 static Scalar fugacityCoefficient(const FluidState &fluidState,
395 int phaseIdx,
396 int compIdx)
397 {
398 assert(0 <= phaseIdx && phaseIdx < numPhases);
399 assert(0 <= compIdx && compIdx < numComponents);
400
401 if (phaseIdx == compIdx)
402 // We could calculate the real fugacity coefficient of
403 // the component in the fluid. Probably that's not worth
404 // the effort, since the fugacity coefficient of the other
405 // component is infinite anyway...
406 return 1.0;
407 return std::numeric_limits<Scalar>::infinity();
408 }
409
433 template <class FluidState>
434 static Scalar diffusionCoefficient(const FluidState &fluidState,
435 int phaseIdx,
436 int compIdx)
437 {
438 DUNE_THROW(Dune::InvalidStateException,
439 "Diffusion coefficients of components are meaningless if"
440 " immiscibility is assumed");
441 }
442
453 template <class FluidState>
454 static Scalar binaryDiffusionCoefficient(const FluidState &fluidState,
455 int phaseIdx,
456 int compIIdx,
457 int compJIdx)
458
459 {
460 DUNE_THROW(Dune::InvalidStateException,
461 "Binary diffusion coefficients of components are meaningless if"
462 " immiscibility is assumed");
463 }
464
465 using Base::enthalpy;
471 template <class FluidState>
472 static Scalar enthalpy(const FluidState &fluidState,
473 int phaseIdx)
474 {
475 assert(0 <= phaseIdx && phaseIdx < numPhases);
476
477 Scalar temperature = fluidState.temperature(phaseIdx);
478 Scalar pressure = fluidState.pressure(phaseIdx);
479 if (phaseIdx == phase0Idx)
480 return Fluid0::enthalpy(temperature, pressure);
481 return Fluid1::enthalpy(temperature, pressure);
482 }
483
490 template <class FluidState>
491 static Scalar thermalConductivity(const FluidState &fluidState,
492 int phaseIdx)
493 {
494 assert(0 <= phaseIdx && phaseIdx < numPhases);
495
496 Scalar temperature = fluidState.temperature(phaseIdx);
497 Scalar pressure = fluidState.pressure(phaseIdx);
498 if (phaseIdx == phase0Idx)
499 return Fluid0::thermalConductivity(temperature, pressure);
500 return Fluid1::thermalConductivity(temperature, pressure);
501 }
502
503 using Base::heatCapacity;
515 template <class FluidState>
516 static Scalar heatCapacity(const FluidState &fluidState,
517 int phaseIdx)
518 {
519 assert(0 <= phaseIdx && phaseIdx < numPhases);
520
521 Scalar temperature = fluidState.temperature(phaseIdx);
522 Scalar pressure = fluidState.pressure(phaseIdx);
523 if (phaseIdx == phase0Idx)
524 return Fluid0::heatCapacity(temperature, pressure);
525 return Fluid1::heatCapacity(temperature, pressure);
526 }
527};
528
529} // end namespace FluidSystems
530} // end namespace Dumux
531
532#endif
A collection of input/output field names for common physical quantities.
Represents all relevant thermodynamic quantities of a multi-phase fluid system assuming immiscibility...
A gaseous phase consisting of a single component.
A liquid phase consisting of a single component.
Definition: adapt.hh:29
std::string temperature() noexcept
I/O name of temperature for equilibrium models.
Definition: name.hh:51
std::string gaseousPhase() noexcept
I/O name of gaseous phase.
Definition: name.hh:123
std::string viscosity(int phaseIdx) noexcept
I/O name of viscosity for multiphase systems.
Definition: name.hh:74
std::string molarDensity(int phaseIdx) noexcept
I/O name of molar density for multiphase systems.
Definition: name.hh:83
std::string naplPhase() noexcept
I/O name of napl phase.
Definition: name.hh:131
std::string liquidPhase() noexcept
I/O name of liquid phase.
Definition: name.hh:119
std::string aqueousPhase() noexcept
I/O name of aqueous phase.
Definition: name.hh:127
std::string pressure(int phaseIdx) noexcept
I/O name of pressure for multiphase systems.
Definition: name.hh:34
std::string density(int phaseIdx) noexcept
I/O name of density for multiphase systems.
Definition: name.hh:65
IsAqueous struct.
Definition: components/base.hh:47
A fluid system for two-phase models assuming immiscibility and thermodynamic equilibrium.
Definition: 2pimmiscible.hh:59
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: 2pimmiscible.hh:454
static std::string phaseName(int phaseIdx)
Return the human readable name of a fluid phase.
Definition: 2pimmiscible.hh:86
static std::string componentName(int compIdx)
Return the human readable name of a component.
Definition: 2pimmiscible.hh:223
static constexpr bool isCompressible(int phaseIdx)
Returns true if and only if a fluid phase is assumed to be compressible.
Definition: 2pimmiscible.hh:174
static Scalar acentricFactor(int compIdx)
The acentric factor of a component .
Definition: 2pimmiscible.hh:275
static Scalar enthalpy(const FluidState &fluidState, int phaseIdx)
Return the specific enthalpy of a fluid phase .
Definition: 2pimmiscible.hh:472
static constexpr bool isMiscible()
Returns whether the fluids are miscible.
Definition: 2pimmiscible.hh:112
static bool isIdealFluid1(int phaseIdx)
Returns true if and only if a fluid phase is assumed to be an ideal gas.
Definition: 2pimmiscible.hh:205
static Scalar thermalConductivity(const FluidState &fluidState, int phaseIdx)
Thermal conductivity of a fluid phase .
Definition: 2pimmiscible.hh:491
static bool isIdealMixture(int phaseIdx)
Returns true if and only if a fluid phase is assumed to be an ideal mixture.
Definition: 2pimmiscible.hh:141
static void init(Scalar tempMin, Scalar tempMax, std::size_t nTemp, Scalar pressMin, Scalar pressMax, std::size_t nPress)
Initialize the fluid system's static parameters using problem specific temperature and pressure range...
Definition: 2pimmiscible.hh:309
static Scalar viscosity(const FluidState &fluidState, int phaseIdx)
Return the viscosity of a phase .
Definition: 2pimmiscible.hh:364
static Scalar fugacityCoefficient(const FluidState &fluidState, int phaseIdx, int compIdx)
Calculate the fugacity coefficient of an individual component in a fluid phase.
Definition: 2pimmiscible.hh:394
static Scalar diffusionCoefficient(const FluidState &fluidState, int phaseIdx, int compIdx)
Calculate the binary molecular diffusion coefficient for a component in a fluid phase .
Definition: 2pimmiscible.hh:434
static constexpr bool isIdealGas(int phaseIdx)
Returns true if and only if a fluid phase is assumed to be an ideal gas.
Definition: 2pimmiscible.hh:155
static constexpr int comp0Idx
index of the frist component
Definition: 2pimmiscible.hh:76
static Scalar heatCapacity(const FluidState &fluidState, int phaseIdx)
Thermal conductivity of a fluid phase .
Definition: 2pimmiscible.hh:516
static constexpr int phase0Idx
index of the first phase
Definition: 2pimmiscible.hh:74
static Scalar density(const FluidState &fluidState, int phaseIdx)
Calculate the density of a fluid phase.
Definition: 2pimmiscible.hh:325
static constexpr bool viscosityIsConstant(int phaseIdx)
Returns true if the liquid phase viscostiy is constant.
Definition: 2pimmiscible.hh:189
static constexpr int numPhases
Number of phases in the fluid system.
Definition: 2pimmiscible.hh:71
static Scalar molarDensity(const FluidState &fluidState, int phaseIdx)
The molar density of a fluid phase in .
Definition: 2pimmiscible.hh:348
static void init()
Initialize the fluid system's static parameters.
Definition: 2pimmiscible.hh:291
static Scalar criticalPressure(int compIdx)
Critical pressure of a component .
Definition: 2pimmiscible.hh:262
static Scalar criticalTemperature(int compIdx)
Critical temperature of a component .
Definition: 2pimmiscible.hh:249
static constexpr bool isGas(int phaseIdx)
Return whether a phase is gaseous.
Definition: 2pimmiscible.hh:119
static constexpr int comp1Idx
index of the second component
Definition: 2pimmiscible.hh:77
static Scalar molarMass(int compIdx)
Return the molar mass of a component in .
Definition: 2pimmiscible.hh:236
static constexpr int numComponents
Number of components in the fluid system.
Definition: 2pimmiscible.hh:72
static constexpr int phase1Idx
index of the second phase
Definition: 2pimmiscible.hh:75
Fluid system base class.
Definition: fluidsystems/base.hh:45
Scalar Scalar
export the scalar type
Definition: fluidsystems/base.hh:48
static Scalar density(const FluidState &fluidState, int phaseIdx)
Calculate the density of a fluid phase.
Definition: fluidsystems/base.hh:134
static Scalar thermalConductivity(const FluidState &fluidState, int phaseIdx)
Thermal conductivity of a fluid phase .
Definition: fluidsystems/base.hh:390
static Scalar fugacityCoefficient(const FluidState &fluidState, int phaseIdx, int compIdx)
Calculate the fugacity coefficient of an individual component in a fluid phase.
Definition: fluidsystems/base.hh:197
static Scalar diffusionCoefficient(const FluidState &fluidState, int phaseIdx, int compIdx)
Calculate the binary molecular diffusion coefficient for a component in a fluid phase .
Definition: fluidsystems/base.hh:278
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: fluidsystems/base.hh:326
static Scalar enthalpy(const FluidState &fluidState, int phaseIdx)
Given a phase's composition, temperature, pressure and density, calculate its specific enthalpy .
Definition: fluidsystems/base.hh:363
static Scalar molarDensity(const FluidState &fluidState, int phaseIdx)
Calculate the molar density of a fluid phase.
Definition: fluidsystems/base.hh:160
static Scalar viscosity(const FluidState &fluidState, int phaseIdx)
Calculate the dynamic viscosity of a fluid phase .
Definition: fluidsystems/base.hh:236
static Scalar heatCapacity(const FluidState &fluidState, int phaseIdx)
Specific isobaric heat capacity of a fluid phase .
Definition: fluidsystems/base.hh:424
Base class for all components Components provide the thermodynamic relations for the liquid,...
Fluid system base class.