3.4
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
immiscible.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 *****************************************************************************/
26#ifndef DUMUX_IMMISCIBLE_FLUID_STATE_HH
27#define DUMUX_IMMISCIBLE_FLUID_STATE_HH
28
29#include <limits>
30#include <type_traits>
31
32namespace Dumux {
33
40template <class ScalarType, class FluidSystem>
42{
43public:
44 static constexpr int numPhases = FluidSystem::numPhases;
45 static constexpr int numComponents = FluidSystem::numComponents;
46
48 using Scalar = ScalarType;
49
52
54 template <class FluidState, typename std::enable_if_t<!std::is_same<FluidState, ImmiscibleFluidState>::value, int> = 0>
55 ImmiscibleFluidState(const FluidState &fs)
56 { assign(fs); }
57
58 // copy and move constructor / assignment operator
63
64 /*****************************************************
65 * Generic access to fluid properties (No assumptions
66 * on thermodynamic equilibrium required)
67 *****************************************************/
68
73 int wettingPhase() const { return wPhaseIdx_; }
74
83 Scalar saturation(int phaseIdx) const
84 { return saturation_[phaseIdx]; }
85
95 Scalar moleFraction(int phaseIdx, int compIdx) const
96 { return (phaseIdx == compIdx) ? 1.0 : 0.0; }
97
106 Scalar massFraction(int phaseIdx, int compIdx) const
107 { return (phaseIdx == compIdx) ? 1.0 : 0.0; }
108
120 Scalar averageMolarMass(int phaseIdx) const
121 { return FluidSystem::molarMass(/*compIdx=*/phaseIdx); }
122
132 Scalar molarity(int phaseIdx, int compIdx) const
133 { return molarDensity(phaseIdx)*moleFraction(phaseIdx, compIdx); }
134
158 Scalar fugacity(int phaseIdx, int compIdx) const
159 { return phaseIdx == compIdx ? pressure(phaseIdx) : 0.0; }
160
169 Scalar fugacityCoefficient(int phaseIdx, int compIdx) const
170 { return phaseIdx == compIdx ? 1.0 : std::numeric_limits<Scalar>::infinity(); }
171
179 Scalar partialPressure(int phaseIdx, int compIdx) const
180 { return phaseIdx == compIdx ? pressure(phaseIdx) : 0.0; }
181
187 Scalar molarVolume(int phaseIdx) const
188 { return 1.0/molarDensity(phaseIdx); }
189
194 Scalar density(int phaseIdx) const
195 { return density_[phaseIdx]; }
196
205 Scalar molarDensity(int phaseIdx) const
206 { return molarDensity_[phaseIdx]; }
207
211 Scalar temperature(int phaseIdx) const
212 { return temperature_[phaseIdx]; }
213
217 Scalar pressure(int phaseIdx) const
218 { return pressure_[phaseIdx]; }
219
223 Scalar enthalpy(int phaseIdx) const
224 { return enthalpy_[phaseIdx]; }
225
233 Scalar internalEnergy(int phaseIdx) const
234 { return enthalpy_[phaseIdx] - pressure(phaseIdx)/density(phaseIdx); }
235
239 Scalar viscosity(int phaseIdx) const
240 { return viscosity_[phaseIdx]; }
241
242 /*****************************************************
243 * Access to fluid properties which only make sense
244 * if assuming thermodynamic equilibrium
245 *****************************************************/
246
251 { return temperature_[0]; }
252
258 Scalar fugacity(int compIdx) const
259 { return fugacity(0, compIdx); }
260
261
262 /*****************************************************
263 * Setter methods. Note that these are not part of the
264 * generic FluidState interface but specific for each
265 * implementation...
266 *****************************************************/
267
277 template <class FluidState>
278 void assign(const FluidState &fs)
279 {
280 for (int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx)
281 {
282 pressure_[phaseIdx] = fs.pressure(phaseIdx);
283 saturation_[phaseIdx] = fs.saturation(phaseIdx);
284 density_[phaseIdx] = fs.density(phaseIdx);
285 molarDensity_[phaseIdx] = fs.molarDensity(phaseIdx);
286 enthalpy_[phaseIdx] = fs.enthalpy(phaseIdx);
287 viscosity_[phaseIdx] = fs.viscosity(phaseIdx);
288 temperature_[phaseIdx] = fs.temperature(0);
289 }
290 }
291
295 void setTemperature(int phaseIdx, Scalar value)
296 { temperature_[phaseIdx] = value; }
297
302 {
303 for (int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx)
304 temperature_[phaseIdx] = value;
305 }
306
310 void setPressure(int phaseIdx, Scalar value)
311 { pressure_[phaseIdx] = value; }
312
316 void setSaturation(int phaseIdx, Scalar value)
317 { saturation_[phaseIdx] = value; }
318
322 void setDensity(int phaseIdx, Scalar value)
323 { density_[phaseIdx] = value; }
324
328 void setMolarDensity(int phaseIdx, Scalar value)
329 { molarDensity_[phaseIdx] = value; }
330
334 void setEnthalpy(int phaseIdx, Scalar value)
335 { enthalpy_[phaseIdx] = value; }
336
340 void setViscosity(int phaseIdx, Scalar value)
341 { viscosity_[phaseIdx] = value; }
342
346 void setWettingPhase(int phaseIdx)
347 { wPhaseIdx_ = phaseIdx; }
348protected:
357
359};
360
361} // end namespace Dumux
362
363#endif
Definition: adapt.hh:29
Represents all relevant thermodynamic quantities of a multi-phase fluid system assuming immiscibility...
Definition: immiscible.hh:42
ImmiscibleFluidState(ImmiscibleFluidState &&fs)=default
Scalar temperature() const
The temperature within the domain .
Definition: immiscible.hh:250
Scalar averageMolarMass(int phaseIdx) const
The average molar mass of phase in .
Definition: immiscible.hh:120
Scalar enthalpy(int phaseIdx) const
The specific enthalpy of a fluid phase in .
Definition: immiscible.hh:223
Scalar molarDensity(int phaseIdx) const
The molar density of a fluid phase in .
Definition: immiscible.hh:205
void assign(const FluidState &fs)
Retrieve all parameters from an arbitrary fluid state.
Definition: immiscible.hh:278
Scalar fugacityCoefficient(int phaseIdx, int compIdx) const
The fugacity coefficient of component in fluid phase in .
Definition: immiscible.hh:169
Scalar temperature_[numPhases]
Definition: immiscible.hh:356
static constexpr int numComponents
Definition: immiscible.hh:45
ImmiscibleFluidState(const ImmiscibleFluidState &fs)=default
Scalar partialPressure(int phaseIdx, int compIdx) const
The partial pressure of a component in a phase .
Definition: immiscible.hh:179
Scalar saturation(int phaseIdx) const
Returns the saturation of a fluid phase in .
Definition: immiscible.hh:83
Scalar moleFraction(int phaseIdx, int compIdx) const
Returns the molar fraction of the component in fluid phase in .
Definition: immiscible.hh:95
Scalar enthalpy_[numPhases]
Definition: immiscible.hh:354
ImmiscibleFluidState(const FluidState &fs)
copy constructor from arbitrary fluid state
Definition: immiscible.hh:55
ImmiscibleFluidState & operator=(const ImmiscibleFluidState &fs)=default
Scalar pressure(int phaseIdx) const
The pressure of a fluid phase in .
Definition: immiscible.hh:217
Scalar viscosity(int phaseIdx) const
The dynamic viscosity of fluid phase in .
Definition: immiscible.hh:239
Scalar molarVolume(int phaseIdx) const
The molar volume of a fluid phase in .
Definition: immiscible.hh:187
Scalar fugacity(int phaseIdx, int compIdx) const
The fugacity of component in fluid phase in .
Definition: immiscible.hh:158
ScalarType Scalar
export the scalar type
Definition: immiscible.hh:48
Scalar density_[numPhases]
Definition: immiscible.hh:352
void setDensity(int phaseIdx, Scalar value)
Set the density of a phase .
Definition: immiscible.hh:322
int wettingPhase() const
Returns the index of the most wetting phase in the fluid-solid configuration (for porous medium syste...
Definition: immiscible.hh:73
static constexpr int numPhases
Definition: immiscible.hh:44
Scalar massFraction(int phaseIdx, int compIdx) const
Returns the mass fraction of component in fluid phase in .
Definition: immiscible.hh:106
Scalar molarity(int phaseIdx, int compIdx) const
The molar concentration of component in fluid phase in .
Definition: immiscible.hh:132
void setTemperature(int phaseIdx, Scalar value)
Set the temperature of a fluid phase.
Definition: immiscible.hh:295
Scalar internalEnergy(int phaseIdx) const
The specific internal energy of a fluid phase in .
Definition: immiscible.hh:233
Scalar viscosity_[numPhases]
Definition: immiscible.hh:355
Scalar saturation_[numPhases]
Definition: immiscible.hh:351
int wPhaseIdx_
Definition: immiscible.hh:358
Scalar pressure_[numPhases]
zero-initialize all data members with braces syntax
Definition: immiscible.hh:350
void setSaturation(int phaseIdx, Scalar value)
Set the saturation of a phase .
Definition: immiscible.hh:316
Scalar fugacity(int compIdx) const
The fugacity of a component .
Definition: immiscible.hh:258
Scalar molarDensity_[numPhases]
Definition: immiscible.hh:353
Scalar temperature(int phaseIdx) const
The absolute temperature of a fluid phase in .
Definition: immiscible.hh:211
ImmiscibleFluidState & operator=(ImmiscibleFluidState &&fs)=default
void setWettingPhase(int phaseIdx)
Set the index of the most wetting phase.
Definition: immiscible.hh:346
void setMolarDensity(int phaseIdx, Scalar value)
Set the molar density of a phase .
Definition: immiscible.hh:328
ImmiscibleFluidState()=default
default constructor
void setViscosity(int phaseIdx, Scalar value)
Set the dynamic viscosity of a phase .
Definition: immiscible.hh:340
void setEnthalpy(int phaseIdx, Scalar value)
Set the specific enthalpy of a phase .
Definition: immiscible.hh:334
void setTemperature(Scalar value)
Set the temperature of a fluid phase.
Definition: immiscible.hh:301
void setPressure(int phaseIdx, Scalar value)
Set the fluid pressure of a phase .
Definition: immiscible.hh:310
Scalar density(int phaseIdx) const
The mass density of the fluid phase in .
Definition: immiscible.hh:194