3.1-git
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
77 Scalar saturation(int phaseIdx) const
78 { return saturation_[phaseIdx]; }
79
89 Scalar moleFraction(int phaseIdx, int compIdx) const
90 { return (phaseIdx == compIdx) ? 1.0 : 0.0; }
91
100 Scalar massFraction(int phaseIdx, int compIdx) const
101 { return (phaseIdx == compIdx) ? 1.0 : 0.0; }
102
114 Scalar averageMolarMass(int phaseIdx) const
115 { return FluidSystem::molarMass(/*compIdx=*/phaseIdx); }
116
126 Scalar molarity(int phaseIdx, int compIdx) const
127 { return molarDensity(phaseIdx)*moleFraction(phaseIdx, compIdx); }
128
152 Scalar fugacity(int phaseIdx, int compIdx) const
153 { return phaseIdx == compIdx ? pressure(phaseIdx) : 0.0; }
154
163 Scalar fugacityCoefficient(int phaseIdx, int compIdx) const
164 { return phaseIdx == compIdx ? 1.0 : std::numeric_limits<Scalar>::infinity(); }
165
173 Scalar partialPressure(int phaseIdx, int compIdx) const
174 { return phaseIdx == compIdx ? pressure(phaseIdx) : 0.0; }
175
181 Scalar molarVolume(int phaseIdx) const
182 { return 1.0/molarDensity(phaseIdx); }
183
188 Scalar density(int phaseIdx) const
189 { return density_[phaseIdx]; }
190
199 Scalar molarDensity(int phaseIdx) const
200 { return molarDensity_[phaseIdx]; }
201
205 Scalar temperature(int phaseIdx) const
206 { return temperature_[phaseIdx]; }
207
211 Scalar pressure(int phaseIdx) const
212 { return pressure_[phaseIdx]; }
213
217 Scalar enthalpy(int phaseIdx) const
218 { return enthalpy_[phaseIdx]; }
219
227 Scalar internalEnergy(int phaseIdx) const
228 { return enthalpy_[phaseIdx] - pressure(phaseIdx)/density(phaseIdx); }
229
233 Scalar viscosity(int phaseIdx) const
234 { return viscosity_[phaseIdx]; }
235
236 /*****************************************************
237 * Access to fluid properties which only make sense
238 * if assuming thermodynamic equilibrium
239 *****************************************************/
240
245 { return temperature_[0]; }
246
252 Scalar fugacity(int compIdx) const
253 { return fugacity(0, compIdx); }
254
255
256 /*****************************************************
257 * Setter methods. Note that these are not part of the
258 * generic FluidState interface but specific for each
259 * implementation...
260 *****************************************************/
261
271 template <class FluidState>
272 void assign(const FluidState &fs)
273 {
274 for (int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx)
275 {
276 pressure_[phaseIdx] = fs.pressure(phaseIdx);
277 saturation_[phaseIdx] = fs.saturation(phaseIdx);
278 density_[phaseIdx] = fs.density(phaseIdx);
279 molarDensity_[phaseIdx] = fs.molarDensity(phaseIdx);
280 enthalpy_[phaseIdx] = fs.enthalpy(phaseIdx);
281 viscosity_[phaseIdx] = fs.viscosity(phaseIdx);
282 temperature_[phaseIdx] = fs.temperature(0);
283 }
284 }
285
289 void setTemperature(int phaseIdx, Scalar value)
290 { temperature_[phaseIdx] = value; }
291
296 {
297 for (int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx)
298 temperature_[phaseIdx] = value;
299 }
300
304 void setPressure(int phaseIdx, Scalar value)
305 { pressure_[phaseIdx] = value; }
306
310 void setSaturation(int phaseIdx, Scalar value)
311 { saturation_[phaseIdx] = value; }
312
316 void setDensity(int phaseIdx, Scalar value)
317 { density_[phaseIdx] = value; }
318
322 void setMolarDensity(int phaseIdx, Scalar value)
323 { molarDensity_[phaseIdx] = value; }
324
328 void setEnthalpy(int phaseIdx, Scalar value)
329 { enthalpy_[phaseIdx] = value; }
330
334 void setViscosity(int phaseIdx, Scalar value)
335 { viscosity_[phaseIdx] = value; }
336protected:
345};
346
347} // end namespace Dumux
348
349#endif
make the local view function available whenever we use the grid geometry
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:244
Scalar averageMolarMass(int phaseIdx) const
The average molar mass of phase in .
Definition: immiscible.hh:114
Scalar enthalpy(int phaseIdx) const
The specific enthalpy of a fluid phase in .
Definition: immiscible.hh:217
Scalar molarDensity(int phaseIdx) const
The molar density of a fluid phase in .
Definition: immiscible.hh:199
void assign(const FluidState &fs)
Retrieve all parameters from an arbitrary fluid state.
Definition: immiscible.hh:272
Scalar fugacityCoefficient(int phaseIdx, int compIdx) const
The fugacity coefficient of component in fluid phase in .
Definition: immiscible.hh:163
Scalar temperature_[numPhases]
Definition: immiscible.hh:344
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:173
Scalar saturation(int phaseIdx) const
Returns the saturation of a fluid phase in .
Definition: immiscible.hh:77
Scalar moleFraction(int phaseIdx, int compIdx) const
Returns the molar fraction of the component in fluid phase in .
Definition: immiscible.hh:89
Scalar enthalpy_[numPhases]
Definition: immiscible.hh:342
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:211
Scalar viscosity(int phaseIdx) const
The dynamic viscosity of fluid phase in .
Definition: immiscible.hh:233
Scalar molarVolume(int phaseIdx) const
The molar volume of a fluid phase in .
Definition: immiscible.hh:181
Scalar fugacity(int phaseIdx, int compIdx) const
The fugacity of component in fluid phase in .
Definition: immiscible.hh:152
ScalarType Scalar
export the scalar type
Definition: immiscible.hh:48
Scalar density_[numPhases]
Definition: immiscible.hh:340
void setDensity(int phaseIdx, Scalar value)
Set the density of a phase .
Definition: immiscible.hh:316
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:100
Scalar molarity(int phaseIdx, int compIdx) const
The molar concentration of component in fluid phase in .
Definition: immiscible.hh:126
void setTemperature(int phaseIdx, Scalar value)
Set the temperature of a fluid phase.
Definition: immiscible.hh:289
Scalar internalEnergy(int phaseIdx) const
The specific internal energy of a fluid phase in .
Definition: immiscible.hh:227
Scalar viscosity_[numPhases]
Definition: immiscible.hh:343
Scalar saturation_[numPhases]
Definition: immiscible.hh:339
Scalar pressure_[numPhases]
zero-initialize all data members with braces syntax
Definition: immiscible.hh:338
void setSaturation(int phaseIdx, Scalar value)
Set the saturation of a phase .
Definition: immiscible.hh:310
Scalar fugacity(int compIdx) const
The fugacity of a component .
Definition: immiscible.hh:252
Scalar molarDensity_[numPhases]
Definition: immiscible.hh:341
Scalar temperature(int phaseIdx) const
The absolute temperature of a fluid phase in .
Definition: immiscible.hh:205
ImmiscibleFluidState & operator=(ImmiscibleFluidState &&fs)=default
void setMolarDensity(int phaseIdx, Scalar value)
Set the molar density of a phase .
Definition: immiscible.hh:322
ImmiscibleFluidState()=default
default constructor
void setViscosity(int phaseIdx, Scalar value)
Set the dynamic viscosity of a phase .
Definition: immiscible.hh:334
void setEnthalpy(int phaseIdx, Scalar value)
Set the specific enthalpy of a phase .
Definition: immiscible.hh:328
void setTemperature(Scalar value)
Set the temperature of a fluid phase.
Definition: immiscible.hh:295
void setPressure(int phaseIdx, Scalar value)
Set the fluid pressure of a phase .
Definition: immiscible.hh:304
Scalar density(int phaseIdx) const
The mass density of the fluid phase in .
Definition: immiscible.hh:188