version 3.8
pseudo1p2c.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//
12#ifndef DUMUX_PSEUDO1P2C_FLUID_STATE_HH
13#define DUMUX_PSEUDO1P2C_FLUID_STATE_HH
14
15#include <cassert>
16
17namespace Dumux {
18
30template <class ScalarType, class FluidSystem>
32{
33
34public:
35 static constexpr int numPhases = FluidSystem::numPhases;
36 static constexpr int numComponents = FluidSystem::numComponents;
37
39 using Scalar = ScalarType;
40
41 enum {
42 phase0Idx = FluidSystem::phase0Idx,
43 phase1Idx = FluidSystem::phase1Idx,
44
45 comp0Idx = FluidSystem::comp0Idx,
46 comp1Idx = FluidSystem::comp1Idx
47 };
48
59 Scalar saturation(int phaseIdx) const
60 { return phaseIdx == presentPhaseIdx_ ? 1.0 : 0.0; }
61
63 int presentPhaseIdx() const
64 { return presentPhaseIdx_; }
65
75 Scalar partialPressure(int compIdx) const
76 { return partialPressure(phase1Idx, compIdx); }
77
82 Scalar partialPressure(int phaseIdx, int compIdx) const
83 {
84 assert(FluidSystem::isGas(phaseIdx));
85 return pressure(phaseIdx)*moleFraction(phaseIdx, compIdx);
86 }
87
91 Scalar pressure(int phaseIdx) const
92 { return pressure_[phaseIdx]; }
93
97 Scalar density(int phaseIdx) const
98 { return phaseIdx == presentPhaseIdx_ ? density_ : 0.0; }
99
103 Scalar molarDensity(int phaseIdx) const
104 { return phaseIdx == presentPhaseIdx_ ? molarDensity_ : 0.0; }
105
109 Scalar massFraction(int phaseIdx, int compIdx) const
110 {
111 if (phaseIdx != presentPhaseIdx_)
112 return phaseIdx == compIdx ? 1.0 : 0.0;
113
114 return compIdx == phase0Idx ? massFractionWater_ : 1.0 - massFractionWater_;
115 }
116
127 Scalar moleFraction(int phaseIdx, int compIdx) const
128 {
129 if (phaseIdx != presentPhaseIdx_)
130 return phaseIdx == compIdx ? 1.0 : 0.0;
131
132 return compIdx == phase0Idx ? moleFractionWater_ : 1.0 - moleFractionWater_;
133 }
134
138 Scalar viscosity(int phaseIdx) const
139 {
140 assert(phaseIdx == presentPhaseIdx_);
141 return viscosity_;
142 }
143
152 Scalar averageMolarMass(int phaseIdx) const
153 { return averageMolarMass_; }
154
158 Scalar enthalpy(int phaseIdx) const
159 { return phaseIdx == presentPhaseIdx_ ? enthalpy_ : 0.0; }
160
168 Scalar internalEnergy(int phaseIdx) const
169 { return phaseIdx == presentPhaseIdx_ ? enthalpy_ - pressure(phaseIdx)/density(phaseIdx) : 0.0; }
170
177 Scalar temperature(int phaseIdx) const
178 { return temperature_; }
180
191 void setViscosity(int phaseIdx, Scalar value)
192 {
193 assert(phaseIdx == presentPhaseIdx_);
194 viscosity_ = value;
195 }
196
204 void setMassFraction(int phaseIdx, int compIdx, Scalar value)
205 { massFractionWater_ = compIdx == comp0Idx ? value : 1.0 - value; }
206
214 void setMoleFraction(int phaseIdx, int compIdx, Scalar value)
215 { moleFractionWater_ = compIdx == comp0Idx ? value : 1.0 - value; }
216
223 void setDensity(int phaseIdx, Scalar value)
224 {
225 assert(phaseIdx == presentPhaseIdx_);
226 density_ = value;
227 }
228
235 void setMolarDensity(int phaseIdx, Scalar value)
236 {
237 assert(phaseIdx == presentPhaseIdx_);
238 molarDensity_ = value;
239 }
240
245 void setPresentPhaseIdx(int phaseIdx)
246 { presentPhaseIdx_ = phaseIdx; }
247
254 { temperature_ = value; }
255
264 void setAverageMolarMass(int phaseIdx, Scalar value)
265 { averageMolarMass_ = value; }
266
270 void setPressure(int phaseIdx, Scalar value)
271 { pressure_[phaseIdx] = value; }
272
279 void setEnthalpy(int phaseIdx, Scalar value)
280 {
281 assert(phaseIdx == presentPhaseIdx_);
282 enthalpy_ = value;
283 }
285
286protected:
298};
299
300} // end namespace Dumux
301
302#endif
Container for compositional variables in a 1p2c situation.
Definition: pseudo1p2c.hh:32
Scalar temperature_
Definition: pseudo1p2c.hh:296
ScalarType Scalar
export the scalar type
Definition: pseudo1p2c.hh:39
Scalar averageMolarMass_
Definition: pseudo1p2c.hh:289
@ phase1Idx
Definition: pseudo1p2c.hh:43
@ phase0Idx
Definition: pseudo1p2c.hh:42
@ comp0Idx
Definition: pseudo1p2c.hh:45
@ comp1Idx
Definition: pseudo1p2c.hh:46
void setAverageMolarMass(int phaseIdx, Scalar value)
Set the average molar mass of a fluid phase [kg/mol].
Definition: pseudo1p2c.hh:264
Scalar enthalpy_
Definition: pseudo1p2c.hh:295
void setMassFraction(int phaseIdx, int compIdx, Scalar value)
Sets the mass fraction of a component in a phase.
Definition: pseudo1p2c.hh:204
Scalar partialPressure(int compIdx) const
Return the partial pressure of a component in the gas phase.
Definition: pseudo1p2c.hh:75
Scalar massFractionWater_
Definition: pseudo1p2c.hh:290
void setPresentPhaseIdx(int phaseIdx)
Sets the phase Index that is present in this fluidState.
Definition: pseudo1p2c.hh:245
Scalar internalEnergy(int phaseIdx) const
The specific internal energy of a fluid phase in .
Definition: pseudo1p2c.hh:168
Scalar density_
Definition: pseudo1p2c.hh:292
Scalar moleFractionWater_
Definition: pseudo1p2c.hh:291
void setPressure(int phaseIdx, Scalar value)
Sets the phase pressure .
Definition: pseudo1p2c.hh:270
Scalar massConcentration_[numComponents]
Definition: pseudo1p2c.hh:288
Scalar viscosity(int phaseIdx) const
The dynamic viscosity of fluid phase in .
Definition: pseudo1p2c.hh:138
Scalar density(int phaseIdx) const
Set the density of a phase .
Definition: pseudo1p2c.hh:97
int presentPhaseIdx() const
Returns the index of the phase that is present in that cell.
Definition: pseudo1p2c.hh:63
Scalar viscosity_
Definition: pseudo1p2c.hh:294
Scalar pressure_[numPhases]
Definition: pseudo1p2c.hh:287
int presentPhaseIdx_
Definition: pseudo1p2c.hh:297
static constexpr int numComponents
Definition: pseudo1p2c.hh:36
Scalar molarDensity(int phaseIdx) const
The molar density of the fluid phase in .
Definition: pseudo1p2c.hh:103
Scalar pressure(int phaseIdx) const
The pressure of a fluid phase in .
Definition: pseudo1p2c.hh:91
Scalar moleFraction(int phaseIdx, int compIdx) const
Returns the molar fraction of the component in fluid phase in .
Definition: pseudo1p2c.hh:127
Scalar partialPressure(int phaseIdx, int compIdx) const
The partial pressure of a component in a phase .
Definition: pseudo1p2c.hh:82
void setDensity(int phaseIdx, Scalar value)
Sets the density of a phase .
Definition: pseudo1p2c.hh:223
Scalar enthalpy(int phaseIdx) const
The specific enthalpy of a fluid phase in .
Definition: pseudo1p2c.hh:158
void setViscosity(int phaseIdx, Scalar value)
Sets the viscosity of a phase .
Definition: pseudo1p2c.hh:191
void setEnthalpy(int phaseIdx, Scalar value)
Sets phase enthalpy.
Definition: pseudo1p2c.hh:279
void setMolarDensity(int phaseIdx, Scalar value)
Set the molar density of a phase .
Definition: pseudo1p2c.hh:235
void setTemperature(Scalar value)
Sets the temperature.
Definition: pseudo1p2c.hh:253
Scalar temperature(int phaseIdx) const
Returns the temperature of the fluids .
Definition: pseudo1p2c.hh:177
Scalar massFraction(int phaseIdx, int compIdx) const
Returns the mass fraction of component in fluid phase in .
Definition: pseudo1p2c.hh:109
void setMoleFraction(int phaseIdx, int compIdx, Scalar value)
Sets the molar fraction of a component in a fluid phase.
Definition: pseudo1p2c.hh:214
Scalar averageMolarMass(int phaseIdx) const
The average molar mass of phase in .
Definition: pseudo1p2c.hh:152
Scalar saturation(int phaseIdx) const
Returns the saturation of a fluid phase in .
Definition: pseudo1p2c.hh:59
Scalar molarDensity_
Definition: pseudo1p2c.hh:293
static constexpr int numPhases
Definition: pseudo1p2c.hh:35
Definition: adapt.hh:17