FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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-2010 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
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your 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, see <http://www.gnu.org/licenses/>.
00023 
00024 Class
00025     Foam::specieThermo
00026 
00027 Description
00028     Basic thermodynamics type based on the use of fitting functions for
00029     cp, h, s obtained from the template argument type thermo.  All other
00030     properties are derived from these primitive functions.
00031 
00032 SourceFiles
00033     specieThermoI.H
00034     specieThermo.C
00035 
00036 \*---------------------------------------------------------------------------*/
00037 
00038 #ifndef specieThermo_H
00039 #define specieThermo_H
00040 
00041 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00042 
00043 namespace Foam
00044 {
00045 
00046 // Forward declaration of friend functions and operators
00047 
00048 template<class thermo> class specieThermo;
00049 
00050 template<class thermo>
00051 inline specieThermo<thermo> operator+
00052 (
00053     const specieThermo<thermo>&,
00054     const specieThermo<thermo>&
00055 );
00056 
00057 template<class thermo>
00058 inline specieThermo<thermo> operator-
00059 (
00060     const specieThermo<thermo>&,
00061     const specieThermo<thermo>&
00062 );
00063 
00064 template<class thermo>
00065 inline specieThermo<thermo> operator*
00066 (
00067     const scalar,
00068     const specieThermo<thermo>&
00069 );
00070 
00071 template<class thermo>
00072 inline specieThermo<thermo> operator==
00073 (
00074     const specieThermo<thermo>&,
00075     const specieThermo<thermo>&
00076 );
00077 
00078 template<class thermo>
00079 Ostream& operator<<
00080 (
00081     Ostream&,
00082     const specieThermo<thermo>&
00083 );
00084 
00085 
00086 /*---------------------------------------------------------------------------*\
00087                            Class specieThermo Declaration
00088 \*---------------------------------------------------------------------------*/
00089 
00090 template<class thermo>
00091 class specieThermo
00092 :
00093     public thermo
00094 {
00095     // Private data
00096 
00097         //- Convergence tolerance of energy -> temperature inversion functions
00098         static const scalar tol_;
00099 
00100         //- Max number of iterations in energy->temperature inversion functions
00101         static const int maxIter_;
00102 
00103 
00104     // Private member functions
00105 
00106         //- return the temperature corresponding to the value of the
00107         //  thermodynamic property f, given the function f = F(T) and dF(T)/dT
00108         inline scalar T
00109         (
00110             scalar f,
00111             scalar T0,
00112             scalar (specieThermo::*F)(const scalar) const,
00113             scalar (specieThermo::*dFdT)(const scalar) const
00114         ) const;
00115 
00116 
00117 public:
00118 
00119     // Constructors
00120 
00121         //- construct from components
00122         inline specieThermo(const thermo& sp);
00123 
00124         //- Construct from Istream
00125         specieThermo(Istream&);
00126 
00127         //- Construct as named copy
00128         inline specieThermo(const word& name, const specieThermo&);
00129 
00130 
00131     // Member Functions
00132 
00133         // Fundamaental properties
00134         // (These functions must be provided in derived types)
00135 
00136             // Heat capacity at constant pressure [J/(kmol K)]
00137             //scalar cp(const scalar) const;
00138 
00139             // Enthalpy [J/kmol]
00140             //scalar h(const scalar) const;
00141 
00142             // Sensible enthalpy [J/kmol]
00143             //scalar hs(const scalar) const;
00144 
00145             // Chemical enthalpy [J/kmol]
00146             //scalar hc(const scalar) const;
00147 
00148             // Entropy [J/(kmol K)]
00149             //scalar s(const scalar) const;
00150 
00151 
00152         // Calculate and return derived properties
00153         // (These functions need not provided in derived types)
00154 
00155             // Mole specific properties
00156 
00157                 //- Heat capacity at constant volume [J/(kmol K)]
00158                 inline scalar cv(const scalar T) const;
00159 
00160                 //- gamma = cp/cv []
00161                 inline scalar gamma(const scalar T) const;
00162 
00163                 //- Internal energy [J/kmol]
00164                 inline scalar e(const scalar T) const;
00165 
00166                 //- Sensible internal energy [J/kmol]
00167                 inline scalar es(const scalar T) const;
00168 
00169                 //- Gibbs free energy [J/kmol]
00170                 inline scalar g(const scalar T) const;
00171 
00172                 //- Helmholtz free energy [J/kmol]
00173                 inline scalar a(const scalar T) const;
00174 
00175 
00176             // Mass specific properties
00177 
00178                 //- Heat capacity at constant pressure [J/(kg K)]
00179                 inline scalar Cp(const scalar T) const;
00180 
00181                 //- Heat capacity at constant volume [J/(kg K)]
00182                 inline scalar Cv(const scalar T) const;
00183 
00184                 //- Enthalpy [J/kg]
00185                 inline scalar H(const scalar T) const;
00186 
00187                 //- Sensible enthalpy [J/kg]
00188                 inline scalar Hs(const scalar T) const;
00189 
00190                 //- Chemical enthalpy [J/kg]
00191                 inline scalar Hc() const;
00192 
00193                 //- Entropy [J/(kg K)]
00194                 inline scalar S(const scalar T) const;
00195 
00196                 //- Internal energy [J/kg]
00197                 inline scalar E(const scalar T) const;
00198 
00199                 //- Gibbs free energy [J/kg]
00200                 inline scalar G(const scalar T) const;
00201 
00202                 //- Helmholtz free energy [J/kg]
00203                 inline scalar A(const scalar T) const;
00204 
00205 
00206         // Equilibrium reaction thermodynamics
00207 
00208             //- Equilibrium constant [] i.t.o fugacities
00209             //  = PIi(fi/Pstd)^nui
00210             inline scalar K(const scalar T) const;
00211 
00212             //- Equilibrium constant [] i.t.o. partial pressures
00213             //  = PIi(pi/Pstd)^nui
00214             //  For low pressures (where the gas mixture is near perfect) Kp = K
00215             inline scalar Kp(const scalar T) const;
00216 
00217             //- Equilibrium constant i.t.o. molar concentration
00218             //  = PIi(ci/cstd)^nui
00219             //  For low pressures (where the gas mixture is near perfect)
00220             //  Kc = Kp(pstd/(RR*T))^nu
00221             inline scalar Kc(const scalar T) const;
00222 
00223             //- Equilibrium constant [] i.t.o. mole-fractions
00224             //  For low pressures (where the gas mixture is near perfect)
00225             //  Kx = Kp(pstd/p)^nui
00226             inline scalar Kx(const scalar T, const scalar p) const;
00227 
00228             //- Equilibrium constant [] i.t.o. number of moles
00229             //  For low pressures (where the gas mixture is near perfect)
00230             //  Kn = Kp(n*pstd/p)^nui where n = number of moles in mixture
00231             inline scalar Kn
00232             (
00233                 const scalar T,
00234                 const scalar p,
00235                 const scalar n
00236             ) const;
00237 
00238 
00239         // Energy->temperature  inversion functions
00240 
00241             //- Temperature from Enthalpy given an initial temperature T0
00242             inline scalar TH(const scalar H, const scalar T0) const;
00243 
00244             //- Temperature from sensible Enthalpy given an initial T0
00245             inline scalar THs(const scalar Hs, const scalar T0) const;
00246 
00247             //- Temperature from internal energy given an initial temperature T0
00248             inline scalar TE(const scalar E, const scalar T0) const;
00249 
00250 
00251     // Member operators
00252 
00253         inline void operator+=(const specieThermo&);
00254         inline void operator-=(const specieThermo&);
00255 
00256         inline void operator*=(const scalar);
00257 
00258 
00259     // Friend operators
00260 
00261         friend specieThermo operator+ <thermo>
00262         (
00263             const specieThermo&,
00264             const specieThermo&
00265         );
00266 
00267         friend specieThermo operator- <thermo>
00268         (
00269             const specieThermo&,
00270             const specieThermo&
00271         );
00272 
00273         friend specieThermo operator* <thermo>
00274         (
00275             const scalar s,
00276             const specieThermo&
00277         );
00278 
00279         friend specieThermo operator== <thermo>
00280         (
00281             const specieThermo&,
00282             const specieThermo&
00283         );
00284 
00285 
00286     // Ostream Operator
00287 
00288         friend Ostream& operator<< <thermo>
00289         (
00290             Ostream&,
00291             const specieThermo&
00292         );
00293 };
00294 
00295 
00296 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00297 
00298 } // End namespace Foam
00299 
00300 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00301 
00302 #include <specie/specieThermoI.H>
00303 
00304 #ifdef NoRepository
00305 #   include <specie/specieThermo.C>
00306 #endif
00307 
00308 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00309 
00310 #endif
00311 
00312 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines