3.1-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 *****************************************************/
75 Scalar saturation(int phaseIdx) const
76 { return saturation_[phaseIdx]; }
77
87 Scalar moleFraction(int phaseIdx, int compIdx) const
88 { return (phaseIdx == compIdx) ? 1.0 : 0.0; }
89
98 Scalar massFraction(int phaseIdx, int compIdx) const
99 { return (phaseIdx == compIdx) ? 1.0 : 0.0; }
100
112 Scalar averageMolarMass(int phaseIdx) const
113 { return FluidSystem::molarMass(/*compIdx=*/phaseIdx); }
114
124 Scalar molarity(int phaseIdx, int compIdx) const
125 { return molarDensity(phaseIdx)*moleFraction(phaseIdx, compIdx); }
126
137 Scalar fugacity(int phaseIdx, int compIdx) const
138 { return phaseIdx == compIdx ? pressure(phaseIdx) : 0.0; }
139
148 Scalar fugacityCoefficient(int phaseIdx, int compIdx) const
149 { return phaseIdx == compIdx ? 1.0 : std::numeric_limits<Scalar>::infinity(); }
150
156 Scalar molarVolume(int phaseIdx) const
157 { return 1.0/molarDensity(phaseIdx); }
158
163 Scalar density(int phaseIdx) const
164 { return density_[phaseIdx]; }
165
174 Scalar molarDensity(int phaseIdx) const
175 { return molarDensity_[phaseIdx]; }
176
180 Scalar temperature(int phaseIdx) const
181 { return temperature_; }
182
187 { return temperature_; }
188
192 Scalar pressure(int phaseIdx) const
193 { return pressure_[phaseIdx]; }
194
199 Scalar enthalpy(int phaseIdx) const
200 { DUNE_THROW(Dune::NotImplemented,"No enthalpy() function defined for isothermal systems!"); }
201
209 Scalar internalEnergy(int phaseIdx) const
210 { DUNE_THROW(Dune::NotImplemented,"No internalEnergy() function defined for isothermal systems!"); }
211
215 Scalar viscosity(int phaseIdx) const
216 { return viscosity_[phaseIdx]; }
217
218 /*****************************************************
219 * Setter methods. Note that these are not part of the
220 * generic FluidState interface but specific for each
221 * implementation...
222 *****************************************************/
223
229 template <class FluidState>
230 void assign(const FluidState &fs)
231 {
232 for (int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx)
233 {
234 pressure_[phaseIdx] = fs.pressure(phaseIdx);
235 saturation_[phaseIdx] = fs.saturation(phaseIdx);
236 density_[phaseIdx] = fs.density(phaseIdx);
237 molarDensity_[phaseIdx] = fs.molarDensity(phaseIdx);
238 viscosity_[phaseIdx] = fs.viscosity(phaseIdx);
239 }
240 temperature_ = fs.temperature(0);
241 }
242
247 { temperature_ = value; }
248
252 void setPressure(int phaseIdx, Scalar value)
253 { pressure_[phaseIdx] = value; }
254
258 void setSaturation(int phaseIdx, Scalar value)
259 { saturation_[phaseIdx] = value; }
260
264 void setDensity(int phaseIdx, Scalar value)
265 { density_[phaseIdx] = value; }
266
270 void setMolarDensity(int phaseIdx, Scalar value)
271 { molarDensity_[phaseIdx] = value; }
272
276 void setViscosity(int phaseIdx, Scalar value)
277 { viscosity_[phaseIdx] = value; }
278
279protected:
286};
287
288} // end namespace Dumux
289
290#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: 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:98
static constexpr int numComponents
Definition: isothermalimmiscible.hh:45
Scalar averageMolarMass(int phaseIdx) const
The average molar mass of phase in .
Definition: isothermalimmiscible.hh:112
Scalar temperature() const
The temperature within the domain .
Definition: isothermalimmiscible.hh:186
Scalar viscosity(int phaseIdx) const
The dynamic viscosity of fluid phase in .
Definition: isothermalimmiscible.hh:215
Scalar molarVolume(int phaseIdx) const
The molar volume of a fluid phase in .
Definition: isothermalimmiscible.hh:156
Scalar density_[numPhases]
Definition: isothermalimmiscible.hh:282
void setDensity(int phaseIdx, Scalar value)
Set the density of a phase .
Definition: isothermalimmiscible.hh:264
Scalar viscosity_[numPhases]
Definition: isothermalimmiscible.hh:284
Scalar internalEnergy(int phaseIdx) const
The specific internal energy of a fluid phase in .
Definition: isothermalimmiscible.hh:209
Scalar fugacityCoefficient(int phaseIdx, int compIdx) const
The fugacity coefficient of component in fluid phase in .
Definition: isothermalimmiscible.hh:148
void setMolarDensity(int phaseIdx, Scalar value)
Set the molar density of a phase .
Definition: isothermalimmiscible.hh:270
void setSaturation(int phaseIdx, Scalar value)
Set the saturation of a phase .
Definition: isothermalimmiscible.hh:258
Scalar molarity(int phaseIdx, int compIdx) const
The molar concentration of component in fluid phase in .
Definition: isothermalimmiscible.hh:124
Scalar pressure_[numPhases]
Definition: isothermalimmiscible.hh:280
IsothermalImmiscibleFluidState()=default
default constructor
Scalar saturation_[numPhases]
Definition: isothermalimmiscible.hh:281
Scalar density(int phaseIdx) const
The mass density of the fluid phase in .
Definition: isothermalimmiscible.hh:163
Scalar temperature(int phaseIdx) const
The temperature of a fluid phase .
Definition: isothermalimmiscible.hh:180
Scalar pressure(int phaseIdx) const
The pressure of a fluid phase in .
Definition: isothermalimmiscible.hh:192
IsothermalImmiscibleFluidState & operator=(IsothermalImmiscibleFluidState &&fs)=default
void setViscosity(int phaseIdx, Scalar value)
Set the dynamic viscosity of a phase .
Definition: isothermalimmiscible.hh:276
Scalar temperature_
Definition: isothermalimmiscible.hh:285
void setPressure(int phaseIdx, Scalar value)
Set the fluid pressure of a phase .
Definition: isothermalimmiscible.hh:252
IsothermalImmiscibleFluidState(const FluidState &fs)
copy constructor from arbitrary fluid state
Definition: isothermalimmiscible.hh:55
IsothermalImmiscibleFluidState(IsothermalImmiscibleFluidState &&fs)=default
void assign(const FluidState &fs)
Retrieve all parameters from an arbitrary fluid state.
Definition: isothermalimmiscible.hh:230
Scalar moleFraction(int phaseIdx, int compIdx) const
Returns the molar fraction of the component in fluid phase in .
Definition: isothermalimmiscible.hh:87
Scalar fugacity(int phaseIdx, int compIdx) const
The fugacity of component in fluid phase in .
Definition: isothermalimmiscible.hh:137
Scalar molarDensity(int phaseIdx) const
The molar density of a fluid phase in .
Definition: isothermalimmiscible.hh:174
void setTemperature(Scalar value)
Set the temperature of a fluid phase.
Definition: isothermalimmiscible.hh:246
Scalar enthalpy(int phaseIdx) const
The specific enthalpy of a fluid phase in This is not defined for an isothermal fluidstate.
Definition: isothermalimmiscible.hh:199
Scalar saturation(int phaseIdx) const
Returns the saturation of a fluid phase in .
Definition: isothermalimmiscible.hh:75
Scalar molarDensity_[numPhases]
Definition: isothermalimmiscible.hh:283
static constexpr int numPhases
Definition: isothermalimmiscible.hh:44
ScalarType Scalar
export the scalar type
Definition: isothermalimmiscible.hh:48
IsothermalImmiscibleFluidState(const IsothermalImmiscibleFluidState &fs)=default