initial commit for version 1.5.x patch release
[OpenFOAM-1.5.x.git] / applications / utilities / thermophysical / adiabaticFlameT / adiabaticFlameT.C
blob3d494b6cc0315b35633d3ea3a447a67426e0a8b7
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2008 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
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 the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
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.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 Application
26     adiabaticFlameT
28 Description
29     Calculates the adiabatic flame temperature for a given fuel over a
30     range of unburnt temperatures and equivalence ratios.
32 \*---------------------------------------------------------------------------*/
34 #include "argList.H"
35 #include "Time.H"
36 #include "dictionary.H"
37 #include "IFstream.H"
38 #include "OSspecific.H"
40 #include "specieThermo.H"
41 #include "janafThermo.H"
42 #include "perfectGas.H"
44 using namespace Foam;
46 typedef specieThermo<janafThermo<perfectGas> > thermo;
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 int main(int argc, char *argv[])
53     argList::validArgs.clear();
54     argList::validArgs.append("controlFile");
55     argList args(argc, argv);
57     fileName controlFileName(args.additionalArgs()[0]);
59     // Construct control dictionary
60     IFstream controlFile(controlFileName);
62     // Check controlFile stream is OK
63     if (!controlFile.good())
64     {
65         FatalErrorIn(args.executable())
66             << "Cannot read file " << controlFileName
67             << exit(FatalError);
68     }
70     dictionary control(controlFile);
73     scalar T0(readScalar(control.lookup("T0")));
74     word fuelName(control.lookup("fuel"));
75     scalar n(readScalar(control.lookup("n")));
76     scalar m(readScalar(control.lookup("m")));
79     Info<< nl << "Reading Burcat data dictionary" << endl;
81     fileName BurcatCpDataFileName(dotFoam("thermoData/BurcatCpData"));
83     // Construct control dictionary
84     IFstream BurcatCpDataFile(BurcatCpDataFileName);
86     // Check BurcatCpData stream is OK
87     if (!BurcatCpDataFile.good())
88     {
89         FatalErrorIn(args.executable())
90             << "Cannot read file " << BurcatCpDataFileName
91             << exit(FatalError);
92     }
94     dictionary CpData(BurcatCpDataFile);
97     scalar stoicO2 = n + m/4.0;
98     scalar stoicN2 = (0.79/0.21)*(n + m/4.0);
99     scalar stoicCO2 = n;
100     scalar stoicH2O = m/2.0;
102     thermo fuel
103     (
104         "fuel",
105         thermo(CpData.lookup(fuelName))
106     );
108     thermo oxidant
109     (
110         "oxidant",
111         stoicO2*thermo(CpData.lookup("O2"))
112       + stoicN2*thermo(CpData.lookup("N2"))
113     );
115     dimensionedScalar stoichiometricAirFuelMassRatio
116     (
117         "stoichiometricAirFuelMassRatio",
118         dimless,
119         (oxidant.W()*oxidant.nMoles())/fuel.W()
120     );
122     Info<< "stoichiometricAirFuelMassRatio "
123         << stoichiometricAirFuelMassRatio << ';' << endl;
125     for (int i=0; i<300; i++)
126     {
127         scalar equiv = (i + 1)*0.01;
128         scalar ft = 1/(1 + stoichiometricAirFuelMassRatio.value()/equiv);
130         Info<< "phi = " << equiv << nl
131             << "ft = " << ft << endl;
133         scalar o2 = (1.0/equiv)*stoicO2;
134         scalar n2 = (0.79/0.21)*o2;
135         scalar fres = max(1.0 - 1.0/equiv, 0.0);
136         scalar ores = max(1.0/equiv - 1.0, 0.0);
137         scalar fburnt = 1.0 - fres;
139         thermo fuel
140         (
141             "fuel",
142             thermo(CpData.lookup(fuelName))
143         );
144         Info<< "fuel " << fuel << ';' << endl;
146         thermo oxidant
147         (
148             "oxidant",
149             o2*thermo(CpData.lookup("O2"))
150           + n2*thermo(CpData.lookup("N2"))
151         );
152         Info<< "oxidant " << (1/oxidant.nMoles())*oxidant << ';' << endl;
154         thermo reactants
155         (
156             "reactants",
157             fuel + oxidant
158         );
159         Info<< "reactants " << (1/reactants.nMoles())*reactants << ';' << endl;
161         thermo burntProducts
162         (
163             "burntProducts",
164           + (n2 - (0.79/0.21)*ores*stoicO2)*thermo(CpData.lookup("N2"))
165           + fburnt*stoicCO2*thermo(CpData.lookup("CO2"))
166           + fburnt*stoicH2O*thermo(CpData.lookup("H2O"))
167         );
168         Info<< "burntProducts "
169             << (1/burntProducts.nMoles())*burntProducts << ';' << endl;
171         thermo products
172         (
173             "products",
174             fres*fuel
175           + n2*thermo(CpData.lookup("N2"))
176           + fburnt*stoicCO2*thermo(CpData.lookup("CO2"))
177           + fburnt*stoicH2O*thermo(CpData.lookup("H2O"))
178           + ores*stoicO2*thermo(CpData.lookup("O2"))
179         );
181         Info<< "products " << (1/products.nMoles())*products << ';' << endl;
183         scalar Tad = products.TH(reactants.H(T0), 1000.0);
184         Info<< "Tad = " << Tad << nl << endl;
185     }
187     Info<< nl << "end" << endl;
189     return(0);
193 // ************************************************************************* //