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>
303 const label si = lhs()[i].index;
305 Cf *= c[si] >= small || el >= 1 ?
pow(
max(c[si], 0), el) : 0;
310 const label si = rhs()[i].index;
312 Cr *= c[si] >= small || er >= 1 ?
pow(
max(c[si], 0), er) : 0;
317 template<
class ReactionThermo>
328 const scalar clippedT =
min(
max(T, this->Tlow()), this->Thigh());
331 const scalar kf = this->kf(p, clippedT, c, li);
332 const scalar kr = this->kr(kf, p, clippedT, c, li);
336 this->
C(p, T, c, li, Cf, Cr);
341 return omegaf - omegar;
345 template<
class ReactionThermo>
358 scalar omegaf, omegar;
359 const scalar omega = this->omega(p, T, c, li, omegaf, omegar);
363 const label si = reduced ? c2s[lhs()[i].index] : lhs()[i].index;
364 const scalar sl = lhs()[i].stoichCoeff;
365 dNdtByV[Nsi0 + si] -= sl*omega;
369 const label si = reduced ? c2s[rhs()[i].index] : rhs()[i].index;
370 const scalar sr = rhs()[i].stoichCoeff;
371 dNdtByV[Nsi0 + si] += sr*omega;
376 template<
class ReactionThermo>
394 const scalar kf = this->kf(p, T, c, li);
395 const scalar kr = this->kr(kf, p, T, c, li);
399 this->
C(p, T, c, li, Cf, Cr);
402 const scalar omega = kf*Cf - kr*Cr;
407 const label si = reduced ? c2s[lhs()[i].index] : lhs()[i].index;
408 const scalar sl = lhs()[i].stoichCoeff;
409 dNdtByV[Nsi0 + si] -= sl*omega;
413 const label si = reduced ? c2s[rhs()[i].index] : rhs()[i].index;
414 const scalar sr = rhs()[i].stoichCoeff;
415 dNdtByV[Nsi0 + si] += sr*omega;
423 const label sj = reduced ? c2s[lhs()[j].index] : lhs()[j].index;
428 const label si = lhs()[i].index;
433 c[si] >= small || el >= 1
440 c[si] >= small || el >= 1
448 const label si = reduced ? c2s[lhs()[i].index] : lhs()[i].index;
449 const scalar sl = lhs()[i].stoichCoeff;
450 ddNdtByVdcTp(Nsi0 + si, Nsi0 + sj) -= sl*kf*dCfdcj;
454 const label si = reduced ? c2s[rhs()[i].index] : rhs()[i].index;
455 const scalar sr = rhs()[i].stoichCoeff;
456 ddNdtByVdcTp(Nsi0 + si, Nsi0 + sj) += sr*kf*dCfdcj;
462 const label sj = reduced ? c2s[rhs()[j].index] : rhs()[j].index;
467 const label si = rhs()[i].index;
472 c[si] >= small || er >= 1
479 c[si] >= small || er >= 1
487 const label si = reduced ? c2s[lhs()[i].index] : lhs()[i].index;
488 const scalar sl = lhs()[i].stoichCoeff;
489 ddNdtByVdcTp(Nsi0 + si, Nsi0 + sj) += sl*kr*dCrcj;
493 const label si = reduced ? c2s[rhs()[i].index] : rhs()[i].index;
494 const scalar sr = rhs()[i].stoichCoeff;
495 ddNdtByVdcTp(Nsi0 + si, Nsi0 + sj) -= sr*kr*dCrcj;
503 const scalar dkfdT = this->dkfdT(p, T, c, li);
504 const scalar dkrdT = this->dkrdT(p, T, c, li, dkfdT, kr);
506 const scalar dwdT = dkfdT*Cf - dkrdT*Cr;
509 const label si = reduced ? c2s[lhs()[i].index] : lhs()[i].index;
510 const scalar sl = lhs()[i].stoichCoeff;
511 ddNdtByVdcTp(Nsi0 + si, Tsi) -= sl*dwdT;
515 const label si = reduced ? c2s[rhs()[i].index] : rhs()[i].index;
516 const scalar sr = rhs()[i].stoichCoeff;
517 ddNdtByVdcTp(Nsi0 + si, Tsi) += sr*dwdT;
528 this->dkfdc(p, T, c, li, dkfdc);
529 this->dkrdc(p, T, c, li, dkfdc, kr, dkrdc);
533 const label sj = reduced ? c2s[j] : j;
535 if (sj == -1)
continue;
537 const scalar dwdc = dkfdc[j]*Cf - dkrdc[j]*Cr;
540 const label si = reduced ? c2s[lhs()[i].index] : lhs()[i].index;
541 const scalar sl = lhs()[i].stoichCoeff;
542 ddNdtByVdcTp(Nsi0 + si, Nsi0 + sj) -= sl*dwdc;
546 const label si = reduced ? c2s[rhs()[i].index] : rhs()[i].index;
547 const scalar sr = rhs()[i].stoichCoeff;
548 ddNdtByVdcTp(Nsi0 + si, Nsi0 + sj) += sr*dwdc;
Graphite solid properties.
#define forAll(list, i)
Loop across all elements in list.
void dNdtByV(const scalar p, const scalar T, const scalarField &c, const label li, scalarField &dNdtByV, const bool reduced, const List< label > &c2s, const label Nsi0) const
The net reaction rate for each species involved.
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
FvWallInfoData< WallInfo, label > label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
autoPtr< CompressibleMomentumTransportModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const viscosity &viscosity)
scalar omega(const scalar p, const scalar T, const scalarField &c, const label li, scalar &omegaf, scalar &omegar) const
Net reaction rate.
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...
#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 size(const label)
Override size to be inconsistent with allocated storage.
virtual void write(Ostream &) const
Write.
A HashTable specialisation for hashing pointers.
Simple extension of ReactionThermo to handle reaction kinetics in addition to the equilibrium thermod...
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.
A class for handling words, derived from string.
void write(std::ostream &os, const bool binary, List< floatScalar > &fField)
Write floats ascii or binary.
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
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...
word name(const complex &)
Return a string representation of a complex.
void ddNdtByVdcTp(const scalar p, const scalar T, const scalarField &c, const label li, scalarField &dNdtByV, scalarSquareMatrix &ddNdtByVdcTp, const bool reduced, const List< label > &c2s, const label csi0, const label Tsi, scalarField &cTpWork0, scalarField &cTpWork1) const
Derivative of the net reaction rate for each species involved.
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,.
void C(const scalar p, const scalar T, const scalarField &c, const label li, scalar &Cf, scalar &Cr) const
Concentration powers.
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...
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.