/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 4.0
\\ / A nd | Web: http://www.foam-extend.org
\\/ M anipulation | For copyright notice see file Copyright
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see .
Application
IFC (infinitely-fast chemistry) look-up table generator
Description
Calculate the the infinitely-fast chemistry relationships in function of ft.
for a given fuel.
The output is given in moles.
i.e. dictionary:
fileName "SpeciesTable";
fuel CH4(ANHARMONIC);
n 1;
m 4;
fields
(
{
name ft;
min 0.;
max 1.;
N 100;
}
);
output
(
{
name CH4;
}
{
name CO2;
}
{
name H2O;
}
);
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "IFstream.H"
#include "OFstream.H"
#include "specieThermo.H"
#include "janafThermo.H"
#include "perfectGas.H"
#include "IOdictionary.H"
#include "interpolationLookUpTable.H"
using namespace Foam;
typedef specieThermo > thermo;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
argList::validArgs.clear();
argList::validArgs.append("controlFile");
argList args(argc, argv);
fileName controlFileName(args.additionalArgs()[0]);
enum varinput
{
fti,
CH4i,
CO2i,
H2Oi
};
// Construct control dictionary
IFstream controlFile(controlFileName);
// Check controlFile stream is OK
if (!controlFile.good())
{
FatalErrorIn(args.executable())
<< "Cannot read file " << controlFileName
<< exit(FatalError);
}
dictionary control(controlFile);
// fuel-air mix
fileName BurcatCpDataFileName(findEtcFile("thermoData/BurcatCpData"));
// Construct control dictionary
IFstream BurcatCpDataFile(BurcatCpDataFileName);
// Check BurcatCpData stream is OK
if (!BurcatCpDataFile.good())
{
FatalErrorIn(args.executable())
<< "Cannot read file " << BurcatCpDataFileName
<< exit(FatalError);
}
dictionary CpData(BurcatCpDataFile);
word fuelName(control.lookup("fuel"));
scalar n(readScalar(control.lookup("n")));
scalar m(readScalar(control.lookup("m")));
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(CpData.lookup(fuelName))
);
thermo oxidant
(
"oxidant",
stoicO2*thermo(CpData.lookup("O2"))
+ stoicN2*thermo(CpData.lookup("N2"))
);
dimensionedScalar stoicRatio
(
"stoichiometricAirFuelMassRatio",
dimless,
(oxidant.W()*oxidant.nMoles())/(fuel.W()*fuel.nMoles())
);
// Open File for Look Up Table
fileName LookUpTableFile(control.lookup("fileName"));
OFstream controlFileOutput(LookUpTableFile);
if (!controlFileOutput.good())
{
FatalErrorIn(args.executable())
<< "Cannot open file " << LookUpTableFile
<< exit(FatalError);
}
// Create Look Up Table
interpolationLookUpTable LookUpTable(control);
const List