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-2024 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(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  nuSoot_(dict.lookup<scalar>("nuSoot")),
75  Wsoot_(dict.lookup<scalar>("Wsoot")),
76  sootMax_(-1),
77  mappingFieldName_
78  (
79  dict.lookupOrDefault<word>("mappingField", "none")
80  ),
81  mapFieldMax_(1)
82 {
83  const combustionModels::singleStepCombustion& combustion =
85  (
87  );
88 
89  const reaction& singleReaction = combustion.singleReaction();
90 
91  scalar totalMol = 0;
92  forAll(singleReaction.rhs(), i)
93  {
94  const scalar stoichCoeff = singleReaction.rhs()[i].stoichCoeff;
95  totalMol += mag(stoichCoeff);
96  }
97 
98  totalMol += nuSoot_;
99 
100  scalarList Xi(singleReaction.rhs().size());
101 
102  scalar Wm = 0;
103  forAll(singleReaction.rhs(), i)
104  {
105  const label speciei = singleReaction.rhs()[i].index;
106  const scalar stoichCoeff = singleReaction.rhs()[i].stoichCoeff;
107  Xi[i] = mag(stoichCoeff)/totalMol;
108  Wm += Xi[i]*combustion.thermo().WiValue(speciei);
109  }
110 
111  scalarList Yprod0(combustion.thermo().species().size(), 0.0);
112 
113  forAll(singleReaction.rhs(), i)
114  {
115  const label speciei = singleReaction.rhs()[i].index;
116  Yprod0[speciei] = combustion.thermo().WiValue(speciei)/Wm*Xi[i];
117  }
118 
119  const scalar XSoot = nuSoot_/totalMol;
120  Wm += XSoot*Wsoot_;
121 
122  sootMax_ = XSoot*Wsoot_/Wm;
123 
124  Info << "Maximum soot mass concentrations: " << sootMax_ << nl;
125 
126  if (mappingFieldName_ == "none")
127  {
128  const label index = singleReaction.rhs()[0].index;
129  mappingFieldName_ = combustion.thermo().Y(index).name();
130  }
131 
132  const label mapFieldIndex =
133  combustion.thermo().species()[mappingFieldName_];
134 
135  mapFieldMax_ = Yprod0[mapFieldIndex];
136 }
137 
138 
139 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
140 
142 {}
143 
144 
145 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
146 
148 {
149  const volScalarField& mapField =
150  mesh_.lookupObject<volScalarField>(mappingFieldName_);
151 
152  soot_ = sootMax_*(mapField/mapFieldMax_);
153 }
154 
155 
156 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:433
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 keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:96
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:108
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
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
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
void mag(LagrangianPatchField< scalar > &f, const LagrangianPatchField< Type > &f1)
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
static const char nl
Definition: Ostream.H:267
dictionary dict