OpenFOAM logo
The Open Source CFD Toolbox
  Programmer’s C++ Doxygen OpenCFD Solutions Contact OpenFOAM

chemistryModel.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-2007 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     chemistryModel
00027 
00028 Description
00029 
00030 SourceFiles
00031     chemistryModelI.H
00032     chemistryModel.C
00033 
00034 \*---------------------------------------------------------------------------*/
00035 
00036 #ifndef chemistryModel_H
00037 #define chemistryModel_H
00038 
00039 #include "hCombustionThermo.H"
00040 #include "reactingMixture.H"
00041 #include "Matrix.H"
00042 #include "ODE.H"
00043 
00044 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00045 
00046 namespace Foam
00047 {
00048 
00049 class chemistrySolver;
00050 
00051 /*---------------------------------------------------------------------------*\
00052                            Class chemistryModel Declaration
00053 \*---------------------------------------------------------------------------*/
00054 
00055 class chemistryModel
00056 :
00057     public ODE
00058 {
00059 
00060 public:
00061 
00062     typedef reactingMixture::reaction reaction;
00063     typedef reactingMixture::reactionThermo reactionThermo;
00064 
00065 
00066 private:
00067 
00068     // Private data
00069     
00070         const hCombustionThermo& thermo_;
00071 
00072         PtrList<volScalarField>& Y_;
00073         const volScalarField& rho_;
00074 
00075         IOdictionary chemistryProperties_;
00076 
00077         //- Do the chemistry or not.
00078         Switch chemistry_;
00079 
00080         //- The reactions
00081         const PtrList<reaction>& reactions_;
00082 
00083         //- thermodynamic data of the species
00084         const PtrList<reactionThermo>& specieThermo_;
00085 
00086         //- The number of species
00087         label Ns_;
00088 
00089         //- The number of reactions
00090         label Nr_;
00091 
00092         //- chemistry solver
00093         autoPtr<chemistrySolver> solver_;
00094 
00095         //- the chemical source term
00096         PtrList<scalarField> RR_;
00097 
00098         //- Latest estimation of integration step
00099         scalarField deltaTChem_;
00100 
00101 
00102     // Private Member Functions
00103 
00104         //- Disallow default bitwise assignment
00105         void operator=(const chemistryModel&);
00106 
00107 
00108 public:
00109 
00110     // Constructors
00111 
00112         //- Construct from components
00113         chemistryModel
00114         (
00115             hCombustionThermo& thermo,
00116             const volScalarField& rho
00117         );
00118 
00119 
00120     // Destructor
00121 
00122         virtual ~chemistryModel();
00123 
00124 
00125     // Member Functions
00126 
00127         //- Return the thermodynamics model
00128         const hCombustionThermo& thermo() const
00129         {
00130             return thermo_;
00131         }
00132 
00133         //- Access the fractions of the species
00134         const PtrList<volScalarField>& Y() const
00135         {
00136             return Y_;
00137         }
00138 
00139         //- Access the density field
00140         const volScalarField& rho() const 
00141         {
00142             return rho_;
00143         }
00144 
00145         //- Return the chemistry properties
00146         inline const IOdictionary& chemistryProperties() const
00147         {
00148             return chemistryProperties_;
00149         }
00150 
00151         //- Do the chemistry or not.
00152         inline Switch chemistry() const
00153         {
00154             return chemistry_;
00155         }
00156 
00157         inline const PtrList<reaction>& reactions() const
00158         {
00159             return reactions_;
00160         }
00161 
00162         inline const PtrList<reactionThermo>& specieThermo() const
00163         {
00164             return specieThermo_;
00165         }
00166 
00167         //- The number of species
00168         inline label Ns() const
00169         {
00170             return Ns_;
00171         }
00172 
00173         //- The number of reactions
00174         inline label Nr() const
00175         {
00176             return Nr_;
00177         }
00178 
00179         // Return the chemisty solver
00180         inline const chemistrySolver& solver() const
00181         {
00182             return solver_;
00183         }
00184 
00185         //- Return the chemical source terms
00186         inline tmp<volScalarField> RR(const label i) const;
00187 
00188         //- Return the latest estimation of integration step
00189         const scalarField& deltaTChem() const
00190         {
00191             return deltaTChem_;
00192         }
00193 
00194         //- The chemical time scale
00195         tmp<volScalarField> tc() const;
00196 
00197         //- dc/dt = omega, rate of change in concentration, for each species
00198         scalarField omega
00199         (
00200             const scalarField& c,
00201             const scalar T,
00202             const scalar p
00203         ) const;
00204 
00205         //- return the reaction rate for reaction r and the reference
00206         //  species and charateristic times
00207         scalar omega
00208         (
00209             const reaction& r,
00210             const scalarField& c,
00211             const scalar T,
00212             const scalar p,
00213             scalar& pf,
00214             scalar& cf,
00215             label& lRef,
00216             scalar& pr,
00217             scalar& cr,
00218             label& rRef
00219         ) const;
00220 
00221         //- The number of ODE to solve
00222         label nEqns() const;
00223 
00224         void derivatives
00225         (
00226             const scalar t,
00227             const scalarField& c,
00228             scalarField& dcdt
00229         ) const;
00230 
00231         void jacobian
00232         (
00233             const scalar t,
00234             const scalarField& c,
00235             scalarField& dcdt,
00236             Matrix<scalar>& dfdc
00237         ) const;
00238 
00239         //- Calculates the reaction rates
00240         void calculate();
00241 
00242         //- Solve the reaction system for the given start time and time-step
00243         // and return the characteristic time
00244         scalar solve
00245         (
00246             const scalar t0,
00247             const scalar deltaT
00248         );
00249 };
00250 
00251 
00252 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00253 
00254 } // End namespace Foam
00255 
00256 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00257 
00258 #include "chemistryModelI.H"
00259 
00260 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00261 
00262 #endif
00263 
00264 // ************************************************************************* //
Copyright © 2000-2007 OpenCFD Ltd