30 template<
class ReactionThermo>
33 template<
class ReactionThermo>
36 template<
class ReactionThermo>
42 template<
class ReactionThermo>
45 return nUnNamedReactions++;
49 template<
class ReactionThermo>
52 const HashPtrTable<ReactionThermo>& thermoDatabase
55 typename ReactionThermo::thermoType rhsThermo
58 *(*thermoDatabase[species_[rhs_[0].index]]).
W()
59 *(*thermoDatabase[species_[rhs_[0].index]])
62 for (
label i=1; i<rhs_.size(); ++i)
66 *(*thermoDatabase[species_[rhs_[i].index]]).
W()
67 *(*thermoDatabase[species_[rhs_[i].index]]);
70 typename ReactionThermo::thermoType lhsThermo
73 *(*thermoDatabase[species_[lhs_[0].index]]).
W()
74 *(*thermoDatabase[species_[lhs_[0].index]])
77 for (
label i=1; i<lhs_.size(); ++i)
81 *(*thermoDatabase[species_[lhs_[i].index]]).
W()
82 *(*thermoDatabase[species_[lhs_[i].index]]);
85 ReactionThermo::thermoType::operator=(lhsThermo == rhsThermo);
91 template<
class ReactionThermo>
100 ReactionThermo::thermoType(*thermoDatabase[species[0]]),
101 name_(
"un-named-reaction-" +
Foam::name(getNewReactionID())),
104 Thigh_(ThighDefault),
108 setThermo(thermoDatabase);
112 template<
class ReactionThermo>
119 ReactionThermo::thermoType(r),
120 name_(r.
name() +
"Copy"),
129 template<
class ReactionThermo>
137 ReactionThermo::thermoType(*thermoDatabase[species[0]]),
143 specieCoeffs::setLRhs
150 setThermo(thermoDatabase);
156 template<
class ReactionThermo>
165 const word& reactionTypeName = dict.
lookup(
"type");
167 typename dictionaryConstructorTable::iterator cstrIter =
168 dictionaryConstructorTablePtr_->find(reactionTypeName);
174 if (cstrIter == dictionaryConstructorTablePtr_->end())
176 cstrIter = dictionaryConstructorTablePtr_->find
182 if (cstrIter == dictionaryConstructorTablePtr_->end())
185 <<
"Unknown reaction type " 186 << reactionTypeName <<
nl <<
nl 187 <<
"Valid reaction types are :" <<
nl 188 << dictionaryConstructorTablePtr_->sortedToc()
194 cstrIter()(species, thermoDatabase,
dict)
199 template<
class ReactionThermo>
211 if (!objectRegistryConstructorTablePtr_)
213 return New(species, thermoDatabase, dict);
216 const word& reactionTypeName = dict.
lookup(
"type");
218 typename objectRegistryConstructorTable::iterator cstrIter =
219 objectRegistryConstructorTablePtr_->find(reactionTypeName);
222 if (cstrIter == objectRegistryConstructorTablePtr_->end())
224 cstrIter = objectRegistryConstructorTablePtr_->find
230 if (cstrIter == objectRegistryConstructorTablePtr_->end())
232 typename dictionaryConstructorTable::iterator cstrIter =
233 dictionaryConstructorTablePtr_->find(reactionTypeName);
236 if (cstrIter == dictionaryConstructorTablePtr_->end())
238 cstrIter = dictionaryConstructorTablePtr_->find
244 if (cstrIter == dictionaryConstructorTablePtr_->end())
247 <<
"Unknown reaction type " 248 << reactionTypeName <<
nl <<
nl 249 <<
"Valid reaction types are :" <<
nl 250 << dictionaryConstructorTablePtr_->sortedToc()
251 << objectRegistryConstructorTablePtr_->sortedToc()
257 cstrIter()(species, thermoDatabase,
dict)
263 cstrIter()(species, thermoDatabase, ob,
dict)
268 template<
class ReactionThermo>
282 speciesThermo[i].
name(),
283 speciesThermo[i].
clone().ptr()
287 return New(species, thermoDatabase, dict);
293 template<
class ReactionThermo>
301 specieCoeffs::reactionStr(reaction, species_, lhs_, rhs_)
306 template<
class ReactionThermo>
319 template<
class ReactionThermo>
332 template<
class ReactionThermo>
342 scalar pf, cf, pr, cr;
345 scalar omegaI = omega
347 p, T, c, li, pf, cf, lRef, pr, cr, rRef
352 const label si = lhs_[i].index;
353 const scalar sl = lhs_[i].stoichCoeff;
354 dcdt[si] -= sl*omegaI;
358 const label si = rhs_[i].index;
359 const scalar sr = rhs_[i].stoichCoeff;
360 dcdt[si] += sr*omegaI;
365 template<
class ReactionThermo>
381 scalar clippedT =
min(
max(T, this->Tlow()), this->Thigh());
383 const scalar kf = this->kf(p, clippedT, c, li);
384 const scalar kr = this->kr(kf, p, clippedT, c, li);
389 const label Nl = lhs_.size();
390 const label Nr = rhs_.size();
393 lRef = lhs_[slRef].index;
398 const label si = lhs_[
s].index;
402 const scalar
exp = lhs_[slRef].exponent;
403 pf *=
pow(
max(c[lRef], 0), exp);
409 const scalar
exp = lhs_[
s].exponent;
410 pf *=
pow(
max(c[si], 0), exp);
413 cf =
max(c[lRef], 0);
416 const scalar
exp = lhs_[slRef].exponent;
421 pf *=
pow(cf, exp - 1);
430 pf *=
pow(cf, exp - 1);
435 rRef = rhs_[srRef].index;
441 const label si = rhs_[
s].index;
444 const scalar
exp = rhs_[srRef].exponent;
445 pr *=
pow(
max(c[rRef], 0), exp);
451 const scalar
exp = rhs_[
s].exponent;
452 pr *=
pow(
max(c[si], 0), exp);
455 cr =
max(c[rRef], 0);
458 const scalar
exp = rhs_[srRef].exponent;
463 pr *=
pow(cr, exp - 1);
472 pr *=
pow(cr, exp - 1);
476 return pf*cf - pr*cr;
480 template<
class ReactionThermo>
496 scalar pf, cf, pr, cr;
499 omegaI = omega(p, T, c, li, pf, cf, lRef, pr, cr, rRef);
503 const label si = reduced ? c2s[lhs_[i].index] : lhs_[i].index;
504 const scalar sl = lhs_[i].stoichCoeff;
505 dcdt[si] -= sl*omegaI;
509 const label si = reduced ? c2s[rhs_[i].index] : rhs_[i].index;
510 const scalar sr = rhs_[i].stoichCoeff;
511 dcdt[si] += sr*omegaI;
514 kfwd = this->kf(p, T, c, li);
515 kbwd = this->kr(kfwd, p, T, c, li);
519 const label sj = reduced ? c2s[lhs_[j].index] : lhs_[j].index;
523 const label si = lhs_[i].index;
524 const scalar el = lhs_[i].exponent;
540 kf *= el*
pow(c[si], el - 1);
545 kf *=
pow(c[si], el);
551 const label si = reduced ? c2s[lhs_[i].index] : lhs_[i].index;
552 const scalar sl = lhs_[i].stoichCoeff;
557 const label si = reduced ? c2s[rhs_[i].index] : rhs_[i].index;
558 const scalar sr = rhs_[i].stoichCoeff;
565 const label sj = reduced ? c2s[rhs_[j].index] : rhs_[j].index;
569 const label si = rhs_[i].index;
570 const scalar er = rhs_[i].exponent;
586 kr *= er*
pow(c[si], er - 1);
591 kr *=
pow(c[si], er);
597 const label si = reduced ? c2s[lhs_[i].index] : lhs_[i].index;
598 const scalar sl = lhs_[i].stoichCoeff;
603 const label si = reduced ? c2s[rhs_[i].index] : rhs_[i].index;
604 const scalar sr = rhs_[i].stoichCoeff;
616 this->dcidc(p, T, c, li, dcidc);
621 sj = reduced ? c2s[sj] : sj;
627 reduced ? c2s[lhs_[i].index] : lhs_[i].index;
628 const scalar sl = lhs_[i].stoichCoeff;
629 J(si, sj) -= sl*dcidc[j]*omegaI;
634 reduced ? c2s[rhs_[i].index] : rhs_[i].index;
635 const scalar sr = rhs_[i].stoichCoeff;
636 J(si, sj) += sr*dcidc[j]*omegaI;
644 template<
class ReactionThermo>
663 scalar dkfdT = this->dkfdT(p, T, c, li);
664 scalar dkrdT = this->dkrdT(p, T, c, li, dkfdT, kr);
669 const label si = lhs_[i].index;
670 const scalar el = lhs_[i].exponent;
671 const scalar cExp =
pow(c[si], el);
681 const label si = rhs_[i].index;
682 const scalar er = rhs_[i].exponent;
683 const scalar cExp =
pow(c[si], er);
691 scalar dqidT = dkfdT - dkrdT + kf - kr;
695 scalar dcidT = this->dcidT(p, T, c, li);
701 const label si = reduced ? c2s[lhs_[i].index] : lhs_[i].index;
702 const scalar sl = lhs_[i].stoichCoeff;
703 J(si, indexT) -= sl*(dqidT + dcidT);
707 const label si = reduced ? c2s[rhs_[i].index] : rhs_[i].index;
708 const scalar sr = rhs_[i].stoichCoeff;
709 J(si, indexT) += sr*(dqidT + dcidT);
714 template<
class ReactionThermo>
#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 > &)
const word & name() const
Return the name of the reaction.
#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...
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.
static const scalar SMALL
A HashTable specialization 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.
scalar Tlow() const
Return the lower temperature limit for the reaction.
static scalar TlowDefault
Default temperature limits of applicability of reaction rates.
const word dictName() const
Return the local dictionary name (final part of scoped name)
bool insert(const Key &, const T * &newElmt)
Insert a new hashedEntry.
const speciesTable & species() const
Return the specie list.
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
dimensionedScalar exp(const dimensionedScalar &ds)
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 fdot(const scalar p, const scalar T, const scalarField &c, const label li, scalarField &f) const
Backward reaction rate.
void ddot(const scalar p, const scalar T, const scalarField &c, const label li, scalarField &d) const
Forward reaction rate.
CombustionModel< rhoReactionThermo > & reaction
static scalar ThighDefault
An Ostream is an abstract base class for all output systems (streams, files, token lists...
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
word name(const complex &)
Return a string representation of a complex.
scalar Thigh() const
Return the upper temperature limit for the reaction.
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,.
static const scalar VSMALL
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...
Input from memory buffer stream.
const scalarList W(::W(thermo))
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.
static label nUnNamedReactions
Number of un-named reactions.
bool removeTrailing(const char)
Remove trailing character returning true if string changed.
Output to memory buffer stream.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.