31 template<
class ReactionThermo>
34 template<
class ReactionThermo>
40 template<
class ReactionThermo>
43 const HashPtrTable<ReactionThermo>& thermoDatabase
46 typename ReactionThermo::thermoType rhsThermo
49 *(*thermoDatabase[species()[rhs()[0].index]]).
W()
50 *(*thermoDatabase[species()[rhs()[0].index]])
57 *(*thermoDatabase[species()[rhs()[i].index]]).
W()
58 *(*thermoDatabase[species()[rhs()[i].index]]);
61 typename ReactionThermo::thermoType lhsThermo
64 *(*thermoDatabase[species()[lhs()[0].index]]).
W()
65 *(*thermoDatabase[species()[lhs()[0].index]])
72 *(*thermoDatabase[species()[lhs()[i].index]]).
W()
73 *(*thermoDatabase[species()[lhs()[i].index]]);
79 if (
mag(lhsThermo.Y() - rhsThermo.Y()) > 0.1)
82 <<
"Mass imbalance for reaction " <<
name() <<
": " 83 <<
mag(lhsThermo.Y() - rhsThermo.Y()) <<
" kg/kmol" 87 ReactionThermo::thermoType::operator=(lhsThermo == rhsThermo);
93 template<
class ReactionThermo>
103 ReactionThermo::thermoType(*thermoDatabase[species[0]]),
107 setThermo(thermoDatabase);
111 template<
class ReactionThermo>
119 ReactionThermo::thermoType(r),
125 template<
class ReactionThermo>
134 ReactionThermo::thermoType(*thermoDatabase[species[0]]),
138 setThermo(thermoDatabase);
144 template<
class ReactionThermo>
153 const word& reactionTypeName = dict.
lookup(
"type");
155 typename dictionaryConstructorTable::iterator cstrIter =
156 dictionaryConstructorTablePtr_->find(reactionTypeName);
162 if (cstrIter == dictionaryConstructorTablePtr_->end())
164 cstrIter = dictionaryConstructorTablePtr_->find
170 if (cstrIter == dictionaryConstructorTablePtr_->end())
173 <<
"Unknown reaction type " 174 << reactionTypeName <<
nl <<
nl 175 <<
"Valid reaction types are :" <<
nl 176 << dictionaryConstructorTablePtr_->sortedToc()
182 cstrIter()(species, thermoDatabase,
dict)
187 template<
class ReactionThermo>
199 if (!objectRegistryConstructorTablePtr_)
201 return New(species, thermoDatabase, dict);
204 const word& reactionTypeName = dict.
lookup(
"type");
206 typename objectRegistryConstructorTable::iterator cstrIter =
207 objectRegistryConstructorTablePtr_->find(reactionTypeName);
210 if (cstrIter == objectRegistryConstructorTablePtr_->end())
212 cstrIter = objectRegistryConstructorTablePtr_->find
218 if (cstrIter == objectRegistryConstructorTablePtr_->end())
220 typename dictionaryConstructorTable::iterator cstrIter =
221 dictionaryConstructorTablePtr_->find(reactionTypeName);
224 if (cstrIter == dictionaryConstructorTablePtr_->end())
226 cstrIter = dictionaryConstructorTablePtr_->find
232 if (cstrIter == dictionaryConstructorTablePtr_->end())
235 <<
"Unknown reaction type " 236 << reactionTypeName <<
nl <<
nl 237 <<
"Valid reaction types are :" <<
nl 238 << dictionaryConstructorTablePtr_->sortedToc()
239 << objectRegistryConstructorTablePtr_->sortedToc()
245 cstrIter()(species, thermoDatabase,
dict)
251 cstrIter()(species, thermoDatabase, ob,
dict)
256 template<
class ReactionThermo>
270 speciesThermo[i].
name(),
271 speciesThermo[i].
clone().ptr()
275 return New(species, thermoDatabase, dict);
281 template<
class ReactionThermo>
288 template<
class ReactionThermo>
298 scalar omegaf, omegar;
300 const scalar omegaI = omega(p, T, c, li, omegaf, omegar);
304 const label si = lhs()[i].index;
305 const scalar sl = lhs()[i].stoichCoeff;
306 dcdt[si] -= sl*omegaI;
310 const label si = rhs()[i].index;
311 const scalar sr = rhs()[i].stoichCoeff;
312 dcdt[si] += sr*omegaI;
317 template<
class ReactionThermo>
328 scalar clippedT =
min(
max(T, this->Tlow()), this->Thigh());
330 omegaf = this->kf(p, clippedT, c, li);
331 omegar = this->kr(omegaf, p, clippedT, c, li);
335 const label si = lhs()[i].index;
336 const scalar el = lhs()[i].exponent;
337 omegaf *= c[si] >= small || el >= 1 ?
pow(
max(c[si], 0), el) : 0;
341 const label si = rhs()[i].index;
342 const scalar er = rhs()[i].exponent;
343 omegar *= c[si] >= small || er >= 1 ?
pow(
max(c[si], 0), er) : 0;
346 return omegaf - omegar;
350 template<
class ReactionThermo>
366 scalar omegaf, omegar;
368 omegaI = omega(p, T, c, li, omegaf, omegar);
372 const label si = reduced ? c2s[lhs()[i].index] : lhs()[i].index;
373 const scalar sl = lhs()[i].stoichCoeff;
374 dcdt[si] -= sl*omegaI;
378 const label si = reduced ? c2s[rhs()[i].index] : rhs()[i].index;
379 const scalar sr = rhs()[i].stoichCoeff;
380 dcdt[si] += sr*omegaI;
383 kfwd = this->kf(p, T, c, li);
384 kbwd = this->kr(kfwd, p, T, c, li);
388 const label sj = reduced ? c2s[lhs()[j].index] : lhs()[j].index;
392 const label si = lhs()[i].index;
393 const scalar el = lhs()[i].exponent;
397 c[si] >= small || el >= 1
398 ? el*
pow(
max(c[si], 0), el - 1)
404 c[si] >= small || el >= 1
412 const label si = reduced ? c2s[lhs()[i].index] : lhs()[i].index;
413 const scalar sl = lhs()[i].stoichCoeff;
418 const label si = reduced ? c2s[rhs()[i].index] : rhs()[i].index;
419 const scalar sr = rhs()[i].stoichCoeff;
426 const label sj = reduced ? c2s[rhs()[j].index] : rhs()[j].index;
430 const label si = rhs()[i].index;
431 const scalar er = rhs()[i].exponent;
435 c[si] >= small || er >= 1
436 ? er*
pow(
max(c[si], 0), er - 1)
442 c[si] >= small || er >= 1
450 const label si = reduced ? c2s[lhs()[i].index] : lhs()[i].index;
451 const scalar sl = lhs()[i].stoichCoeff;
456 const label si = reduced ? c2s[rhs()[i].index] : rhs()[i].index;
457 const scalar sr = rhs()[i].stoichCoeff;
469 this->dcidc(p, T, c, li, dcidc);
474 sj = reduced ? c2s[sj] : sj;
480 reduced ? c2s[lhs()[i].index] : lhs()[i].index;
481 const scalar sl = lhs()[i].stoichCoeff;
482 J(si, sj) -= sl*dcidc[j]*omegaI;
487 reduced ? c2s[rhs()[i].index] : rhs()[i].index;
488 const scalar sr = rhs()[i].stoichCoeff;
489 J(si, sj) += sr*dcidc[j]*omegaI;
497 template<
class ReactionThermo>
513 scalar dkfdT = this->dkfdT(p, T, c, li);
514 scalar dkrdT = this->dkrdT(p, T, c, li, dkfdT, kbwd);
518 const label si = lhs()[i].index;
519 const scalar el = lhs()[i].exponent;
520 dkfdT *= c[si] >= small || el >= 1 ?
pow(
max(c[si], 0), el) : 0;
524 const label si = rhs()[i].index;
525 const scalar er = rhs()[i].exponent;
526 dkrdT *= c[si] >= small || er >= 1 ?
pow(
max(c[si], 0), er) : 0;
529 const scalar dqidT = dkfdT - dkrdT;
533 const scalar dcidT = omegaI*this->dcidT(p, T, c, li);
538 const label si = reduced ? c2s[lhs()[i].index] : lhs()[i].index;
539 const scalar sl = lhs()[i].stoichCoeff;
540 J(si, indexT) -= sl*(dqidT + dcidT);
544 const label si = reduced ? c2s[rhs()[i].index] : rhs()[i].index;
545 const scalar sr = rhs()[i].stoichCoeff;
546 J(si, indexT) += sr*(dqidT + dcidT);
#define forAll(list, i)
Loop across all elements in list.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
errorManipArg< error, int > exit(error &err, const int errNo=1)
A list of keyword definitions, which are a keyword followed by any number of values (e...
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
combustionModel & reaction
void dwdc(const scalar p, const scalar T, const scalarField &c, const label li, scalarSquareMatrix &J, scalarField &dcdt, scalar &omegaI, scalar &kfwd, scalar &kbwd, const bool reduced, const List< label > &c2s) const
Derivative of the net reaction rate for each species involved.
void size(const label)
Override size to be inconsistent with allocated storage.
virtual void write(Ostream &) const
Write.
A HashTable specialisation for hashing pointers.
T & first()
Return the first element of the list.
Simple extension of ReactionThermo to handle reaction kinetics in addition to the equilibrium thermod...
void omega(const scalar p, const scalar T, const scalarField &c, const label li, scalarField &dcdt) const
Net reaction rate for individual species.
static scalar TlowDefault
Default temperature limits of applicability of reaction rates.
bool insert(const Key &, const T * &newElmt)
Insert a new hashedEntry.
scalar Tlow() const
Return the lower temperature limit for the reaction.
autoPtr< BasicCompressibleMomentumTransportModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const typename BasicCompressibleMomentumTransportModel::transportModel &transport)
A class for handling words, derived from string.
void write(std::ostream &os, const bool binary, List< floatScalar > &fField)
Write floats ascii or binary.
scalar Thigh() const
Return the upper temperature limit for the reaction.
static scalar ThighDefault
An Ostream is an abstract base class for all output systems (streams, files, token lists...
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
word name(const complex &)
Return a string representation of a complex.
bool notNull(const T &t)
Return true if t is not a reference to the nullObject of type T.
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
Reaction(const speciesTable &species, const List< specieCoeffs > &lhs, const List< specieCoeffs > &rhs, const HashPtrTable< ReactionThermo > &thermoDatabase)
Construct from components.
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
A wordList with hashed indices for faster lookup by name.
static autoPtr< Reaction< ReactionThermo > > New(const speciesTable &species, const HashPtrTable< ReactionThermo > &thermoDatabase, const dictionary &dict)
Return a pointer to new patchField created on freestore.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
const scalarList W(::W(thermo))
dimensioned< scalar > mag(const dimensioned< Type > &)
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
void dwdT(const scalar p, const scalar T, const scalarField &c, const label li, const scalar omegaI, const scalar kfwd, const scalar kbwd, scalarSquareMatrix &J, const bool reduced, const List< label > &c2s, const label indexT) const
Derivative of the net reaction rate for each species involved.
Registry of regIOobjects.
bool removeTrailing(const char)
Remove trailing character returning true if string changed.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.