FreeFOAM The Cross-Platform CFD Toolkit
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) 1991-2010 OpenCFD Ltd.
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 Usage
32 
33  - adiabaticFlameT [OPTIONS] <controlFile>
34 
35  @param <controlFile> \n
36  @todo Detailed description of argument.
37 
38  @param -case <dir>\n
39  Case directory.
40 
41  @param -parallel \n
42  Run in parallel.
43 
44  @param -help \n
45  Display help message.
46 
47  @param -doc \n
48  Display Doxygen API documentation page for this application.
49 
50  @param -srcDoc \n
51  Display Doxygen source documentation page for this application.
52 
53 \*---------------------------------------------------------------------------*/
54 
55 #include <OpenFOAM/argList.H>
56 #include <OpenFOAM/Time.H>
57 #include <OpenFOAM/dictionary.H>
58 #include <OpenFOAM/IFstream.H>
59 #include <OpenFOAM/OSspecific.H>
60 
61 #include <specie/specieThermo.H>
62 #include <specie/janafThermo.H>
63 #include <specie/perfectGas.H>
64 
65 using namespace Foam;
66 
68 
69 
70 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
71 
72 int main(int argc, char *argv[])
73 {
75  argList::validArgs.append("controlFile");
76  argList args(argc, argv);
77 
78  fileName controlFileName(args.additionalArgs()[0]);
79 
80  // Construct control dictionary
81  IFstream controlFile(controlFileName);
82 
83  // Check controlFile stream is OK
84  if (!controlFile.good())
85  {
87  << "Cannot read file " << controlFileName
88  << exit(FatalError);
89  }
90 
91  dictionary control(controlFile);
92 
93 
94  scalar T0(readScalar(control.lookup("T0")));
95  word fuelName(control.lookup("fuel"));
96  scalar n(readScalar(control.lookup("n")));
97  scalar m(readScalar(control.lookup("m")));
98 
99 
100  Info<< nl << "Reading Burcat data dictionary" << endl;
101 
102  fileName BurcatCpDataFileName(findEtcFile("thermoData/BurcatCpData"));
103 
104  // Construct control dictionary
105  IFstream BurcatCpDataFile(BurcatCpDataFileName);
106 
107  // Check BurcatCpData stream is OK
108  if (!BurcatCpDataFile.good())
109  {
111  << "Cannot read file " << BurcatCpDataFileName
112  << exit(FatalError);
113  }
114 
115  dictionary CpData(BurcatCpDataFile);
116 
117 
118  scalar stoicO2 = n + m/4.0;
119  scalar stoicN2 = (0.79/0.21)*(n + m/4.0);
120  scalar stoicCO2 = n;
121  scalar stoicH2O = m/2.0;
122 
123  thermo fuel
124  (
125  "fuel",
126  thermo(CpData.lookup(fuelName))
127  );
128 
129  thermo oxidant
130  (
131  "oxidant",
132  stoicO2*thermo(CpData.lookup("O2"))
133  + stoicN2*thermo(CpData.lookup("N2"))
134  );
135 
136  dimensionedScalar stoichiometricAirFuelMassRatio
137  (
138  "stoichiometricAirFuelMassRatio",
139  dimless,
140  (oxidant.W()*oxidant.nMoles())/fuel.W()
141  );
142 
143  Info<< "stoichiometricAirFuelMassRatio "
144  << stoichiometricAirFuelMassRatio << ';' << endl;
145 
146  for (int i=0; i<300; i++)
147  {
148  scalar equiv = (i + 1)*0.01;
149  scalar ft = 1/(1 + stoichiometricAirFuelMassRatio.value()/equiv);
150 
151  Info<< "phi = " << equiv << nl
152  << "ft = " << ft << endl;
153 
154  scalar o2 = (1.0/equiv)*stoicO2;
155  scalar n2 = (0.79/0.21)*o2;
156  scalar fres = max(1.0 - 1.0/equiv, 0.0);
157  scalar ores = max(1.0/equiv - 1.0, 0.0);
158  scalar fburnt = 1.0 - fres;
159 
160  thermo fuel
161  (
162  "fuel",
163  thermo(CpData.lookup(fuelName))
164  );
165  Info<< "fuel " << fuel << ';' << endl;
166 
167  thermo oxidant
168  (
169  "oxidant",
170  o2*thermo(CpData.lookup("O2"))
171  + n2*thermo(CpData.lookup("N2"))
172  );
173  Info<< "oxidant " << (1/oxidant.nMoles())*oxidant << ';' << endl;
174 
175  thermo reactants
176  (
177  "reactants",
178  fuel + oxidant
179  );
180  Info<< "reactants " << (1/reactants.nMoles())*reactants << ';' << endl;
181 
182  thermo burntProducts
183  (
184  "burntProducts",
185  + (n2 - (0.79/0.21)*ores*stoicO2)*thermo(CpData.lookup("N2"))
186  + fburnt*stoicCO2*thermo(CpData.lookup("CO2"))
187  + fburnt*stoicH2O*thermo(CpData.lookup("H2O"))
188  );
189  Info<< "burntProducts "
190  << (1/burntProducts.nMoles())*burntProducts << ';' << endl;
191 
192  thermo products
193  (
194  "products",
195  fres*fuel
196  + n2*thermo(CpData.lookup("N2"))
197  + fburnt*stoicCO2*thermo(CpData.lookup("CO2"))
198  + fburnt*stoicH2O*thermo(CpData.lookup("H2O"))
199  + ores*stoicO2*thermo(CpData.lookup("O2"))
200  );
201 
202  Info<< "products " << (1/products.nMoles())*products << ';' << endl;
203 
204  scalar Tad = products.TH(reactants.H(T0), 1000.0);
205  Info<< "Tad = " << Tad << nl << endl;
206  }
207 
208  Info<< nl << "end" << endl;
209 
210  return 0;
211 }
212 
213 
214 // ************************ vim: set sw=4 sts=4 et: ************************ //