1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 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 "reactionTypes.H"
52 #include <FlexLexer.h>
54 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
59 /*---------------------------------------------------------------------------*\
60 Class chemkinReader Declaration
61 \*---------------------------------------------------------------------------*/
65 public chemistryReader<gasThermoPhysics>,
86 bool operator==(const specieElement& se) const
91 && elementName == se.elementName
95 bool operator!=(const specieElement& se) const
97 return !operator==(se);
100 friend Ostream& operator<<(Ostream& os, const specieElement& se)
102 os << se.nAtoms << token::SPACE << se.elementName;
112 static int yyBufSize;
115 //- Table of reaction type keywords
116 HashTable<int> reactionKeywordTable_;
118 //- Currently supported reaction types
121 thirdBodyReactionType,
122 unimolecularFallOffReactionType,
123 chemicallyActivatedBimolecularReactionType,
126 LandauTellerReactionType,
127 reverseLandauTellerReactionType,
129 powerSeriesReactionRateType,
130 radiationActivatedReactionType,
131 speciesTempReactionType,
132 energyLossReactionType,
133 plasmaMomentumTransfer,
134 collisionCrossSection,
135 nonEquilibriumReversibleReactionType,
136 duplicateReactionType,
147 nonEquilibriumReversible,
151 static const char* reactionTypeNames[4];
153 enum reactionRateType
158 chemicallyActivatedBimolecular,
162 unknownReactionRateType
165 static const char* reactionRateTypeNames[8];
167 enum fallOffFunctionType
172 unknownFallOffFunctionType
175 static const char* fallOffFunctionNames[4];
178 void initReactionKeywordTable();
182 DynamicList<word> elementNames_;
185 HashTable<label> elementIndices_;
187 //- Isotope molecular weights
188 HashTable<scalar> isotopeAtomicWts_;
191 DynamicList<word> specieNames_;
194 HashTable<label> specieIndices_;
197 speciesTable speciesTable_;
200 HashTable<phase> speciePhase_;
202 //- Table of the thermodynamic data given in the CHEMKIN file
203 HashPtrTable<gasThermoPhysics> speciesThermo_;
205 //- Table of species composition
206 HashTable<List<specieElement> > specieComposition_;
208 //- List of the reactions
209 SLPtrList<gasReaction> reactions_;
212 // Private Member Functions
214 //- Flex lexer to read the CHEMKIN III file
217 inline scalar stringToScalar(const string& s)
219 string& str = const_cast<string&>(s);
220 str.replaceAll(" ", "");
221 str.replaceAll("D", "e");
222 str.replaceAll("d", "e");
223 return atof(str.c_str());
226 inline scalar stringToScalar(const char* cstr)
228 return stringToScalar(string(cstr));
231 inline void correctElementName(word& elementName)
233 if (elementName.size() == 2)
235 elementName[1] = tolower(elementName[1]);
237 else if(elementName[0] == 'E')
243 scalar molecularWeight
245 const List<specieElement>& specieComposition
248 void finishElements(labelList& currentAtoms);
252 const scalarList& reactionCoeffs,
253 const char* reationRateName,
257 template<class ReactionRateType>
260 const reactionType rType,
261 DynamicList<gasReaction::specieCoeffs>& lhs,
262 DynamicList<gasReaction::specieCoeffs>& rhs,
263 const ReactionRateType& rr
266 template<template<class, class> class PressureDependencyType>
267 void addPressureDependentReaction
269 const reactionType rType,
270 const fallOffFunctionType fofType,
271 DynamicList<gasReaction::specieCoeffs>& lhs,
272 DynamicList<gasReaction::specieCoeffs>& rhs,
273 const scalarList& thirdBodyEfficiencies,
274 const scalarList& k0Coeffs,
275 const scalarList& kInfCoeffs,
276 const HashTable<scalarList>& reactionCoeffsTable,
277 const scalar Afactor0,
278 const scalar AfactorInf,
284 DynamicList<gasReaction::specieCoeffs>& lhs,
285 DynamicList<gasReaction::specieCoeffs>& rhs,
286 const scalarList& thirdBodyEfficiencies,
287 const reactionType rType,
288 const reactionRateType rrType,
289 const fallOffFunctionType fofType,
290 const scalarList& ArrheniusReactionCoeffs,
291 HashTable<scalarList>& reactionCoeffsTable,
295 // Read the CHEMKIN files
298 const fileName& CHEMKINFileName,
299 const fileName& thermoFileName
303 //- Disallow default bitwise copy construct
304 chemkinReader(const chemkinReader&);
306 //- Disallow default bitwise assignment
307 void operator=(const chemkinReader&);
312 //- Runtime type information
313 TypeName("chemkinReader");
318 //- Construct from CHEMKIN III file name
321 const fileName& chemkinFile,
322 const fileName& thermoFileName = fileName::null
325 //- Construct by getting the CHEMKIN III file name from dictionary
326 chemkinReader(const dictionary& thermoDict);
331 virtual ~chemkinReader()
338 const wordList& elementNames() const
340 return elementNames_;
344 const HashTable<label>& elementIndices() const
346 return elementIndices_;
349 //- Isotope molecular weights
350 const HashTable<scalar>& isotopeAtomicWts() const
352 return isotopeAtomicWts_;
356 const speciesTable& species() const
358 return speciesTable_;
362 const HashTable<phase>& speciePhase() const
367 //- Table of the thermodynamic data given in the CHEMKIN file
368 const HashPtrTable<gasThermoPhysics>& speciesThermo() const
370 return speciesThermo_;
373 //- Table of species composition
374 const HashTable<List<specieElement> >& specieComposition() const
376 return specieComposition_;
379 //- List of the reactions
380 const SLPtrList<gasReaction>& reactions() const
387 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
389 } // End namespace Foam
391 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
395 // ************************************************************************* //