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

adiabaticFlameT.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 adiabatic flame temperature for a given fuel over a
00030     range of unburnt temperatures and equivalence ratios.
00031 
00032 \*---------------------------------------------------------------------------*/
00033 
00034 #include "argList.H"
00035 #include "Time.H"
00036 #include "dictionary.H"
00037 #include "IFstream.H"
00038 #include "OSspecific.H"
00039 
00040 #include "specieThermo.H"
00041 #include "janafThermo.H"
00042 #include "perfectGas.H"
00043 
00044 using namespace Foam;
00045 
00046 typedef specieThermo<janafThermo<perfectGas> > thermo;
00047 
00048 
00049 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00050 
00051 int main(int argc, char *argv[])
00052 {
00053     argList::validArgs.clear();
00054     argList::validArgs.append("controlFile");
00055     argList args(argc, argv);
00056 
00057     fileName controlFileName(args.additionalArgs()[0]);
00058 
00059     // Construct control dictionary
00060     IFstream controlFile(controlFileName);
00061 
00062     // Check controlFile stream is OK
00063     if (!controlFile.good())
00064     {
00065         FatalErrorIn(args.executable())
00066             << "Cannot read file " << controlFileName
00067             << exit(FatalError);
00068     }
00069 
00070     dictionary control(controlFile);
00071 
00072 
00073     scalar T0(readScalar(control.lookup("T0")));
00074     word fuelName(control.lookup("fuel"));
00075     scalar n(readScalar(control.lookup("n")));
00076     scalar m(readScalar(control.lookup("m")));
00077 
00078 
00079     Info<< nl << "Reading Burcat data dictionary" << endl;
00080 
00081     fileName BurcatCpDataFileName(findEtcFile("thermoData/BurcatCpData"));
00082 
00083     // Construct control dictionary
00084     IFstream BurcatCpDataFile(BurcatCpDataFileName);
00085 
00086     // Check BurcatCpData stream is OK
00087     if (!BurcatCpDataFile.good())
00088     {
00089         FatalErrorIn(args.executable())
00090             << "Cannot read file " << BurcatCpDataFileName
00091             << exit(FatalError);
00092     }
00093 
00094     dictionary CpData(BurcatCpDataFile);
00095 
00096 
00097     scalar stoicO2 = n + m/4.0;
00098     scalar stoicN2 = (0.79/0.21)*(n + m/4.0);
00099     scalar stoicCO2 = n;
00100     scalar stoicH2O = m/2.0;
00101 
00102     thermo fuel
00103     (
00104         "fuel",
00105         thermo(CpData.lookup(fuelName))
00106     );
00107 
00108     thermo oxidant
00109     (
00110         "oxidant",
00111         stoicO2*thermo(CpData.lookup("O2"))
00112       + stoicN2*thermo(CpData.lookup("N2"))
00113     );
00114 
00115     dimensionedScalar stoichiometricAirFuelMassRatio
00116     (
00117         "stoichiometricAirFuelMassRatio",
00118         dimless,
00119         (oxidant.W()*oxidant.nMoles())/fuel.W()
00120     );
00121 
00122     Info<< "stoichiometricAirFuelMassRatio "
00123         << stoichiometricAirFuelMassRatio << ';' << endl;
00124 
00125     for (int i=0; i<300; i++)
00126     {
00127         scalar equiv = (i + 1)*0.01;
00128         scalar ft = 1/(1 + stoichiometricAirFuelMassRatio.value()/equiv);
00129 
00130         Info<< "phi = " << equiv << nl
00131             << "ft = " << ft << endl;
00132 
00133         scalar o2 = (1.0/equiv)*stoicO2;
00134         scalar n2 = (0.79/0.21)*o2;
00135         scalar fres = max(1.0 - 1.0/equiv, 0.0);
00136         scalar ores = max(1.0/equiv - 1.0, 0.0);
00137         scalar fburnt = 1.0 - fres;
00138 
00139         thermo fuel
00140         (
00141             "fuel",
00142             thermo(CpData.lookup(fuelName))
00143         );
00144         Info<< "fuel " << fuel << ';' << endl;
00145 
00146         thermo oxidant
00147         (
00148             "oxidant",
00149             o2*thermo(CpData.lookup("O2"))
00150           + n2*thermo(CpData.lookup("N2"))
00151         );
00152         Info<< "oxidant " << (1/oxidant.nMoles())*oxidant << ';' << endl;
00153 
00154         thermo reactants
00155         (
00156             "reactants",
00157             fuel + oxidant
00158         );
00159         Info<< "reactants " << (1/reactants.nMoles())*reactants << ';' << endl;
00160 
00161         thermo burntProducts
00162         (
00163             "burntProducts",
00164           + (n2 - (0.79/0.21)*ores*stoicO2)*thermo(CpData.lookup("N2"))
00165           + fburnt*stoicCO2*thermo(CpData.lookup("CO2"))
00166           + fburnt*stoicH2O*thermo(CpData.lookup("H2O"))
00167         );
00168         Info<< "burntProducts "
00169             << (1/burntProducts.nMoles())*burntProducts << ';' << endl;
00170 
00171         thermo products
00172         (
00173             "products",
00174             fres*fuel
00175           + n2*thermo(CpData.lookup("N2"))
00176           + fburnt*stoicCO2*thermo(CpData.lookup("CO2"))
00177           + fburnt*stoicH2O*thermo(CpData.lookup("H2O"))
00178           + ores*stoicO2*thermo(CpData.lookup("O2"))
00179         );
00180 
00181         Info<< "products " << (1/products.nMoles())*products << ';' << endl;
00182 
00183         scalar Tad = products.TH(reactants.H(T0), 1000.0);
00184         Info<< "Tad = " << Tad << nl << endl;
00185     }
00186 
00187     Info<< nl << "end" << endl;
00188 
00189     return 0;
00190 }
00191 
00192 
00193 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd