31 template<
class ReactionThermo>
34 template<
class ReactionThermo>
37 template<
class ReactionThermo>
42 template<
class ReactionThermo>
48 for (
label i = 0; i < lhs_.size(); ++i)
54 if (
mag(lhs_[i].stoichCoeff - 1) > small)
56 reaction << lhs_[i].stoichCoeff;
58 reaction << species_[lhs_[i].index];
59 if (
mag(lhs_[i].exponent - lhs_[i].stoichCoeff) > small)
61 reaction <<
"^" << lhs_[i].exponent;
67 template<
class ReactionThermo>
73 for (
label i = 0; i < rhs_.size(); ++i)
79 if (
mag(rhs_[i].stoichCoeff - 1) > small)
81 reaction << rhs_[i].stoichCoeff;
83 reaction << species_[rhs_[i].index];
84 if (
mag(rhs_[i].exponent - rhs_[i].stoichCoeff) > small)
86 reaction <<
"^" << rhs_[i].exponent;
94 template<
class ReactionThermo>
97 return nUnNamedReactions++;
101 template<
class ReactionThermo>
107 reactionStrLeft(reaction);
109 reactionStrRight(reaction);
110 return reaction.
str();
114 template<
class ReactionThermo>
120 typename ReactionThermo::thermoType rhsThermo
123 *(*thermoDatabase[species_[rhs_[0].index]]).
W()
124 *(*thermoDatabase[species_[rhs_[0].index]])
127 for (
label i=1; i<rhs_.size(); ++i)
131 *(*thermoDatabase[species_[rhs_[i].index]]).
W()
132 *(*thermoDatabase[species_[rhs_[i].index]]);
135 typename ReactionThermo::thermoType lhsThermo
138 *(*thermoDatabase[species_[lhs_[0].index]]).
W()
139 *(*thermoDatabase[species_[lhs_[0].index]])
142 for (
label i=1; i<lhs_.size(); ++i)
146 *(*thermoDatabase[species_[lhs_[i].index]]).
W()
147 *(*thermoDatabase[species_[lhs_[i].index]]);
150 ReactionThermo::thermoType::operator=(lhsThermo == rhsThermo);
157 template<
class ReactionThermo>
166 ReactionThermo::thermoType(*thermoDatabase[species[0]]),
167 name_(
"un-named-reaction-" +
Foam::name(getNewReactionID())),
170 Thigh_(ThighDefault),
174 setThermo(thermoDatabase);
178 template<
class ReactionThermo>
185 ReactionThermo::thermoType(r),
186 name_(r.
name() +
"Copy"),
195 template<
class ReactionThermo>
213 exponent = stoichCoeff;
219 size_t i = specieName.find(
'^');
223 string exponentStr = specieName
226 specieName.size() - i - 1
228 exponent = atof(exponentStr.c_str());
229 specieName = specieName(0, i);
234 index = species[specieName];
244 <<
"Expected a word but found " << t.
info()
250 template<
class ReactionThermo>
265 if (dlrhs.
last().index != -1)
273 else if (t == token::ASSIGN)
303 else if (t == token::ASSIGN)
328 <<
"Cannot continue reading reaction data from stream" 333 template<
class ReactionThermo>
341 ReactionThermo::thermoType(*thermoDatabase[species[0]]),
354 setThermo(thermoDatabase);
360 template<
class ReactionThermo>
369 const word& reactionTypeName = dict.
lookup(
"type");
371 typename dictionaryConstructorTable::iterator cstrIter
372 = dictionaryConstructorTablePtr_->find(reactionTypeName);
374 if (cstrIter == dictionaryConstructorTablePtr_->end())
377 <<
"Unknown reaction type " 378 << reactionTypeName <<
nl <<
nl 379 <<
"Valid reaction types are :" <<
nl 380 << dictionaryConstructorTablePtr_->sortedToc()
386 cstrIter()(species, thermoDatabase,
dict)
393 template<
class ReactionThermo>
398 << token::END_STATEMENT <<
nl;
402 template<
class ReactionThermo>
414 template<
class ReactionThermo>
426 template<
class ReactionThermo>
435 scalar pf, cf, pr, cr;
438 scalar omegaI = omega
440 p, T, c, pf, cf, lRef, pr, cr, rRef
445 const label si = lhs_[i].index;
446 const scalar sl = lhs_[i].stoichCoeff;
447 dcdt[si] -= sl*omegaI;
451 const label si = rhs_[i].index;
452 const scalar sr = rhs_[i].stoichCoeff;
453 dcdt[si] += sr*omegaI;
458 template<
class ReactionThermo>
473 scalar clippedT =
min(
max(T, this->Tlow()), this->Thigh());
475 const scalar kf = this->kf(p, clippedT, c);
476 const scalar kr = this->kr(kf, p, clippedT, c);
481 const label Nl = lhs_.size();
482 const label Nr = rhs_.size();
485 lRef = lhs_[slRef].index;
490 const label si = lhs_[
s].index;
494 const scalar
exp = lhs_[slRef].exponent;
495 pf *=
pow(
max(c[lRef], 0), exp);
501 const scalar
exp = lhs_[
s].exponent;
502 pf *=
pow(
max(c[si], 0), exp);
505 cf =
max(c[lRef], 0);
508 const scalar
exp = lhs_[slRef].exponent;
513 pf *=
pow(cf, exp - 1);
522 pf *=
pow(cf, exp - 1);
527 rRef = rhs_[srRef].index;
533 const label si = rhs_[
s].index;
536 const scalar
exp = rhs_[srRef].exponent;
537 pr *=
pow(
max(c[rRef], 0), exp);
543 const scalar
exp = rhs_[
s].exponent;
544 pr *=
pow(
max(c[si], 0), exp);
547 cr =
max(c[rRef], 0);
550 const scalar
exp = rhs_[srRef].exponent;
555 pr *=
pow(cr, exp - 1);
564 pr *=
pow(cr, exp - 1);
568 return pf*cf - pr*cr;
572 template<
class ReactionThermo>
587 scalar pf, cf, pr, cr;
590 omegaI = omega(p, T, c, pf, cf, lRef, pr, cr, rRef);
594 const label si = reduced ? c2s[lhs_[i].index] : lhs_[i].index;
595 const scalar sl = lhs_[i].stoichCoeff;
596 dcdt[si] -= sl*omegaI;
600 const label si = reduced ? c2s[rhs_[i].index] : rhs_[i].index;
601 const scalar sr = rhs_[i].stoichCoeff;
602 dcdt[si] += sr*omegaI;
605 kfwd = this->kf(p, T, c);
606 kbwd = this->kr(kfwd, p, T, c);
610 const label sj = reduced ? c2s[lhs_[j].index] : lhs_[j].index;
614 const label si = lhs_[i].index;
615 const scalar el = lhs_[i].exponent;
631 kf *= el*
pow(c[si], el - 1);
636 kf *=
pow(c[si], el);
642 const label si = reduced ? c2s[lhs_[i].index] : lhs_[i].index;
643 const scalar sl = lhs_[i].stoichCoeff;
648 const label si = reduced ? c2s[rhs_[i].index] : rhs_[i].index;
649 const scalar sr = rhs_[i].stoichCoeff;
656 const label sj = reduced ? c2s[rhs_[j].index] : rhs_[j].index;
660 const label si = rhs_[i].index;
661 const scalar er = rhs_[i].exponent;
677 kr *= er*
pow(c[si], er - 1);
682 kr *=
pow(c[si], er);
688 const label si = reduced ? c2s[lhs_[i].index] : lhs_[i].index;
689 const scalar sl = lhs_[i].stoichCoeff;
694 const label si = reduced ? c2s[rhs_[i].index] : rhs_[i].index;
695 const scalar sr = rhs_[i].stoichCoeff;
707 this->dcidc(p, T, c, dcidc);
712 sj = reduced ? c2s[sj] : sj;
718 reduced ? c2s[lhs_[i].index] : lhs_[i].index;
719 const scalar sl = lhs_[i].stoichCoeff;
720 J(si, sj) -= sl*dcidc[j]*omegaI;
725 reduced ? c2s[rhs_[i].index] : rhs_[i].index;
726 const scalar sr = rhs_[i].stoichCoeff;
727 J(si, sj) += sr*dcidc[j]*omegaI;
735 template<
class ReactionThermo>
753 scalar dkfdT = this->dkfdT(p, T, c);
754 scalar dkrdT = this->dkrdT(p, T, c, dkfdT, kr);
759 const label si = lhs_[i].index;
760 const scalar el = lhs_[i].exponent;
761 const scalar cExp =
pow(c[si], el);
771 const label si = rhs_[i].index;
772 const scalar er = rhs_[i].exponent;
773 const scalar cExp =
pow(c[si], er);
781 scalar dqidT = dkfdT - dkrdT + kf - kr;
785 scalar dcidT = this->dcidT(p, T, c);
791 const label si = reduced ? c2s[lhs_[i].index] : lhs_[i].index;
792 const scalar sl = lhs_[i].stoichCoeff;
793 J(si, indexT) -= sl*(dqidT + dcidT);
797 const label si = reduced ? c2s[rhs_[i].index] : rhs_[i].index;
798 const scalar sr = rhs_[i].stoichCoeff;
799 J(si, indexT) += sr*(dqidT + dcidT);
804 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.
bool empty() const
Return true if the UList is empty (ie, size() is zero)
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...
InfoProxy< token > info() const
Return info proxy.
const word & wordToken() const
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
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.
A token holds items read from Istream.
virtual void write(Ostream &) const
Write.
void putBack(const token &)
Put back token.
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.
bool good() const
Return true if next operation might succeed.
Class to hold the specie index and its coefficients in the.
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))
void reactionStrLeft(OStringStream &reaction) const
Return string representation of the left of the reaction.
dimensionedScalar exp(const dimensionedScalar &ds)
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
A class for handling words, derived from string.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
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...
DynamicList< T, SizeInc, SizeMult, SizeDiv > & shrink()
Shrink the allocated space to the number of elements used.
Ostream & writeKeyword(const keyType &)
Write the keyword followed by an appropriate indentation.
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.
void reactionStrRight(OStringStream &reaction) const
Return string representation of the right of the reaction.
T remove()
Remove and return the top element.
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.
void setLRhs(Istream &, const speciesTable &, List< specieCoeffs > &lhs, List< specieCoeffs > &rhs)
Construct the left- and right-hand-side reaction coefficients.
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
static const scalar VSMALL
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
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))
string str() const
Return the string.
dimensionedScalar beta("beta", dimless/dimTemperature, laminarTransport)
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...
bool contains(const word &) const
Does the list contain the specified name.
T & last()
Return the last element of the list.
void clear()
Clear the addressed list, i.e. set the size to zero.
static label nUnNamedReactions
Number of un-named reactions.
A class for handling character strings derived from std::string.
Output to memory buffer stream.
bool isPunctuation() const
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.