adiabaticFlameT.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-2017 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 Application
27  adiabaticFlameT
28 
29 Group
30  grpThermophysicalUtilities
31 
32 Description
33  Calculate adiabatic flame temperature for a given fuel over a
34  range of unburnt temperatures and equivalence ratios.
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #include "argList.H"
39 #include "Time.H"
40 #include "dictionary.H"
41 #include "IFstream.H"
42 #include "OSspecific.H"
43 #include "etcFiles.H"
44 
45 #include "specie.H"
46 #include "perfectGas.H"
47 #include "thermo.H"
48 #include "janafThermo.H"
49 #include "absoluteEnthalpy.H"
50 
51 using namespace Foam;
52 
54  thermo;
55 
56 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
57 
58 int main(int argc, char *argv[])
59 {
61  (
62  "Calculate the adiabatic flame temperature for a given fuel over a "
63  " range of unburnt temperatures and equivalence ratios."
64  );
65 
67  argList::noFunctionObjects(); // Never use function objects
68 
69  argList::addArgument("controlFile");
70 
71  argList args(argc, argv);
72 
73  const fileName controlFileName = args[1];
74 
75  // Construct control dictionary
76  IFstream controlFile(controlFileName);
77 
78  // Check controlFile stream is OK
79  if (!controlFile.good())
80  {
82  << "Cannot read file " << controlFileName
83  << exit(FatalError);
84  }
85 
86  dictionary control(controlFile);
87 
88 
89  const scalar P(control.get<scalar>("P"));
90  const scalar T0(control.get<scalar>("T0"));
91  const word fuelName(control.get<word>("fuel"));
92  const scalar n(control.get<scalar>("n"));
93  const scalar m(control.get<scalar>("m"));
94 
95  Info<< nl << "Reading thermodynamic data dictionary" << endl;
96 
97  fileName thermoDataFileName(findEtcFile("thermoData/thermoData"));
98 
99  // Construct control dictionary
100  IFstream thermoDataFile(thermoDataFileName);
101 
102  // Check thermoData stream is OK
103  if (!thermoDataFile.good())
104  {
106  << "Cannot read file " << thermoDataFileName
107  << exit(FatalError);
108  }
109 
110  dictionary thermoData(thermoDataFile);
111 
112 
113  scalar stoicO2 = n + m/4.0;
114  scalar stoicN2 = (0.79/0.21)*stoicO2;
115  scalar stoicCO2 = n;
116  scalar stoicH2O = m/2.0;
117 
118  thermo FUEL
119  (
120  "fuel",
121  thermo(thermoData.subDict(fuelName))
122  );
123  Info<< "fuel " << FUEL << ';' << endl;
124  FUEL *= FUEL.W();
125 
126  thermo O2
127  (
128  "O2",
129  thermo(thermoData.subDict("O2"))
130  );
131  O2 *= O2.W();
132 
133  thermo N2
134  (
135  "N2",
136  thermo(thermoData.subDict("N2"))
137  );
138  N2 *= N2.W();
139 
140  thermo CO2
141  (
142  "CO2",
143  thermo(thermoData.subDict("CO2"))
144  );
145  CO2 *= CO2.W();
146 
147  thermo H2O
148  (
149  "H2O",
150  thermo(thermoData.subDict("H2O"))
151  );
152  H2O *= H2O.W();
153 
154  thermo oxidant
155  (
156  "oxidant",
157  stoicO2*O2
158  + stoicN2*N2
159  );
160  Info<< "oxidant " << (1/oxidant.Y())*oxidant << ';' << endl;
161 
162  dimensionedScalar stoichiometricAirFuelMassRatio
163  (
164  "stoichiometricAirFuelMassRatio",
165  dimless,
166  oxidant.Y()/FUEL.W()
167  );
168 
169  Info<< "stoichiometricAirFuelMassRatio "
170  << stoichiometricAirFuelMassRatio << ';' << endl;
171 
172  for (int i=0; i<300; i++)
173  {
174  scalar equiv = (i + 1)*0.01;
175  scalar ft = 1/(1 + stoichiometricAirFuelMassRatio.value()/equiv);
176 
177  Info<< "phi = " << equiv << nl
178  << "ft = " << ft << endl;
179 
180  scalar o2 = (1.0/equiv)*stoicO2;
181  scalar n2 = (0.79/0.21)*o2;
182  scalar fres = max(1.0 - 1.0/equiv, 0.0);
183  scalar ores = max(1.0/equiv - 1.0, 0.0);
184  scalar fburnt = 1.0 - fres;
185 
186  thermo reactants
187  (
188  "reactants",
189  FUEL + (1.0/equiv)*oxidant
190  );
191  Info<< "reactants " << (1/reactants.Y())*reactants << ';' << endl;
192 
193  thermo burntProducts
194  (
195  "burntProducts",
196  + (n2 - (0.79/0.21)*ores*stoicO2)*N2
197  + fburnt*stoicCO2*CO2
198  + fburnt*stoicH2O*H2O
199  );
200  Info<< "burntProducts "
201  << (1/burntProducts.Y())*burntProducts << ';' << endl;
202 
203  thermo products
204  (
205  "products",
206  fres*FUEL
207  + n2*N2
208  + fburnt*stoicCO2*CO2
209  + fburnt*stoicH2O*H2O
210  + ores*stoicO2*O2
211  );
212 
213  Info<< "products " << (1/products.Y())*products << ';' << endl;
214 
215  scalar Tad = products.THa(reactants.Ha(P, T0), P, 1000.0);
216  Info<< "Tad = " << Tad << nl << endl;
217  }
218 
219  Info<< nl << "End" << endl;
220 
221  return 0;
222 }
223 
224 
225 // ************************************************************************* //
OSspecific.H
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
Foam::dimless
const dimensionSet dimless(0, 0, 0, 0, 0, 0, 0)
Dimensionless.
Definition: dimensionSets.H:50
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::fileName
A class for handling file names.
Definition: fileName.H:69
Foam::IFstream
Input from file stream, using an ISstream.
Definition: IFstream.H:85
Foam::N2
Liquid N2.
Definition: N2.H:60
thermo
psiReactionThermo & thermo
Definition: createFields.H:28
Foam::absoluteEnthalpy
Thermodynamics mapping class to expose the absolute enthalpy functions.
Definition: absoluteEnthalpy.H:49
Foam::argList::addNote
static void addNote(const string &note)
Add extra notes for the usage information.
Definition: argList.C:413
thermo
Basic thermodynamics type based on the use of fitting functions for cp, h, s obtained from the templa...
Foam::argList
Extract command arguments and options from the supplied argc and argv parameters.
Definition: argList.H:123
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:350
specie.H
Foam::thermophysicalProperties::W
scalar W() const
Molecular weight [kg/kmol].
Definition: thermophysicalPropertiesI.H:36
Foam::argList::addArgument
static void addArgument(const string &argName, const string &usage="")
Append a (mandatory) argument to validArgs.
Definition: argList.C:302
n
label n
Definition: TABSMDCalcMethod2.H:31
Foam::argList::noFunctionObjects
static void noFunctionObjects(bool addWithOption=false)
Remove '-noFunctionObjects' option and ignore any occurrences.
Definition: argList.C:454
Foam::findEtcFile
fileName findEtcFile(const fileName &name, const bool mandatory=false, unsigned short location=0777)
Search for a single FILE within the etc directories.
Definition: etcFiles.C:446
Foam::Info
messageStream Info
Information stream (uses stdout - output is on the master only)
janafThermo.H
Foam::H2O
water
Definition: H2O.H:59
argList.H
Foam::max
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:47
IFstream.H
perfectGas.H
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
Foam::dimensioned< scalar >
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::species::thermo
Definition: thermo.H:54
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
etcFiles.H
Functions to search 'etc' directories for configuration files etc.
Time.H
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:372
Foam::nl
constexpr char nl
Definition: Ostream.H:385
dictionary.H
Foam::argList::noParallel
static void noParallel()
Remove the parallel options.
Definition: argList.C:491
args
Foam::argList args(argc, argv)
T0
scalar T0
Definition: createFields.H:22
absoluteEnthalpy.H