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) 2011-2012 OpenFOAM Foundation
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::chemistryModel
00026 
00027 Description
00028     Extends base chemistry model by adding a thermo package, and ODE functions.
00029     Introduces chemistry equation system and evaluation of chemical source
00030     terms.
00031 
00032 SourceFiles
00033     chemistryModelI.H
00034     chemistryModel.C
00035 
00036 \*---------------------------------------------------------------------------*/
00037 
00038 #ifndef chemistryModel_H
00039 #define chemistryModel_H
00040 
00041 #include "Reaction.H"
00042 #include "ODE.H"
00043 #include "volFieldsFwd.H"
00044 #include "simpleMatrix.H"
00045 #include "DimensionedField.H"
00046 
00047 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00048 
00049 namespace Foam
00050 {
00051 
00052 // Forward declaration of classes
00053 class fvMesh;
00054 
00055 /*---------------------------------------------------------------------------*\
00056                       Class chemistryModel Declaration
00057 \*---------------------------------------------------------------------------*/
00058 
00059 template<class CompType, class ThermoType>
00060 class chemistryModel
00061 :
00062     public CompType,
00063     public ODE
00064 {
00065     // Private Member Functions
00066 
00067         //- Disallow copy constructor
00068         chemistryModel(const chemistryModel&);
00069 
00070         //- Disallow default bitwise assignment
00071         void operator=(const chemistryModel&);
00072 
00073 
00074 protected:
00075 
00076     // Private data
00077 
00078         //- Reference to the field of specie mass fractions
00079         PtrList<volScalarField>& Y_;
00080 
00081         //- Reactions
00082         const PtrList<Reaction<ThermoType> >& reactions_;
00083 
00084         //- Thermodynamic data of the species
00085         const PtrList<ThermoType>& specieThermo_;
00086 
00087         //- Number of species
00088         label nSpecie_;
00089 
00090         //- Number of reactions
00091         label nReaction_;
00092 
00093         //- List of reaction rate per specie [kg/m3/s]
00094         PtrList<DimensionedField<scalar, volMesh> > RR_;
00095 
00096 
00097     // Protected Member Functions
00098 
00099         //- Write access to chemical source terms
00100         //  (e.g. for multi-chemistry model)
00101         inline PtrList<DimensionedField<scalar, volMesh> >& RR();
00102 
00103 
00104 public:
00105 
00106     //- Runtime type information
00107     TypeName("chemistryModel");
00108 
00109 
00110     // Constructors
00111 
00112         //- Construct from mesh
00113         chemistryModel(const fvMesh& mesh);
00114 
00115 
00116     //- Destructor
00117     virtual ~chemistryModel();
00118 
00119 
00120     // Member Functions
00121 
00122         //- The reactions
00123         inline const PtrList<Reaction<ThermoType> >& reactions() const;
00124 
00125         //- Thermodynamic data of the species
00126         inline const PtrList<ThermoType>& specieThermo() const;
00127 
00128         //- The number of species
00129         inline label nSpecie() const;
00130 
00131         //- The number of reactions
00132         inline label nReaction() const;
00133 
00134         //- dc/dt = omega, rate of change in concentration, for each species
00135         virtual tmp<scalarField> omega
00136         (
00137             const scalarField& c,
00138             const scalar T,
00139             const scalar p
00140         ) const;
00141 
00142         //- Return the reaction rate for reaction r and the reference
00143         //  species and charateristic times
00144         virtual scalar omega
00145         (
00146             const Reaction<ThermoType>& r,
00147             const scalarField& c,
00148             const scalar T,
00149             const scalar p,
00150             scalar& pf,
00151             scalar& cf,
00152             label& lRef,
00153             scalar& pr,
00154             scalar& cr,
00155             label& rRef
00156         ) const;
00157 
00158 
00159         //- Return the reaction rate for iReaction and the reference
00160         //  species and charateristic times
00161         virtual scalar omegaI
00162         (
00163             label iReaction,
00164             const scalarField& c,
00165             const scalar T,
00166             const scalar p,
00167             scalar& pf,
00168             scalar& cf,
00169             label& lRef,
00170             scalar& pr,
00171             scalar& cr,
00172             label& rRef
00173         ) const;
00174 
00175         //- Calculates the reaction rates
00176         virtual void calculate();
00177 
00178         //- Update concentrations in reaction i given dt and reaction rate omega
00179         // used by sequential solver
00180         void updateConcsInReactionI
00181         (
00182             const label i,
00183             const scalar dt,
00184             const scalar omega,
00185             scalarField& c
00186         ) const;
00187 
00188         //- Update matrix RR for reaction i. Used by EulerImplicit
00189         void updateRRInReactionI
00190         (
00191             const label i,
00192             const scalar pr,
00193             const scalar pf,
00194             const scalar corr,
00195             const label lRef,
00196             const label rRef,
00197             simpleMatrix<scalar>& RR
00198         ) const;
00199 
00200 
00201         // Chemistry model functions (overriding abstract functions in
00202         // basicChemistryModel.H)
00203 
00204             //- Return const access to the chemical source terms for specie, i
00205             inline const DimensionedField<scalar, volMesh>& RR
00206             (
00207                 const label i
00208             ) const;
00209 
00210             //- Solve the reaction system for the given start time and time
00211             //  step and return the characteristic time
00212             virtual scalar solve(const scalar t0, const scalar deltaT);
00213 
00214             //- Return the chemical time scale
00215             virtual tmp<volScalarField> tc() const;
00216 
00217             //- Return source for enthalpy equation [kg/m/s3]
00218             virtual tmp<volScalarField> Sh() const;
00219 
00220             //- Return the heat release, i.e. enthalpy/sec [m2/s3]
00221             virtual tmp<volScalarField> dQ() const;
00222 
00223 
00224         // ODE functions (overriding abstract functions in ODE.H)
00225 
00226             //- Number of ODE's to solve
00227             virtual label nEqns() const;
00228 
00229             virtual void derivatives
00230             (
00231                 const scalar t,
00232                 const scalarField& c,
00233                 scalarField& dcdt
00234             ) const;
00235 
00236             virtual void jacobian
00237             (
00238                 const scalar t,
00239                 const scalarField& c,
00240                 scalarField& dcdt,
00241                 scalarSquareMatrix& dfdc
00242             ) const;
00243 
00244             virtual scalar solve
00245             (
00246                 scalarField &c,
00247                 const scalar T,
00248                 const scalar p,
00249                 const scalar t0,
00250                 const scalar dt
00251             ) const;
00252 };
00253 
00254 
00255 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00256 
00257 } // End namespace Foam
00258 
00259 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00260 
00261 #include "chemistryModelI.H"
00262 
00263 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00264 
00265 #ifdef NoRepository
00266 #   include "chemistryModel.C"
00267 #endif
00268 
00269 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00270 
00271 #endif
00272 
00273 // ************************************************************************* //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines