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 | Copyright (C) 2011-2015 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 Application
25  adiabaticFlameT
26 
27 Description
28  Calculates the adiabatic flame temperature for a given fuel over a
29  range of unburnt temperatures and equivalence ratios.
30 
31 \*---------------------------------------------------------------------------*/
32 
33 #include "argList.H"
34 #include "Time.H"
35 #include "dictionary.H"
36 #include "IFstream.H"
37 #include "OSspecific.H"
38 
39 #include "specie.H"
40 #include "perfectGas.H"
41 #include "thermo.H"
42 #include "janafThermo.H"
43 #include "absoluteEnthalpy.H"
44 
45 using namespace Foam;
46 
48  thermo;
49 
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 
52 int main(int argc, char *argv[])
53 {
54  argList::validArgs.append("controlFile");
55  argList args(argc, argv);
56 
57  const fileName controlFileName = args[1];
58 
59  // Construct control dictionary
60  IFstream controlFile(controlFileName);
61 
62  // Check controlFile stream is OK
63  if (!controlFile.good())
64  {
66  << "Cannot read file " << controlFileName
67  << exit(FatalError);
68  }
69 
70  dictionary control(controlFile);
71 
72 
73  scalar P(readScalar(control.lookup("P")));
74  scalar T0(readScalar(control.lookup("T0")));
75  const word fuelName(control.lookup("fuel"));
76  scalar n(readScalar(control.lookup("n")));
77  scalar m(readScalar(control.lookup("m")));
78 
79 
80  Info<< nl << "Reading thermodynamic data dictionary" << endl;
81 
82  fileName thermoDataFileName(findEtcFile("thermoData/thermoData"));
83 
84  // Construct control dictionary
85  IFstream thermoDataFile(thermoDataFileName);
86 
87  // Check thermoData stream is OK
88  if (!thermoDataFile.good())
89  {
91  << "Cannot read file " << thermoDataFileName
92  << exit(FatalError);
93  }
94 
95  dictionary thermoData(thermoDataFile);
96 
97 
98  scalar stoicO2 = n + m/4.0;
99  scalar stoicN2 = (0.79/0.21)*(n + m/4.0);
100  scalar stoicCO2 = n;
101  scalar stoicH2O = m/2.0;
102 
103  thermo fuel
104  (
105  "fuel",
106  thermo(thermoData.subDict(fuelName))
107  );
108 
109  thermo oxidant
110  (
111  "oxidant",
112  stoicO2*thermo(thermoData.subDict("O2"))
113  + stoicN2*thermo(thermoData.subDict("N2"))
114  );
115 
116  dimensionedScalar stoichiometricAirFuelMassRatio
117  (
118  "stoichiometricAirFuelMassRatio",
119  dimless,
120  (oxidant.W()*oxidant.nMoles())/fuel.W()
121  );
122 
123  Info<< "stoichiometricAirFuelMassRatio "
124  << stoichiometricAirFuelMassRatio << ';' << endl;
125 
126  for (int i=0; i<300; i++)
127  {
128  scalar equiv = (i + 1)*0.01;
129  scalar ft = 1/(1 + stoichiometricAirFuelMassRatio.value()/equiv);
130 
131  Info<< "phi = " << equiv << nl
132  << "ft = " << ft << endl;
133 
134  scalar o2 = (1.0/equiv)*stoicO2;
135  scalar n2 = (0.79/0.21)*o2;
136  scalar fres = max(1.0 - 1.0/equiv, 0.0);
137  scalar ores = max(1.0/equiv - 1.0, 0.0);
138  scalar fburnt = 1.0 - fres;
139 
140  thermo fuel
141  (
142  "fuel",
143  thermo(thermoData.subDict(fuelName))
144  );
145  Info<< "fuel " << fuel << ';' << endl;
146 
147  thermo oxidant
148  (
149  "oxidant",
150  o2*thermo(thermoData.subDict("O2"))
151  + n2*thermo(thermoData.subDict("N2"))
152  );
153  Info<< "oxidant " << (1/oxidant.nMoles())*oxidant << ';' << endl;
154 
155  thermo reactants
156  (
157  "reactants",
158  fuel + oxidant
159  );
160  Info<< "reactants " << (1/reactants.nMoles())*reactants << ';' << endl;
161 
162  thermo burntProducts
163  (
164  "burntProducts",
165  + (n2 - (0.79/0.21)*ores*stoicO2)*thermo(thermoData.subDict("N2"))
166  + fburnt*stoicCO2*thermo(thermoData.subDict("CO2"))
167  + fburnt*stoicH2O*thermo(thermoData.subDict("H2O"))
168  );
169  Info<< "burntProducts "
170  << (1/burntProducts.nMoles())*burntProducts << ';' << endl;
171 
172  thermo products
173  (
174  "products",
175  fres*fuel
176  + n2*thermo(thermoData.subDict("N2"))
177  + fburnt*stoicCO2*thermo(thermoData.subDict("CO2"))
178  + fburnt*stoicH2O*thermo(thermoData.subDict("H2O"))
179  + ores*stoicO2*thermo(thermoData.subDict("O2"))
180  );
181 
182  Info<< "products " << (1/products.nMoles())*products << ';' << endl;
183 
184  scalar Tad = products.THa(reactants.Ha(P, T0), P, 1000.0);
185  Info<< "Tad = " << Tad << nl << endl;
186  }
187 
188  Info<< nl << "end" << endl;
189 
190  return 0;
191 }
192 
193 
194 // ************************************************************************* //
Foam::argList::validArgs
static SLList< string > validArgs
A list of valid (mandatory) arguments.
Definition: argList.H:143
Foam::findEtcFile
fileName findEtcFile(const fileName &, bool mandatory=false)
Search for a file using findEtcFiles.
Definition: POSIX.C:404
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)
Definition: dimensionSets.H:47
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::fileName
A class for handling file names.
Definition: fileName.H:69
Foam::IFstream
Input from file stream.
Definition: IFstream.H:81
thermo.H
Foam::absoluteEnthalpy
Thermodynamics mapping class to expose the absolute enthalpy function as the standard enthalpy functi...
Definition: absoluteEnthalpy.H:45
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:97
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
specie.H
thermo
rhoThermo & thermo
Definition: setRegionFluidFields.H:3
n
label n
Definition: TABSMDCalcMethod2.H:31
Foam::nl
static const char nl
Definition: Ostream.H:260
Foam::Info
messageStream Info
janafThermo.H
argList.H
main
int main(int argc, char *argv[])
Definition: postCalc.C:54
IFstream.H
perfectGas.H
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam::dimensioned
Generic dimensioned Type class.
Definition: dimensionedScalarFwd.H:41
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::species::thermo
Definition: thermo.H:52
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
Foam::max
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:318
Foam::readScalar
bool readScalar(const char *buf, doubleScalar &s)
Read whole of buf as a scalar. Return true if succesful.
Definition: doubleScalar.H:63
dictionary.H
args
Foam::argList args(argc, argv)
absoluteEnthalpy.H