3.2-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
isothermalimmiscible.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 *****************************************************************************/
25#ifndef DUMUX_ISOIMMISCIBLE_FLUID_STATE_HH
26#define DUMUX_ISOIMMISCIBLE_FLUID_STATE_HH
27
28#include <limits>
29#include <type_traits>
30#include <dune/common/exceptions.hh>
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, IsothermalImmiscibleFluidState>::value, int> = 0>
55 IsothermalImmiscibleFluidState(const FluidState &fs)
56 { assign(fs); }
57
58 // copy and move constructor / assignment operator
63
64 /*****************************************************
65 * Generic access to fluid properties
66 *****************************************************/
67
72 int wettingPhase() const { return wPhaseIdx_; }
73
82 Scalar saturation(int phaseIdx) const
83 { return saturation_[phaseIdx]; }
84
94 Scalar moleFraction(int phaseIdx, int compIdx) const
95 { return (phaseIdx == compIdx) ? 1.0 : 0.0; }
96
105 Scalar massFraction(int phaseIdx, int compIdx) const
106 { return (phaseIdx == compIdx) ? 1.0 : 0.0; }
107
119 Scalar averageMolarMass(int phaseIdx) const
120 { return FluidSystem::molarMass(/*compIdx=*/phaseIdx); }
121
131 Scalar molarity(int phaseIdx, int compIdx) const
132 { return molarDensity(phaseIdx)*moleFraction(phaseIdx, compIdx); }
133
144 Scalar fugacity(int phaseIdx, int compIdx) const
145 { return phaseIdx == compIdx ? pressure(phaseIdx) : 0.0; }
146
155 Scalar fugacityCoefficient(int phaseIdx, int compIdx) const
156 { return phaseIdx == compIdx ? 1.0 : std::numeric_limits<Scalar>::infinity(); }
157
163 Scalar molarVolume(int phaseIdx) const
164 { return 1.0/molarDensity(phaseIdx); }
165
170 Scalar density(int phaseIdx) const
171 { return density_[phaseIdx]; }
172
181 Scalar molarDensity(int phaseIdx) const
182 { return molarDensity_[phaseIdx]; }
183
187 Scalar temperature(int phaseIdx) const
188 { return temperature_; }
189
194 { return temperature_; }
195
199 Scalar pressure(int phaseIdx) const
200 { return pressure_[phaseIdx]; }
201
206 Scalar enthalpy(int phaseIdx) const
207 { DUNE_THROW(Dune::NotImplemented,"No enthalpy() function defined for isothermal systems!"); }
208
216 Scalar internalEnergy(int phaseIdx) const
217 { DUNE_THROW(Dune::NotImplemented,"No internalEnergy() function defined for isothermal systems!"); }
218
222 Scalar viscosity(int phaseIdx) const
223 { return viscosity_[phaseIdx]; }
224
225 /*****************************************************
226 * Setter methods. Note that these are not part of the
227 * generic FluidState interface but specific for each
228 * implementation...
229 *****************************************************/
230
236 template <class FluidState>
237 void assign(const FluidState &fs)
238 {
239 for (int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx)
240 {
241 pressure_[phaseIdx] = fs.pressure(phaseIdx);
242 saturation_[phaseIdx] = fs.saturation(phaseIdx);
243 density_[phaseIdx] = fs.density(phaseIdx);
244 molarDensity_[phaseIdx] = fs.molarDensity(phaseIdx);
245 viscosity_[phaseIdx] = fs.viscosity(phaseIdx);
246 }
247 temperature_ = fs.temperature(0);
248 }
249
254 { temperature_ = value; }
255
259 void setPressure(int phaseIdx, Scalar value)
260 { pressure_[phaseIdx] = value; }
261
265 void setSaturation(int phaseIdx, Scalar value)
266 { saturation_[phaseIdx] = value; }
267
271 void setDensity(int phaseIdx, Scalar value)
272 { density_[phaseIdx] = value; }
273
277 void setMolarDensity(int phaseIdx, Scalar value)
278 { molarDensity_[phaseIdx] = value; }
279
283 void setViscosity(int phaseIdx, Scalar value)
284 { viscosity_[phaseIdx] = value; }
285
289 void setWettingPhase(int phaseIdx)
290 { wPhaseIdx_ = phaseIdx; }
291protected:
298
300};
301
302} // end namespace Dumux
303
304#endif
Definition: adapt.hh:29
Represents all relevant thermodynamic quantities of a multi-phase fluid system assuming immiscibility...
Definition: isothermalimmiscible.hh:42
IsothermalImmiscibleFluidState & operator=(const IsothermalImmiscibleFluidState &fs)=default
Scalar massFraction(int phaseIdx, int compIdx) const
Returns the mass fraction of component in fluid phase in .
Definition: isothermalimmiscible.hh:105
static constexpr int numComponents
Definition: isothermalimmiscible.hh:45
Scalar averageMolarMass(int phaseIdx) const
The average molar mass of phase in .
Definition: isothermalimmiscible.hh:119
Scalar temperature() const
The temperature within the domain .
Definition: isothermalimmiscible.hh:193
Scalar viscosity(int phaseIdx) const
The dynamic viscosity of fluid phase in .
Definition: isothermalimmiscible.hh:222
void setWettingPhase(int phaseIdx)
Set the index of the most wetting phase.
Definition: isothermalimmiscible.hh:289
Scalar molarVolume(int phaseIdx) const
The molar volume of a fluid phase in .
Definition: isothermalimmiscible.hh:163
Scalar density_[numPhases]
Definition: isothermalimmiscible.hh:294
void setDensity(int phaseIdx, Scalar value)
Set the density of a phase .
Definition: isothermalimmiscible.hh:271
Scalar viscosity_[numPhases]
Definition: isothermalimmiscible.hh:296
Scalar internalEnergy(int phaseIdx) const
The specific internal energy of a fluid phase in .
Definition: isothermalimmiscible.hh:216
int wettingPhase() const
Returns the index of the most wetting phase in the fluid-solid configuration (for porous medium syste...
Definition: isothermalimmiscible.hh:72
Scalar fugacityCoefficient(int phaseIdx, int compIdx) const
The fugacity coefficient of component in fluid phase in .
Definition: isothermalimmiscible.hh:155
void setMolarDensity(int phaseIdx, Scalar value)
Set the molar density of a phase .
Definition: isothermalimmiscible.hh:277
void setSaturation(int phaseIdx, Scalar value)
Set the saturation of a phase .
Definition: isothermalimmiscible.hh:265
Scalar molarity(int phaseIdx, int compIdx) const
The molar concentration of component in fluid phase in .
Definition: isothermalimmiscible.hh:131
Scalar pressure_[numPhases]
Definition: isothermalimmiscible.hh:292
IsothermalImmiscibleFluidState()=default
default constructor
Scalar saturation_[numPhases]
Definition: isothermalimmiscible.hh:293
Scalar density(int phaseIdx) const
The mass density of the fluid phase in .
Definition: isothermalimmiscible.hh:170
Scalar temperature(int phaseIdx) const
The temperature of a fluid phase .
Definition: isothermalimmiscible.hh:187
Scalar pressure(int phaseIdx) const
The pressure of a fluid phase in .
Definition: isothermalimmiscible.hh:199
IsothermalImmiscibleFluidState & operator=(IsothermalImmiscibleFluidState &&fs)=default
void setViscosity(int phaseIdx, Scalar value)
Set the dynamic viscosity of a phase .
Definition: isothermalimmiscible.hh:283
Scalar temperature_
Definition: isothermalimmiscible.hh:297
void setPressure(int phaseIdx, Scalar value)
Set the fluid pressure of a phase .
Definition: isothermalimmiscible.hh:259
IsothermalImmiscibleFluidState(const FluidState &fs)
copy constructor from arbitrary fluid state
Definition: isothermalimmiscible.hh:55
IsothermalImmiscibleFluidState(IsothermalImmiscibleFluidState &&fs)=default
int wPhaseIdx_
Definition: isothermalimmiscible.hh:299
void assign(const FluidState &fs)
Retrieve all parameters from an arbitrary fluid state.
Definition: isothermalimmiscible.hh:237
Scalar moleFraction(int phaseIdx, int compIdx) const
Returns the molar fraction of the component in fluid phase in .
Definition: isothermalimmiscible.hh:94
Scalar fugacity(int phaseIdx, int compIdx) const
The fugacity of component in fluid phase in .
Definition: isothermalimmiscible.hh:144
Scalar molarDensity(int phaseIdx) const
The molar density of a fluid phase in .
Definition: isothermalimmiscible.hh:181
void setTemperature(Scalar value)
Set the temperature of a fluid phase.
Definition: isothermalimmiscible.hh:253
Scalar enthalpy(int phaseIdx) const
The specific enthalpy of a fluid phase in This is not defined for an isothermal fluidstate.
Definition: isothermalimmiscible.hh:206
Scalar saturation(int phaseIdx) const
Returns the saturation of a fluid phase in .
Definition: isothermalimmiscible.hh:82
Scalar molarDensity_[numPhases]
Definition: isothermalimmiscible.hh:295
static constexpr int numPhases
Definition: isothermalimmiscible.hh:44
ScalarType Scalar
export the scalar type
Definition: isothermalimmiscible.hh:48
IsothermalImmiscibleFluidState(const IsothermalImmiscibleFluidState &fs)=default