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  Copyright (C) 2021 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Application
28  mixtureAdiabaticFlameT
29 
30 Group
31  grpThermophysicalUtilities
32 
33 Description
34  Calculate adiabatic flame temperature for a given mixture
35  at a given temperature.
36 
37 \*---------------------------------------------------------------------------*/
38 
39 #include "argList.H"
40 #include "dictionary.H"
41 #include "IFstream.H"
42 #include "OSspecific.H"
43 #include "etcFiles.H"
44 
45 #include "specie.H"
46 #include "perfectGas.H"
47 #include "thermo.H"
48 #include "janafThermo.H"
49 #include "absoluteEnthalpy.H"
50 #include "mixture.H"
51 
52 using namespace Foam;
53 
55  thermo;
56 
57 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
58 
59 int main(int argc, char *argv[])
60 {
62  (
63  "Calculate adiabatic flame temperature for a given mixture"
64  " at a given temperature"
65  );
66 
68  argList::noFunctionObjects(); // Never use function objects
69  argList::addArgument("controlFile");
70 
71  argList args(argc, argv);
72 
73  const auto controlFileName = args.get<fileName>(1);
74 
75  // Construct control dictionary
76  IFstream controlFile(controlFileName);
77 
78  // Check controlFile stream is OK
79  if (!controlFile.good())
80  {
82  << "Cannot read file " << controlFileName
83  << abort(FatalError);
84  }
85 
86  dictionary control(controlFile);
87 
88 
89  const scalar P(control.get<scalar>("P"));
90  const scalar T0(control.get<scalar>("T0"));
91  mixture rMix(control.lookup("reactants"));
92  mixture pMix(control.lookup("products"));
93 
94 
95  Info<< nl << "Reading thermodynamic data dictionary" << endl;
96 
97  fileName thermoDataFileName(findEtcFile("thermoData/thermoData"));
98 
99  // Construct control dictionary
100  IFstream thermoDataFile(thermoDataFileName);
101 
102  // Check thermoData stream is OK
103  if (!thermoDataFile.good())
104  {
106  << "Cannot read file " << thermoDataFileName
107  << abort(FatalError);
108  }
109 
110  dictionary thermoData(thermoDataFile);
111 
112 
113  thermo reactants
114  (
115  rMix[0].volFrac()*thermo(thermoData.subDict(rMix[0].name()))
116  );
117 
118  for (label i = 1; i < rMix.size(); i++)
119  {
120  reactants = reactants
121  + rMix[i].volFrac()*thermo(thermoData.subDict(rMix[i].name()));
122  }
123 
124 
125  thermo products
126  (
127  2*pMix[0].volFrac()*thermo(thermoData.subDict(pMix[0].name()))
128  );
129 
130  for (label i = 1; i < pMix.size(); i++)
131  {
132  products = products
133  + 2*pMix[i].volFrac()*thermo(thermoData.subDict(pMix[i].name()));
134  }
135 
136  Info<< "Adiabatic flame temperature of mixture " << rMix.name() << " = "
137  << products.THa(reactants.Ha(P, T0), P, 1000.0) << " K" << endl;
138 
139  return 0;
140 }
141 
142 
143 // ************************************************************************* //
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:73
Foam::IFstream
Input from file stream, using an ISstream.
Definition: IFstream.H:53
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:412
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:369
specie.H
Foam::argList::get
T get(const label index) const
Get a value from the argument at index.
Definition: argListI.H:278
Foam::argList::addArgument
static void addArgument(const string &argName, const string &usage="")
Append a (mandatory) argument to validArgs.
Definition: argList.C:301
Foam::argList::noFunctionObjects
static void noFunctionObjects(bool addWithOption=false)
Remove '-noFunctionObjects' option and ignore any occurrences.
Definition: argList.C:473
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 (stdout output on master, null elsewhere)
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:123
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:144
Foam::species::thermo
Definition: thermo.H:55
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:453
Foam::nl
constexpr char nl
Definition: Ostream.H:404
dictionary.H
Foam::argList::noParallel
static void noParallel()
Remove the parallel options.
Definition: argList.C:510
args
Foam::argList args(argc, argv)
T0
scalar T0
Definition: createFields.H:22
absoluteEnthalpy.H
Foam::mixture
Definition: mixture.H:54