OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

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-2009 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     Foam::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 friend functions and operators
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             // Sensible enthalpy [J/kmol]
00144             //scalar hs(const scalar) const;
00145 
00146             // Chemical enthalpy [J/kmol]
00147             //scalar hc(const scalar) const;
00148 
00149             // Entropy [J/(kmol K)]
00150             //scalar s(const scalar) const;
00151 
00152 
00153         // Calculate and return derived properties
00154         // (These functions need not provided in derived types)
00155 
00156             // Mole specific properties
00157 
00158                 //- Heat capacity at constant volume [J/(kmol K)]
00159                 inline scalar cv(const scalar T) const;
00160 
00161                 //- gamma = cp/cv []
00162                 inline scalar gamma(const scalar T) const;
00163 
00164                 //- Internal energy [J/kmol]
00165                 inline scalar e(const scalar T) const;
00166 
00167                 //- Sensible internal energy [J/kmol]
00168                 inline scalar es(const scalar T) const;
00169 
00170                 //- Gibbs free energy [J/kmol]
00171                 inline scalar g(const scalar T) const;
00172 
00173                 //- Helmholtz free energy [J/kmol]
00174                 inline scalar a(const scalar T) const;
00175 
00176 
00177             // Mass specific properties
00178 
00179                 //- Heat capacity at constant pressure [J/(kg K)]
00180                 inline scalar Cp(const scalar T) const;
00181 
00182                 //- Heat capacity at constant volume [J/(kg K)]
00183                 inline scalar Cv(const scalar T) const;
00184 
00185                 //- Enthalpy [J/kg]
00186                 inline scalar H(const scalar T) const;
00187 
00188                 //- Sensible enthalpy [J/kg]
00189                 inline scalar Hs(const scalar T) const;
00190 
00191                 //- Chemical enthalpy [J/kg]
00192                 inline scalar Hc() const;
00193 
00194                 //- Entropy [J/(kg K)]
00195                 inline scalar S(const scalar T) const;
00196 
00197                 //- Internal energy [J/kg]
00198                 inline scalar E(const scalar T) const;
00199 
00200                 //- Gibbs free energy [J/kg]
00201                 inline scalar G(const scalar T) const;
00202 
00203                 //- Helmholtz free energy [J/kg]
00204                 inline scalar A(const scalar T) const;
00205 
00206 
00207         // Equilibrium reaction thermodynamics
00208 
00209             //- Equilibrium constant [] i.t.o fugacities
00210             //  = PIi(fi/Pstd)^nui
00211             inline scalar K(const scalar T) const;
00212 
00213             //- Equilibrium constant [] i.t.o. partial pressures
00214             //  = PIi(pi/Pstd)^nui
00215             //  For low pressures (where the gas mixture is near perfect) Kp = K
00216             inline scalar Kp(const scalar T) const;
00217 
00218             //- Equilibrium constant i.t.o. molar concentration
00219             //  = PIi(ci/cstd)^nui
00220             //  For low pressures (where the gas mixture is near perfect)
00221             //  Kc = Kp(pstd/(RR*T))^nu
00222             inline scalar Kc(const scalar T) const;
00223 
00224             //- Equilibrium constant [] i.t.o. mole-fractions
00225             //  For low pressures (where the gas mixture is near perfect)
00226             //  Kx = Kp(pstd/p)^nui
00227             inline scalar Kx(const scalar T, const scalar p) const;
00228 
00229             //- Equilibrium constant [] i.t.o. number of moles
00230             //  For low pressures (where the gas mixture is near perfect)
00231             //  Kn = Kp(n*pstd/p)^nui where n = number of moles in mixture
00232             inline scalar Kn
00233             (
00234                 const scalar T,
00235                 const scalar p,
00236                 const scalar n
00237             ) const;
00238 
00239 
00240         // Energy->temperature  inversion functions
00241 
00242             //- Temperature from Enthalpy given an initial temperature T0
00243             inline scalar TH(const scalar H, const scalar T0) const;
00244 
00245             //- Temperature from internal energy given an initial temperature T0
00246             inline scalar TE(const scalar E, const scalar T0) const;
00247 
00248 
00249     // Member operators
00250 
00251         inline void operator+=(const specieThermo&);
00252         inline void operator-=(const specieThermo&);
00253 
00254         inline void operator*=(const scalar);
00255 
00256 
00257     // Friend operators
00258 
00259         friend specieThermo operator+ <thermo>
00260         (
00261             const specieThermo&,
00262             const specieThermo&
00263         );
00264 
00265         friend specieThermo operator- <thermo>
00266         (
00267             const specieThermo&,
00268             const specieThermo&
00269         );
00270 
00271         friend specieThermo operator* <thermo>
00272         (
00273             const scalar s,
00274             const specieThermo&
00275         );
00276 
00277         friend specieThermo operator== <thermo>
00278         (
00279             const specieThermo&,
00280             const specieThermo&
00281         );
00282 
00283 
00284     // Ostream Operator
00285 
00286         friend Ostream& operator<< <thermo>
00287         (
00288             Ostream&,
00289             const specieThermo&
00290         );
00291 };
00292 
00293 
00294 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00295 
00296 } // End namespace Foam
00297 
00298 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00299 
00300 #include "specieThermoI.H"
00301 
00302 #ifdef NoRepository
00303 #   include "specieThermo.C"
00304 #endif
00305 
00306 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00307 
00308 #endif
00309 
00310 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd