version 3.8
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// SPDX-FileCopyrightInfo: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5// SPDX-License-Identifier: GPL-3.0-or-later
6//
14#ifndef DUMUX_IMMISCIBLE_FLUID_STATE_HH
15#define DUMUX_IMMISCIBLE_FLUID_STATE_HH
16
17#include <limits>
18#include <type_traits>
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, ImmiscibleFluidState>::value, int> = 0>
43 ImmiscibleFluidState(const FluidState &fs)
44 { assign(fs); }
45
46 // copy and move constructor / assignment operator
51
52 /*****************************************************
53 * Generic access to fluid properties (No assumptions
54 * on thermodynamic equilibrium required)
55 *****************************************************/
56
61 int wettingPhase() const { return wPhaseIdx_; }
62
71 Scalar saturation(int phaseIdx) const
72 { return saturation_[phaseIdx]; }
73
83 Scalar moleFraction(int phaseIdx, int compIdx) const
84 { return (phaseIdx == compIdx) ? 1.0 : 0.0; }
85
94 Scalar massFraction(int phaseIdx, int compIdx) const
95 { return (phaseIdx == compIdx) ? 1.0 : 0.0; }
96
108 Scalar averageMolarMass(int phaseIdx) const
109 { return FluidSystem::molarMass(/*compIdx=*/phaseIdx); }
110
120 Scalar molarity(int phaseIdx, int compIdx) const
121 { return molarDensity(phaseIdx)*moleFraction(phaseIdx, compIdx); }
122
146 Scalar fugacity(int phaseIdx, int compIdx) const
147 { return phaseIdx == compIdx ? pressure(phaseIdx) : 0.0; }
148
157 Scalar fugacityCoefficient(int phaseIdx, int compIdx) const
158 { return phaseIdx == compIdx ? 1.0 : std::numeric_limits<Scalar>::infinity(); }
159
167 Scalar partialPressure(int phaseIdx, int compIdx) const
168 { return phaseIdx == compIdx ? pressure(phaseIdx) : 0.0; }
169
175 Scalar molarVolume(int phaseIdx) const
176 { return 1.0/molarDensity(phaseIdx); }
177
182 Scalar density(int phaseIdx) const
183 { return density_[phaseIdx]; }
184
193 Scalar molarDensity(int phaseIdx) const
194 { return molarDensity_[phaseIdx]; }
195
199 Scalar temperature(int phaseIdx) const
200 { return temperature_[phaseIdx]; }
201
205 Scalar pressure(int phaseIdx) const
206 { return pressure_[phaseIdx]; }
207
211 Scalar enthalpy(int phaseIdx) const
212 { return enthalpy_[phaseIdx]; }
213
221 Scalar internalEnergy(int phaseIdx) const
222 { return enthalpy_[phaseIdx] - pressure(phaseIdx)/density(phaseIdx); }
223
227 Scalar viscosity(int phaseIdx) const
228 { return viscosity_[phaseIdx]; }
229
230 /*****************************************************
231 * Access to fluid properties which only make sense
232 * if assuming thermodynamic equilibrium
233 *****************************************************/
234
239 { return temperature_[0]; }
240
246 Scalar fugacity(int compIdx) const
247 { return fugacity(0, compIdx); }
248
249
250 /*****************************************************
251 * Setter methods. Note that these are not part of the
252 * generic FluidState interface but specific for each
253 * implementation...
254 *****************************************************/
255
265 template <class FluidState>
266 void assign(const FluidState &fs)
267 {
268 for (int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx)
269 {
270 pressure_[phaseIdx] = fs.pressure(phaseIdx);
271 saturation_[phaseIdx] = fs.saturation(phaseIdx);
272 density_[phaseIdx] = fs.density(phaseIdx);
273 molarDensity_[phaseIdx] = fs.molarDensity(phaseIdx);
274 enthalpy_[phaseIdx] = fs.enthalpy(phaseIdx);
275 viscosity_[phaseIdx] = fs.viscosity(phaseIdx);
276 temperature_[phaseIdx] = fs.temperature(0);
277 }
278 }
279
283 void setTemperature(int phaseIdx, Scalar value)
284 { temperature_[phaseIdx] = value; }
285
290 {
291 for (int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx)
292 temperature_[phaseIdx] = value;
293 }
294
298 void setPressure(int phaseIdx, Scalar value)
299 { pressure_[phaseIdx] = value; }
300
304 void setSaturation(int phaseIdx, Scalar value)
305 { saturation_[phaseIdx] = value; }
306
310 void setDensity(int phaseIdx, Scalar value)
311 { density_[phaseIdx] = value; }
312
316 void setMolarDensity(int phaseIdx, Scalar value)
317 { molarDensity_[phaseIdx] = value; }
318
322 void setEnthalpy(int phaseIdx, Scalar value)
323 { enthalpy_[phaseIdx] = value; }
324
328 void setViscosity(int phaseIdx, Scalar value)
329 { viscosity_[phaseIdx] = value; }
330
334 void setWettingPhase(int phaseIdx)
335 { wPhaseIdx_ = phaseIdx; }
336protected:
345
347};
348
349} // end namespace Dumux
350
351#endif
Represents all relevant thermodynamic quantities of a multi-phase fluid system assuming immiscibility...
Definition: immiscible.hh:30
ImmiscibleFluidState(ImmiscibleFluidState &&fs)=default
Scalar temperature() const
The temperature within the domain .
Definition: immiscible.hh:238
Scalar averageMolarMass(int phaseIdx) const
The average molar mass of phase in .
Definition: immiscible.hh:108
Scalar enthalpy(int phaseIdx) const
The specific enthalpy of a fluid phase in .
Definition: immiscible.hh:211
Scalar molarDensity(int phaseIdx) const
The molar density of a fluid phase in .
Definition: immiscible.hh:193
void assign(const FluidState &fs)
Retrieve all parameters from an arbitrary fluid state.
Definition: immiscible.hh:266
Scalar fugacityCoefficient(int phaseIdx, int compIdx) const
The fugacity coefficient of component in fluid phase in .
Definition: immiscible.hh:157
Scalar temperature_[numPhases]
Definition: immiscible.hh:344
static constexpr int numComponents
Definition: immiscible.hh:33
ImmiscibleFluidState(const ImmiscibleFluidState &fs)=default
Scalar partialPressure(int phaseIdx, int compIdx) const
The partial pressure of a component in a phase .
Definition: immiscible.hh:167
Scalar saturation(int phaseIdx) const
Returns the saturation of a fluid phase in .
Definition: immiscible.hh:71
Scalar moleFraction(int phaseIdx, int compIdx) const
Returns the molar fraction of the component in fluid phase in .
Definition: immiscible.hh:83
Scalar enthalpy_[numPhases]
Definition: immiscible.hh:342
ImmiscibleFluidState(const FluidState &fs)
copy constructor from arbitrary fluid state
Definition: immiscible.hh:43
ImmiscibleFluidState & operator=(const ImmiscibleFluidState &fs)=default
Scalar pressure(int phaseIdx) const
The pressure of a fluid phase in .
Definition: immiscible.hh:205
Scalar viscosity(int phaseIdx) const
The dynamic viscosity of fluid phase in .
Definition: immiscible.hh:227
Scalar molarVolume(int phaseIdx) const
The molar volume of a fluid phase in .
Definition: immiscible.hh:175
Scalar fugacity(int phaseIdx, int compIdx) const
The fugacity of component in fluid phase in .
Definition: immiscible.hh:146
ScalarType Scalar
export the scalar type
Definition: immiscible.hh:36
Scalar density_[numPhases]
Definition: immiscible.hh:340
void setDensity(int phaseIdx, Scalar value)
Set the density of a phase .
Definition: immiscible.hh:310
int wettingPhase() const
Returns the index of the most wetting phase in the fluid-solid configuration (for porous medium syste...
Definition: immiscible.hh:61
static constexpr int numPhases
Definition: immiscible.hh:32
Scalar massFraction(int phaseIdx, int compIdx) const
Returns the mass fraction of component in fluid phase in .
Definition: immiscible.hh:94
Scalar molarity(int phaseIdx, int compIdx) const
The molar concentration of component in fluid phase in .
Definition: immiscible.hh:120
void setTemperature(int phaseIdx, Scalar value)
Set the temperature of a fluid phase.
Definition: immiscible.hh:283
Scalar internalEnergy(int phaseIdx) const
The specific internal energy of a fluid phase in .
Definition: immiscible.hh:221
Scalar viscosity_[numPhases]
Definition: immiscible.hh:343
Scalar saturation_[numPhases]
Definition: immiscible.hh:339
int wPhaseIdx_
Definition: immiscible.hh:346
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:304
Scalar fugacity(int compIdx) const
The fugacity of a component .
Definition: immiscible.hh:246
Scalar molarDensity_[numPhases]
Definition: immiscible.hh:341
Scalar temperature(int phaseIdx) const
The absolute temperature of a fluid phase in .
Definition: immiscible.hh:199
ImmiscibleFluidState & operator=(ImmiscibleFluidState &&fs)=default
void setWettingPhase(int phaseIdx)
Set the index of the most wetting phase.
Definition: immiscible.hh:334
void setMolarDensity(int phaseIdx, Scalar value)
Set the molar density of a phase .
Definition: immiscible.hh:316
ImmiscibleFluidState()=default
default constructor
void setViscosity(int phaseIdx, Scalar value)
Set the dynamic viscosity of a phase .
Definition: immiscible.hh:328
void setEnthalpy(int phaseIdx, Scalar value)
Set the specific enthalpy of a phase .
Definition: immiscible.hh:322
void setTemperature(Scalar value)
Set the temperature of a fluid phase.
Definition: immiscible.hh:289
void setPressure(int phaseIdx, Scalar value)
Set the fluid pressure of a phase .
Definition: immiscible.hh:298
Scalar density(int phaseIdx) const
The mass density of the fluid phase in .
Definition: immiscible.hh:182
Definition: adapt.hh:17