1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
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
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
35 \*---------------------------------------------------------------------------*/
37 #ifndef chemkinReader_H
38 #define chemkinReader_H
40 #include "chemistryReader.H"
43 #include "HashPtrTable.H"
44 #include "SLPtrList.H"
45 #include "DynamicList.H"
46 #include "labelList.H"
47 #include "speciesTable.H"
48 #include "atomicWeights.H"
50 #include <FlexLexer.h>
52 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
57 /*---------------------------------------------------------------------------*\
58 Class chemkin Declaration
59 \*---------------------------------------------------------------------------*/
63 public chemistryReader,
84 bool operator==(const specieElement& se) const
89 && elementName == se.elementName
93 bool operator!=(const specieElement& se) const
95 return !operator==(se);
98 friend Ostream& operator<<(Ostream& os, const specieElement& se)
100 os << se.nAtoms << token::SPACE << se.elementName;
110 static int yyBufSize;
113 //- Table of reaction type keywords
114 HashTable<int> reactionKeywordTable_;
116 //- Currently supported reaction types
119 thirdBodyReactionType,
120 unimolecularFallOffReactionType,
121 chemicallyActivatedBimolecularReactionType,
124 LandauTellerReactionType,
125 reverseLandauTellerReactionType,
127 powerSeriesReactionRateType,
128 radiationActivatedReactionType,
129 speciesTempReactionType,
130 energyLossReactionType,
131 plasmaMomentumTransfer,
132 collisionCrossSection,
133 nonEquilibriumReversibleReactionType,
134 duplicateReactionType,
145 nonEquilibriumReversible,
149 static const char* reactionTypeNames[4];
151 enum reactionRateType
156 chemicallyActivatedBimolecular,
160 unknownReactionRateType
163 static const char* reactionRateTypeNames[8];
165 enum fallOffFunctionType
170 unknownFallOffFunctionType
173 static const char* fallOffFunctionNames[4];
176 void initReactionKeywordTable();
180 DynamicList<word> elementNames_;
183 HashTable<label> elementIndices_;
185 //- Isotope molecular weights
186 HashTable<scalar> isotopeAtomicWts_;
189 DynamicList<word> specieNames_;
192 HashTable<label> specieIndices_;
195 speciesTable speciesTable_;
198 HashTable<phase> speciePhase_;
200 //- Table of the thermodynamic data given in the CHEMKIN file
201 HashPtrTable<reactionThermo> speciesThermo_;
203 //- Table of species composition
204 HashTable<List<specieElement> > specieComposition_;
206 //- List of the reactions
207 SLPtrList<reaction> reactions_;
210 // Private Member Functions
212 //- Flex lexer to read the CHEMKIN III file
215 inline scalar stringToScalar(const string& s)
217 string& str = const_cast<string&>(s);
218 str.replaceAll(" ", "");
219 str.replaceAll("D", "e");
220 str.replaceAll("d", "e");
221 return atof(str.c_str());
224 inline scalar stringToScalar(const char* cstr)
226 return stringToScalar(string(cstr));
229 inline void correctElementName(word& elementName)
231 if (elementName.size() == 2)
233 elementName[1] = tolower(elementName[1]);
235 else if(elementName[0] == 'E')
241 scalar molecularWeight
243 const List<specieElement>& specieComposition
246 void finishElements(labelList& currentAtoms);
250 const scalarList& reactionCoeffs,
251 const char* reationRateName,
255 template<class ReactionRateType>
258 const reactionType rType,
259 DynamicList<reaction::specieCoeffs>& lhs,
260 DynamicList<reaction::specieCoeffs>& rhs,
261 const ReactionRateType& rr
264 template<template<class, class> class PressureDependencyType>
265 void addPressureDependentReaction
267 const reactionType rType,
268 const fallOffFunctionType fofType,
269 DynamicList<reaction::specieCoeffs>& lhs,
270 DynamicList<reaction::specieCoeffs>& rhs,
271 const scalarList& thirdBodyEfficiencies,
272 const scalarList& k0Coeffs,
273 const scalarList& kInfCoeffs,
274 const HashTable<scalarList>& reactionCoeffsTable,
275 const scalar Afactor0,
276 const scalar AfactorInf,
282 DynamicList<reaction::specieCoeffs>& lhs,
283 DynamicList<reaction::specieCoeffs>& rhs,
284 const scalarList& thirdBodyEfficiencies,
285 const reactionType rType,
286 const reactionRateType rrType,
287 const fallOffFunctionType fofType,
288 const scalarList& ArrheniusReactionCoeffs,
289 HashTable<scalarList>& reactionCoeffsTable,
293 // Read the CHEMKIN files
296 const fileName& CHEMKINFileName,
297 const fileName& thermoFileName
301 //- Disallow default bitwise copy construct
302 chemkinReader(const chemkinReader&);
304 //- Disallow default bitwise assignment
305 void operator=(const chemkinReader&);
310 //- Runtime type information
311 TypeName("chemkinReader");
316 //- Construct from CHEMKIN III file name
319 const fileName& chemkinFile,
320 const fileName& thermoFileName = fileName::null
323 //- Construct by getting the CHEMKIN III file name from dictionary
324 chemkinReader(const dictionary& thermoDict);
329 virtual ~chemkinReader()
336 const wordList& elementNames() const
338 return elementNames_;
342 const HashTable<label>& elementIndices() const
344 return elementIndices_;
347 //- Isotope molecular weights
348 const HashTable<scalar>& isotopeAtomicWts() const
350 return isotopeAtomicWts_;
354 const speciesTable& species() const
356 return speciesTable_;
360 const HashTable<phase>& speciePhase() const
365 //- Table of the thermodynamic data given in the CHEMKIN file
366 const HashPtrTable<reactionThermo>& speciesThermo() const
368 return speciesThermo_;
371 //- Table of species composition
372 const HashTable<List<specieElement> >& specieComposition() const
374 return specieComposition_;
377 //- List of the reactions
378 const SLPtrList<reaction>& reactions() const
385 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
387 } // End namespace Foam
389 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
393 // ************************************************************************* //