OpenFOAM logo
Open Source CFD Toolkit

specieThermo.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2005 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Class
00026     specieThermo
00027 
00028 Description
00029     Basic thermodynamics type based on the use of fitting functions for
00030     cp, h, s obtained from the template argument type thermo.  All other
00031     properties are derived from these primitive functions.
00032 
00033 SourceFiles
00034     specieThermoI.H
00035     specieThermo.C
00036 
00037 \*---------------------------------------------------------------------------*/
00038 
00039 #ifndef specieThermo_H
00040 #define specieThermo_H
00041 
00042 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00043 
00044 namespace Foam
00045 {
00046 
00047 // * * * * * * Forward declaration of template friend fuctions * * * * * * * //
00048 
00049 template<class thermo> class specieThermo;
00050 
00051 template<class thermo>
00052 inline specieThermo<thermo> operator+
00053 (
00054     const specieThermo<thermo>&,
00055     const specieThermo<thermo>&
00056 );
00057 
00058 template<class thermo>
00059 inline specieThermo<thermo> operator-
00060 (
00061     const specieThermo<thermo>&,
00062     const specieThermo<thermo>&
00063 );
00064 
00065 template<class thermo>
00066 inline specieThermo<thermo> operator*
00067 (
00068     const scalar,
00069     const specieThermo<thermo>&
00070 );
00071 
00072 template<class thermo>
00073 inline specieThermo<thermo> operator==
00074 (
00075     const specieThermo<thermo>&,
00076     const specieThermo<thermo>&
00077 );
00078 
00079 template<class thermo>
00080 Ostream& operator<<
00081 (
00082     Ostream&,
00083     const specieThermo<thermo>&
00084 );
00085 
00086 
00087 /*---------------------------------------------------------------------------*\
00088                            Class specieThermo Declaration
00089 \*---------------------------------------------------------------------------*/
00090 
00091 template<class thermo>
00092 class specieThermo
00093 :
00094     public thermo
00095 {
00096     // Private data
00097 
00098         //- Convergence tolerance of energy -> temperature inversion functions
00099         static const scalar tol_;
00100 
00101         //- Max number of iterations in energy->temperature inversion functions
00102         static const int maxIter_;
00103 
00104 
00105     // Private member functions
00106 
00107         //- return the temperature corresponding to the value of the
00108         //  thermodynamic property f, given the function f = F(T) and dF(T)/dT
00109         inline scalar T
00110         (
00111             scalar f,
00112             scalar T0,
00113             scalar (specieThermo::*F)(const scalar) const,
00114             scalar (specieThermo::*dFdT)(const scalar) const
00115         ) const;
00116 
00117 
00118 public:
00119 
00120     // Constructors
00121 
00122         //- construct from components
00123         inline specieThermo(const thermo& sp);
00124 
00125         //- Construct from Istream
00126         specieThermo(Istream&);
00127 
00128         //- Construct as named copy
00129         inline specieThermo(const word& name, const specieThermo&);
00130 
00131 
00132     // Member Functions
00133 
00134         // Fundamaental properties
00135         // (These functions must be provided in derived types)
00136 
00137             // Heat capacity at constant pressure [J/(kmol K)]
00138             //scalar cp(const scalar) const;
00139 
00140             // Enthalpy [J/kmol]
00141             //scalar h(const scalar) const;
00142 
00143             // Entropy [J/(kmol K)]
00144             //scalar s(const scalar) const;
00145 
00146 
00147         // Calculate and return derived properties
00148         // (These functions need not provided in derived types)
00149 
00150             // Mole specific properties
00151 
00152                 //- Heat capacity at constant volume [J/(kmol K)]
00153                 inline scalar cv(const scalar T) const;
00154 
00155                 //- gamma = cp/cv []
00156                 inline scalar gamma(const scalar T) const;
00157 
00158                 //- Internal energy [J/kmol]
00159                 inline scalar e(const scalar T) const;
00160 
00161                 //- Gibbs free energy [J/kmol]
00162                 inline scalar g(const scalar T) const;
00163 
00164                 //- Helmholtz free energy [J/kmol]
00165                 inline scalar a(const scalar T) const;
00166 
00167 
00168             // Mass specific properties
00169 
00170                 //- Heat capacity at constant pressure [J/(kg K)]
00171                 inline scalar Cp(const scalar T) const;
00172 
00173                 //- Heat capacity at constant volume [J/(kg K)]
00174                 inline scalar Cv(const scalar T) const;
00175 
00176                 //- Enthalpy [J/kg]
00177                 inline scalar H(const scalar T) const;
00178 
00179                 //- Entropy [J/(kg K)]
00180                 inline scalar S(const scalar T) const;
00181 
00182                 //- Internal energy [J/kg]
00183                 inline scalar E(const scalar T) const;
00184 
00185                 //- Gibbs free energy [J/kg]
00186                 inline scalar G(const scalar T) const;
00187 
00188                 //- Helmholtz free energy [J/kg]
00189                 inline scalar A(const scalar T) const;
00190 
00191 
00192         // Equilibrium reaction thermodynamics
00193 
00194             //- Equilibrium constant [] i.t.o fugacities
00195             //  = PIi(fi/Pstd)^nui
00196             inline scalar K(const scalar T) const;
00197 
00198             //- Equilibrium constant [] i.t.o. partial pressures
00199             //  = PIi(pi/Pstd)^nui
00200             //  For low pressures (where the gas mixture is near perfect) Kp = K
00201             inline scalar Kp(const scalar T) const;
00202 
00203             //- Equilibrium constant i.t.o. molar concentration
00204             //  = PIi(ci/cstd)^nui
00205             //  For low pressures (where the gas mixture is near perfect)
00206             //  Kc = Kp(pstd/(RR*T))^nu
00207             inline scalar Kc(const scalar T) const;
00208 
00209             //- Equilibrium constant [] i.t.o. mole-fractions
00210             //  For low pressures (where the gas mixture is near perfect) 
00211             //  Kx = Kp(pstd/p)^nui
00212             inline scalar Kx(const scalar T, const scalar p) const;
00213 
00214             //- Equilibrium constant [] i.t.o. number of moles
00215             //  For low pressures (where the gas mixture is near perfect) 
00216             //  Kn = Kp(n*pstd/p)^nui where n = number of moles in mixture
00217             inline scalar Kn
00218             (
00219                 const scalar T,
00220                 const scalar p,
00221                 const scalar n
00222             ) const;
00223 
00224 
00225         // Energy->temperature  inversion functions
00226 
00227             //- Temperature from Enthalpy given an initial temperature T0
00228             inline scalar TH(const scalar H, const scalar T0) const;
00229 
00230             //- Temperature from internal energy given an initial temperature T0
00231             inline scalar TE(const scalar E, const scalar T0) const;
00232 
00233 
00234     // Member operators
00235 
00236         inline void operator+=(const specieThermo&);
00237         inline void operator-=(const specieThermo&);
00238 
00239         inline void operator*=(const scalar);
00240 
00241 
00242     // Friend operators
00243 
00244         friend specieThermo operator+ <thermo>
00245         (
00246             const specieThermo&,
00247             const specieThermo&
00248         );
00249 
00250         friend specieThermo operator- <thermo>
00251         (
00252             const specieThermo&,
00253             const specieThermo&
00254         );
00255 
00256         friend specieThermo operator* <thermo>
00257         (
00258             const scalar s,
00259             const specieThermo&
00260         );
00261 
00262         friend specieThermo operator== <thermo>
00263         (
00264             const specieThermo&,
00265             const specieThermo&
00266         );
00267 
00268 
00269     // Ostream Operator
00270 
00271         friend Ostream& operator<< <thermo>
00272         (
00273             Ostream&,
00274             const specieThermo&
00275         );
00276 };
00277 
00278 
00279 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00280 
00281 } // End namespace Foam
00282 
00283 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00284 
00285 #include "specieThermoI.H"
00286 
00287 #ifdef NoRepository
00288 #   include "specieThermo.C"
00289 #endif
00290 
00291 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00292 
00293 #endif
00294 
00295 // ************************************************************************* //
For further information go to www.openfoam.org