3.3.0
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
liquidphase2c.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_LIQUID_TWOC_PHASE_HH
25#define DUMUX_LIQUID_TWOC_PHASE_HH
26
27#include <cassert>
28#include <limits>
29
30#include <dune/common/exceptions.hh>
33#include <dumux/io/name.hh>
34
35namespace Dumux {
36namespace FluidSystems {
37
43template <class Scalar, class MainComponent, class SecondComponent>
45: public Base<Scalar, LiquidPhaseTwoC<Scalar, MainComponent, SecondComponent> >
46{
50
51public:
53
54 static constexpr int numPhases = 1;
55 static constexpr int numComponents = 2;
56
57 static constexpr int liquidPhaseIdx = 0;
58 static constexpr int phase0Idx = liquidPhaseIdx;
59
60 static constexpr int comp0Idx = 0;
61 static constexpr int comp1Idx = 1;
62 static constexpr int mainCompIdx = comp0Idx;
63 static constexpr int secondCompIdx = comp1Idx;
64
68 static void init() {}
69
70 /****************************************
71 * Fluid phase related static parameters
72 ****************************************/
78 static std::string phaseName(int phaseIdx = 0)
79 { return IOName::liquidPhase(); }
80
85 static constexpr bool isMiscible()
86 { return false; }
87
93 static std::string componentName(int compIdx)
94 { return compIdx ? SecondComponent::name() : MainComponent::name(); }
95
99 static std::string name()
100 { return "LiquidPhaseTwoC"; }
101
105 static constexpr bool isGas(int phaseIdx = 0)
106 { return false; }
107
122 static bool isIdealMixture(int phaseIdx = 0)
123 { return true; }
124
128 static constexpr bool isCompressible(int phaseIdx = 0)
129 { return MainComponent::liquidIsCompressible(); }
130
134 static bool isIdealGas(int phaseIdx = 0)
135 { return false; /* we're a liquid! */ }
136
140 static Scalar molarMass(int compIdx)
141 { return compIdx ? SecondComponent::molarMass() : MainComponent::molarMass(); }
142
147 { return MainComponent::criticalTemperature(); }
148
153 { return MainComponent::criticalPressure(); }
154
159 { return MainComponent::tripleTemperature(); }
160
165 { return MainComponent::triplePressure(); }
166
172 { return MainComponent::vaporPressure(T); }
173
178 { return MainComponent::liquidDensity(temperature, pressure); }
179
180 using Base::density;
184 template <class FluidState>
185 static Scalar density(const FluidState &fluidState,
186 const int phaseIdx = 0)
187 {
188 const Scalar T = fluidState.temperature(phaseIdx);
189 const Scalar p = fluidState.pressure(phaseIdx);
190
191 // See: Eq. (7) in Class et al. (2002a)
192 // This assumes each gas molecule displaces exactly one
193 // molecule in the liquid.
194 const Scalar pureComponentMolarDensity = MainComponent::liquidMolarDensity(T, p);
195
196 return pureComponentMolarDensity
197 * (MainComponent::molarMass()*fluidState.moleFraction(phase0Idx, mainCompIdx)
198 + SecondComponent::molarMass()*fluidState.moleFraction(phase0Idx, secondCompIdx));
199 }
200
201 using Base::molarDensity;
211 template <class FluidState>
212 static Scalar molarDensity(const FluidState &fluidState, int phaseIdx)
213 {
214 const Scalar T = fluidState.temperature(phaseIdx);
215 const Scalar p = fluidState.pressure(phaseIdx);
216
217 // assume pure component or that each gas molecule displaces exactly one
218 // molecule in the liquid.
219 return MainComponent::liquidMolarDensity(T, p);
220 }
221
226 { return MainComponent::liquidPressure(temperature, density); }
227
232 { return MainComponent::liquidEnthalpy(temperature, pressure); }
233
234 using Base::enthalpy;
238 template <class FluidState>
239 static Scalar enthalpy(const FluidState &fluidState,
240 const int phaseIdx)
241 {
242 return enthalpy(fluidState.temperature(phaseIdx),
243 fluidState.pressure(phaseIdx));
244 }
245
252 template <class FluidState>
253 static Scalar componentEnthalpy(const FluidState &fluidState,
254 int phaseIdx,
255 int componentIdx)
256 {
257 const Scalar T = fluidState.temperature(phaseIdx);
258 const Scalar p = fluidState.pressure(phaseIdx);
259
260 if (componentIdx == mainCompIdx)
261 return MainComponent::liquidEnthalpy(T, p);
262 else if (componentIdx == secondCompIdx)
263 return SecondComponent::liquidEnthalpy(T, p);
264 else
265 DUNE_THROW(Dune::InvalidStateException, "Invalid component index " << componentIdx);
266 }
267
272 { return MainComponent::liquidInternalEnergy(temperature, pressure); }
273
278 { return MainComponent::liquidViscosity(temperature, pressure); }
279
280 using Base::viscosity;
284 template <class FluidState>
285 static Scalar viscosity(const FluidState &fluidState,
286 const int phaseIdx)
287 {
288 return viscosity(fluidState.temperature(phaseIdx),
289 fluidState.pressure(phaseIdx));
290 }
291
300 template <class FluidState>
301 static Scalar fugacityCoefficient(const FluidState &fluidState,
302 int phaseIdx,
303 int compIdx)
304 {
305 assert(0 <= phaseIdx && phaseIdx < numPhases);
306 assert(0 <= compIdx && compIdx < numComponents);
307
308 if (phaseIdx == compIdx)
309 // We could calculate the real fugacity coefficient of
310 // the component in the fluid. Probably that's not worth
311 // the effort, since the fugacity coefficient of the other
312 // component is infinite anyway...
313 return 1.0;
314 return std::numeric_limits<Scalar>::infinity();
315 }
316
325 template <class FluidState>
326 static Scalar diffusionCoefficient(const FluidState &fluidState,
327 int phaseIdx,
328 int compIdx)
329 {
330 DUNE_THROW(Dune::InvalidStateException, "Not applicable: Diffusion coefficients");
331 }
332
342 template <class FluidState>
343 static Scalar binaryDiffusionCoefficient(const FluidState &fluidState, int phaseIdx, int compIIdx, int compJIdx)
344 {
345 assert(phaseIdx < numPhases);
346 return BinaryCoefficients::liquidDiffCoeff(fluidState.temperature(phaseIdx), fluidState.pressure(phaseIdx));
347 }
348
353 { return MainComponent::liquidThermalConductivity(temperature, pressure); }
354
359 template <class FluidState>
360 static Scalar thermalConductivity(const FluidState &fluidState,
361 const int phaseIdx)
362 {
363 return thermalConductivity(fluidState.temperature(phaseIdx),
364 fluidState.pressure(phaseIdx));
365 }
366
371 { return MainComponent::liquidHeatCapacity(temperature, pressure); }
372
373 using Base::heatCapacity;
377 template <class FluidState>
378 static Scalar heatCapacity(const FluidState &fluidState,
379 const int phaseIdx)
380 {
381 return heatCapacity(fluidState.temperature(phaseIdx),
382 fluidState.pressure(phaseIdx));
383 }
384};
385
386} // namespace FluidSystems
387
388} // namespace Dumux
389
390#endif
A collection of input/output field names for common physical quantities.
Binary coefficients for water and a "constant" component.
Definition: adapt.hh:29
std::string temperature() noexcept
I/O name of temperature for equilibrium models.
Definition: name.hh:51
std::string liquidPhase() noexcept
I/O name of liquid phase.
Definition: name.hh:119
Binary coefficients for water and another component.
Definition: h2o_constant.hh:43
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
A liquid phase consisting of a two components, a main component and a conservative tracer component.
Definition: liquidphase2c.hh:46
static constexpr int liquidPhaseIdx
index of the liquid phase
Definition: liquidphase2c.hh:57
static constexpr bool isMiscible()
Returns whether the fluids are miscible.
Definition: liquidphase2c.hh:85
static constexpr bool isCompressible(int phaseIdx=0)
Returns true if the fluid is assumed to be compressible.
Definition: liquidphase2c.hh:128
static constexpr int numComponents
Number of components in the fluid system.
Definition: liquidphase2c.hh:55
static Scalar componentEnthalpy(const FluidState &fluidState, int phaseIdx, int componentIdx)
Returns the specific enthalpy of a component in the specified phase.
Definition: liquidphase2c.hh:253
static Scalar thermalConductivity(Scalar temperature, Scalar pressure)
Thermal conductivity of the fluid .
Definition: liquidphase2c.hh:352
static constexpr int mainCompIdx
index of the main component
Definition: liquidphase2c.hh:62
static const Scalar internalEnergy(Scalar temperature, Scalar pressure)
Specific internal energy the pure component as a liquid.
Definition: liquidphase2c.hh:271
static Scalar molarDensity(const FluidState &fluidState, int phaseIdx)
The molar density of a fluid phase in .
Definition: liquidphase2c.hh:212
static std::string phaseName(int phaseIdx=0)
Return the human readable name of a fluid phase.
Definition: liquidphase2c.hh:78
static Scalar pressure(Scalar temperature, Scalar density)
The pressure of the component at a given density and temperature.
Definition: liquidphase2c.hh:225
static Scalar density(Scalar temperature, Scalar pressure)
The density of the phase at a given pressure and temperature.
Definition: liquidphase2c.hh:177
static Scalar criticalTemperature()
Returns the critical temperature of the main component.
Definition: liquidphase2c.hh:146
static Scalar tripleTemperature()
Returns the temperature at the main component's triple point.
Definition: liquidphase2c.hh:158
static constexpr int comp0Idx
index of the frist component
Definition: liquidphase2c.hh:60
static bool isIdealMixture(int phaseIdx=0)
Returns true if and only if a fluid phase is assumed to be an ideal mixture.
Definition: liquidphase2c.hh:122
static Scalar viscosity(const FluidState &fluidState, const int phaseIdx)
The dynamic liquid viscosity of the pure component.
Definition: liquidphase2c.hh:285
static Scalar triplePressure()
Returns the pressure at the main component's triple point.
Definition: liquidphase2c.hh:164
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: liquidphase2c.hh:343
static Scalar viscosity(Scalar temperature, Scalar pressure)
The dynamic liquid viscosity of the pure component.
Definition: liquidphase2c.hh:277
static std::string name()
A human readable name for the fluid system.
Definition: liquidphase2c.hh:99
static std::string componentName(int compIdx)
A human readable name for the component.
Definition: liquidphase2c.hh:93
static Scalar heatCapacity(Scalar temperature, Scalar pressure)
Specific isobaric heat capacity of the fluid .
Definition: liquidphase2c.hh:370
static bool isIdealGas(int phaseIdx=0)
Returns true if the fluid is assumed to be an ideal gas.
Definition: liquidphase2c.hh:134
static Scalar density(const FluidState &fluidState, const int phaseIdx=0)
The density of the phase at a given pressure and temperature.
Definition: liquidphase2c.hh:185
static Scalar enthalpy(const FluidState &fluidState, const int phaseIdx)
Specific enthalpy the pure component as a liquid.
Definition: liquidphase2c.hh:239
static void init()
Initialize the fluid system's static parameters generically.
Definition: liquidphase2c.hh:68
static constexpr int phase0Idx
index of the only phase
Definition: liquidphase2c.hh:58
static const Scalar enthalpy(Scalar temperature, Scalar pressure)
Specific enthalpy the pure component as a liquid.
Definition: liquidphase2c.hh:231
static constexpr int secondCompIdx
index of the secondary component
Definition: liquidphase2c.hh:63
static Scalar vaporPressure(Scalar T)
The vapor pressure in of the main component at a given temperature.
Definition: liquidphase2c.hh:171
static Scalar molarMass(int compIdx)
The mass in of one mole of the component.
Definition: liquidphase2c.hh:140
static Scalar heatCapacity(const FluidState &fluidState, const int phaseIdx)
Specific isobaric heat capacity of the fluid .
Definition: liquidphase2c.hh:378
static Scalar criticalPressure()
Returns the critical pressure of the main component.
Definition: liquidphase2c.hh:152
static Scalar thermalConductivity(const FluidState &fluidState, const int phaseIdx)
Thermal conductivity of the fluid .
Definition: liquidphase2c.hh:360
static Scalar fugacityCoefficient(const FluidState &fluidState, int phaseIdx, int compIdx)
Calculate the fugacity coefficient of an individual component in a fluid phase.
Definition: liquidphase2c.hh:301
static constexpr bool isGas(int phaseIdx=0)
Returns whether the fluid is gaseous.
Definition: liquidphase2c.hh:105
static constexpr int comp1Idx
index of the second component
Definition: liquidphase2c.hh:61
static constexpr int numPhases
Number of phases in the fluid system.
Definition: liquidphase2c.hh:54
static Scalar diffusionCoefficient(const FluidState &fluidState, int phaseIdx, int compIdx)
Calculate the binary molecular diffusion coefficient for a component in a fluid phase .
Definition: liquidphase2c.hh:326
The a parameter cache which does nothing.
Definition: nullparametercache.hh:34
Fluid system base class.