OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

equilibriumFlameT.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Application
00026     adiabaticFlameT
00027 
00028 Description
00029     Calculates the equilibrium flame temperature for a given fuel and
00030     pressure for a range of unburnt gas temperatures and equivalence
00031     ratios; the effects of dissociation on O2, H2O and CO2 are included.
00032 
00033 \*---------------------------------------------------------------------------*/
00034 
00035 #include "argList.H"
00036 #include "Time.H"
00037 #include "dictionary.H"
00038 #include "IFstream.H"
00039 #include "OSspecific.H"
00040 #include "IOmanip.H"
00041 
00042 #include "specieThermo.H"
00043 #include "janafThermo.H"
00044 #include "perfectGas.H"
00045 
00046 using namespace Foam;
00047 
00048 typedef specieThermo<janafThermo<perfectGas> > thermo;
00049 
00050 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00051 
00052 int main(int argc, char *argv[])
00053 {
00054     argList::validArgs.clear();
00055     argList::validArgs.append("controlFile");
00056     argList args(argc, argv);
00057 
00058     fileName controlFileName(args.additionalArgs()[0]);
00059 
00060     // Construct control dictionary
00061     IFstream controlFile(controlFileName);
00062 
00063     // Check controlFile stream is OK
00064     if (!controlFile.good())
00065     {
00066         FatalErrorIn(args.executable())
00067             << "Cannot read file " << controlFileName
00068             << abort(FatalError);
00069     }
00070 
00071     dictionary control(controlFile);
00072 
00073 
00074     scalar P(readScalar(control.lookup("P")));
00075     word fuel(control.lookup("fuel"));
00076     scalar n(readScalar(control.lookup("n")));
00077     scalar m(readScalar(control.lookup("m")));
00078 
00079 
00080     Info<< nl << "Reading Burcat data dictionary" << endl;
00081 
00082     fileName BurcatCpDataFileName(findEtcFile("thermoData/BurcatCpData"));
00083 
00084     // Construct control dictionary
00085     IFstream BurcatCpDataFile(BurcatCpDataFileName);
00086 
00087     // Check BurcatCpData stream is OK
00088     if (!BurcatCpDataFile.good())
00089     {
00090         FatalErrorIn(args.executable())
00091             << "Cannot read file " << BurcatCpDataFileName
00092             << abort(FatalError);
00093     }
00094 
00095     dictionary thermoData(BurcatCpDataFile);
00096 
00097 
00098     Info<< nl << "Reading Burcat data for relevant species" << nl << endl;
00099 
00100     // Reactants
00101     thermo FUEL(thermoData.lookup(fuel));
00102     thermo O2(thermoData.lookup("O2"));
00103     thermo N2(thermoData.lookup("N2"));
00104 
00105     // Products
00106     thermo CO2(thermoData.lookup("CO2"));
00107     thermo H2O(thermoData.lookup("H2O"));
00108 
00109     // Product fragments
00110     thermo CO(thermoData.lookup("CO"));
00111     thermo H2(thermoData.lookup("H2"));
00112 
00113 
00114     // Product dissociation reactions
00115 
00116     thermo CO2BreakUp
00117     (
00118         CO2 == CO + 0.5* O2
00119     );
00120 
00121     thermo H2OBreakUp
00122     (
00123         H2O == H2 + 0.5*O2
00124     );
00125 
00126 
00127     // Stoiciometric number of moles of species for one mole of fuel
00128     scalar stoicO2 = n + m/4.0;
00129     scalar stoicN2 = (0.79/0.21)*(n + m/4.0);
00130     scalar stoicCO2 = n;
00131     scalar stoicH2O = m/2.0;
00132 
00133     // Oxidant
00134     thermo oxidant
00135     (
00136         "oxidant",
00137         stoicO2*O2
00138       + stoicN2*N2
00139     );
00140 
00141     dimensionedScalar stoichiometricAirFuelMassRatio
00142     (
00143         "stoichiometricAirFuelMassRatio",
00144         dimless,
00145         (oxidant.W()*oxidant.nMoles())/FUEL.W()
00146     );
00147 
00148     Info<< "stoichiometricAirFuelMassRatio "
00149         << stoichiometricAirFuelMassRatio << ';' << endl;
00150 
00151     Info<< "Equilibrium flame temperature data ("
00152         << P/1e5 << " bar)" << nl << nl
00153         << setw(3) << "Phi"
00154         << setw(12) << "ft"
00155         << setw(7) << "T0"
00156         << setw(12) << "Tad"
00157         << setw(12) << "Teq"
00158         << setw(12) << "Terror"
00159         << setw(20) << "O2res (mole frac)" << nl
00160         << endl;
00161 
00162 
00163     // Loop over equivalence ratios
00164     for (int i=0; i<16; i++)
00165     {
00166         scalar equiv = 0.6 + i*0.05;
00167         scalar ft = 1/(1 + stoichiometricAirFuelMassRatio.value()/equiv);
00168 
00169     // Loop over initial temperatures
00170     for (int j=0; j<28; j++)
00171     {
00172         scalar T0 = 300.0 + j*100.0;
00173 
00174         // Number of moles of species for one mole of fuel
00175         scalar o2 = (1.0/equiv)*stoicO2;
00176         scalar n2 = (0.79/0.21)*o2;
00177         scalar fres = max(1.0 - 1.0/equiv, 0.0);
00178         scalar fburnt = 1.0 - fres;
00179 
00180         // Initial guess for number of moles of product species
00181         // ignoring product dissociation
00182         scalar oresInit = max(1.0/equiv - 1.0, 0.0)*stoicO2;
00183         scalar co2Init = fburnt*stoicCO2;
00184         scalar h2oInit = fburnt*stoicH2O;
00185 
00186         scalar ores = oresInit;
00187         scalar co2 = co2Init;
00188         scalar h2o = h2oInit;
00189 
00190         scalar co = 0.0;
00191         scalar h2 = 0.0;
00192 
00193         // Total number of moles in system
00194         scalar N = fres + n2 + co2 + h2o + ores;
00195 
00196 
00197         // Initial guess for adiabatic flame temperature
00198         scalar adiabaticFlameTemperature =
00199             T0
00200           + (fburnt/(1.0 + o2 + n2))/(1.0/(1.0 + (1.0 + 0.79/0.21)*stoicO2))
00201            *2000.0;
00202 
00203         scalar equilibriumFlameTemperature = adiabaticFlameTemperature;
00204 
00205 
00206         // Iteration loop for adiabatic flame temperature
00207         for (int j=0; j<20; j++)
00208         {
00209 
00210             if (j > 0)
00211             {
00212                 co = co2*
00213                     min
00214                     (
00215                         CO2BreakUp.Kn(equilibriumFlameTemperature, P, N)
00216                        /::sqrt(max(ores, 0.001)),
00217                         1.0
00218                     );
00219 
00220                 h2 = h2o*
00221                     min
00222                     (
00223                         H2OBreakUp.Kn(equilibriumFlameTemperature, P, N)
00224                        /::sqrt(max(ores, 0.001)),
00225                         1.0
00226                     );
00227 
00228                 co2 = co2Init - co;
00229                 h2o = h2oInit - h2;
00230                 ores = oresInit + 0.5*co + 0.5*h2;
00231             }
00232 
00233             thermo reactants
00234             (
00235                 FUEL + o2*O2 + n2*N2
00236             );
00237 
00238             thermo products
00239             (
00240                 fres*FUEL + ores*O2 + n2*N2
00241               + co2*CO2 + h2o*H2O + co*CO + h2*H2
00242             );
00243 
00244 
00245             scalar equilibriumFlameTemperatureNew =
00246                 products.TH(reactants.H(T0), adiabaticFlameTemperature);
00247 
00248             if (j==0)
00249             {
00250                 adiabaticFlameTemperature = equilibriumFlameTemperatureNew;
00251             }
00252             else
00253             {
00254                 equilibriumFlameTemperature = 0.5*
00255                 (
00256                     equilibriumFlameTemperature
00257                   + equilibriumFlameTemperatureNew
00258                 );
00259             }
00260         }
00261 
00262         Info<< setw(3) << equiv
00263             << setw(12) << ft
00264             << setw(7) << T0
00265             << setw(12) << adiabaticFlameTemperature
00266             << setw(12) << equilibriumFlameTemperature
00267             << setw(12)
00268             << adiabaticFlameTemperature - equilibriumFlameTemperature
00269             << setw(12) << ores/N
00270             << endl;
00271     }
00272     }
00273 
00274     Info<< nl << "end" << endl;
00275 
00276     return 0;
00277 }
00278 
00279 
00280 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd