pseudo1p2c.hh 11.2 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*****************************************************************************
 *   See the file COPYING for full copying permissions.                      *
 *                                                                           *
 *   This program is free software: you can redistribute it and/or modify    *
 *   it under the terms of the GNU General Public License as published by    *
 *   the Free Software Foundation, either version 2 of the License, or       *
 *   (at your option) any later version.                                     *
 *                                                                           *
 *   This program is distributed in the hope that it will be useful,         *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of          *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the            *
 *   GNU General Public License for more details.                            *
 *                                                                           *
 *   You should have received a copy of the GNU General Public License       *
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.   *
 *****************************************************************************/
/*!
 * \file
21
 * \ingroup FluidStates
22
23
24
25
26
 * \brief Calculates phase state for a single phase but two-component state.
 */
#ifndef DUMUX_PSEUDO1P2C_FLUID_STATE_HH
#define DUMUX_PSEUDO1P2C_FLUID_STATE_HH

Timo Koch's avatar
Timo Koch committed
27
28
29
30
#include <cassert>

namespace Dumux {

31
32
33
34
35
36
37
38
/*!
 * \ingroup FluidStates
 * \brief Container for compositional variables in a 1p2c situation
 *
 *  This class holds variables for single-phase situations in a 2p2c context.
 *  It is used in case of a multiphysics approach. For the non-present phase,
 *  no information is stored but 0-values are returned to allow for general output
 *  methods.
39
 *  The "flash" calculation routines are in the sequential flash constrain solver, see
40
 *  CompositionalFlash .
41
 */
42
template <class Scalar, class FluidSystem>
43
44
45
46
class PseudoOnePTwoCFluidState
{

public:
47
48
49
    enum { numPhases = FluidSystem::numPhases,
           numComponents = FluidSystem::numComponents
        };
50
    enum {
51
52
        wPhaseIdx = FluidSystem::wPhaseIdx,
        nPhaseIdx = FluidSystem::nPhaseIdx,
53

54
55
        wCompIdx = FluidSystem::wPhaseIdx,
        nCompIdx = FluidSystem::nPhaseIdx
56
57
58
59
60
    };

public:
    /*! \name Acess functions */
    //@{
61
62
63
64
65
66
67
    /*!
     * \brief Returns the saturation \f$S_\alpha\f$ of a fluid phase \f$\alpha\f$ in \f$\mathrm{[-]}\f$.
     *
     * The saturation is defined as the pore space occupied by the fluid divided by the total pore space:
     *  \f[S_\alpha := \frac{\phi \mathcal{V}_\alpha}{\phi \mathcal{V}}\f]
     * This is set either to 1 or 0 depending on the phase presence.
     * \param phaseIdx the index of the phase
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
     */
    Scalar saturation(int phaseIdx) const
    {
        if (phaseIdx == presentPhaseIdx_)
            return 1.;
        else
            return 0.;
    }

    //! \brief Returns the index of the phase that is present in that cell.
    int presentPhaseIdx() const
    {
        return presentPhaseIdx_;
    }

    /*!
     * \brief Return the partial pressure of a component in the gas phase.
     *
     * For an ideal gas, this means \f$ R*T*c \f$.
     * Unit: \f$\mathrm{[Pa] = [N/m^2]}\f$
     *
     * \param compIdx the index of the component
     */
    Scalar partialPressure(int compIdx) const
    {
        return partialPressure(nPhaseIdx, compIdx);
    }

    /*!
97
     * \brief The partial pressure of a component in a phase \f$\mathrm{[Pa]}\f$
98
99
100
101
102
103
104
     */
    Scalar partialPressure(int phaseIdx, int compIdx) const
    {
        assert(FluidSystem::isGas(phaseIdx));
        return pressure(phaseIdx)*moleFraction(phaseIdx, compIdx);
    }

105
106
    /*!
     * \brief The pressure \f$p_\alpha\f$ of a fluid phase \f$\alpha\f$ in \f$\mathrm{[Pa]}\f$
107
108
109
110
111
     */
    Scalar pressure(int phaseIdx) const
    { return pressure_[phaseIdx]; }

