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-2023 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("fuel", thermoData.subDict(fuelName));
105  Info<< "fuel " << FUEL << ';' << endl;
106  FUEL *= FUEL.W();
107 
108  thermo O2("O2", thermoData.subDict("O2"));
109  O2 *= O2.W();
110 
111  thermo N2("N2", thermoData.subDict("N2"));
112  N2 *= N2.W();
113 
114  thermo CO2("CO2", thermoData.subDict("CO2"));
115  CO2 *= CO2.W();
116 
117  thermo H2O("H2O", thermoData.subDict("H2O"));
118  H2O *= H2O.W();
119 
120  thermo oxidant("oxidant", stoicO2*O2 + stoicN2*N2);
121  Info<< "oxidant " << (1/oxidant.Y())*oxidant << ';' << endl;
122 
123  dimensionedScalar stoichiometricAirFuelMassRatio
124  (
125  "stoichiometricAirFuelMassRatio",
126  dimless,
127  oxidant.Y()/FUEL.W()
128  );
129 
130  Info<< "stoichiometricAirFuelMassRatio "
131  << stoichiometricAirFuelMassRatio << ';' << endl;
132 
133  for (int i=0; i<300; i++)
134  {
135  scalar equiv = (i + 1)*0.01;
136  scalar ft = 1/(1 + stoichiometricAirFuelMassRatio.value()/equiv);
137 
138  Info<< "phi = " << equiv << nl
139  << "ft = " << ft << endl;
140 
141  scalar o2 = (1.0/equiv)*stoicO2;
142  scalar n2 = (0.79/0.21)*o2;
143  scalar fres = max(1.0 - 1.0/equiv, 0.0);
144  scalar ores = max(1.0/equiv - 1.0, 0.0);
145  scalar fburnt = 1.0 - fres;
146 
147  thermo reactants
148  (
149  "reactants",
150  FUEL + (1.0/equiv)*oxidant
151  );
152  Info<< "reactants " << (1/reactants.Y())*reactants << ';' << endl;
153 
154  thermo burntProducts
155  (
156  "burntProducts",
157  + (n2 - (0.79/0.21)*ores*stoicO2)*N2
158  + fburnt*stoicCO2*CO2
159  + fburnt*stoicH2O*H2O
160  );
161  Info<< "burntProducts "
162  << (1/burntProducts.Y())*burntProducts << ';' << endl;
163 
164  thermo products
165  (
166  "products",
167  fres*FUEL
168  + n2*N2
169  + fburnt*stoicCO2*CO2
170  + fburnt*stoicH2O*H2O
171  + ores*stoicO2*O2
172  );
173 
174  Info<< "products " << (1/products.Y())*products << ';' << endl;
175 
176  scalar Tad = products.THa(reactants.Ha(P, T0), P, 1000.0);
177  Info<< "Tad = " << Tad << nl << endl;
178  }
179 
180  Info<< nl << "end" << endl;
181 
182  return 0;
183 }
184 
185 
186 // ************************************************************************* //
label n
water
Definition: H2O.H:60
Input from file stream.
Definition: IFstream.H:85
Liquid N2.
Definition: N2.H:61
Thermodynamics mapping class to expose the absolute enthalpy functions.
Extract command arguments and options from the supplied argc and argv parameters.
Definition: argList.H:103
static SLList< string > validArgs
A list of valid (mandatory) arguments.
Definition: argList.H:153
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:160
A class for handling file names.
Definition: fileName.H:82
Basic thermodynamics type based on the use of fitting functions for cp, h, s obtained from the templa...
Definition: thermo.H:92
scalar W() const
Molecular weight [kg/kmol].
A class for handling words, derived from string.
Definition: word.H:62
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:306
Functions to search 'etc' directories for configuration files etc.
int main(int argc, char *argv[])
Definition: financialFoam.C:44
Namespace for OpenFOAM.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
const dimensionSet dimless
messageStream Info
fileName findEtcFile(const fileName &, bool mandatory=false)
Search for a file using findEtcFiles.
Definition: etcFiles.C:252
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
error FatalError
static const char nl
Definition: Ostream.H:260
Foam::argList args(argc, argv)
fluidMulticomponentThermo & thermo
Definition: createFields.H:31
scalar T0
Definition: createFields.H:22