mixtureFractionSoot.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) 2013-2016 OpenFOAM Foundation
9 Copyright (C) 2020 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
27\*---------------------------------------------------------------------------*/
28
29#include "mixtureFractionSoot.H"
31
32// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33
34
35template<class ThermoType>
38(
39 const fluidThermo& thermo
40)
41{
42 if (isA<singleStepReactingMixture<ThermoType>>(thermo))
43 {
44 return dynamic_cast<const singleStepReactingMixture<ThermoType>&>
45 (
46 thermo
47 );
48 }
49 else
50 {
52 << "Inconsistent thermo package for " << thermo.type()
53 << "Please select a thermo package based on "
54 << "singleStepReactingMixture" << exit(FatalError);
55
56 return dynamic_cast<const singleStepReactingMixture<ThermoType>&>
57 (
58 thermo
59 );
60 }
61
62}
63
64
65// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
66
67template<class ThermoType>
69(
70 const dictionary& dict,
71 const fvMesh& mesh,
72 const word& modelType
73)
74:
75 sootModel(dict, mesh, modelType),
76 soot_
77 (
79 (
80 "soot",
81 mesh_.time().timeName(),
82 mesh_,
83 IOobject::MUST_READ,
84 IOobject::AUTO_WRITE
85 ),
86 mesh_
87 ),
88 coeffsDict_(dict.subOrEmptyDict(modelType + "Coeffs")),
89 nuSoot_(coeffsDict_.get<scalar>("nuSoot")),
90 Wsoot_(coeffsDict_.get<scalar>("Wsoot")),
91 sootMax_(-1),
92 mappingFieldName_
93 (
94 coeffsDict_.getOrDefault<word>("mappingField", "none")
95 ),
96 mapFieldMax_(1),
97 thermo_(mesh.lookupObject<fluidThermo>(basicThermo::dictName)),
98 mixture_(checkThermo(thermo_))
99{
100 const Reaction<ThermoType>& reaction = mixture_.operator[](0);
101
102 const scalarList& specieStoichCoeffs(mixture_.specieStoichCoeffs());
103
104 scalar totalMol = 0.0;
105 forAll(reaction.rhs(), i)
106 {
107 label speciei = reaction.rhs()[i].index;
108 totalMol += mag(specieStoichCoeffs[speciei]);
109 }
110
111 totalMol += nuSoot_;
112
113 scalarList Xi(reaction.rhs().size());
114
115 scalar Wm = 0.0;
116 forAll(reaction.rhs(), i)
117 {
118 const label speciei = reaction.rhs()[i].index;
119 Xi[i] = mag(specieStoichCoeffs[speciei])/totalMol;
120 Wm += Xi[i]*mixture_.speciesData()[speciei].W();
121 }
122
123 const scalar XSoot = nuSoot_/totalMol;
124 Wm += XSoot*Wsoot_;
125
126 sootMax_ = XSoot*Wsoot_/Wm;
127
128 Info << "Maximum soot mass concentrations: " << sootMax_ << nl;
129
130 if (mappingFieldName_ == "none")
131 {
132 const label index = reaction.rhs()[0].index;
133 mappingFieldName_ = mixture_.Y(index).name();
134 }
135
136 const label mapFieldIndex = mixture_.species().find(mappingFieldName_);
137
138 mapFieldMax_ = mixture_.Yprod0()[mapFieldIndex];
139
140}
141
142
143// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
144
145template<class ThermoType>
147{}
148
149
150// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
151
152template<class ThermoType>
154{
155 const volScalarField& mapField =
156 mesh_.lookupObject<volScalarField>(mappingFieldName_);
157
158 soot_ = sootMax_*(mapField/mapFieldMax_);
159}
160
161// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:170
Simple extension of ReactionThermo to handle reaction kinetics in addition to the equilibrium thermod...
Definition: Reaction.H:73
Abstract base-class for fluid and solid thermodynamic properties.
Definition: basicThermo.H:66
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
Fundamental fluid thermodynamic properties.
Definition: fluidThermo.H:56
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:91
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.
Base class for soor models.
Definition: sootModel.H:56
Single step reacting mixture.
Basic thermodynamics type based on the use of fitting functions for cp, h, s obtained from the templa...
A class for handling words, derived from Foam::string.
Definition: word.H:68
dynamicFvMesh & mesh
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
const word dictName("faMeshDefinition")
CombustionModel< rhoReactionThermo > & reaction
word timeName
Definition: getTimeIndex.H:3
messageStream Info
Information stream (stdout output on master, null elsewhere)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53
dictionary dict
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333