1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
36 // Construct from components
41 const scalar molWeight
50 // Construct from components without name
54 const scalar molWeight
63 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
66 inline specie::specie(const specie& st)
70 molWeight_(st.molWeight_)
74 // Construct as named copy
75 inline specie::specie(const word& name, const specie& st)
79 molWeight_(st.molWeight_)
83 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
85 //- Molecular weight [kg/kmol]
86 inline scalar specie::W() const
91 //- No of moles of this species in mixture
92 inline scalar specie::nMoles() const
97 //- Gas constant [J/(kg K)]
98 inline scalar specie::R() const
100 return RR/molWeight_;
104 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
106 inline void specie::operator=(const specie& st)
109 nMoles_ = st.nMoles_;
110 molWeight_ = st.molWeight_;
114 inline void specie::operator+=(const specie& st)
116 scalar sumNmoles_ = max(nMoles_ + st.nMoles_, SMALL);
119 nMoles_/sumNmoles_*molWeight_
120 + st.nMoles_/sumNmoles_*st.molWeight_;
122 nMoles_ = sumNmoles_;
126 inline void specie::operator-=(const specie& st)
128 scalar diffnMoles_ = nMoles_ - st.nMoles_;
129 if (mag(diffnMoles_) < SMALL)
135 nMoles_/diffnMoles_*molWeight_
136 - st.nMoles_/diffnMoles_*st.molWeight_;
138 nMoles_ = diffnMoles_;
142 inline void specie::operator*=(const scalar s)
148 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
150 inline specie operator+(const specie& st1, const specie& st2)
152 scalar sumNmoles_ = max(st1.nMoles_ + st2.nMoles_, SMALL);
157 st1.nMoles_/sumNmoles_*st1.molWeight_
158 + st2.nMoles_/sumNmoles_*st2.molWeight_
163 inline specie operator-(const specie& st1, const specie& st2)
165 scalar diffNmoles_ = st1.nMoles_ - st2.nMoles_;
166 if (mag(diffNmoles_) < SMALL)
174 st1.nMoles_/diffNmoles_*st1.molWeight_
175 - st2.nMoles_/diffNmoles_*st2.molWeight_
180 inline specie operator*(const scalar s, const specie& st)
190 inline specie operator==(const specie& st1, const specie& st2)
196 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
198 } // End namespace Foam
200 // ************************************************************************* //