Line | Branch | Exec | Source |
---|---|---|---|
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 | // | ||
7 | /*! | ||
8 | * \file | ||
9 | * \ingroup FluidStates | ||
10 | * \brief This is a fluid state which allows to set the fluid | ||
11 | * pressures and takes all other quantities from an other | ||
12 | * fluid state. | ||
13 | */ | ||
14 | #ifndef DUMUX_PRESSURE_OVERLAY_FLUID_STATE_HH | ||
15 | #define DUMUX_PRESSURE_OVERLAY_FLUID_STATE_HH | ||
16 | |||
17 | namespace Dumux { | ||
18 | |||
19 | /*! | ||
20 | * \ingroup FluidStates | ||
21 | * \brief This is a fluid state which allows to set the fluid | ||
22 | * pressures and takes all other quantities from an other | ||
23 | * fluid state. | ||
24 | */ | ||
25 | template <class FluidState> | ||
26 | class PressureOverlayFluidState | ||
27 | { | ||
28 | public: | ||
29 | static constexpr int numPhases = FluidState::numPhases; | ||
30 | static constexpr int numComponents = FluidState::numComponents; | ||
31 | |||
32 | //! export the scalar type | ||
33 | using Scalar = typename FluidState::Scalar; | ||
34 | |||
35 | /*! | ||
36 | * \brief Constructor | ||
37 | * | ||
38 | * \param fs Fluidstate | ||
39 | * The overlay fluid state copies the pressures from the argument, | ||
40 | * so it initially behaves exactly like the underlying fluid | ||
41 | * state. | ||
42 | */ | ||
43 | 1 | PressureOverlayFluidState(const FluidState &fs) | |
44 | 1 | : fs_(&fs) | |
45 | { | ||
46 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1 times.
|
3 | for (int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) |
47 | 4 | pressure_[phaseIdx] = fs.pressure(phaseIdx); | |
48 | } | ||
49 | |||
50 | // copy & move constructor / assignment operators | ||
51 | PressureOverlayFluidState(const PressureOverlayFluidState &fs) = default; | ||
52 | PressureOverlayFluidState(PressureOverlayFluidState &&fs) = default; | ||
53 | PressureOverlayFluidState& operator=(const PressureOverlayFluidState &fs) = default; | ||
54 | PressureOverlayFluidState& operator=(PressureOverlayFluidState &&fs) = default; | ||
55 | |||
56 | /***************************************************** | ||
57 | * Generic access to fluid properties (No assumptions | ||
58 | * on thermodynamic equilibrium required) | ||
59 | *****************************************************/ | ||
60 | /*! | ||
61 | * \brief Returns the saturation \f$S_\alpha\f$ of a fluid phase \f$\alpha\f$ in \f$\mathrm{[-]}\f$. | ||
62 | * | ||
63 | * The saturation is defined as the pore space occupied by the fluid divided by the total pore space: | ||
64 | * \f[S_\alpha := \frac{\phi \mathcal{V}_\alpha}{\phi \mathcal{V}}\f] | ||
65 | * | ||
66 | * \param phaseIdx the index of the phase | ||
67 | */ | ||
68 | ✗ | Scalar saturation(int phaseIdx) const | |
69 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
2 | { return fs_->saturation(phaseIdx); } |
70 | |||
71 | /*! | ||
72 | * \brief Returns the molar fraction \f$x^\kappa_\alpha\f$ of the component \f$\kappa\f$ in fluid phase \f$\alpha\f$ in \f$\mathrm{[-]}\f$. | ||
73 | * | ||
74 | * The molar fraction \f$x^\kappa_\alpha\f$ is defined as the ratio of the number of molecules | ||
75 | * of component \f$\kappa\f$ and the total number of molecules of the phase \f$\alpha\f$. | ||
76 | * | ||
77 | * \param phaseIdx the index of the phase | ||
78 | * \param compIdx the index of the component | ||
79 | */ | ||
80 | ✗ | Scalar moleFraction(int phaseIdx, int compIdx) const | |
81 | 2 | { return fs_->moleFraction(phaseIdx, compIdx); } | |
82 | |||
83 | /*! | ||
84 | * \brief Returns the mass fraction \f$X^\kappa_\alpha\f$ of component \f$\kappa\f$ in fluid phase \f$\alpha\f$ in \f$\mathrm{[-]}\f$. | ||
85 | * | ||
86 | * The mass fraction \f$X^\kappa_\alpha\f$ is defined as the weight of all molecules of a | ||
87 | * component divided by the total mass of the fluid phase. It is related with the component's mole fraction by means of the relation | ||
88 | * | ||
89 | * \f[X^\kappa_\alpha = x^\kappa_\alpha \frac{M^\kappa}{\overline M_\alpha}\;,\f] | ||
90 | * | ||
91 | * where \f$M^\kappa\f$ is the molar mass of component \f$\kappa\f$ and | ||
92 | * \f$\overline M_\alpha\f$ is the mean molar mass of a molecule of phase | ||
93 | * \f$\alpha\f$. | ||
94 | * | ||
95 | * \param phaseIdx the index of the phase | ||
96 | * \param compIdx the index of the component | ||
97 | */ | ||
98 | ✗ | Scalar massFraction(int phaseIdx, int compIdx) const | |
99 | 1 | { return fs_->massFraction(phaseIdx, compIdx); } | |
100 | |||
101 | /*! | ||
102 | * \brief The average molar mass \f$\overline M_\alpha\f$ of phase \f$\alpha\f$ in \f$\mathrm{[kg/mol]}\f$ | ||
103 | * | ||
104 | * The average molar mass is the mean mass of a mole of the | ||
105 | * fluid at current composition. It is defined as the sum of the | ||
106 | * component's molar masses weighted by the current mole fraction: | ||
107 | * \f[\mathrm{ \overline M_\alpha = \sum_\kappa M^\kappa x_\alpha^\kappa}\f] | ||
108 | */ | ||
109 | ✗ | Scalar averageMolarMass(int phaseIdx) const | |
110 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
2 | { return fs_->averageMolarMass(phaseIdx); } |
111 | |||
112 | /*! | ||
113 | * \brief The molar concentration \f$c^\kappa_\alpha\f$ of component \f$\kappa\f$ in fluid phase \f$\alpha\f$ in \f$\mathrm{[mol/m^3]}\f$ | ||
114 | * | ||
115 | * This quantity is usually called "molar concentration" or just | ||
116 | * "concentration", but there are many other (though less common) | ||
117 | * measures for concentration. | ||
118 | * | ||
119 | * http://en.wikipedia.org/wiki/Concentration | ||
120 | */ | ||
121 | ✗ | Scalar molarity(int phaseIdx, int compIdx) const | |
122 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
2 | { return fs_->molarity(phaseIdx, compIdx); } |
123 | |||
124 | /*! | ||
125 | * \brief The fugacity \f$f^\kappa_\alpha\f$ of component \f$\kappa\f$ | ||
126 | * in fluid phase \f$\alpha\f$ in \f$\mathrm{[Pa]}\f$ | ||
127 | * | ||
128 | * The fugacity is defined as: | ||
129 | * \f$f_\alpha^\kappa := \Phi^\kappa_\alpha x^\kappa_\alpha p_\alpha \;,\f$ | ||
130 | * where \f$\Phi^\kappa_\alpha\f$ is the fugacity coefficient \cite reid1987 . | ||
131 | * The physical meaning of fugacity becomes clear from the equation: | ||
132 | * \f[f_\alpha^\kappa = p_\alpha \exp\left\{\frac{\zeta^\kappa_\alpha}{R T_\alpha} \right\} \;,\f] | ||
133 | * where \f$\zeta^\kappa_\alpha\f$ represents the \f$\kappa\f$'s chemical | ||
134 | * potential in phase \f$\alpha\f$, \f$R\f$ stands for the ideal gas constant, | ||
135 | * and \f$T_\alpha\f$ for the absolute temperature of phase \f$\alpha\f$. Assuming thermal equilibrium, | ||
136 | * there is a one-to-one mapping between a component's chemical potential | ||
137 | * \f$\zeta^\kappa_\alpha\f$ and its fugacity \f$f^\kappa_\alpha\f$. In this | ||
138 | * case chemical equilibrium can thus be expressed by: | ||
139 | * \f[f^\kappa := f^\kappa_\alpha = f^\kappa_\beta\quad\forall \alpha, \beta\f] | ||
140 | */ | ||
141 | ✗ | Scalar fugacity(int phaseIdx, int compIdx) const | |
142 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
2 | { return fs_->fugacity(phaseIdx, compIdx); } |
143 | |||
144 | /*! | ||
145 | * \brief The fugacity coefficient \f$\Phi^\kappa_\alpha\f$ of component \f$\kappa\f$ in fluid phase \f$\alpha\f$ in \f$\mathrm{[-]}\f$ | ||
146 | */ | ||
147 | ✗ | Scalar fugacityCoefficient(int phaseIdx, int compIdx) const | |
148 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
2 | { return fs_->fugacityCoefficient(phaseIdx, compIdx); } |
149 | |||
150 | /*! | ||
151 | * \brief The molar volume \f$v_{mol,\alpha}\f$ of a fluid phase \f$\alpha\f$ in \f$\mathrm{[m^3/mol]}\f$ | ||
152 | * | ||
153 | * This quantity is the inverse of the molar density. | ||
154 | */ | ||
155 | ✗ | Scalar molarVolume(int phaseIdx) const | |
156 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
2 | { return fs_->molarVolume(phaseIdx); } |
157 | |||
158 | /*! | ||
159 | * \brief The mass density \f$\rho_\alpha\f$ of the fluid phase | ||
160 | * \f$\alpha\f$ in \f$\mathrm{[kg/m^3]}\f$ | ||
161 | */ | ||
162 | ✗ | Scalar density(int phaseIdx) const | |
163 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
2 | { return fs_->density(phaseIdx); } |
164 | |||
165 | /*! | ||
166 | * \brief The molar density \f$\rho_{mol,\alpha}\f$ | ||
167 | * of a fluid phase \f$\alpha\f$ in \f$\mathrm{[mol/m^3]}\f$ | ||
168 | * | ||
169 | * The molar density is defined by the mass density \f$\rho_\alpha\f$ and the mean molar mass \f$\overline M_\alpha\f$: | ||
170 | * | ||
171 | * \f[\rho_{mol,\alpha} = \frac{\rho_\alpha}{\overline M_\alpha} \;.\f] | ||
172 | */ | ||
173 | ✗ | Scalar molarDensity(int phaseIdx) const | |
174 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
2 | { return fs_->molarDensity(phaseIdx); } |
175 | |||
176 | /*! | ||
177 | * \brief The absolute temperature\f$T_\alpha\f$ of a fluid phase \f$\alpha\f$ in \f$\mathrm{[K]}\f$ | ||
178 | */ | ||
179 | ✗ | Scalar temperature(int phaseIdx) const | |
180 | 2 | { return fs_->temperature(phaseIdx); } | |
181 | |||
182 | /*! | ||
183 | * \brief The pressure \f$p_\alpha\f$ of a fluid phase \f$\alpha\f$ in \f$\mathrm{[Pa]}\f$ | ||
184 | */ | ||
185 | Scalar pressure(int phaseIdx) const | ||
186 | 1 | { return pressure_[phaseIdx]; } | |
187 | |||
188 | /*! | ||
189 | * \brief The specific enthalpy \f$h_\alpha\f$ of a fluid phase \f$\alpha\f$ in \f$\mathrm{[J/kg]}\f$ | ||
190 | */ | ||
191 | ✗ | Scalar enthalpy(int phaseIdx) const | |
192 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
2 | { return fs_->enthalpy(phaseIdx); } |
193 | |||
194 | /*! | ||
195 | * \brief The specific internal energy \f$u_\alpha\f$ of a fluid phase \f$\alpha\f$ in \f$\mathrm{[J/kg]}\f$ | ||
196 | * | ||
197 | * The specific internal energy is defined by the relation: | ||
198 | * | ||
199 | * \f[u_\alpha = h_\alpha - \frac{p_\alpha}{\rho_\alpha}\f] | ||
200 | */ | ||
201 | ✗ | Scalar internalEnergy(int phaseIdx) const | |
202 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
2 | { return fs_->internalEnergy(phaseIdx); } |
203 | |||
204 | /*! | ||
205 | * \brief The dynamic viscosity \f$\mu_\alpha\f$ of fluid phase \f$\alpha\f$ in \f$\mathrm{[Pa s]}\f$ | ||
206 | */ | ||
207 | ✗ | Scalar viscosity(int phaseIdx) const | |
208 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
2 | { return fs_->viscosity(phaseIdx); } |
209 | |||
210 | |||
211 | /***************************************************** | ||
212 | * Setter methods. Note that these are not part of the | ||
213 | * generic FluidState interface but specific for each | ||
214 | * implementation... | ||
215 | *****************************************************/ | ||
216 | /*! | ||
217 | * \brief Set the pressure \f$\mathrm{[Pa]}\f$ of a fluid phase | ||
218 | */ | ||
219 | void setPressure(int phaseIdx, Scalar value) | ||
220 | { pressure_[phaseIdx] = value; } | ||
221 | |||
222 | protected: | ||
223 | const FluidState *fs_; | ||
224 | Scalar pressure_[numPhases] = {}; | ||
225 | }; | ||
226 | |||
227 | } // end namespace Dumux | ||
228 | |||
229 | #endif | ||
230 |