    /*!
112
     * \brief Set the density of a phase \f$\mathrm{[kg / m^3]}\f$
113
114
115
116
117
118
119
120
121
122
123
     */
    Scalar density(int phaseIdx) const
    {
        if(phaseIdx == presentPhaseIdx_)
            return density_;
        else
            return 0.;
//            return FluidSystem::density(*this, phaseIdx);
    }

    /*!
124
125
126
127
128
129
130
131
132
133
134
135
     * \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$.
     *
     * The mass fraction \f$X^\kappa_\alpha\f$ is defined as the weight of all molecules of a
     * component divided by the total mass of the fluid phase. It is related with the component's mole fraction by means of the relation
     *
     * This is either set to 1 or 0 depending on the phase presence for the
     * non-wetting phase in general.
     * It is set to the mass fraction of water or 1-massFractionWater
     * if the considered component is the main component of the wetting phase.
     *
     * \param phaseIdx the index of the phase
     * \param compIdx the index of the component
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
     */
    Scalar massFraction(int phaseIdx, int compIdx) const
    {
        if(phaseIdx != presentPhaseIdx_)
        {
            if(phaseIdx == compIdx)
                return 1.;
            else
                return 0.;
        }


        if (compIdx == wPhaseIdx)
            return massFractionWater_;
        else
            return 1.-massFractionWater_;

    }

    /*!
156
157
158
159
160
161
162
163
     * \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$.
     *
     * This is either set to 1 or 0 depending on the phase presence for the
     * non-wetting phase in general.
     * It is set to the mole fraction of water or 1-moleFractionWater
     * if the considered component is the main component of the wetting phase.
     * \param phaseIdx the index of the phase
     * \param compIdx the index of the component
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
     */
    Scalar moleFraction(int phaseIdx, int compIdx) const
    {
        if(phaseIdx != presentPhaseIdx_)
        {
            if(phaseIdx == compIdx)
                return 1.;
            else
                return 0.;
        }

        if (compIdx == wPhaseIdx)
            return moleFractionWater_;
        else
            return 1.-moleFractionWater_;
    }

    /*!
182
     * \brief The dynamic viscosity \f$\mu_\alpha\f$ of fluid phase \f$\alpha\f$ in \f$\mathrm{[Pa s]}\f$
183
184
185
186
187
188
189
190
     */
    Scalar viscosity(int phaseIdx) const
    {
        assert(phaseIdx == presentPhaseIdx_);
        return viscosity_;
    }

    /*!
191
192
193
194
195
196
     * \brief The average molar mass \f$\overline M_\alpha\f$ of phase \f$\alpha\f$ in \f$\mathrm{[kg/mol]}\f$
     *
     * The average molar mass is the mean mass of a mole of the
     * fluid at current composition. It is defined as the sum of the
     * component's molar masses weighted by the current mole fraction:
     * \f[\mathrm{ \overline M_\alpha = \sum_\kappa M^\kappa x_\alpha^\kappa}\f]
197
198
199
200
201
202
203
     */
    Scalar averageMolarMass(int phaseIdx) const
    {
        return aveMoMass_;
    }

    /*!
204
     * \brief The specific enthalpy \f$h_\alpha\f$ of a fluid phase \f$\alpha\f$ in \f$\mathrm{[J/kg]}\f$
205
206
207
208
209
210
211
212
213
214
     */
    Scalar enthalpy(int phaseIdx) const
    {
        if(phaseIdx == presentPhaseIdx_)
            return enthalpy_;
        else
            return 0.;
    }

    /*!
215
216
217
218
219
     * \brief The specific internal energy \f$u_\alpha\f$ of a fluid phase \f$\alpha\f$ in \f$\mathrm{[J/kg]}\f$
     *
     * The specific internal energy is defined by the relation:
     *
     * \f[u_\alpha = h_\alpha - \frac{p_\alpha}{\rho_\alpha}\f]
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
     */
    Scalar internalEnergy(int phaseIdx) const
    {
        if(phaseIdx == presentPhaseIdx_)
            return enthalpy_ - this->pressure(phaseIdx)/this->density(phaseIdx);
        else
            return 0.;
    }

