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);
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)
189 template<
class ReactionThermo>
197 specieCoeffs::reactionStr(reaction, species_, lhs_, rhs_)
202 template<
class ReactionThermo>
214 template<
class ReactionThermo>
226 template<
class ReactionThermo>
235 scalar pf, cf, pr, cr;
238 scalar omegaI = omega
240 p, T, c, pf, cf, lRef, pr, cr, rRef
245 const label si = lhs_[i].index;
246 const scalar sl = lhs_[i].stoichCoeff;
247 dcdt[si] -= sl*omegaI;
251 const label si = rhs_[i].index;
252 const scalar sr = rhs_[i].stoichCoeff;
253 dcdt[si] += sr*omegaI;
258 template<
class ReactionThermo>
273 scalar clippedT =
min(
max(T, this->Tlow()), this->Thigh());
275 const scalar kf = this->kf(p, clippedT, c);
276 const scalar kr = this->kr(kf, p, clippedT, c);
281 const label Nl = lhs_.size();
282 const label Nr = rhs_.size();
285 lRef = lhs_[slRef].index;
290 const label si = lhs_[
s].index;
294 const scalar
exp = lhs_[slRef].exponent;
295 pf *=
pow(
max(c[lRef], 0), exp);
301 const scalar
exp = lhs_[
s].exponent;
302 pf *=
pow(
max(c[si], 0), exp);
305 cf =
max(c[lRef], 0);
308 const scalar
exp = lhs_[slRef].exponent;
313 pf *=
pow(cf, exp - 1);
322 pf *=
pow(cf, exp - 1);
327 rRef = rhs_[srRef].index;
333 const label si = rhs_[
s].index;
336 const scalar
exp = rhs_[srRef].exponent;
337 pr *=
pow(
max(c[rRef], 0), exp);
343 const scalar
exp = rhs_[
s].exponent;
344 pr *=
pow(
max(c[si], 0), exp);
347 cr =
max(c[rRef], 0);
350 const scalar
exp = rhs_[srRef].exponent;
355 pr *=
pow(cr, exp - 1);
364 pr *=
pow(cr, exp - 1);
368 return pf*cf - pr*cr;
372 template<
class ReactionThermo>
387 scalar pf, cf, pr, cr;
390 omegaI = omega(p, T, c, pf, cf, lRef, pr, cr, rRef);
394 const label si = reduced ? c2s[lhs_[i].index] : lhs_[i].index;
395 const scalar sl = lhs_[i].stoichCoeff;
396 dcdt[si] -= sl*omegaI;
400 const label si = reduced ? c2s[rhs_[i].index] : rhs_[i].index;
401 const scalar sr = rhs_[i].stoichCoeff;
402 dcdt[si] += sr*omegaI;
405 kfwd = this->kf(p, T, c);
406 kbwd = this->kr(kfwd, p, T, c);
410 const label sj = reduced ? c2s[lhs_[j].index] : lhs_[j].index;
414 const label si = lhs_[i].index;
415 const scalar el = lhs_[i].exponent;
431 kf *= el*
pow(c[si], el - 1);
436 kf *=
pow(c[si], el);
442 const label si = reduced ? c2s[lhs_[i].index] : lhs_[i].index;
443 const scalar sl = lhs_[i].stoichCoeff;
448 const label si = reduced ? c2s[rhs_[i].index] : rhs_[i].index;
449 const scalar sr = rhs_[i].stoichCoeff;
456 const label sj = reduced ? c2s[rhs_[j].index] : rhs_[j].index;
460 const label si = rhs_[i].index;
461 const scalar er = rhs_[i].exponent;
477 kr *= er*
pow(c[si], er - 1);
482 kr *=
pow(c[si], er);
488 const label si = reduced ? c2s[lhs_[i].index] : lhs_[i].index;
489 const scalar sl = lhs_[i].stoichCoeff;
494 const label si = reduced ? c2s[rhs_[i].index] : rhs_[i].index;
495 const scalar sr = rhs_[i].stoichCoeff;
507 this->dcidc(p, T, c, dcidc);
512 sj = reduced ? c2s[sj] : sj;
518 reduced ? c2s[lhs_[i].index] : lhs_[i].index;
519 const scalar sl = lhs_[i].stoichCoeff;
520 J(si, sj) -= sl*dcidc[j]*omegaI;
525 reduced ? c2s[rhs_[i].index] : rhs_[i].index;
526 const scalar sr = rhs_[i].stoichCoeff;
527 J(si, sj) += sr*dcidc[j]*omegaI;
535 template<
class ReactionThermo>
553 scalar dkfdT = this->dkfdT(p, T, c);
554 scalar dkrdT = this->dkrdT(p, T, c, dkfdT, kr);
559 const label si = lhs_[i].index;
560 const scalar el = lhs_[i].exponent;
561 const scalar cExp =
pow(c[si], el);
571 const label si = rhs_[i].index;
572 const scalar er = rhs_[i].exponent;
573 const scalar cExp =
pow(c[si], er);
581 scalar dqidT = dkfdT - dkrdT + kf - kr;
585 scalar dcidT = this->dcidT(p, T, c);
591 const label si = reduced ? c2s[lhs_[i].index] : lhs_[i].index;
592 const scalar sl = lhs_[i].stoichCoeff;
593 J(si, indexT) -= sl*(dqidT + dcidT);
597 const label si = reduced ? c2s[rhs_[i].index] : rhs_[i].index;
598 const scalar sr = rhs_[i].stoichCoeff;
599 J(si, indexT) += sr*(dqidT + dcidT);
604 template<
class ReactionThermo>
void ddot(const scalar p, const scalar T, const scalarField &c, scalarField &d) const
Forward reaction rate.
#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.
void dwdT(const scalar p, const scalar T, const scalarField &c, 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.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void size(const label)
Override size to be inconsistent with allocated storage.
void fdot(const scalar p, const scalar T, const scalarField &c, scalarField &f) const
Backward reaction rate.
virtual void write(Ostream &) const
Write.
static const scalar SMALL
A HashTable specialization for hashing pointers.
void omega(const scalar p, const scalar T, const scalarField &c, scalarField &dcdt) const
Net reaction rate for individual species.
T & first()
Return the first element of the list.
Simple extension of ReactionThermo to handle reaction kinetics in addition to the equilibrium thermod...
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)
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)
A class for handling words, derived from string.
CombustionModel< rhoReactionThermo > & reaction
void dwdc(const scalar p, const scalar T, const scalarField &c, 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.
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 from dict.
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...
static label nUnNamedReactions
Number of un-named reactions.
Output to memory buffer stream.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.