1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195
|
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Application
adiabaticFlameT
Description
Calculates the adiabatic flame temperature for a given fuel over a
range of unburnt temperatures and equivalence ratios.
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "Time.H"
#include "dictionary.H"
#include "IFstream.H"
#include "OSspecific.H"
#include "etcFiles.H"
#include "specie.H"
#include "perfectGas.H"
#include "thermo.H"
#include "janafThermo.H"
#include "absoluteEnthalpy.H"
using namespace Foam;
typedef species::thermo<janafThermo<perfectGas<specie>>, absoluteEnthalpy>
thermo;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
argList::validArgs.append("controlFile");
argList args(argc, argv);
const fileName controlFileName = args[1];
// Construct control dictionary
IFstream controlFile(controlFileName);
// Check controlFile stream is OK
if (!controlFile.good())
{
FatalErrorInFunction
<< "Cannot read file " << controlFileName
<< exit(FatalError);
}
dictionary control(controlFile);
scalar P(readScalar(control.lookup("P")));
scalar T0(readScalar(control.lookup("T0")));
const word fuelName(control.lookup("fuel"));
scalar n(readScalar(control.lookup("n")));
scalar m(readScalar(control.lookup("m")));
Info<< nl << "Reading thermodynamic data dictionary" << endl;
fileName thermoDataFileName(findEtcFile("thermoData/thermoData"));
// Construct control dictionary
IFstream thermoDataFile(thermoDataFileName);
// Check thermoData stream is OK
if (!thermoDataFile.good())
{
FatalErrorInFunction
<< "Cannot read file " << thermoDataFileName
<< exit(FatalError);
}
dictionary thermoData(thermoDataFile);
scalar stoicO2 = n + m/4.0;
scalar stoicN2 = (0.79/0.21)*(n + m/4.0);
scalar stoicCO2 = n;
scalar stoicH2O = m/2.0;
thermo fuel
(
"fuel",
thermo(thermoData.subDict(fuelName))
);
thermo oxidant
(
"oxidant",
stoicO2*thermo(thermoData.subDict("O2"))
+ stoicN2*thermo(thermoData.subDict("N2"))
);
dimensionedScalar stoichiometricAirFuelMassRatio
(
"stoichiometricAirFuelMassRatio",
dimless,
(oxidant.W()*oxidant.nMoles())/fuel.W()
);
Info<< "stoichiometricAirFuelMassRatio "
<< stoichiometricAirFuelMassRatio << ';' << endl;
for (int i=0; i<300; i++)
{
scalar equiv = (i + 1)*0.01;
scalar ft = 1/(1 + stoichiometricAirFuelMassRatio.value()/equiv);
Info<< "phi = " << equiv << nl
<< "ft = " << ft << endl;
scalar o2 = (1.0/equiv)*stoicO2;
scalar n2 = (0.79/0.21)*o2;
scalar fres = max(1.0 - 1.0/equiv, 0.0);
scalar ores = max(1.0/equiv - 1.0, 0.0);
scalar fburnt = 1.0 - fres;
thermo fuel
(
"fuel",
thermo(thermoData.subDict(fuelName))
);
Info<< "fuel " << fuel << ';' << endl;
thermo oxidant
(
"oxidant",
o2*thermo(thermoData.subDict("O2"))
+ n2*thermo(thermoData.subDict("N2"))
);
Info<< "oxidant " << (1/oxidant.nMoles())*oxidant << ';' << endl;
thermo reactants
(
"reactants",
fuel + oxidant
);
Info<< "reactants " << (1/reactants.nMoles())*reactants << ';' << endl;
thermo burntProducts
(
"burntProducts",
+ (n2 - (0.79/0.21)*ores*stoicO2)*thermo(thermoData.subDict("N2"))
+ fburnt*stoicCO2*thermo(thermoData.subDict("CO2"))
+ fburnt*stoicH2O*thermo(thermoData.subDict("H2O"))
);
Info<< "burntProducts "
<< (1/burntProducts.nMoles())*burntProducts << ';' << endl;
thermo products
(
"products",
fres*fuel
+ n2*thermo(thermoData.subDict("N2"))
+ fburnt*stoicCO2*thermo(thermoData.subDict("CO2"))
+ fburnt*stoicH2O*thermo(thermoData.subDict("H2O"))
+ ores*stoicO2*thermo(thermoData.subDict("O2"))
);
Info<< "products " << (1/products.nMoles())*products << ';' << endl;
scalar Tad = products.THa(reactants.Ha(P, T0), P, 1000.0);
Info<< "Tad = " << Tad << nl << endl;
}
Info<< nl << "end" << endl;
return 0;
}
// ************************************************************************* //
|