version 3.10-dev
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// SPDX-FileCopyrightInfo: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5// SPDX-License-Identifier: GPL-3.0-or-later
6//
13#ifndef DUMUX_ISOIMMISCIBLE_FLUID_STATE_HH
14#define DUMUX_ISOIMMISCIBLE_FLUID_STATE_HH
15
16#include <limits>
17#include <type_traits>
18#include <dune/common/exceptions.hh>
19
20namespace Dumux {
21
28template <class ScalarType, class FluidSystem>
30{
31public:
32 static constexpr int numPhases = FluidSystem::numPhases;
33 static constexpr int numComponents = FluidSystem::numComponents;
34
36 using Scalar = ScalarType;
37
40
42 template <class FluidState, typename std::enable_if_t<!std::is_same<FluidState, IsothermalImmiscibleFluidState>::value, int> = 0>
43 IsothermalImmiscibleFluidState(const FluidState &fs)
44 { assign(fs); }
45
46 // copy and move constructor / assignment operator
51
52 /*****************************************************
53 * Generic access to fluid properties
54 *****************************************************/
55
60 int wettingPhase() const { return wPhaseIdx_; }
61
70 Scalar saturation(int phaseIdx) const
71 { return saturation_[phaseIdx]; }
72
82 Scalar moleFraction(int phaseIdx, int compIdx) const
83 { return (phaseIdx == compIdx) ? 1.0 : 0.0; }
84
93 Scalar massFraction(int phaseIdx, int compIdx) const
94 { return (phaseIdx == compIdx) ? 1.0 : 0.0; }
95
107 Scalar averageMolarMass(int phaseIdx) const
108 { return FluidSystem::molarMass(/*compIdx=*/phaseIdx); }
109
119 Scalar molarity(int phaseIdx, int compIdx) const
120 { return molarDensity(phaseIdx)*moleFraction(phaseIdx, compIdx); }
121
132 Scalar fugacity(int phaseIdx, int compIdx) const
133 { return phaseIdx == compIdx ? pressure(phaseIdx) : 0.0; }
134
143 Scalar fugacityCoefficient(int phaseIdx, int compIdx) const
144 { return phaseIdx == compIdx ? 1.0 : std::numeric_limits<Scalar>::infinity(); }
145
151 Scalar molarVolume(int phaseIdx) const
152 { return 1.0/molarDensity(phaseIdx); }
153
158 Scalar density(int phaseIdx) const
159 { return density_[phaseIdx]; }
160
169 Scalar molarDensity(int phaseIdx) const
170 { return molarDensity_[phaseIdx]; }
171
175 Scalar temperature(int phaseIdx) const
176 { return temperature_; }
177
182 { return temperature_; }
183
187 Scalar pressure(int phaseIdx) const
188 { return pressure_[phaseIdx]; }
189
194 Scalar enthalpy(int phaseIdx) const
195 { DUNE_THROW(Dune::NotImplemented,"No enthalpy() function defined for isothermal systems!"); }
196
204 Scalar internalEnergy(int phaseIdx) const
205 { DUNE_THROW(Dune::NotImplemented,"No internalEnergy() function defined for isothermal systems!"); }
206
210 Scalar viscosity(int phaseIdx) const
211 { return viscosity_[phaseIdx]; }
212
213 /*****************************************************
214 * Setter methods. Note that these are not part of the
215 * generic FluidState interface but specific for each
216 * implementation...
217 *****************************************************/
218
224 template <class FluidState>
225 void assign(const FluidState &fs)
226 {
227 for (int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx)
228 {
229 pressure_[phaseIdx] = fs.pressure(phaseIdx);
230 saturation_[phaseIdx] = fs.saturation(phaseIdx);
231 density_[phaseIdx] = fs.density(phaseIdx);
232 molarDensity_[phaseIdx] = fs.molarDensity(phaseIdx);
233 viscosity_[phaseIdx] = fs.viscosity(phaseIdx);
234 }
235 temperature_ = fs.temperature(0);
236 }
237
242 { temperature_ = value; }
243
247 void setPressure(int phaseIdx, Scalar value)
248 { pressure_[phaseIdx] = value; }
249
253 void setSaturation(int phaseIdx, Scalar value)
254 { saturation_[phaseIdx] = value; }
255
259 void setDensity(int phaseIdx, Scalar value)
260 { density_[phaseIdx] = value; }
261
265 void setMolarDensity(int phaseIdx, Scalar value)
266 { molarDensity_[phaseIdx] = value; }
267
271 void setViscosity(int phaseIdx, Scalar value)
272 { viscosity_[phaseIdx] = value; }
273
277 void setWettingPhase(int phaseIdx)
278 { wPhaseIdx_ = phaseIdx; }
279protected:
286
288};
289
290} // end namespace Dumux
291
292#endif
Represents all relevant thermodynamic quantities of a multi-phase fluid system assuming immiscibility...
Definition: isothermalimmiscible.hh:30
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:93
static constexpr int numComponents
Definition: isothermalimmiscible.hh:33
Scalar averageMolarMass(int phaseIdx) const
The average molar mass of phase in .
Definition: isothermalimmiscible.hh:107
Scalar temperature() const
The temperature within the domain .
Definition: isothermalimmiscible.hh:181
Scalar viscosity(int phaseIdx) const
The dynamic viscosity of fluid phase in .
Definition: isothermalimmiscible.hh:210
void setWettingPhase(int phaseIdx)
Set the index of the most wetting phase.
Definition: isothermalimmiscible.hh:277
Scalar molarVolume(int phaseIdx) const
The molar volume of a fluid phase in .
Definition: isothermalimmiscible.hh:151
Scalar density_[numPhases]
Definition: isothermalimmiscible.hh:282
void setDensity(int phaseIdx, Scalar value)
Set the density of a phase .
Definition: isothermalimmiscible.hh:259
Scalar viscosity_[numPhases]
Definition: isothermalimmiscible.hh:284
Scalar internalEnergy(int phaseIdx) const
The specific internal energy of a fluid phase in .
Definition: isothermalimmiscible.hh:204
int wettingPhase() const
Returns the index of the most wetting phase in the fluid-solid configuration (for porous medium syste...
Definition: isothermalimmiscible.hh:60
Scalar fugacityCoefficient(int phaseIdx, int compIdx) const
The fugacity coefficient of component in fluid phase in .
Definition: isothermalimmiscible.hh:143
void setMolarDensity(int phaseIdx, Scalar value)
Set the molar density of a phase .
Definition: isothermalimmiscible.hh:265
void setSaturation(int phaseIdx, Scalar value)
Set the saturation of a phase .
Definition: isothermalimmiscible.hh:253
Scalar molarity(int phaseIdx, int compIdx) const
The molar concentration of component in fluid phase in .
Definition: isothermalimmiscible.hh:119
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:158
Scalar temperature(int phaseIdx) const
The temperature of a fluid phase .
Definition: isothermalimmiscible.hh:175
Scalar pressure(int phaseIdx) const
The pressure of a fluid phase in .
Definition: isothermalimmiscible.hh:187
IsothermalImmiscibleFluidState & operator=(IsothermalImmiscibleFluidState &&fs)=default
void setViscosity(int phaseIdx, Scalar value)
Set the dynamic viscosity of a phase .
Definition: isothermalimmiscible.hh:271
Scalar temperature_
Definition: isothermalimmiscible.hh:285
void setPressure(int phaseIdx, Scalar value)
Set the fluid pressure of a phase .
Definition: isothermalimmiscible.hh:247
IsothermalImmiscibleFluidState(const FluidState &fs)
copy constructor from arbitrary fluid state
Definition: isothermalimmiscible.hh:43
IsothermalImmiscibleFluidState(IsothermalImmiscibleFluidState &&fs)=default
int wPhaseIdx_
Definition: isothermalimmiscible.hh:287
void assign(const FluidState &fs)
Retrieve all parameters from an arbitrary fluid state.
Definition: isothermalimmiscible.hh:225
Scalar moleFraction(int phaseIdx, int compIdx) const
Returns the molar fraction of the component in fluid phase in .
Definition: isothermalimmiscible.hh:82
Scalar fugacity(int phaseIdx, int compIdx) const
The fugacity of component in fluid phase in .
Definition: isothermalimmiscible.hh:132
Scalar molarDensity(int phaseIdx) const
The molar density of a fluid phase in .
Definition: isothermalimmiscible.hh:169
void setTemperature(Scalar value)
Set the temperature of a fluid phase.
Definition: isothermalimmiscible.hh:241
Scalar enthalpy(int phaseIdx) const
The specific enthalpy of a fluid phase in This is not defined for an isothermal fluidstate.
Definition: isothermalimmiscible.hh:194
Scalar saturation(int phaseIdx) const
Returns the saturation of a fluid phase in .
Definition: isothermalimmiscible.hh:70
Scalar molarDensity_[numPhases]
Definition: isothermalimmiscible.hh:283
static constexpr int numPhases
Definition: isothermalimmiscible.hh:32
ScalarType Scalar
export the scalar type
Definition: isothermalimmiscible.hh:36
IsothermalImmiscibleFluidState(const IsothermalImmiscibleFluidState &fs)=default
Definition: adapt.hh:17