31 template<
class ThermoType>
34 template<
class ThermoType>
40 template<
class ThermoType>
43 const PtrList<ThermoType>& speciesThermo
46 typename ThermoType::thermoType rhsThermo
49 *speciesThermo[rhs()[0].index].
W()
50 *speciesThermo[rhs()[0].index]
53 for (
label i=1; i<rhs().size(); ++i)
57 *speciesThermo[rhs()[i].index].W()
58 *speciesThermo[rhs()[i].index];
61 typename ThermoType::thermoType lhsThermo
64 *speciesThermo[lhs()[0].index].
W()
65 *speciesThermo[lhs()[0].index]
68 for (
label i=1; i<lhs().size(); ++i)
72 *speciesThermo[lhs()[i].index].W()
73 *speciesThermo[lhs()[i].index];
78 if (
mag(lhsThermo.Y() - rhsThermo.Y()) > 0.1)
81 <<
"Mass imbalance for reaction " <<
name() <<
": "
82 <<
mag(lhsThermo.Y() - rhsThermo.Y()) <<
" kg/kmol"
86 ThermoType::thermoType::operator=(lhsThermo == rhsThermo);
92 template<
class ThermoType>
102 ThermoType::thermoType(speciesThermo[0]),
106 setThermo(speciesThermo);
110 template<
class ThermoType>
118 ThermoType::thermoType(r),
124 template<
class ThermoType>
133 ThermoType::thermoType(speciesThermo[0]),
134 Tlow_(
dict.lookupOrDefault<scalar>(
"Tlow", TlowDefault)),
135 Thigh_(
dict.lookupOrDefault<scalar>(
"Thigh", ThighDefault))
137 setThermo(speciesThermo);
143 template<
class ThermoType>
154 typename dictionaryConstructorTable::iterator cstrIter =
155 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, speciesThermo,
dict)
187 template<
class ThermoType>
199 if (!objectRegistryConstructorTablePtr_)
201 return New(species, speciesThermo,
dict);
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, speciesThermo,
dict)
251 cstrIter()(species, speciesThermo, ob,
dict)
258 template<
class ThermoType>
264 order += lhs()[i].exponent;
270 template<
class ThermoType>
276 order += rhs()[i].exponent;
282 template<
class ThermoType>
297 const label si = lhs()[i].index;
299 Cf *=
c[si] >= small || el >= 1 ?
pow(
max(
c[si], 0), el) : 0;
304 const label si = rhs()[i].index;
306 Cr *=
c[si] >= small || er >= 1 ?
pow(
max(
c[si], 0), er) : 0;
311 template<
class ThermoType>
322 const scalar clippedT =
min(
max(
T, this->Tlow()), this->Thigh());
325 const scalar kf = this->kf(
p, clippedT,
c, li);
326 const scalar kr = this->kr(kf,
p, clippedT,
c, li);
330 this->
C(p,
T,
c, li, Cf, Cr);
335 return omegaf - omegar;
339 template<
class ThermoType>
352 scalar omegaf, omegar;
353 const scalar
omega = this->
omega(p,
T,
c, li, omegaf, omegar);
357 const label si = reduced ? c2s[lhs()[i].index] : lhs()[i].index;
358 const scalar sl = lhs()[i].stoichCoeff;
359 dNdtByV[Nsi0 + si] -= sl*
omega;
363 const label si = reduced ? c2s[rhs()[i].index] : rhs()[i].index;
364 const scalar sr = rhs()[i].stoichCoeff;
365 dNdtByV[Nsi0 + si] += sr*
omega;
370 template<
class ThermoType>
388 const scalar kf = this->kf(
p,
T,
c, li);
389 const scalar kr = this->kr(kf,
p,
T,
c, li);
393 this->
C(p,
T,
c, li, Cf, Cr);
396 const scalar
omega = kf*Cf - kr*Cr;
401 const label si = reduced ? c2s[lhs()[i].index] : lhs()[i].index;
402 const scalar sl = lhs()[i].stoichCoeff;
403 dNdtByV[Nsi0 + si] -= sl*
omega;
407 const label si = reduced ? c2s[rhs()[i].index] : rhs()[i].index;
408 const scalar sr = rhs()[i].stoichCoeff;
409 dNdtByV[Nsi0 + si] += sr*
omega;
417 const label sj = reduced ? c2s[lhs()[j].index] : lhs()[j].index;
422 const label si = lhs()[i].index;
427 c[si] >= small || el >= 1
434 c[si] >= small || el >= 1
442 const label si = reduced ? c2s[lhs()[i].index] : lhs()[i].index;
443 const scalar sl = lhs()[i].stoichCoeff;
444 ddNdtByVdcTp(Nsi0 + si, Nsi0 + sj) -= sl*kf*dCfdcj;
448 const label si = reduced ? c2s[rhs()[i].index] : rhs()[i].index;
449 const scalar sr = rhs()[i].stoichCoeff;
450 ddNdtByVdcTp(Nsi0 + si, Nsi0 + sj) += sr*kf*dCfdcj;
456 const label sj = reduced ? c2s[rhs()[j].index] : rhs()[j].index;
461 const label si = rhs()[i].index;
466 c[si] >= small || er >= 1
473 c[si] >= small || er >= 1
481 const label si = reduced ? c2s[lhs()[i].index] : lhs()[i].index;
482 const scalar sl = lhs()[i].stoichCoeff;
483 ddNdtByVdcTp(Nsi0 + si, Nsi0 + sj) += sl*kr*dCrcj;
487 const label si = reduced ? c2s[rhs()[i].index] : rhs()[i].index;
488 const scalar sr = rhs()[i].stoichCoeff;
489 ddNdtByVdcTp(Nsi0 + si, Nsi0 + sj) -= sr*kr*dCrcj;
497 const scalar dkfdT = this->dkfdT(
p,
T,
c, li);
498 const scalar dkrdT = this->dkrdT(
p,
T,
c, li, dkfdT, kr);
500 const scalar dwdT = dkfdT*Cf - dkrdT*Cr;
503 const label si = reduced ? c2s[lhs()[i].index] : lhs()[i].index;
504 const scalar sl = lhs()[i].stoichCoeff;
505 ddNdtByVdcTp(Nsi0 + si, Tsi) -= sl*dwdT;
509 const label si = reduced ? c2s[rhs()[i].index] : rhs()[i].index;
510 const scalar sr = rhs()[i].stoichCoeff;
511 ddNdtByVdcTp(Nsi0 + si, Tsi) += sr*dwdT;
522 this->dkfdc(
p,
T,
c, li, dkfdc);
523 this->dkrdc(
p,
T,
c, li, dkfdc, kr, dkrdc);
527 const label sj = reduced ? c2s[j] : j;
529 if (sj == -1)
continue;
531 const scalar dwdc = dkfdc[j]*Cf - dkrdc[j]*Cr;
534 const label si = reduced ? c2s[lhs()[i].index] : lhs()[i].index;
535 const scalar sl = lhs()[i].stoichCoeff;
536 ddNdtByVdcTp(Nsi0 + si, Nsi0 + sj) -= sl*dwdc;
540 const label si = reduced ? c2s[rhs()[i].index] : rhs()[i].index;
541 const scalar sr = rhs()[i].stoichCoeff;
542 ddNdtByVdcTp(Nsi0 + si, Nsi0 + sj) += sr*dwdc;
549 template<
class ThermoType>
static const Foam::dimensionedScalar C("C", Foam::dimTemperature, 234.5)
#define forAll(list, i)
Loop across all elements in list.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Simple extension of ThermoType to handle reaction kinetics in addition to the equilibrium thermodynam...
virtual void write(Ostream &) const
Write.
static scalar TlowDefault
Default temperature limits of applicability of reaction rates.
static scalar ThighDefault
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.
void C(const scalar p, const scalar T, const scalarField &c, const label li, scalar &Cf, scalar &Cr) const
Concentration powers.
dimensionSet kfDims() const
Dimensions of the forward rate.
dimensionSet krDims() const
Dimensions of the reverse rate.
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.
static autoPtr< Reaction< ThermoType > > New(const speciesTable &species, const PtrList< ThermoType > &speciesThermo, const dictionary &dict)
Return a pointer to new reaction created from a dictionary.
scalar omega(const scalar p, const scalar T, const scalarField &c, const label li, scalar &omegaf, scalar &omegar) const
Net reaction rate.
Reaction(const speciesTable &species, const PtrList< ThermoType > &speciesThermo, const List< specieCoeffs > &lhs, const List< specieCoeffs > &rhs)
Construct from components.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
A list of keyword definitions, which are a keyword followed by any number of values (e....
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Dimension set for the base types.
A wordList with hashed indices for faster lookup by name.
Registry of regIOobjects.
Convenience class to handle the input of constant rotational speed. Reads an omega entry with default...
Reaction base-class holding the specie names and coefficients.
void write(Ostream &) const
Write.
Type for exponents of species in reaction. Can take either integer or scalar value,...
bool removeTrailing(const char)
Remove trailing character returning true if string changed.
A class for handling words, derived from string.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const dimensionedScalar c
Speed of light in a vacuum.
errorManipArg< error, int > exit(error &err, const int errNo=1)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
word name(const bool)
Return a word representation of a bool.
int order(const scalar s)
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
const dimensionSet dimTime
const dimensionSet dimVolume
dimensioned< scalar > mag(const dimensioned< Type > &)
const dimensionSet dimMoles
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
const scalarList W(::W(thermo))