FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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-2010 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
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your 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, see <http://www.gnu.org/licenses/>.
00023 
00024 Application
00025     equilibriumFlameT
00026 
00027 Description
00028     Calculates the equilibrium flame temperature.
00029 
00030     Calculates the equilibrium flame temperature for a given fuel and
00031     pressure for a range of unburnt gas temperatures and equivalence
00032     ratios; the effects of dissociation on O2, H2O and CO2 are included.
00033 
00034 Usage
00035 
00036     - equilibriumFlameT [OPTIONS] <controlFile>
00037 
00038     @param <controlFile> \n
00039     @todo Detailed description of argument.
00040 
00041     @param -case <dir>\n
00042     Case directory.
00043 
00044     @param -parallel \n
00045     Run in parallel.
00046 
00047     @param -help \n
00048     Display help message.
00049 
00050     @param -doc \n
00051     Display Doxygen API documentation page for this application.
00052 
00053     @param -srcDoc \n
00054     Display Doxygen source documentation page for this application.
00055 
00056 \*---------------------------------------------------------------------------*/
00057 
00058 #include <OpenFOAM/argList.H>
00059 #include <OpenFOAM/Time.H>
00060 #include <OpenFOAM/dictionary.H>
00061 #include <OpenFOAM/IFstream.H>
00062 #include <OpenFOAM/OSspecific.H>
00063 #include <OpenFOAM/IOmanip.H>
00064 
00065 #include <specie/specieThermo.H>
00066 #include <specie/janafThermo.H>
00067 #include <specie/perfectGas.H>
00068 
00069 using namespace Foam;
00070 
00071 typedef specieThermo<janafThermo<perfectGas> > thermo;
00072 
00073 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00074 
00075 int main(int argc, char *argv[])
00076 {
00077     argList::validArgs.clear();
00078     argList::validArgs.append("controlFile");
00079     argList args(argc, argv);
00080 
00081     fileName controlFileName(args.additionalArgs()[0]);
00082 
00083     // Construct control dictionary
00084     IFstream controlFile(controlFileName);
00085 
00086     // Check controlFile stream is OK
00087     if (!controlFile.good())
00088     {
00089         FatalErrorIn(args.executable())
00090             << "Cannot read file " << controlFileName
00091             << abort(FatalError);
00092     }
00093 
00094     dictionary control(controlFile);
00095 
00096 
00097     scalar P(readScalar(control.lookup("P")));
00098     word fuel(control.lookup("fuel"));
00099     scalar n(readScalar(control.lookup("n")));
00100     scalar m(readScalar(control.lookup("m")));
00101 
00102 
00103     Info<< nl << "Reading Burcat data dictionary" << endl;
00104 
00105     fileName BurcatCpDataFileName(findEtcFile("thermoData/BurcatCpData"));
00106 
00107     // Construct control dictionary
00108     IFstream BurcatCpDataFile(BurcatCpDataFileName);
00109 
00110     // Check BurcatCpData stream is OK
00111     if (!BurcatCpDataFile.good())
00112     {
00113         FatalErrorIn(args.executable())
00114             << "Cannot read file " << BurcatCpDataFileName
00115             << abort(FatalError);
00116     }
00117 
00118     dictionary thermoData(BurcatCpDataFile);
00119 
00120 
00121     Info<< nl << "Reading Burcat data for relevant species" << nl << endl;
00122 
00123     // Reactants
00124     thermo FUEL(thermoData.lookup(fuel));
00125     thermo O2(thermoData.lookup("O2"));
00126     thermo N2(thermoData.lookup("N2"));
00127 
00128     // Products
00129     thermo CO2(thermoData.lookup("CO2"));
00130     thermo H2O(thermoData.lookup("H2O"));
00131 
00132     // Product fragments
00133     thermo CO(thermoData.lookup("CO"));
00134     thermo H2(thermoData.lookup("H2"));
00135 
00136 
00137     // Product dissociation reactions
00138 
00139     thermo CO2BreakUp
00140     (
00141         CO2 == CO + 0.5* O2
00142     );
00143 
00144     thermo H2OBreakUp
00145     (
00146         H2O == H2 + 0.5*O2
00147     );
00148 
00149 
00150     // Stoiciometric number of moles of species for one mole of fuel
00151     scalar stoicO2 = n + m/4.0;
00152     scalar stoicN2 = (0.79/0.21)*(n + m/4.0);
00153     scalar stoicCO2 = n;
00154     scalar stoicH2O = m/2.0;
00155 
00156     // Oxidant
00157     thermo oxidant
00158     (
00159         "oxidant",
00160         stoicO2*O2
00161       + stoicN2*N2
00162     );
00163 
00164     dimensionedScalar stoichiometricAirFuelMassRatio
00165     (
00166         "stoichiometricAirFuelMassRatio",
00167         dimless,
00168         (oxidant.W()*oxidant.nMoles())/FUEL.W()
00169     );
00170 
00171     Info<< "stoichiometricAirFuelMassRatio "
00172         << stoichiometricAirFuelMassRatio << ';' << endl;
00173 
00174     Info<< "Equilibrium flame temperature data ("
00175         << P/1e5 << " bar)" << nl << nl
00176         << setw(3) << "Phi"
00177         << setw(12) << "ft"
00178         << setw(7) << "T0"
00179         << setw(12) << "Tad"
00180         << setw(12) << "Teq"
00181         << setw(12) << "Terror"
00182         << setw(20) << "O2res (mole frac)" << nl
00183         << endl;
00184 
00185 
00186     // Loop over equivalence ratios
00187     for (int i=0; i<16; i++)
00188     {
00189         scalar equiv = 0.6 + i*0.05;
00190         scalar ft = 1/(1 + stoichiometricAirFuelMassRatio.value()/equiv);
00191 
00192     // Loop over initial temperatures
00193     for (int j=0; j<28; j++)
00194     {
00195         scalar T0 = 300.0 + j*100.0;
00196 
00197         // Number of moles of species for one mole of fuel
00198         scalar o2 = (1.0/equiv)*stoicO2;
00199         scalar n2 = (0.79/0.21)*o2;
00200         scalar fres = max(1.0 - 1.0/equiv, 0.0);
00201         scalar fburnt = 1.0 - fres;
00202 
00203         // Initial guess for number of moles of product species
00204         // ignoring product dissociation
00205         scalar oresInit = max(1.0/equiv - 1.0, 0.0)*stoicO2;
00206         scalar co2Init = fburnt*stoicCO2;
00207         scalar h2oInit = fburnt*stoicH2O;
00208 
00209         scalar ores = oresInit;
00210         scalar co2 = co2Init;
00211         scalar h2o = h2oInit;
00212 
00213         scalar co = 0.0;
00214         scalar h2 = 0.0;
00215 
00216         // Total number of moles in system
00217         scalar N = fres + n2 + co2 + h2o + ores;
00218 
00219 
00220         // Initial guess for adiabatic flame temperature
00221         scalar adiabaticFlameTemperature =
00222             T0
00223           + (fburnt/(1.0 + o2 + n2))/(1.0/(1.0 + (1.0 + 0.79/0.21)*stoicO2))
00224            *2000.0;
00225 
00226         scalar equilibriumFlameTemperature = adiabaticFlameTemperature;
00227 
00228 
00229         // Iteration loop for adiabatic flame temperature
00230         for (int j=0; j<20; j++)
00231         {
00232 
00233             if (j > 0)
00234             {
00235                 co = co2*
00236                     min
00237                     (
00238                         CO2BreakUp.Kn(equilibriumFlameTemperature, P, N)
00239                        /::sqrt(max(ores, 0.001)),
00240                         1.0
00241                     );
00242 
00243                 h2 = h2o*
00244                     min
00245                     (
00246                         H2OBreakUp.Kn(equilibriumFlameTemperature, P, N)
00247                        /::sqrt(max(ores, 0.001)),
00248                         1.0
00249                     );
00250 
00251                 co2 = co2Init - co;
00252                 h2o = h2oInit - h2;
00253                 ores = oresInit + 0.5*co + 0.5*h2;
00254             }
00255 
00256             thermo reactants
00257             (
00258                 FUEL + o2*O2 + n2*N2
00259             );
00260 
00261             thermo products
00262             (
00263                 fres*FUEL + ores*O2 + n2*N2
00264               + co2*CO2 + h2o*H2O + co*CO + h2*H2
00265             );
00266 
00267 
00268             scalar equilibriumFlameTemperatureNew =
00269                 products.TH(reactants.H(T0), adiabaticFlameTemperature);
00270 
00271             if (j==0)
00272             {
00273                 adiabaticFlameTemperature = equilibriumFlameTemperatureNew;
00274             }
00275             else
00276             {
00277                 equilibriumFlameTemperature = 0.5*
00278                 (
00279                     equilibriumFlameTemperature
00280                   + equilibriumFlameTemperatureNew
00281                 );
00282             }
00283         }
00284 
00285         Info<< setw(3) << equiv
00286             << setw(12) << ft
00287             << setw(7) << T0
00288             << setw(12) << adiabaticFlameTemperature
00289             << setw(12) << equilibriumFlameTemperature
00290             << setw(12)
00291             << adiabaticFlameTemperature - equilibriumFlameTemperature
00292             << setw(12) << ores/N
00293             << endl;
00294     }
00295     }
00296 
00297     Info<< nl << "end" << endl;
00298 
00299     return 0;
00300 }
00301 
00302 
00303 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines