chemkinReader.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "chemkinReader.H"
29 #include <fstream>
30 #include "atomicWeights.H"
31 #include "IrreversibleReaction.H"
32 #include "ReversibleReaction.H"
34 #include "ArrheniusReactionRate.H"
36 #include "FallOffReactionRate.H"
39 #include "TroeFallOffFunction.H"
40 #include "SRIFallOffFunction.H"
42 #include "JanevReactionRate.H"
45 
46 
47 /* * * * * * * * * * * * * * * * * Static data * * * * * * * * * * * * * * * */
48 
49 namespace Foam
50 {
52 }
53 
54 
55 /* * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * */
56 
57 const char* Foam::chemkinReader::reactionTypeNames[4] =
58 {
59  "irreversible",
60  "reversible",
61  "nonEquilibriumReversible",
62  "unknownReactionType"
63 };
64 
65 const char* Foam::chemkinReader::reactionRateTypeNames[8] =
66 {
67  "Arrhenius",
68  "thirdBodyArrhenius",
69  "unimolecularFallOff",
70  "chemicallyActivatedBimolecular",
71  "LandauTeller",
72  "Janev",
73  "powerSeries",
74  "unknownReactionRateType"
75 };
76 
77 const char* Foam::chemkinReader::fallOffFunctionNames[4] =
78 {
79  "Lindemann",
80  "Troe",
81  "SRI",
82  "unknownFallOffFunctionType"
83 };
84 
85 void Foam::chemkinReader::initReactionKeywordTable()
86 {
87  reactionKeywordTable_.insert("M", thirdBodyReactionType);
88  reactionKeywordTable_.insert("LOW", unimolecularFallOffReactionType);
89  reactionKeywordTable_.insert
90  (
91  "HIGH",
92  chemicallyActivatedBimolecularReactionType
93  );
94  reactionKeywordTable_.insert("TROE", TroeReactionType);
95  reactionKeywordTable_.insert("SRI", SRIReactionType);
96  reactionKeywordTable_.insert("LT", LandauTellerReactionType);
97  reactionKeywordTable_.insert("RLT", reverseLandauTellerReactionType);
98  reactionKeywordTable_.insert("JAN", JanevReactionType);
99  reactionKeywordTable_.insert("FIT1", powerSeriesReactionRateType);
100  reactionKeywordTable_.insert("HV", radiationActivatedReactionType);
101  reactionKeywordTable_.insert("TDEP", speciesTempReactionType);
102  reactionKeywordTable_.insert("EXCI", energyLossReactionType);
103  reactionKeywordTable_.insert("MOME", plasmaMomentumTransfer);
104  reactionKeywordTable_.insert("XSMI", collisionCrossSection);
105  reactionKeywordTable_.insert("REV", nonEquilibriumReversibleReactionType);
106  reactionKeywordTable_.insert("DUPLICATE", duplicateReactionType);
107  reactionKeywordTable_.insert("DUP", duplicateReactionType);
108  reactionKeywordTable_.insert("FORD", speciesOrderForward);
109  reactionKeywordTable_.insert("RORD", speciesOrderReverse);
110  reactionKeywordTable_.insert("UNITS", UnitsOfReaction);
111  reactionKeywordTable_.insert("END", end);
112 }
113 
114 
115 Foam::scalar Foam::chemkinReader::molecularWeight
116 (
117  const List<specieElement>& specieComposition
118 ) const
119 {
120  scalar molWt = 0.0;
121 
122  forAll(specieComposition, i)
123  {
124  label nAtoms = specieComposition[i].nAtoms();
125  const word& elementName = specieComposition[i].name();
126 
127  if (isotopeAtomicWts_.found(elementName))
128  {
129  molWt += nAtoms*isotopeAtomicWts_[elementName];
130  }
131  else if (atomicWeights.found(elementName))
132  {
133  molWt += nAtoms*atomicWeights[elementName];
134  }
135  else
136  {
138  << "Unknown element " << elementName
139  << " on line " << lineNo_-1 << nl
140  << " specieComposition: " << specieComposition
141  << exit(FatalError);
142  }
143  }
144 
145  return molWt;
146 }
147 
148 
149 void Foam::chemkinReader::checkCoeffs
150 (
151  const scalarList& reactionCoeffs,
152  const char* reactionRateName,
153  const label nCoeffs
154 ) const
155 {
156  if (reactionCoeffs.size() != nCoeffs)
157  {
159  << "Wrong number of coefficients for the " << reactionRateName
160  << " rate expression on line "
161  << lineNo_-1 << ", should be "
162  << nCoeffs << " but " << reactionCoeffs.size() << " supplied." << nl
163  << "Coefficients are "
164  << reactionCoeffs << nl
165  << exit(FatalError);
166  }
167 }
168 
169 template<class ReactionRateType>
170 void Foam::chemkinReader::addReactionType
171 (
172  const reactionType rType,
173  DynamicList<gasHReaction::specieCoeffs>& lhs,
174  DynamicList<gasHReaction::specieCoeffs>& rhs,
175  const ReactionRateType& rr
176 )
177 {
178  switch (rType)
179  {
180  case irreversible:
181  {
182  reactions_.append
183  (
184  new IrreversibleReaction
185  <Reaction, gasHThermoPhysics, ReactionRateType>
186  (
187  Reaction<gasHThermoPhysics>
188  (
189  speciesTable_,
190  lhs.shrink(),
191  rhs.shrink(),
192  speciesThermo_
193  ),
194  rr
195  )
196  );
197  }
198  break;
199 
200  case reversible:
201  {
202  reactions_.append
203  (
204  new ReversibleReaction
205  <Reaction, gasHThermoPhysics, ReactionRateType>
206  (
207  Reaction<gasHThermoPhysics>
208  (
209  speciesTable_,
210  lhs.shrink(),
211  rhs.shrink(),
212  speciesThermo_
213  ),
214  rr
215  )
216  );
217  }
218  break;
219 
220  default:
221 
222  if (rType < 3)
223  {
225  << "Reaction type " << reactionTypeNames[rType]
226  << " on line " << lineNo_-1
227  << " not handled by this function"
228  << exit(FatalError);
229  }
230  else
231  {
233  << "Unknown reaction type " << rType
234  << " on line " << lineNo_-1
235  << exit(FatalError);
236  }
237  }
238 }
239 
240 template<template<class, class> class PressureDependencyType>
241 void Foam::chemkinReader::addPressureDependentReaction
242 (
243  const reactionType rType,
244  const fallOffFunctionType fofType,
245  DynamicList<gasHReaction::specieCoeffs>& lhs,
246  DynamicList<gasHReaction::specieCoeffs>& rhs,
247  const scalarList& efficiencies,
248  const scalarList& k0Coeffs,
249  const scalarList& kInfCoeffs,
250  const HashTable<scalarList>& reactionCoeffsTable,
251  const scalar Afactor0,
252  const scalar AfactorInf,
253  const scalar RR
254 )
255 {
256  checkCoeffs(k0Coeffs, "k0", 3);
257  checkCoeffs(kInfCoeffs, "kInf", 3);
258 
259  switch (fofType)
260  {
261  case Lindemann:
262  {
263  addReactionType
264  (
265  rType,
266  lhs, rhs,
267  PressureDependencyType
268  <ArrheniusReactionRate, LindemannFallOffFunction>
269  (
270  ArrheniusReactionRate
271  (
272  Afactor0*k0Coeffs[0],
273  k0Coeffs[1],
274  k0Coeffs[2]/RR
275  ),
276  ArrheniusReactionRate
277  (
278  AfactorInf*kInfCoeffs[0],
279  kInfCoeffs[1],
280  kInfCoeffs[2]/RR
281  ),
282  LindemannFallOffFunction(),
283  thirdBodyEfficiencies(speciesTable_, efficiencies)
284  )
285  );
286  break;
287  }
288  case Troe:
289  {
290  scalarList TroeCoeffs
291  (
292  reactionCoeffsTable[fallOffFunctionNames[fofType]]
293  );
294 
295  if (TroeCoeffs.size() != 4 && TroeCoeffs.size() != 3)
296  {
298  << "Wrong number of coefficients for Troe rate expression"
299  " on line " << lineNo_-1 << ", should be 3 or 4 but "
300  << TroeCoeffs.size() << " supplied." << nl
301  << "Coefficients are "
302  << TroeCoeffs << nl
303  << exit(FatalError);
304  }
305 
306  if (TroeCoeffs.size() == 3)
307  {
308  TroeCoeffs.setSize(4);
309  TroeCoeffs[3] = GREAT;
310  }
311 
312  addReactionType
313  (
314  rType,
315  lhs, rhs,
316  PressureDependencyType
317  <ArrheniusReactionRate, TroeFallOffFunction>
318  (
319  ArrheniusReactionRate
320  (
321  Afactor0*k0Coeffs[0],
322  k0Coeffs[1],
323  k0Coeffs[2]/RR
324  ),
325  ArrheniusReactionRate
326  (
327  AfactorInf*kInfCoeffs[0],
328  kInfCoeffs[1],
329  kInfCoeffs[2]/RR
330  ),
331  TroeFallOffFunction
332  (
333  TroeCoeffs[0],
334  TroeCoeffs[1],
335  TroeCoeffs[2],
336  TroeCoeffs[3]
337  ),
338  thirdBodyEfficiencies(speciesTable_, efficiencies)
339  )
340  );
341  break;
342  }
343  case SRI:
344  {
345  scalarList SRICoeffs
346  (
347  reactionCoeffsTable[fallOffFunctionNames[fofType]]
348  );
349 
350  if (SRICoeffs.size() != 5 && SRICoeffs.size() != 3)
351  {
353  << "Wrong number of coefficients for SRI rate expression"
354  " on line " << lineNo_-1 << ", should be 3 or 5 but "
355  << SRICoeffs.size() << " supplied." << nl
356  << "Coefficients are "
357  << SRICoeffs << nl
358  << exit(FatalError);
359  }
360 
361  if (SRICoeffs.size() == 3)
362  {
363  SRICoeffs.setSize(5);
364  SRICoeffs[3] = 1.0;
365  SRICoeffs[4] = 0.0;
366  }
367 
368  addReactionType
369  (
370  rType,
371  lhs, rhs,
372  PressureDependencyType
373  <ArrheniusReactionRate, SRIFallOffFunction>
374  (
375  ArrheniusReactionRate
376  (
377  Afactor0*k0Coeffs[0],
378  k0Coeffs[1],
379  k0Coeffs[2]/RR
380  ),
381  ArrheniusReactionRate
382  (
383  AfactorInf*kInfCoeffs[0],
384  kInfCoeffs[1],
385  kInfCoeffs[2]/RR
386  ),
387  SRIFallOffFunction
388  (
389  SRICoeffs[0],
390  SRICoeffs[1],
391  SRICoeffs[2],
392  SRICoeffs[3],
393  SRICoeffs[4]
394  ),
395  thirdBodyEfficiencies(speciesTable_, efficiencies)
396  )
397  );
398  break;
399  }
400  default:
401  {
403  << "Fall-off function type "
404  << fallOffFunctionNames[fofType]
405  << " on line " << lineNo_-1
406  << " not implemented"
407  << exit(FatalError);
408  }
409  }
410 }
411 
412 
413 void Foam::chemkinReader::addReaction
414 (
415  DynamicList<gasHReaction::specieCoeffs>& lhs,
416  DynamicList<gasHReaction::specieCoeffs>& rhs,
417  const scalarList& efficiencies,
418  const reactionType rType,
419  const reactionRateType rrType,
420  const fallOffFunctionType fofType,
421  const scalarList& ArrheniusCoeffs,
422  HashTable<scalarList>& reactionCoeffsTable,
423  const scalar RR
424 )
425 {
426  checkCoeffs(ArrheniusCoeffs, "Arrhenius", 3);
427 
428  scalarList nAtoms(elementNames_.size(), Zero);
429 
430  forAll(lhs, i)
431  {
432  const List<specieElement>& specieComposition =
433  speciesComposition_[speciesTable_[lhs[i].index]];
434 
435  forAll(specieComposition, j)
436  {
437  label elementi = elementIndices_[specieComposition[j].name()];
438  nAtoms[elementi] +=
439  lhs[i].stoichCoeff*specieComposition[j].nAtoms();
440  }
441  }
442 
443  forAll(rhs, i)
444  {
445  const List<specieElement>& specieComposition =
446  speciesComposition_[speciesTable_[rhs[i].index]];
447 
448  forAll(specieComposition, j)
449  {
450  label elementi = elementIndices_[specieComposition[j].name()];
451  nAtoms[elementi] -=
452  rhs[i].stoichCoeff*specieComposition[j].nAtoms();
453  }
454  }
455 
456 
457  // Calculate the unit conversion factor for the A coefficient
458  // for the change from mol/cm^3 to kmol/m^3 concentration units
459  const scalar concFactor = 0.001;
460  scalar sumExp = 0.0;
461  forAll(lhs, i)
462  {
463  sumExp += lhs[i].exponent;
464  }
465  scalar Afactor = pow(concFactor, sumExp - 1.0);
466 
467  scalar AfactorRev = Afactor;
468 
469  if (rType == nonEquilibriumReversible)
470  {
471  sumExp = 0.0;
472  forAll(rhs, i)
473  {
474  sumExp += rhs[i].exponent;
475  }
476  AfactorRev = pow(concFactor, sumExp - 1.0);
477  }
478 
479  switch (rrType)
480  {
481  case Arrhenius:
482  {
483  if (rType == nonEquilibriumReversible)
484  {
485  const scalarList& reverseArrheniusCoeffs =
486  reactionCoeffsTable[reactionTypeNames[rType]];
487 
488  checkCoeffs(reverseArrheniusCoeffs, "reverse Arrhenius", 3);
489 
490  reactions_.append
491  (
492  new NonEquilibriumReversibleReaction
493  <Reaction, gasHThermoPhysics, ArrheniusReactionRate>
494  (
495  Reaction<gasHThermoPhysics>
496  (
497  speciesTable_,
498  lhs.shrink(),
499  rhs.shrink(),
500  speciesThermo_
501  ),
502  ArrheniusReactionRate
503  (
504  Afactor*ArrheniusCoeffs[0],
505  ArrheniusCoeffs[1],
506  ArrheniusCoeffs[2]/RR
507  ),
508  ArrheniusReactionRate
509  (
510  AfactorRev*reverseArrheniusCoeffs[0],
511  reverseArrheniusCoeffs[1],
512  reverseArrheniusCoeffs[2]/RR
513  )
514  )
515  );
516  }
517  else
518  {
519  addReactionType
520  (
521  rType,
522  lhs, rhs,
523  ArrheniusReactionRate
524  (
525  Afactor*ArrheniusCoeffs[0],
526  ArrheniusCoeffs[1],
527  ArrheniusCoeffs[2]/RR
528  )
529  );
530  }
531  break;
532  }
533  case thirdBodyArrhenius:
534  {
535  if (rType == nonEquilibriumReversible)
536  {
537  const scalarList& reverseArrheniusCoeffs =
538  reactionCoeffsTable[reactionTypeNames[rType]];
539 
540  checkCoeffs(reverseArrheniusCoeffs, "reverse Arrhenius", 3);
541 
542  reactions_.append
543  (
544  new NonEquilibriumReversibleReaction
545  <
546  Reaction,
548  thirdBodyArrheniusReactionRate
549  >
550  (
551  Reaction<gasHThermoPhysics>
552  (
553  speciesTable_,
554  lhs.shrink(),
555  rhs.shrink(),
556  speciesThermo_
557  ),
558  thirdBodyArrheniusReactionRate
559  (
560  Afactor*concFactor*ArrheniusCoeffs[0],
561  ArrheniusCoeffs[1],
562  ArrheniusCoeffs[2]/RR,
563  thirdBodyEfficiencies(speciesTable_, efficiencies)
564  ),
565  thirdBodyArrheniusReactionRate
566  (
567  AfactorRev*concFactor*reverseArrheniusCoeffs[0],
568  reverseArrheniusCoeffs[1],
569  reverseArrheniusCoeffs[2]/RR,
570  thirdBodyEfficiencies(speciesTable_, efficiencies)
571  )
572  )
573  );
574  }
575  else
576  {
577  addReactionType
578  (
579  rType,
580  lhs, rhs,
581  thirdBodyArrheniusReactionRate
582  (
583  Afactor*concFactor*ArrheniusCoeffs[0],
584  ArrheniusCoeffs[1],
585  ArrheniusCoeffs[2]/RR,
586  thirdBodyEfficiencies(speciesTable_, efficiencies)
587  )
588  );
589  }
590  break;
591  }
592  case unimolecularFallOff:
593  {
594  addPressureDependentReaction<FallOffReactionRate>
595  (
596  rType,
597  fofType,
598  lhs,
599  rhs,
600  efficiencies,
601  reactionCoeffsTable[reactionRateTypeNames[rrType]],
602  ArrheniusCoeffs,
603  reactionCoeffsTable,
604  concFactor*Afactor,
605  Afactor,
606  RR
607  );
608  break;
609  }
610  case chemicallyActivatedBimolecular:
611  {
612  addPressureDependentReaction<ChemicallyActivatedReactionRate>
613  (
614  rType,
615  fofType,
616  lhs,
617  rhs,
618  efficiencies,
619  ArrheniusCoeffs,
620  reactionCoeffsTable[reactionRateTypeNames[rrType]],
621  reactionCoeffsTable,
622  Afactor,
623  Afactor/concFactor,
624  RR
625  );
626  break;
627  }
628  case LandauTeller:
629  {
630  const scalarList& LandauTellerCoeffs =
631  reactionCoeffsTable[reactionRateTypeNames[rrType]];
632  checkCoeffs(LandauTellerCoeffs, "Landau-Teller", 2);
633 
634  if (rType == nonEquilibriumReversible)
635  {
636  const scalarList& reverseArrheniusCoeffs =
637  reactionCoeffsTable[reactionTypeNames[rType]];
638  checkCoeffs(reverseArrheniusCoeffs, "reverse Arrhenius", 3);
639 
640  const scalarList& reverseLandauTellerCoeffs =
641  reactionCoeffsTable
642  [
643  word(reactionTypeNames[rType])
644  + reactionRateTypeNames[rrType]
645  ];
646  checkCoeffs(LandauTellerCoeffs, "reverse Landau-Teller", 2);
647 
648  reactions_.append
649  (
650  new NonEquilibriumReversibleReaction
651  <Reaction, gasHThermoPhysics, LandauTellerReactionRate>
652  (
653  Reaction<gasHThermoPhysics>
654  (
655  speciesTable_,
656  lhs.shrink(),
657  rhs.shrink(),
658  speciesThermo_
659  ),
660  LandauTellerReactionRate
661  (
662  Afactor*ArrheniusCoeffs[0],
663  ArrheniusCoeffs[1],
664  ArrheniusCoeffs[2]/RR,
665  LandauTellerCoeffs[0],
666  LandauTellerCoeffs[1]
667  ),
668  LandauTellerReactionRate
669  (
670  AfactorRev*reverseArrheniusCoeffs[0],
671  reverseArrheniusCoeffs[1],
672  reverseArrheniusCoeffs[2]/RR,
673  reverseLandauTellerCoeffs[0],
674  reverseLandauTellerCoeffs[1]
675  )
676  )
677  );
678  }
679  else
680  {
681  addReactionType
682  (
683  rType,
684  lhs, rhs,
685  LandauTellerReactionRate
686  (
687  Afactor*ArrheniusCoeffs[0],
688  ArrheniusCoeffs[1],
689  ArrheniusCoeffs[2]/RR,
690  LandauTellerCoeffs[0],
691  LandauTellerCoeffs[1]
692  )
693  );
694  }
695  break;
696  }
697  case Janev:
698  {
699  const scalarList& JanevCoeffs =
700  reactionCoeffsTable[reactionRateTypeNames[rrType]];
701 
702  checkCoeffs(JanevCoeffs, "Janev", 9);
703 
704  addReactionType
705  (
706  rType,
707  lhs, rhs,
708  JanevReactionRate
709  (
710  Afactor*ArrheniusCoeffs[0],
711  ArrheniusCoeffs[1],
712  ArrheniusCoeffs[2]/RR,
713  FixedList<scalar, 9>(JanevCoeffs)
714  )
715  );
716  break;
717  }
718  case powerSeries:
719  {
720  const scalarList& powerSeriesCoeffs =
721  reactionCoeffsTable[reactionRateTypeNames[rrType]];
722 
723  checkCoeffs(powerSeriesCoeffs, "power-series", 4);
724 
725  addReactionType
726  (
727  rType,
728  lhs, rhs,
729  powerSeriesReactionRate
730  (
731  Afactor*ArrheniusCoeffs[0],
732  ArrheniusCoeffs[1],
733  ArrheniusCoeffs[2]/RR,
734  FixedList<scalar, 4>(powerSeriesCoeffs)
735  )
736  );
737  break;
738  }
739  case unknownReactionRateType:
740  {
742  << "Internal error on line " << lineNo_-1
743  << ": reaction rate type has not been set"
744  << exit(FatalError);
745  break;
746  }
747  default:
748  {
750  << "Reaction rate type " << reactionRateTypeNames[rrType]
751  << " on line " << lineNo_-1
752  << " not implemented"
753  << exit(FatalError);
754  }
755  }
756 
757 
758  forAll(nAtoms, i)
759  {
760  if (mag(nAtoms[i]) > imbalanceTol_)
761  {
763  << "Elemental imbalance of " << mag(nAtoms[i])
764  << " in " << elementNames_[i]
765  << " in reaction" << nl
766  << reactions_.last() << nl
767  << " on line " << lineNo_-1
768  << exit(FatalError);
769  }
770  }
771 
772  lhs.clear();
773  rhs.clear();
774  reactionCoeffsTable.clear();
775 }
776 
777 
778 void Foam::chemkinReader::read
779 (
780  const fileName& CHEMKINFileName,
781  const fileName& thermoFileName,
782  const fileName& transportFileName
783 )
784 {
785  transportDict_.read(IFstream(transportFileName)());
786 
787  if (!thermoFileName.empty())
788  {
789  std::ifstream thermoStream(thermoFileName);
790 
791  if (!thermoStream)
792  {
794  << "file " << thermoFileName << " not found"
795  << exit(FatalError);
796  }
797 
798  yy_buffer_state* bufferPtr(yy_create_buffer(&thermoStream, yyBufSize));
799  yy_switch_to_buffer(bufferPtr);
800 
801  while (lex() != 0)
802  {}
803 
804  yy_delete_buffer(bufferPtr);
805 
806  lineNo_ = 1;
807  }
808 
809  std::ifstream CHEMKINStream(CHEMKINFileName);
810 
811  if (!CHEMKINStream)
812  {
814  << "file " << CHEMKINFileName << " not found"
815  << exit(FatalError);
816  }
817 
818  yy_buffer_state* bufferPtr(yy_create_buffer(&CHEMKINStream, yyBufSize));
819  yy_switch_to_buffer(bufferPtr);
820 
821  initReactionKeywordTable();
822 
823  while (lex() != 0)
824  {}
825 
826  yy_delete_buffer(bufferPtr);
827 }
828 
829 
830 // * * * * * * * * * * * * * * * * Constructor * * * * * * * * * * * * * * * //
831 
832 Foam::chemkinReader::chemkinReader
833 (
834  speciesTable& species,
835  const fileName& CHEMKINFileName,
836  const fileName& transportFileName,
837  const fileName& thermoFileName,
838  const bool newFormat
839 )
840 :
841  lineNo_(1),
842  specieNames_(10),
843  speciesTable_(species),
844  reactions_(speciesTable_, speciesThermo_),
845  newFormat_(newFormat),
846  imbalanceTol_(ROOTSMALL)
847 {
848  read(CHEMKINFileName, thermoFileName, transportFileName);
849 }
850 
851 
852 Foam::chemkinReader::chemkinReader
853 (
854  const dictionary& thermoDict,
855  speciesTable& species
856 )
857 :
858  lineNo_(1),
859  specieNames_(10),
860  speciesTable_(species),
861  reactions_(speciesTable_, speciesThermo_),
862  newFormat_(thermoDict.lookupOrDefault("newFormat", false)),
863  imbalanceTol_(thermoDict.lookupOrDefault("imbalanceTolerance", ROOTSMALL))
864 {
865  if (newFormat_)
866  {
867  Info<< "Reading CHEMKIN thermo data in new file format" << endl;
868  }
869 
870  fileName chemkinFile(thermoDict.get<fileName>("CHEMKINFile"));
871  chemkinFile.expand();
872 
873  fileName thermoFile = fileName::null;
874  thermoDict.readIfPresent("CHEMKINThermoFile", thermoFile);
875  thermoFile.expand();
876 
877  fileName transportFile(thermoDict.get<fileName>("CHEMKINTransportFile"));
878  transportFile.expand();
879 
880  // allow relative file names
881  fileName relPath = thermoDict.name().path();
882  if (relPath.size())
883  {
884  if (!chemkinFile.isAbsolute())
885  {
886  chemkinFile = relPath/chemkinFile;
887  }
888 
889  if (thermoFile != fileName::null && !thermoFile.isAbsolute())
890  {
891  thermoFile = relPath/thermoFile;
892  }
893 
894  if (!transportFile.isAbsolute())
895  {
896  transportFile = relPath/transportFile;
897  }
898  }
899 
900  read(chemkinFile, thermoFile, transportFile);
901 }
902 
903 
904 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
thirdBodyArrheniusReactionRate.H
Foam::constant::thermodynamic::RR
const scalar RR
Universal gas constant: default in [J/(kmol K)].
Definition: thermodynamicConstants.C:46
FallOffReactionRate.H
Foam::scalarList
List< scalar > scalarList
A List of scalars.
Definition: scalarList.H:64
ArrheniusReactionRate.H
Foam::fileName
A class for handling file names.
Definition: fileName.H:69
Foam::fileName::path
static std::string path(const std::string &str)
Return directory path name (part before last /)
Definition: fileNameI.H:186
Foam::Zero
static constexpr const zero Zero
Global zero.
Definition: zero.H:128
LandauTellerReactionRate.H
atomicWeights.H
Foam::read
bool read(const char *buf, int32_t &val)
Same as readInt32.
Definition: int32.H:108
Foam::atomicWeights
atomicWeightTable atomicWeights
Definition: atomicWeights.C:155
Foam::HashTable::insert
bool insert(const Key &key, const T &obj)
Copy insert a new entry, not overwriting existing entries.
Definition: HashTableI.H:168
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:337
Foam::dictionary::get
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionaryTemplates.C:81
Foam::dictionary::lookupOrDefault
T lookupOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionary.H:1241
SRIFallOffFunction.H
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:290
IrreversibleReaction.H
Foam::dictionary::name
const fileName & name() const
The dictionary name.
Definition: dictionary.H:446
ChemicallyActivatedReactionRate.H
chemkinReader.H
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:62
Foam::hashedWordList
A wordList with hashed named lookup, which can be faster in some situations than using the normal lis...
Definition: hashedWordList.H:54
powerSeriesReactionRate.H
TroeFallOffFunction.H
Foam::Info
messageStream Info
Information stream (uses stdout - output is on the master only)
Foam::pow
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
Definition: dimensionedScalar.C:75
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::fileName::null
static const fileName null
An empty fileName.
Definition: fileName.H:97
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
Foam::gasHThermoPhysics
sutherlandTransport< species::thermo< janafThermo< perfectGas< specie > >, sensibleEnthalpy > > gasHThermoPhysics
Definition: thermoPhysicsTypes.H:88
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:355
ReversibleReaction.H
thermoDict
const dictionary & thermoDict
Definition: EEqn.H:16
Foam::nl
constexpr char nl
Definition: Ostream.H:372
NonEquilibriumReversibleReaction.H
JanevReactionRate.H
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Foam::string::expand
string & expand(const bool allowEmpty=false)
Definition: string.C:159
LindemannFallOffFunction.H
Foam::addChemistryReaderType
addChemistryReaderType(chemkinReader, gasHThermoPhysics)
Foam::HashTable::found
bool found(const Key &key) const
Return true if hashed entry is found in table.
Definition: HashTableI.H:100
Foam::fileName::isAbsolute
static bool isAbsolute(const std::string &str)
Return true if string starts with a '/'.
Definition: fileNameI.H:136
Foam::dictionary::readIfPresent
bool readIfPresent(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionaryTemplates.C:417