All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
adiabaticFlameT.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-2019 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 "IFstream.H"
35 #include "etcFiles.H"
36 #include "dimensionedTypes.H"
37 
38 #include "specie.H"
39 #include "perfectGas.H"
40 #include "thermo.H"
41 #include "janafThermo.H"
42 #include "absoluteEnthalpy.H"
43 
44 using namespace Foam;
45 
47  thermo;
48 
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 
51 int main(int argc, char *argv[])
52 {
53  #include "removeCaseOptions.H"
54 
55  argList::validArgs.append("properties dictionary");
56  argList args(argc, argv);
57 
58  const fileName propertiesDictName = args[1];
59 
60  // Construct control dictionary
61  IFstream propertiesDict(propertiesDictName);
62 
63  // Check propertiesDict stream is OK
64  if (!propertiesDict.good())
65  {
67  << "Cannot read file " << propertiesDictName
68  << exit(FatalError);
69  }
70 
71  dictionary control(propertiesDict);
72 
73 
74  scalar P(control.lookup<scalar>("P"));
75  scalar T0(control.lookup<scalar>("T0"));
76  const word fuelName(control.lookup("fuel"));
77  scalar n(control.lookup<scalar>("n"));
78  scalar m(control.lookup<scalar>("m"));
79 
80 
81  Info<< nl << "Reading thermodynamic data dictionary" << endl;
82 
83  fileName thermoDataFileName(findEtcFile("thermoData/thermoData"));
84 
85  // Construct control dictionary
86  IFstream thermoDataFile(thermoDataFileName);
87 
88  // Check thermoData stream is OK
89  if (!thermoDataFile.good())
90  {
92  << "Cannot read file " << thermoDataFileName
93  << exit(FatalError);
94  }
95 
96  dictionary thermoData(thermoDataFile);
97 
98 
99  scalar stoicO2 = n + m/4.0;
100  scalar stoicN2 = (0.79/0.21)*stoicO2;
101  scalar stoicCO2 = n;
102  scalar stoicH2O = m/2.0;
103 
104  thermo FUEL
105  (
106  "fuel",
107  thermo(thermoData.subDict(fuelName))
108  );
109  Info<< "fuel " << FUEL << ';' << endl;
110  FUEL *= FUEL.W();
111 
112  thermo O2
113  (
114  "O2",
115  thermo(thermoData.subDict("O2"))
116  );
117  O2 *= O2.W();
118 
119  thermo N2
120  (
121  "N2",
122  thermo(thermoData.subDict("N2"))
123  );
124  N2 *= N2.W();
125 
126  thermo CO2
127  (
128  "CO2",
129  thermo(thermoData.subDict("CO2"))
130  );
131  CO2 *= CO2.W();
132 
133  thermo H2O
134  (
135  "H2O",
136  thermo(thermoData.subDict("H2O"))
137  );
138  H2O *= H2O.W();
139 
140  thermo oxidant
141  (
142  "oxidant",
143  stoicO2*O2
144  + stoicN2*N2
145  );
146  Info<< "oxidant " << (1/oxidant.Y())*oxidant << ';' << endl;
147 
148  dimensionedScalar stoichiometricAirFuelMassRatio
149  (
150  "stoichiometricAirFuelMassRatio",
151  dimless,
152  oxidant.Y()/FUEL.W()
153  );
154 
155  Info<< "stoichiometricAirFuelMassRatio "
156  << stoichiometricAirFuelMassRatio << ';' << endl;
157 
158  for (int i=0; i<300; i++)
159  {
160  scalar equiv = (i + 1)*0.01;
161  scalar ft = 1/(1 + stoichiometricAirFuelMassRatio.value()/equiv);
162 
163  Info<< "phi = " << equiv << nl
164  << "ft = " << ft << endl;
165 
166  scalar o2 = (1.0/equiv)*stoicO2;
167  scalar n2 = (0.79/0.21)*o2;
168  scalar fres = max(1.0 - 1.0/equiv, 0.0);
169  scalar ores = max(1.0/equiv - 1.0, 0.0);
170  scalar fburnt = 1.0 - fres;
171 
172  thermo reactants
173  (
174  "reactants",
175  FUEL + (1.0/equiv)*oxidant
176  );
177  Info<< "reactants " << (1/reactants.Y())*reactants << ';' << endl;
178 
179  thermo burntProducts
180  (
181  "burntProducts",
182  + (n2 - (0.79/0.21)*ores*stoicO2)*N2
183  + fburnt*stoicCO2*CO2
184  + fburnt*stoicH2O*H2O
185  );
186  Info<< "burntProducts "
187  << (1/burntProducts.Y())*burntProducts << ';' << endl;
188 
189  thermo products
190  (
191  "products",
192  fres*FUEL
193  + n2*N2
194  + fburnt*stoicCO2*CO2
195  + fburnt*stoicH2O*H2O
196  + ores*stoicO2*O2
197  );
198 
199  Info<< "products " << (1/products.Y())*products << ';' << endl;
200 
201  scalar Tad = products.THa(reactants.Ha(P, T0), P, 1000.0);
202  Info<< "Tad = " << Tad << nl << endl;
203  }
204 
205  Info<< nl << "end" << endl;
206 
207  return 0;
208 }
209 
210 
211 // ************************************************************************* //
fluidReactionThermo & thermo
Definition: createFields.H:28
A class for handling file names.
Definition: fileName.H:79
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
error FatalError
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:323
water
Definition: H2O.H:57
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
static SLList< string > validArgs
A list of valid (mandatory) arguments.
Definition: argList.H:153
Thermodynamics mapping class to expose the absolute enthalpy functions.
const dimensionSet dimless
A class for handling words, derived from string.
Definition: word.H:59
Functions to search &#39;etc&#39; directories for configuration files etc.
scalar W() const
Molecular weight [kg/kmol].
Extract command arguments and options from the supplied argc and argv parameters. ...
Definition: argList.H:102
fileName findEtcFile(const fileName &, bool mandatory=false)
Search for a file using findEtcFiles.
Definition: etcFiles.C:252
Liquid N2.
Definition: N2.H:58
static const char nl
Definition: Ostream.H:260
Input from file stream.
Definition: IFstream.H:81
Basic thermodynamics type based on the use of fitting functions for cp, h, s obtained from the templa...
Definition: thermo.H:52
messageStream Info
label n
Foam::argList args(argc, argv)
Namespace for OpenFOAM.
scalar T0
Definition: createFields.H:22