mixtureFraction.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) 2013-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 \*---------------------------------------------------------------------------*/
25 
26 #include "mixtureFraction.H"
27 #include "singleStepCombustion.H"
29 
30 
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35 namespace radiationModels
36 {
37 namespace sootModels
38 {
40 
42  (
43  sootModel,
46  );
47 }
48 }
49 }
50 
51 
52 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
53 
55 (
56  const dictionary& dict,
57  const fvMesh& mesh,
58  const word& modelType
59 )
60 :
61  sootModel(dict, mesh, modelType),
62  soot_
63  (
64  IOobject
65  (
66  "soot",
67  mesh_.time().name(),
68  mesh_,
69  IOobject::MUST_READ,
70  IOobject::AUTO_WRITE
71  ),
72  mesh_
73  ),
74  coeffsDict_(dict.subOrEmptyDict(modelType + "Coeffs")),
75  nuSoot_(coeffsDict_.lookup<scalar>("nuSoot")),
76  Wsoot_(coeffsDict_.lookup<scalar>("Wsoot")),
77  sootMax_(-1),
78  mappingFieldName_
79  (
80  coeffsDict_.lookupOrDefault<word>("mappingField", "none")
81  ),
82  mapFieldMax_(1)
83 {
84  const combustionModels::singleStepCombustion& combustion =
86  (
88  );
89 
90  const reaction& singleReaction = combustion.singleReaction();
91 
92  scalar totalMol = 0;
93  forAll(singleReaction.rhs(), i)
94  {
95  const scalar stoichCoeff = singleReaction.rhs()[i].stoichCoeff;
96  totalMol += mag(stoichCoeff);
97  }
98 
99  totalMol += nuSoot_;
100 
101  scalarList Xi(singleReaction.rhs().size());
102 
103  scalar Wm = 0;
104  forAll(singleReaction.rhs(), i)
105  {
106  const label speciei = singleReaction.rhs()[i].index;
107  const scalar stoichCoeff = singleReaction.rhs()[i].stoichCoeff;
108  Xi[i] = mag(stoichCoeff)/totalMol;
109  Wm += Xi[i]*combustion.thermo().WiValue(speciei);
110  }
111 
112  scalarList Yprod0(combustion.thermo().species().size(), 0.0);
113 
114  forAll(singleReaction.rhs(), i)
115  {
116  const label speciei = singleReaction.rhs()[i].index;
117  Yprod0[speciei] = combustion.thermo().WiValue(speciei)/Wm*Xi[i];
118  }
119 
120  const scalar XSoot = nuSoot_/totalMol;
121  Wm += XSoot*Wsoot_;
122 
123  sootMax_ = XSoot*Wsoot_/Wm;
124 
125  Info << "Maximum soot mass concentrations: " << sootMax_ << nl;
126 
127  if (mappingFieldName_ == "none")
128  {
129  const label index = singleReaction.rhs()[0].index;
130  mappingFieldName_ = combustion.thermo().Y(index).name();
131  }
132 
133  const label mapFieldIndex =
134  combustion.thermo().species()[mappingFieldName_];
135 
136  mapFieldMax_ = Yprod0[mapFieldIndex];
137 }
138 
139 
140 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
141 
143 {}
144 
145 
146 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
147 
149 {
150  const volScalarField& mapField =
151  mesh_.lookupObject<volScalarField>(mappingFieldName_);
152 
153  soot_ = sootMax_*(mapField/mapFieldMax_);
154 }
155 
156 
157 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
Macros for easy insertion into run-time selection tables.
Generic GeometricField class.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:99
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
const fluidMulticomponentThermo & thermo() const
Return const access to the thermo.
static const word combustionPropertiesName
Default combustionProperties dictionary name.
Base class for single-step combustion models.
const reaction & singleReaction() const
Return the single step reaction.
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:99
virtual const speciesTable & species() const =0
The table of species.
virtual scalar WiValue(const label speciei) const =0
Molecular weight [kg/kmol].
virtual PtrList< volScalarField > & Y()=0
Access the mass-fraction fields.
const Type & lookupObject(const word &name) const
Lookup and return the object of the given Type and name.
Base class for soot models.
Definition: sootModel.H:51
const fvMesh & mesh() const
Reference to the mesh.
Definition: sootModel.H:112
This soot model is purely an state model. The amount of soot produced is determined by a single step ...
virtual void correct()
Main update/correction routine.
mixtureFraction(const dictionary &dict, const fvMesh &mesh, const word &modelType)
Construct from components.
Reaction base-class holding the specie names and coefficients.
Definition: reaction.H:57
A class for handling words, derived from string.
Definition: word.H:62
addToRunTimeSelectionTable(sootModel, mixtureFraction, dictionary)
defineTypeNameAndDebug(mixtureFraction, 0)
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
word name(const bool)
Return a word representation of a bool.
Definition: boolIO.C:39
messageStream Info
dimensioned< scalar > mag(const dimensioned< Type > &)
static const char nl
Definition: Ostream.H:266
dictionary dict