egrMixture.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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
19  for more details.
20 
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/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "egrMixture.H"
27 
28 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
29 
30 template<class ThermoType>
31 const char* Foam::egrMixture<ThermoType>::specieNames_[3] = {"ft", "b", "egr"};
32 
33 
34 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
35 
36 template<class ThermoType>
38 (
39  const dictionary& thermoDict,
40  const fvMesh& mesh,
41  const word& phaseName
42 )
43 :
45  (
46  thermoDict,
47  speciesTable(nSpecies_, specieNames_),
48  mesh,
49  phaseName
50  ),
51 
52  stoicRatio_(thermoDict.lookup("stoichiometricAirFuelMassRatio")),
53 
54  fuel_("fuel", thermoDict.subDict("fuel")),
55  oxidant_("oxidant", thermoDict.subDict("oxidant")),
56  products_("burntProducts", thermoDict.subDict("burntProducts")),
57 
58  mixture_("mixture", fuel_),
59 
60  ft_(Y("ft")),
61  b_(Y("b")),
62  egr_(Y("egr"))
63 {}
64 
65 
66 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
67 
68 template<class ThermoType>
70 (
71  const scalar ft,
72  const scalar b,
73  const scalar egr
74 ) const
75 {
76  if (ft < 0.0001 && egr < 0.0001)
77  {
78  return oxidant_;
79  }
80  else
81  {
82 
83  scalar fu = b*ft + (1.0 - b)*fres(ft, stoicRatio().value());
84  scalar ox = 1 - ft - (ft - fu)*stoicRatio().value();
85 
86  fu *= (1.0 - egr);
87  ox *= (1.0 - egr);
88 
89  const scalar pr = 1 - fu - ox;
90 
91  mixture_ = fu*fuel_;
92  mixture_ += ox*oxidant_;
93  mixture_ += pr*products_;
94 
95  return mixture_;
96  }
97 }
98 
99 
100 template<class ThermoType>
102 {
103  stoicRatio_ = thermoDict.lookup("stoichiometricAirFuelMassRatio");
104 
105  fuel_ = ThermoType("fuel", thermoDict.subDict("fuel"));
106  oxidant_ = ThermoType("oxidant", thermoDict.subDict("oxidant"));
107  products_ =
108  ThermoType("burntProducts", thermoDict.subDict("burntProducts"));
109 }
110 
111 
112 template<class ThermoType>
114 (
115  const label speciei
116 ) const
117 {
118  if (speciei == 0)
119  {
120  return fuel_;
121  }
122  else if (speciei == 1)
123  {
124  return oxidant_;
125  }
126  else if (speciei == 2)
127  {
128  return products_;
129  }
130  else
131  {
133  << "Unknown specie index " << speciei << ". Valid indices are 0..2"
134  << abort(FatalError);
135 
136  return fuel_;
137  }
138 }
139 
140 
141 // ************************************************************************* //
Specialisation of the basicMixture for combustion.
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:160
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:860
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
Definition: dictionary.C:998
Foam::egrMixture.
Definition: egrMixture.H:52
egrMixture(const dictionary &, const fvMesh &, const word &)
Construct from dictionary, mesh and phaseName.
Definition: egrMixture.C:38
const ThermoType & specieThermo(const label speciei) const
Return thermo based on index.
Definition: egrMixture.C:114
const thermoType & mixture(const scalar, const scalar, const scalar) const
Definition: egrMixture.C:70
void read(const dictionary &)
Read dictionary.
Definition: egrMixture.C:101
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:101
A wordList with hashed indices for faster lookup by name.
A class for handling words, derived from string.
Definition: word.H:62
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:306
volScalarField & b
Definition: createFields.H:27
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:59
errorManip< error > abort(error &err)
Definition: errorManip.H:131
error FatalError
PtrList< volScalarField > & Y