3.6-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
2p1c.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_1C_FLUID_SYSTEM_HH
25#define DUMUX_2P_1C_FLUID_SYSTEM_HH
26
27#include <limits>
28#include <cassert>
29#include <iostream>
30
31#include <dune/common/exceptions.hh>
32
33#include <dumux/io/name.hh>
34
35#include "base.hh"
36
37namespace Dumux {
38namespace FluidSystems {
43template <class Scalar, class ComponentType>
45 : public Base<Scalar, TwoPOneC<Scalar, ComponentType> >
46{
49 using Component = ComponentType;
50
51public:
52 static constexpr int numPhases = 2;
53 static constexpr int numComponents = 1;
54
55 static constexpr int liquidPhaseIdx = 0;
56 static constexpr int gasPhaseIdx = 1;
57 static constexpr int phase0Idx = liquidPhaseIdx;
58 static constexpr int phase1Idx = gasPhaseIdx;
59
60 static constexpr int comp0Idx = 0;
61
62 /****************************************
63 * Fluid phase related static parameters
64 ****************************************/
70 static std::string phaseName(int phaseIdx)
71 {
72 static std::string name[] = {
73 std::string(IOName::liquidPhase()),
74 std::string(IOName::gaseousPhase()),
75 };
76
77 assert(0 <= phaseIdx && phaseIdx < numPhases);
78 return name[phaseIdx];
79 }
80
84 static constexpr bool isMiscible()
85 { return false; }
86
92 static constexpr bool isGas(int phaseIdx)
93 {
94 assert(0 <= phaseIdx && phaseIdx < numPhases);
95 return phaseIdx == gasPhaseIdx;
96 }
97
112 static constexpr bool isIdealMixture(int phaseIdx)
113 {
114 assert(0 <= phaseIdx && phaseIdx < numPhases);
115 // we assume Henry's and Raoult's laws for the water phase and
116 // and no interaction between gas molecules of different
117 // components, so all phases are ideal mixtures!
118 return true;
119 }
120
130 static constexpr bool isCompressible(int phaseIdx)
131 {
132 assert(0 <= phaseIdx && phaseIdx < numPhases);
133 // gases are always compressible
134 if (phaseIdx == gasPhaseIdx)
135 return true;
136 // the component decides for the liquid phase...
137 return Component::liquidIsCompressible();
138 }
139
146 static constexpr bool isIdealGas(int phaseIdx)
147 {
148 assert(0 <= phaseIdx && phaseIdx < numPhases);
149
150 if (phaseIdx == gasPhaseIdx)
151 // let the components decide
152 return Component::gasIsIdeal();
153 return false; // not a gas
154 }
155
156 /****************************************
157 * Component related static parameters
158 ****************************************/
159
165 static std::string componentName(int compIdx)
166 {
167 assert(0 <= compIdx && compIdx < numComponents);
168 return Component::name();
169 }
170
176 static Scalar molarMass(int compIdx)
177 {
178 assert(0 <= compIdx && compIdx < numComponents);
179 return Component::molarMass();
180 }
181
187 static Scalar criticalTemperature(int compIdx)
188 {
189 assert(0 <= compIdx && compIdx < numComponents);
190 return Component::criticalTemperature();
191 }
192
198 static Scalar criticalPressure(int compIdx)
199 {
200 assert(0 <= compIdx && compIdx < numComponents);
201 return Component::criticalPressure();
202 }
203
209 static Scalar criticalMolarVolume(int compIdx)
210 {
211 DUNE_THROW(Dune::NotImplemented,
212 "TwoPOneC::criticalMolarVolume()");
213 return 0;
214 }
215
221 static Scalar acentricFactor(int compIdx)
222 {
223 assert(0 <= compIdx && compIdx < numComponents);
224 return Component::acentricFactor();
225 }
226
227 /****************************************
228 * thermodynamic relations
229 ****************************************/
230
237 static void init()
238 {
239 init(/*tempMin=*/273.15,
240 /*tempMax=*/623.15,
241 /*numTemp=*/100,
242 /*pMin=*/0.0,
243 /*pMax=*/20e6,
244 /*numP=*/200);
245 }
246
258 static void init(Scalar tempMin, Scalar tempMax, unsigned nTemp,
259 Scalar pressMin, Scalar pressMax, unsigned nPress)
260 {
261 if (Component::isTabulated)
262 {
263 Component::init(tempMin, tempMax, nTemp,
264 pressMin, pressMax, nPress);
265 }
266 }
267
274 using Base::density;
275 template <class FluidState>
276 static Scalar density(const FluidState &fluidState,
277 int phaseIdx)
278 {
279 assert(0 <= phaseIdx && phaseIdx < numPhases);
280
281 Scalar temperature = fluidState.temperature(phaseIdx);
282 Scalar pressure = fluidState.pressure(phaseIdx);
283
284 // liquid phase
285 if (phaseIdx == liquidPhaseIdx) {
286 return Component::liquidDensity(temperature, pressure);
287 }
288 else if (phaseIdx == gasPhaseIdx)// gas phase
289 {
290 return Component::gasDensity(temperature, pressure);
291 }
292 else
293 DUNE_THROW(Dune::InvalidStateException, "Invalid phase index.");
294 }
295
296 using Base::molarDensity;
306 template <class FluidState>
307 static Scalar molarDensity(const FluidState &fluidState, int phaseIdx)
308 {
309 Scalar temperature = fluidState.temperature(phaseIdx);
310 Scalar pressure = fluidState.temperature(phaseIdx);
311 if (phaseIdx == liquidPhaseIdx)
312 return Component::liquidMolarDensity(temperature, pressure);
313 else if (phaseIdx == gasPhaseIdx)
314 return Component::gasMolarDensity(temperature, pressure);
315 else
316 DUNE_THROW(Dune::InvalidStateException, "Invalid phase index.");
317 }
318
325 using Base::viscosity;
326 template <class FluidState>
327 static Scalar viscosity(const FluidState &fluidState,
328 int phaseIdx)
329 {
330 assert(0 <= phaseIdx && phaseIdx < numPhases);
331
332 Scalar temperature = fluidState.temperature(phaseIdx);
333 Scalar pressure = fluidState.pressure(phaseIdx);
334
335 // liquid phase
336 if (phaseIdx == liquidPhaseIdx)
337 return Component::liquidViscosity(temperature, pressure);
338 else if (phaseIdx == gasPhaseIdx) // gas phase
339 return Component::gasViscosity(temperature, pressure);
340 else
341 DUNE_THROW(Dune::InvalidStateException, "Invalid phase index.");
342 }
343
350 template <class FluidState>
351 static Scalar vaporTemperature(const FluidState &fluidState,
352 const unsigned int phaseIdx)
353 {
354 assert(0 <= phaseIdx && phaseIdx < numPhases);
355 Scalar pressure = fluidState.pressure(gasPhaseIdx);
356
357 return Component::vaporTemperature(pressure);
358 }
359
388 template <class FluidState>
389 static Scalar fugacityCoefficient(const FluidState &fluidState,
390 int phaseIdx,
391 int compIdx)
392 {
393 assert(0 <= phaseIdx && phaseIdx < numPhases);
394 assert(0 <= compIdx && compIdx < numComponents);
395
396 Scalar temperature = fluidState.temperature(phaseIdx);
397 Scalar pressure = fluidState.pressure(phaseIdx);
398
399 // liquid phase
400 if (phaseIdx == liquidPhaseIdx)
401 return Component::vaporPressure(temperature)/pressure;
402
403 // for the gas phase, assume an ideal gas when it comes to
404 // fugacity (-> fugacity == partial pressure)
405 else if (phaseIdx == gasPhaseIdx)
406 return 1.0;
407
408 else
409 DUNE_THROW(Dune::InvalidStateException, "Invalid phase index.");
410 }
411
412
422 template <class FluidState>
423 static Scalar diffusionCoefficient(const FluidState &fluidState,
424 int phaseIdx,
425 int compIdx)
426 {
427 // TODO!
428 DUNE_THROW(Dune::NotImplemented, "Diffusion coefficients");
429 }
430
442 template <class FluidState>
443 static Scalar binaryDiffusionCoefficient(const FluidState &fluidState,
444 int phaseIdx,
445 int compIIdx,
446 int compJIdx)
447
448 { DUNE_THROW(Dune::NotImplemented, "Binary Diffusion coefficients"); }
449
456 using Base::enthalpy;
457 template <class FluidState>
458 static Scalar enthalpy(const FluidState &fluidState,
459 int phaseIdx)
460 {
461 assert(0 <= phaseIdx && phaseIdx < numPhases);
462
463 // liquid phase
464 if (phaseIdx == liquidPhaseIdx)
465 return Component::liquidEnthalpy(fluidState.temperature(phaseIdx),
466 fluidState.pressure(phaseIdx));
467
468 else if (phaseIdx == gasPhaseIdx) // gas phase
469 return Component::gasEnthalpy(fluidState.temperature(phaseIdx),
470 fluidState.pressure(phaseIdx));
471
472 else
473 DUNE_THROW(Dune::InvalidStateException, "Invalid phase index.");
474 }
475
485 template <class FluidState>
486 static Scalar thermalConductivity(const FluidState &fluidState,
487 const int phaseIdx)
488 {
489 assert(0 <= phaseIdx && phaseIdx < numPhases);
490 // liquid phase
491 if (phaseIdx == liquidPhaseIdx)
492 return Component::liquidThermalConductivity(fluidState.temperature(phaseIdx),
493 fluidState.pressure(phaseIdx)); //0.68 ;
494
495 else if (phaseIdx == gasPhaseIdx) // gas phase
496 return Component::gasThermalConductivity(fluidState.temperature(phaseIdx),
497 fluidState.pressure(phaseIdx)); //0.0248;
498
499 else
500 DUNE_THROW(Dune::InvalidStateException, "Invalid phase index.");
501 }
502
510 using Base::heatCapacity;
511 template <class FluidState>
512 static Scalar heatCapacity(const FluidState &fluidState,
513 int phaseIdx)
514 {
515 assert(0 <= phaseIdx && phaseIdx < numPhases);
516 // liquid phase
517 if (phaseIdx == liquidPhaseIdx)
518 return Component::liquidHeatCapacity(fluidState.temperature(phaseIdx),
519 fluidState.pressure(phaseIdx));//4.217e3 ;
520
521 else if (phaseIdx == gasPhaseIdx) // gas phase
522 return Component::gasHeatCapacity(fluidState.temperature(phaseIdx),
523 fluidState.pressure(phaseIdx));//2.029e3;
524
525 else
526 DUNE_THROW(Dune::InvalidStateException, "Invalid phase index.");
527 }
528};
529
530} // end namespace FluidSystems
531} // end namespace Dumux
532
533#endif
A collection of input/output field names for common physical quantities.
Adaption of the non-isothermal two-phase two-component flow model to problems with CO2.
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 liquidPhase() noexcept
I/O name of liquid phase.
Definition: name.hh:119
std::string pressure(int phaseIdx) noexcept
I/O name of pressure for multiphase systems.
Definition: name.hh:34
A two-phase fluid system with only one component.
Definition: 2p1c.hh:46
static Scalar enthalpy(const FluidState &fluidState, int phaseIdx)
Definition: 2p1c.hh:458
static Scalar molarMass(int compIdx)
Return the molar mass of a component in [kg/mol].
Definition: 2p1c.hh:176
static constexpr bool isMiscible()
Returns whether the fluids are miscible.
Definition: 2p1c.hh:84
static std::string componentName(int compIdx)
Return the human readable name of a component.
Definition: 2p1c.hh:165
static constexpr bool isIdealGas(int phaseIdx)
Returns true if and only if a fluid phase is assumed to be an ideal gas.
Definition: 2p1c.hh:146
static Scalar criticalMolarVolume(int compIdx)
Molar volume of a component at the critical point [m^3/mol].
Definition: 2p1c.hh:209
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: 2p1c.hh:258
static constexpr int comp0Idx
index of the only component
Definition: 2p1c.hh:60
static Scalar criticalTemperature(int compIdx)
Critical temperature of a component [K].
Definition: 2p1c.hh:187
static constexpr int numPhases
Number of phases in the fluid system.
Definition: 2p1c.hh:52
static constexpr bool isCompressible(int phaseIdx)
Returns true if and only if a fluid phase is assumed to be compressible.
Definition: 2p1c.hh:130
static std::string phaseName(int phaseIdx)
Return the human readable name of a fluid phase.
Definition: 2p1c.hh:70
static Scalar fugacityCoefficient(const FluidState &fluidState, int phaseIdx, int compIdx)
Definition: 2p1c.hh:389
static Scalar criticalPressure(int compIdx)
Critical pressure of a component [Pa].
Definition: 2p1c.hh:198
static Scalar heatCapacity(const FluidState &fluidState, int phaseIdx)
Definition: 2p1c.hh:512
static Scalar molarDensity(const FluidState &fluidState, int phaseIdx)
The molar density of a fluid phase in .
Definition: 2p1c.hh:307
static Scalar binaryDiffusionCoefficient(const FluidState &fluidState, int phaseIdx, int compIIdx, int compJIdx)
Definition: 2p1c.hh:443
static constexpr int phase1Idx
index of the second phase
Definition: 2p1c.hh:58
static constexpr int liquidPhaseIdx
index of the liquid phase
Definition: 2p1c.hh:55
static constexpr int numComponents
Number of components in the fluid system.
Definition: 2p1c.hh:53
static Scalar diffusionCoefficient(const FluidState &fluidState, int phaseIdx, int compIdx)
Definition: 2p1c.hh:423
static constexpr int gasPhaseIdx
index of the gas phase
Definition: 2p1c.hh:56
static Scalar thermalConductivity(const FluidState &fluidState, const int phaseIdx)
Definition: 2p1c.hh:486
static Scalar vaporTemperature(const FluidState &fluidState, const unsigned int phaseIdx)
calculate the temperature of vapor at a given pressure on the vapor pressure curve.
Definition: 2p1c.hh:351
static Scalar density(const FluidState &fluidState, int phaseIdx)
Definition: 2p1c.hh:276
static constexpr bool isGas(int phaseIdx)
Return whether a phase is gaseous.
Definition: 2p1c.hh:92
static constexpr bool isIdealMixture(int phaseIdx)
Returns true if and only if a fluid phase is assumed to be an ideal mixture.
Definition: 2p1c.hh:112
static Scalar viscosity(const FluidState &fluidState, int phaseIdx)
Definition: 2p1c.hh:327
static void init()
Initialize the fluid system's static parameters generically.
Definition: 2p1c.hh:237
static constexpr int phase0Idx
index of the first phase
Definition: 2p1c.hh:57
static Scalar acentricFactor(int compIdx)
The acentric factor of a component [].
Definition: 2p1c.hh:221
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
Fluid system base class.