Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086 #include <OpenFOAM/argList.H>
00087
00088 #include <OpenFOAM/IFstream.H>
00089 #include <OpenFOAM/OFstream.H>
00090
00091 #include <specie/specieThermo.H>
00092 #include <specie/janafThermo.H>
00093 #include <specie/perfectGas.H>
00094
00095 #include <OpenFOAM/IOdictionary.H>
00096
00097 #include <radiation/interpolationLookUpTable.H>
00098
00099 using namespace Foam;
00100
00101 typedef specieThermo<janafThermo<perfectGas> > thermo;
00102
00103
00104
00105 int main(int argc, char *argv[])
00106 {
00107 argList::validArgs.clear();
00108 argList::validArgs.append("controlFile");
00109 argList args(argc, argv);
00110
00111 fileName controlFileName(args.additionalArgs()[0]);
00112
00113 enum varinput
00114 {
00115 fti,
00116 CH4i,
00117 CO2i,
00118 H2Oi
00119 };
00120
00121
00122 IFstream controlFile(controlFileName);
00123
00124
00125 if (!controlFile.good())
00126 {
00127 FatalErrorIn(args.executable())
00128 << "Cannot read file " << controlFileName
00129 << exit(FatalError);
00130 }
00131
00132 dictionary control(controlFile);
00133
00134
00135 fileName BurcatCpDataFileName(findEtcFile("thermoData/BurcatCpData"));
00136
00137
00138 IFstream BurcatCpDataFile(BurcatCpDataFileName);
00139
00140
00141 if (!BurcatCpDataFile.good())
00142 {
00143 FatalErrorIn(args.executable())
00144 << "Cannot read file " << BurcatCpDataFileName
00145 << exit(FatalError);
00146 }
00147
00148 dictionary CpData(BurcatCpDataFile);
00149
00150 word fuelName(control.lookup("fuel"));
00151 scalar n(readScalar(control.lookup("n")));
00152 scalar m(readScalar(control.lookup("m")));
00153
00154 scalar stoicO2 = n + m/4.0;
00155 scalar stoicN2 = (0.79/0.21)*(n + m/4.0);
00156 scalar stoicCO2 = n;
00157 scalar stoicH2O = m/2.0;
00158
00159 thermo fuel
00160 (
00161 "fuel",
00162 thermo(CpData.lookup(fuelName))
00163 );
00164
00165 thermo oxidant
00166 (
00167 "oxidant",
00168 stoicO2*thermo(CpData.lookup("O2"))
00169 + stoicN2*thermo(CpData.lookup("N2"))
00170 );
00171
00172 dimensionedScalar stoicRatio
00173 (
00174 "stoichiometricAirFuelMassRatio",
00175 dimless,
00176 (oxidant.W()*oxidant.nMoles())/(fuel.W()*fuel.nMoles())
00177 );
00178
00179
00180
00181 fileName LookUpTableFile(control.lookup("fileName"));
00182
00183 OFstream controlFileOutput(LookUpTableFile);
00184
00185 if (!controlFileOutput.good())
00186 {
00187 FatalErrorIn(args.executable())
00188 << "Cannot open file " << LookUpTableFile
00189 << exit(FatalError);
00190 }
00191
00192
00193 interpolationLookUpTable<scalar> LookUpTable(control);
00194
00195 const List<label>& dim = LookUpTable.dim();
00196
00197 const List<scalar>& min = LookUpTable.min();
00198
00199 const List<scalar>& delta = LookUpTable.delta();
00200
00201 label count = 0;
00202
00203 for (label i=0; i <= dim[fti]; i++)
00204 {
00205 scalar ft = Foam::min(scalar(i)*delta[fti] + min[fti] + 0.001, 0.999);
00206
00207 scalar equiv = Foam::pow(((1.0 / ft) - 1.0), -1.0)*stoicRatio.value();
00208
00209 scalar o2 = (1.0/equiv)*stoicO2;
00210 scalar n2 = (0.79/0.21)*o2;
00211 scalar fres = max(1.0 - 1.0/equiv, 0.0);
00212 scalar ores = max(1.0/equiv - 1.0, 0.0);
00213 scalar fburnt = 1.0 - fres;
00214
00215
00216 thermo fuel
00217 (
00218 "fuel",
00219 fres*thermo(CpData.lookup(fuelName))
00220 );
00221
00222 thermo N2
00223 (
00224 "N2",
00225 n2*thermo(CpData.lookup("N2"))
00226 );
00227
00228 thermo O2
00229 (
00230 "O2",
00231 ores*thermo(CpData.lookup("O2"))
00232 );
00233
00234 thermo CO2
00235 (
00236 "CO2",
00237 fburnt*stoicCO2*thermo(CpData.lookup("CO2"))
00238 );
00239
00240 thermo H2O
00241 (
00242 "H2O",
00243 fburnt*stoicH2O*thermo(CpData.lookup("H2O"))
00244 );
00245
00246
00247 scalar ToTalMoles = fuel.nMoles() + CO2.nMoles() + H2O.nMoles() +
00248 N2.nMoles() + O2.nMoles();
00249
00250 LookUpTable[fti][count] = ft;
00251 LookUpTable[CH4i][count] = fuel.nMoles()/ToTalMoles;
00252 LookUpTable[CO2i][count] = CO2.nMoles()/ToTalMoles;
00253 LookUpTable[H2Oi][count] = H2O.nMoles()/ToTalMoles;
00254 count++;
00255 }
00256
00257 IOobject::writeBanner(controlFileOutput);
00258 controlFileOutput << "\n" << nl;
00259 controlFileOutput.writeKeyword("fields");
00260 controlFileOutput << LookUpTable.entries() << token::END_STATEMENT << nl;
00261
00262 controlFileOutput.writeKeyword("output");
00263 controlFileOutput << LookUpTable.output() << token::END_STATEMENT << nl;
00264
00265 if (LookUpTable.size() == 0)
00266 {
00267 FatalErrorIn
00268 (
00269 "Foam::IFCLookUpTableGen"
00270 ) << "table is empty" << nl
00271 << exit(FatalError);
00272 }
00273
00274 controlFileOutput.writeKeyword("values");
00275 controlFileOutput << LookUpTable << token::END_STATEMENT << nl;
00276
00277 return(0);
00278 }
00279
00280
00281