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-2022 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 basicSpecieMixture& mixture = combustion.mixture();
91 
92  const reaction& singleReaction = combustion.singleReaction();
93 
94  scalar totalMol = 0;
95  forAll(singleReaction.rhs(), i)
96  {
97  const scalar stoichCoeff = singleReaction.rhs()[i].stoichCoeff;
98  totalMol += mag(stoichCoeff);
99  }
100 
101  totalMol += nuSoot_;
102 
103  scalarList Xi(singleReaction.rhs().size());
104 
105  scalar Wm = 0;
106  forAll(singleReaction.rhs(), i)
107  {
108  const label speciei = singleReaction.rhs()[i].index;
109  const scalar stoichCoeff = singleReaction.rhs()[i].stoichCoeff;
110  Xi[i] = mag(stoichCoeff)/totalMol;
111  Wm += Xi[i]*mixture.Wi(speciei);
112  }
113 
114  scalarList Yprod0(mixture.species().size(), 0.0);
115 
116  forAll(singleReaction.rhs(), i)
117  {
118  const label speciei = singleReaction.rhs()[i].index;
119  Yprod0[speciei] = mixture.Wi(speciei)/Wm*Xi[i];
120  }
121 
122  const scalar XSoot = nuSoot_/totalMol;
123  Wm += XSoot*Wsoot_;
124 
125  sootMax_ = XSoot*Wsoot_/Wm;
126 
127  Info << "Maximum soot mass concentrations: " << sootMax_ << nl;
128 
129  if (mappingFieldName_ == "none")
130  {
131  const label index = singleReaction.rhs()[0].index;
132  mappingFieldName_ = mixture.Y(index).name();
133  }
134 
135  const label mapFieldIndex = mixture.species()[mappingFieldName_];
136 
137  mapFieldMax_ = Yprod0[mapFieldIndex];
138 }
139 
140 
141 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
142 
144 {}
145 
146 
147 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
148 
150 {
151  const volScalarField& mapField =
152  mesh_.lookupObject<volScalarField>(mappingFieldName_);
153 
154  soot_ = sootMax_*(mapField/mapFieldMax_);
155 }
156 
157 
158 // ************************************************************************* //
#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
Specialisation of basicMixture for a mixture consisting of a number for molecular species.
static const word combustionPropertiesName
Default combustionProperties dictionary name.
Base class for combustion models using basicSpecieMixture.
const reaction & singleReaction() const
Return the single step reaction.
const basicSpecieMixture & mixture() const
Return the mixture.
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:160
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:101
const word & name() const
Definition: mixture.H:93
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
const List< specieCoeffs > & rhs() const
Return the components of the right hand side.
Definition: reactionI.H:42
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
messageStream Info
dimensioned< scalar > mag(const dimensioned< Type > &)
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
static const char nl
Definition: Ostream.H:260
dictionary dict