-
Notifications
You must be signed in to change notification settings - Fork 122
/
adiabaticFlameT.C
211 lines (165 loc) · 5.39 KB
/
adiabaticFlameT.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Application
adiabaticFlameT
Description
Calculates the adiabatic flame temperature for a given fuel over a
range of unburnt temperatures and equivalence ratios.
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "Time.H"
#include "dictionary.H"
#include "IFstream.H"
#include "OSspecific.H"
#include "etcFiles.H"
#include "specie.H"
#include "perfectGas.H"
#include "thermo.H"
#include "janafThermo.H"
#include "absoluteEnthalpy.H"
using namespace Foam;
typedef species::thermo<janafThermo<perfectGas<specie>>, absoluteEnthalpy>
thermo;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
argList::validArgs.append("control file");
argList args(argc, argv);
const fileName controlFileName = args[1];
// Construct control dictionary
IFstream controlFile(controlFileName);
// Check controlFile stream is OK
if (!controlFile.good())
{
FatalErrorInFunction
<< "Cannot read file " << controlFileName
<< exit(FatalError);
}
dictionary control(controlFile);
scalar P(readScalar(control.lookup("P")));
scalar T0(readScalar(control.lookup("T0")));
const word fuelName(control.lookup("fuel"));
scalar n(readScalar(control.lookup("n")));
scalar m(readScalar(control.lookup("m")));
Info<< nl << "Reading thermodynamic data dictionary" << endl;
fileName thermoDataFileName(findEtcFile("thermoData/thermoData"));
// Construct control dictionary
IFstream thermoDataFile(thermoDataFileName);
// Check thermoData stream is OK
if (!thermoDataFile.good())
{
FatalErrorInFunction
<< "Cannot read file " << thermoDataFileName
<< exit(FatalError);
}
dictionary thermoData(thermoDataFile);
scalar stoicO2 = n + m/4.0;
scalar stoicN2 = (0.79/0.21)*stoicO2;
scalar stoicCO2 = n;
scalar stoicH2O = m/2.0;
thermo FUEL
(
"fuel",
thermo(thermoData.subDict(fuelName))
);
Info<< "fuel " << FUEL << ';' << endl;
FUEL *= FUEL.W();
thermo O2
(
"O2",
thermo(thermoData.subDict("O2"))
);
O2 *= O2.W();
thermo N2
(
"N2",
thermo(thermoData.subDict("N2"))
);
N2 *= N2.W();
thermo CO2
(
"CO2",
thermo(thermoData.subDict("CO2"))
);
CO2 *= CO2.W();
thermo H2O
(
"H2O",
thermo(thermoData.subDict("H2O"))
);
H2O *= H2O.W();
thermo oxidant
(
"oxidant",
stoicO2*O2
+ stoicN2*N2
);
Info<< "oxidant " << (1/oxidant.Y())*oxidant << ';' << endl;
dimensionedScalar stoichiometricAirFuelMassRatio
(
"stoichiometricAirFuelMassRatio",
dimless,
oxidant.Y()/FUEL.W()
);
Info<< "stoichiometricAirFuelMassRatio "
<< stoichiometricAirFuelMassRatio << ';' << endl;
for (int i=0; i<300; i++)
{
scalar equiv = (i + 1)*0.01;
scalar ft = 1/(1 + stoichiometricAirFuelMassRatio.value()/equiv);
Info<< "phi = " << equiv << nl
<< "ft = " << ft << endl;
scalar o2 = (1.0/equiv)*stoicO2;
scalar n2 = (0.79/0.21)*o2;
scalar fres = max(1.0 - 1.0/equiv, 0.0);
scalar ores = max(1.0/equiv - 1.0, 0.0);
scalar fburnt = 1.0 - fres;
thermo reactants
(
"reactants",
FUEL + (1.0/equiv)*oxidant
);
Info<< "reactants " << (1/reactants.Y())*reactants << ';' << endl;
thermo burntProducts
(
"burntProducts",
+ (n2 - (0.79/0.21)*ores*stoicO2)*N2
+ fburnt*stoicCO2*CO2
+ fburnt*stoicH2O*H2O
);
Info<< "burntProducts "
<< (1/burntProducts.Y())*burntProducts << ';' << endl;
thermo products
(
"products",
fres*FUEL
+ n2*N2
+ fburnt*stoicCO2*CO2
+ fburnt*stoicH2O*H2O
+ ores*stoicO2*O2
);
Info<< "products " << (1/products.Y())*products << ';' << endl;
scalar Tad = products.THa(reactants.Ha(P, T0), P, 1000.0);
Info<< "Tad = " << Tad << nl << endl;
}
Info<< nl << "end" << endl;
return 0;
}
// ************************************************************************* //