1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2004-2010 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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
34 \*---------------------------------------------------------------------------*/
36 #ifndef chemkinReader_H
37 #define chemkinReader_H
39 #include "chemistryReader.H"
42 #include "HashPtrTable.H"
43 #include "ReactionList.H"
44 #include "DynamicList.H"
45 #include "labelList.H"
46 #include "speciesTable.H"
47 #include "atomicWeights.H"
49 #include "reactionTypes.H"
51 #include <FlexLexer.h>
53 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
58 /*---------------------------------------------------------------------------*\
59 Class chemkinReader Declaration
60 \*---------------------------------------------------------------------------*/
64 public chemistryReader<gasThermoPhysics>,
85 bool operator==(const specieElement& se) const
90 && elementName == se.elementName
94 bool operator!=(const specieElement& se) const
96 return !operator==(se);
99 friend Ostream& operator<<(Ostream& os, const specieElement& se)
101 os << se.nAtoms << token::SPACE << se.elementName;
111 static int yyBufSize;
114 //- Table of reaction type keywords
115 HashTable<int> reactionKeywordTable_;
117 //- Currently supported reaction types
120 thirdBodyReactionType,
121 unimolecularFallOffReactionType,
122 chemicallyActivatedBimolecularReactionType,
125 LandauTellerReactionType,
126 reverseLandauTellerReactionType,
128 powerSeriesReactionRateType,
129 radiationActivatedReactionType,
130 speciesTempReactionType,
131 energyLossReactionType,
132 plasmaMomentumTransfer,
133 collisionCrossSection,
134 nonEquilibriumReversibleReactionType,
135 duplicateReactionType,
146 nonEquilibriumReversible,
150 static const char* reactionTypeNames[4];
152 enum reactionRateType
157 chemicallyActivatedBimolecular,
161 unknownReactionRateType
164 static const char* reactionRateTypeNames[8];
166 enum fallOffFunctionType
171 unknownFallOffFunctionType
174 static const char* fallOffFunctionNames[4];
177 void initReactionKeywordTable();
181 DynamicList<word> elementNames_;
184 HashTable<label> elementIndices_;
186 //- Isotope molecular weights
187 HashTable<scalar> isotopeAtomicWts_;
190 DynamicList<word> specieNames_;
193 HashTable<label> specieIndices_;
196 speciesTable speciesTable_;
199 HashTable<phase> speciePhase_;
201 //- Table of the thermodynamic data given in the CHEMKIN file
202 HashPtrTable<gasThermoPhysics> speciesThermo_;
204 //- Table of species composition
205 HashTable<List<specieElement> > specieComposition_;
207 //- List of the reactions
208 ReactionList<gasThermoPhysics> reactions_;
211 // Private Member Functions
213 //- Flex lexer to read the CHEMKIN III file
216 inline scalar stringToScalar(const string& s)
218 string& str = const_cast<string&>(s);
219 str.replaceAll(" ", "");
220 str.replaceAll("D", "e");
221 str.replaceAll("d", "e");
222 return atof(str.c_str());
225 inline scalar stringToScalar(const char* cstr)
227 return stringToScalar(string(cstr));
230 inline void correctElementName(word& elementName)
232 if (elementName.size() == 2)
234 elementName[1] = tolower(elementName[1]);
236 else if (elementName[0] == 'E')
242 scalar molecularWeight
244 const List<specieElement>& specieComposition
247 void finishElements(labelList& currentAtoms);
251 const scalarList& reactionCoeffs,
252 const char* reationRateName,
256 template<class ReactionRateType>
259 const reactionType rType,
260 DynamicList<gasReaction::specieCoeffs>& lhs,
261 DynamicList<gasReaction::specieCoeffs>& rhs,
262 const ReactionRateType& rr
265 template<template<class, class> class PressureDependencyType>
266 void addPressureDependentReaction
268 const reactionType rType,
269 const fallOffFunctionType fofType,
270 DynamicList<gasReaction::specieCoeffs>& lhs,
271 DynamicList<gasReaction::specieCoeffs>& rhs,
272 const scalarList& thirdBodyEfficiencies,
273 const scalarList& k0Coeffs,
274 const scalarList& kInfCoeffs,
275 const HashTable<scalarList>& reactionCoeffsTable,
276 const scalar Afactor0,
277 const scalar AfactorInf,
283 DynamicList<gasReaction::specieCoeffs>& lhs,
284 DynamicList<gasReaction::specieCoeffs>& rhs,
285 const scalarList& thirdBodyEfficiencies,
286 const reactionType rType,
287 const reactionRateType rrType,
288 const fallOffFunctionType fofType,
289 const scalarList& ArrheniusReactionCoeffs,
290 HashTable<scalarList>& reactionCoeffsTable,
294 // Read the CHEMKIN files
297 const fileName& CHEMKINFileName,
298 const fileName& thermoFileName
302 //- Disallow default bitwise copy construct
303 chemkinReader(const chemkinReader&);
305 //- Disallow default bitwise assignment
306 void operator=(const chemkinReader&);
311 //- Runtime type information
312 TypeName("chemkinReader");
317 //- Construct from CHEMKIN III file name
320 const fileName& chemkinFile,
321 const fileName& thermoFileName = fileName::null
324 //- Construct by getting the CHEMKIN III file name from dictionary
325 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<gasThermoPhysics>& 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 ReactionList<gasThermoPhysics>& reactions() const
385 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
387 } // End namespace Foam
389 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
393 // ************************************************************************* //