FreeFOAM The Cross-Platform CFD Toolkit
ODEChemistryModel.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2009-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::ODEChemistryModel
26 
27 Description
28  Extends base chemistry model by adding a thermo package, and ODE functions.
29  Introduces chemistry equation system and evaluation of chemical source
30  terms.
31 
32 SourceFiles
33  ODEChemistryModelI.H
34  ODEChemistryModel.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef ODEChemistryModel_H
39 #define ODEChemistryModel_H
40 
41 #include <specie/Reaction.H>
42 #include <ODE/ODE.H>
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 namespace Foam
48 {
49 
50 // Forward declaration of classes
51 class fvMesh;
52 
53 template<class CompType, class ThermoType>
54 class chemistrySolver;
55 
56 /*---------------------------------------------------------------------------*\
57  Class ODEChemistryModel Declaration
58 \*---------------------------------------------------------------------------*/
59 
60 template<class CompType, class ThermoType>
62 :
63  public CompType,
64  public ODE
65 {
66  // Private Member Functions
67 
68  //- Disallow default bitwise assignment
69  void operator=(const ODEChemistryModel&);
70 
71 
72 protected:
73 
74  // Private data
75 
76  //- Reference to the field of specie mass fractions
78 
79  //- Reactions
81 
82  //- Thermodynamic data of the species
84 
85  //- Number of species
86  label nSpecie_;
87 
88  //- Number of reactions
89  label nReaction_;
90 
91  //- Chemistry solver
93 
94  //- Chemical source term [kg/m3/s]
96 
97 
98  // Protected Member Functions
99 
100  //- Write access to chemical source terms
101  // (e.g. for multi-chemistry model)
102  inline PtrList<scalarField>& RR();
103 
104 
105 public:
106 
107  //- Runtime type information
108  TypeName("ODEChemistryModel");
109 
110 
111  // Constructors
112 
113  //- Construct from components
115  (
116  const fvMesh& mesh,
117  const word& compTypeName,
118  const word& thermoTypeName
119  );
120 
121 
122  //- Destructor
123  virtual ~ODEChemistryModel();
124 
125 
126  // Member Functions
127 
128  //- The reactions
129  inline const PtrList<Reaction<ThermoType> >& reactions() const;
130 
131  //- Thermodynamic data of the species
132  inline const PtrList<ThermoType>& specieThermo() const;
133 
134  //- The number of species
135  inline label nSpecie() const;
136 
137  //- The number of reactions
138  inline label nReaction() const;
139 
140  //- Return the chemisty solver
141  inline const chemistrySolver<CompType, ThermoType>& solver() const;
142 
143  //- dc/dt = omega, rate of change in concentration, for each species
144  virtual scalarField omega
145  (
146  const scalarField& c,
147  const scalar T,
148  const scalar p
149  ) const;
150 
151  //- Return the reaction rate for reaction r and the reference
152  // species and charateristic times
153  virtual scalar omega
154  (
155  const Reaction<ThermoType>& r,
156  const scalarField& c,
157  const scalar T,
158  const scalar p,
159  scalar& pf,
160  scalar& cf,
161  label& lRef,
162  scalar& pr,
163  scalar& cr,
164  label& rRef
165  ) const;
166 
167  //- Calculates the reaction rates
168  virtual void calculate();
169 
170 
171  // Chemistry model functions (overriding abstract functions in
172  // basicChemistryModel.H)
173 
174  //- Return const access to the chemical source terms
175  inline tmp<volScalarField> RR(const label i) const;
176 
177  //- Solve the reaction system for the given start time and time
178  // step and return the characteristic time
179  virtual scalar solve(const scalar t0, const scalar deltaT);
180 
181  //- Return the chemical time scale
182  virtual tmp<volScalarField> tc() const;
183 
184  //- Return source for enthalpy equation [kg/m/s3]
185  virtual tmp<volScalarField> Sh() const;
186 
187  //- Return the heat release, i.e. enthalpy/sec [m2/s3]
188  virtual tmp<volScalarField> dQ() const;
189 
190 
191  // ODE functions (overriding abstract functions in ODE.H)
192 
193  //- Number of ODE's to solve
194  virtual label nEqns() const;
195 
196  virtual void derivatives
197  (
198  const scalar t,
199  const scalarField& c,
200  scalarField& dcdt
201  ) const;
202 
203  virtual void jacobian
204  (
205  const scalar t,
206  const scalarField& c,
207  scalarField& dcdt,
208  scalarSquareMatrix& dfdc
209  ) const;
210 };
211 
212 
213 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
214 
215 } // End namespace Foam
216 
217 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
218 
219 #include "ODEChemistryModelI.H"
220 
221 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
222 
223 #ifdef NoRepository
224 # include "ODEChemistryModel.C"
225 #endif
226 
227 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
228 
229 #endif
230 
231 // ************************ vim: set sw=4 sts=4 et: ************************ //