mixtureAdiabaticFlameT.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Application
27  mixtureAdiabaticFlameT
28 
29 Group
30  grpThermophysicalUtilities
31 
32 Description
33  Calculate adiabatic flame temperature for a given mixture
34  at a given temperature.
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #include "argList.H"
39 #include "dictionary.H"
40 #include "IFstream.H"
41 #include "OSspecific.H"
42 #include "etcFiles.H"
43 
44 #include "specie.H"
45 #include "perfectGas.H"
46 #include "thermo.H"
47 #include "janafThermo.H"
48 #include "absoluteEnthalpy.H"
49 #include "mixture.H"
50 
51 using namespace Foam;
52 
54  thermo;
55 
56 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
57 
58 int main(int argc, char *argv[])
59 {
61  (
62  "Calculate adiabatic flame temperature for a given mixture"
63  " at a given temperature"
64  );
65 
67  argList::noFunctionObjects(); // Never use function objects
68  argList::addArgument("controlFile");
69 
70  argList args(argc, argv);
71 
72  const fileName controlFileName(args[1]);
73 
74  // Construct control dictionary
75  IFstream controlFile(controlFileName);
76 
77  // Check controlFile stream is OK
78  if (!controlFile.good())
79  {
81  << "Cannot read file " << controlFileName
82  << abort(FatalError);
83  }
84 
85  dictionary control(controlFile);
86 
87 
88  const scalar P(control.get<scalar>("P"));
89  const scalar T0(control.get<scalar>("T0"));
90  mixture rMix(control.lookup("reactants"));
91  mixture pMix(control.lookup("products"));
92 
93 
94  Info<< nl << "Reading thermodynamic data dictionary" << endl;
95 
96  fileName thermoDataFileName(findEtcFile("thermoData/thermoData"));
97 
98  // Construct control dictionary
99  IFstream thermoDataFile(thermoDataFileName);
100 
101  // Check thermoData stream is OK
102  if (!thermoDataFile.good())
103  {
105  << "Cannot read file " << thermoDataFileName
106  << abort(FatalError);
107  }
108 
109  dictionary thermoData(thermoDataFile);
110 
111 
112  thermo reactants
113  (
114  rMix[0].volFrac()*thermo(thermoData.subDict(rMix[0].name()))
115  );
116 
117  for (label i = 1; i < rMix.size(); i++)
118  {
119  reactants = reactants
120  + rMix[i].volFrac()*thermo(thermoData.subDict(rMix[i].name()));
121  }
122 
123 
124  thermo products
125  (
126  2*pMix[0].volFrac()*thermo(thermoData.subDict(pMix[0].name()))
127  );
128 
129  for (label i = 1; i < pMix.size(); i++)
130  {
131  products = products
132  + 2*pMix[i].volFrac()*thermo(thermoData.subDict(pMix[i].name()));
133  }
134 
135  Info<< "Adiabatic flame temperature of mixture " << rMix.name() << " = "
136  << products.THa(reactants.Ha(P, T0), P, 1000.0) << " K" << endl;
137 
138  return 0;
139 }
140 
141 
142 // ************************************************************************* //
OSspecific.H
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
Foam::fileName
A class for handling file names.
Definition: fileName.H:69
Foam::IFstream
Input from file stream, using an ISstream.
Definition: IFstream.H:85
thermo
psiReactionThermo & thermo
Definition: createFields.H:28
Foam::absoluteEnthalpy
Thermodynamics mapping class to expose the absolute enthalpy functions.
Definition: absoluteEnthalpy.H:49
Foam::argList::addNote
static void addNote(const string &note)
Add extra notes for the usage information.
Definition: argList.C:413
thermo
Basic thermodynamics type based on the use of fitting functions for cp, h, s obtained from the templa...
Foam::argList
Extract command arguments and options from the supplied argc and argv parameters.
Definition: argList.H:123
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:350
specie.H
Foam::argList::addArgument
static void addArgument(const string &argName, const string &usage="")
Append a (mandatory) argument to validArgs.
Definition: argList.C:302
Foam::argList::noFunctionObjects
static void noFunctionObjects(bool addWithOption=false)
Remove '-noFunctionObjects' option and ignore any occurrences.
Definition: argList.C:454
Foam::findEtcFile
fileName findEtcFile(const fileName &name, const bool mandatory=false, unsigned short location=0777)
Search for a single FILE within the etc directories.
Definition: etcFiles.C:446
Foam::Info
messageStream Info
Information stream (uses stdout - output is on the master only)
janafThermo.H
argList.H
IFstream.H
perfectGas.H
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:137
Foam::species::thermo
Definition: thermo.H:54
mixture.H
etcFiles.H
Functions to search 'etc' directories for configuration files etc.
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:372
Foam::nl
constexpr char nl
Definition: Ostream.H:385
dictionary.H
Foam::argList::noParallel
static void noParallel()
Remove the parallel options.
Definition: argList.C:491
args
Foam::argList args(argc, argv)
T0
scalar T0
Definition: createFields.H:22
absoluteEnthalpy.H
Foam::mixture
Definition: mixture.H:54