mixtureAdiabaticFlameT.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Application
25  mixtureAdiabaticFlameT
26 
27 Description
28  Calculates the adiabatic flame temperature for a given mixture
29  at a given temperature.
30 
31 \*---------------------------------------------------------------------------*/
32 
33 #include "argList.H"
34 #include "dictionary.H"
35 #include "IFstream.H"
36 #include "OSspecific.H"
37 #include "etcFiles.H"
38 
39 #include "specie.H"
40 #include "perfectGas.H"
41 #include "thermo.H"
42 #include "janafThermo.H"
43 #include "absoluteEnthalpy.H"
44 #include "mixture.H"
45 
46 using namespace Foam;
47 
49  thermo;
50 
51 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
52 
53 int main(int argc, char *argv[])
54 {
55  #include "removeCaseOptions.H"
56 
57  argList::validArgs.append("properties dictionary");
58  argList args(argc, argv);
59 
60  const fileName propertiesFileName(args[1]);
61 
62  // Construct properties dictionary
63  IFstream propertiesFile(propertiesFileName);
64 
65  // Check propertiesFile stream is OK
66  if (!propertiesFile.good())
67  {
69  << "Cannot read file " << propertiesFileName
70  << abort(FatalError);
71  }
72 
73  dictionary properties(propertiesFile);
74 
75 
76  scalar p(properties.lookup<scalar>("P"));
77  scalar T0(properties.lookup<scalar>("T0"));
78  mixture rMix(properties.lookup("reactants"));
79  mixture pMix(properties.lookup("products"));
80 
81 
82  Info<< nl << "Reading thermodynamic data dictionary" << endl;
83 
84  fileName thermoDataFileName(findEtcFile("thermoData/thermoData"));
85 
86  // Construct properties dictionary
87  IFstream thermoDataFile(thermoDataFileName);
88 
89  // Check thermoData stream is OK
90  if (!thermoDataFile.good())
91  {
93  << "Cannot read file " << thermoDataFileName
94  << abort(FatalError);
95  }
96 
97  dictionary thermoData(thermoDataFile);
98 
99 
100  const thermo reactant0
101  (
102  rMix[0].name(),
103  thermoData.subDict(rMix[0].name())
104  );
105 
106  thermo reactants(rMix[0].volFrac()*reactant0.rho(p, T0)*reactant0);
107 
108  for (label i=1; i<rMix.size(); i++)
109  {
110  const thermo reactanti
111  (
112  rMix[i].name(),
113  thermoData.subDict(rMix[i].name())
114  );
115  reactants += rMix[i].volFrac()*reactanti.rho(p, T0)*reactanti;
116  }
117 
118  const thermo product0
119  (
120  pMix[0].name(),
121  thermoData.subDict(pMix[0].name())
122  );
123  thermo products(pMix[0].volFrac()*product0.rho(p, T0)*product0);
124 
125  for (label i=1; i<pMix.size(); i++)
126  {
127  const thermo producti
128  (
129  pMix[i].name(),
130  thermoData.subDict(pMix[i].name())
131  );
132  products += pMix[i].volFrac()*producti.rho(p, T0)*producti;
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 // ************************************************************************* //
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
Input from file stream.
Definition: IFstream.H:85
Thermodynamics mapping class to expose the absolute enthalpy functions.
Extract command arguments and options from the supplied argc and argv parameters.
Definition: argList.H:103
static SLList< string > validArgs
A list of valid (mandatory) arguments.
Definition: argList.H:153
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:160
A class for handling file names.
Definition: fileName.H:82
Basic thermodynamics type based on the use of fitting functions for cp, h, s obtained from the templa...
Definition: thermo.H:92
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:306
Functions to search 'etc' directories for configuration files etc.
int main(int argc, char *argv[])
Definition: financialFoam.C:44
Namespace for OpenFOAM.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
word name(const bool)
Return a word representation of a bool.
Definition: boolIO.C:39
errorManip< error > abort(error &err)
Definition: errorManip.H:131
messageStream Info
fileName findEtcFile(const fileName &, bool mandatory=false)
Search for a file using findEtcFiles.
Definition: etcFiles.C:252
error FatalError
static const char nl
Definition: Ostream.H:260
Foam::argList args(argc, argv)
volScalarField & p
fluidMulticomponentThermo & thermo
Definition: createFields.H:31
scalar T0
Definition: createFields.H:22