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-------------------------------------------------------------------------------
11License
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
27Application
28 mixtureAdiabaticFlameT
29
30Group
31 grpThermophysicalUtilities
32
33Description
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
52using namespace Foam;
53
55 thermo;
56
57// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
58
59int main(int argc, char *argv[])
60{
61 argList::addNote
62 (
63 "Calculate adiabatic flame temperature for a given mixture"
64 " at a given temperature"
65 );
66
67 argList::noParallel();
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// ************************************************************************* //
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
Input from file stream, using an ISstream.
Definition: IFstream.H:57
Thermodynamics mapping class to expose the absolute enthalpy functions.
Extract command arguments and options from the supplied argc and argv parameters.
Definition: argList.H:124
T get(const label index) const
Get a value from the argument at index.
Definition: argListI.H:278
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
A class for handling file names.
Definition: fileName.H:76
Basic thermodynamics type based on the use of fitting functions for cp, h, s obtained from the templa...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
Functions to search 'etc' directories for configuration files etc.
Namespace for OpenFOAM.
messageStream Info
Information stream (stdout output on master, null elsewhere)
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
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
errorManip< error > abort(error &err)
Definition: errorManip.H:144
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53
Foam::argList args(argc, argv)
scalar T0
Definition: createFields.H:22