    /*!
     * \brief Returns the temperature of the fluids \f$\mathrm{[K]}\f$.
     *
     * Note that we assume thermodynamic equilibrium, so all fluids
     * and the rock matrix exhibit the same temperature.
     */
    Scalar temperature(int phaseIdx) const
    { return temperature_; }
    //@}

    /*!
     * \name Functions to set Data
     */
    //@{
    /*!
     * \brief Sets the viscosity of a phase \f$\mathrm{[Pa*s]}\f$.
     *
     * \param phaseIdx the index of the phase
     * @param value Value to be stored
     */
    void setViscosity(int phaseIdx, Scalar value)
    {
        assert(phaseIdx == presentPhaseIdx_);
        viscosity_ = value;
    }
    /*!
     * \brief Sets the mass fraction of a component in a phase.
     *
     * \param phaseIdx the index of the phase
     * \param compIdx the index of the component
     * @param value Value to be stored
     */
    void setMassFraction(int phaseIdx, int compIdx, Scalar value)
    {
        if (compIdx == wCompIdx)
            massFractionWater_ = value;
        else
            massFractionWater_ = 1- value;
    }

    /*!
     * \brief Sets the molar fraction of a component in a fluid phase.
     *
     * \param phaseIdx the index of the phase
     * \param compIdx the index of the component
     * @param value Value to be stored
     */
    void setMoleFraction(int phaseIdx, int compIdx, Scalar value)
    {
        if (compIdx == wCompIdx)
            moleFractionWater_ = value;
        else
            moleFractionWater_ = 1-value;
    }
    /*!
     * \brief Sets the density of a phase \f$\mathrm{[kg/m^3]}\f$.
     *
     * \param phaseIdx the index of the phase
     * @param value Value to be stored
     */
    void setDensity(int phaseIdx, Scalar value)
    {
        assert(phaseIdx == presentPhaseIdx_);
        density_ = value;
    }
    /*!
     * \brief Sets the phase Index that is present in this fluidState.
     * @param phaseIdx the index of the phase
     */
    void setPresentPhaseIdx(int phaseIdx)
    {
        presentPhaseIdx_ = phaseIdx;
    }

    /*!
     * \brief Sets the temperature
     *
     * @param value Value to be stored
     */
    void setTemperature(Scalar value)
    {
        temperature_ = value;
    }
    /*!
     * \brief Set the average molar mass of a fluid phase [kg/mol]
     *
     * The average molar mass is the mean mass of a mole of the
     * fluid at current composition. It is defined as the sum of the
     * component's molar masses weighted by the current mole fraction:
     * \f[ \bar M_\alpha = \sum_\kappa M^\kappa x_\alpha^\kappa \f]
     */
    void setAverageMolarMass(int phaseIdx, Scalar value)
    {
        aveMoMass_ = value;
    }
    /*!
     * \brief Sets the phase pressure \f$\mathrm{[Pa]}\f$.
     */
    void setPressure(int phaseIdx, Scalar value)
    {
        pressure_[phaseIdx] = value;
    }

    /*!
     * \brief Sets phase enthalpy
     *
     * \param phaseIdx the index of the phase
     * @param value Value to be stored
     */
    void setEnthalpy(int phaseIdx, Scalar value)
    {
        assert(phaseIdx == presentPhaseIdx_);
        enthalpy_ = value;
    }
    //@}

protected:
    Scalar aveMoMass_;
    Scalar massConcentration_[numComponents];
    Scalar massFractionWater_;
    Scalar moleFractionWater_;
    Scalar pressure_[numPhases];
    Scalar density_;
    Scalar viscosity_;
    Scalar enthalpy_;
    Scalar temperature_;
    int presentPhaseIdx_;
};

358
} // end namespace Dumux
359
360

#endif