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