31 template<
class ThermoType>
40 sC_(this->nSpecie_,0),
41 sH_(this->nSpecie_,0),
42 sO_(this->nSpecie_,0),
43 sN_(this->nSpecie_,0),
46 const wordHashSet initSet(this->coeffsDict_.lookup(
"initialSet"));
49 searchInitSet_.append(chemistry.
mixture().species()[iter.key()]);
52 if (this->coeffsDict_.found(
"NGroupBased"))
54 NGroupBased_ = this->coeffsDict_.template lookup<label>(
"NGroupBased");
57 for (
label i=0; i<this->nSpecie_; i++)
60 chemistry.
mixture().specieComposition(i);
63 forAll(curSpecieComposition, j)
66 curSpecieComposition[j];
67 if (curElement.
name() ==
"C")
69 sC_[i] = curElement.
nAtoms();
71 else if (curElement.
name() ==
"H")
73 sH_[i] = curElement.
nAtoms();
75 else if (curElement.
name() ==
"O")
77 sO_[i] = curElement.
nAtoms();
79 else if (curElement.
name() ==
"N")
81 sN_[i] = curElement.
nAtoms();
85 Info<<
"element not considered"<<
endl;
94 template<
class ThermoType>
101 template<
class ThermoType>
110 scalarField& completeC(this->chemistry_.completeC());
113 for (
label i=0; i<this->nSpecie_; i++)
119 c1[this->nSpecie_] =
T;
120 c1[this->nSpecie_+1] =
p;
134 scalarField omegaV(this->chemistry_.reactions().size());
135 forAll(this->chemistry_.reactions(), i)
140 scalar omegaf, omegar;
141 const scalar omegai = R.
omega(p, T, c1, li, omegaf, omegar);
153 scalar sl = -R.
lhs()[
s].stoichCoeff;
172 while(!usedIndex.empty())
175 if (deltaBi[curIndex])
178 deltaBi[curIndex] =
false;
180 if (rABPos(ss, curIndex)==-1)
182 rABPos(ss, curIndex) = NbrABInit[ss];
184 rABNum(ss, rABPos(ss, curIndex)) = sl*omegai;
185 rABOtherSpec(ss, rABPos(ss, curIndex)) = curIndex;
189 rABNum(ss, rABPos(ss, curIndex)) += sl*omegai;
204 wA.append(sl*omegai);
213 scalar sl = R.
rhs()[
s].stoichCoeff;
232 while(!usedIndex.empty())
235 if (deltaBi[curIndex])
238 deltaBi[curIndex] =
false;
240 if (rABPos(ss, curIndex)==-1)
242 rABPos(ss, curIndex) = NbrABInit[ss];
244 rABNum(ss, rABPos(ss, curIndex)) = sl*omegai;
245 rABOtherSpec(ss, rABPos(ss, curIndex)) = curIndex;
249 rABNum(ss, rABPos(ss, curIndex)) += sl*omegai;
265 wA.append(sl*omegai);
278 if (PA[wAID[
id]] == 0.0)
280 PA[wAID[id]] = wA[id];
284 PA[wAID[id]] += wA[id];
289 if (CA[wAID[
id]] == 0.0)
291 CA[wAID[id]] = -wA[id];
295 CA[wAID[id]] += -wA[id];
308 for (
label i=0; i<this->nSpecie_; i++)
310 Pa[0] += sC_[i]*
max(0.0,(PA[i]-CA[i]));
311 Ca[0] += sC_[i]*
max(0.0,-(PA[i]-CA[i]));
312 Pa[1] += sH_[i]*
max(0.0,(PA[i]-CA[i]));
313 Ca[1] += sH_[i]*
max(0.0,-(PA[i]-CA[i]));
314 Pa[2] += sO_[i]*
max(0.0,(PA[i]-CA[i]));
315 Ca[2] += sO_[i]*
max(0.0,-(PA[i]-CA[i]));
316 Pa[3] += sN_[i]*
max(0.0,(PA[i]-CA[i]));
317 Ca[3] += sN_[i]*
max(0.0,-(PA[i]-CA[i]));
323 label speciesNumber = 0;
324 List<bool> disabledSpecies(this->nSpecie_,
false);
328 for (
label i=0; i<this->nSpecie_; i++)
330 this->activeSpecies_[i] =
false;
334 const labelList& SIS(this->searchInitSet_);
348 scalar alphaTmp = (sC_[q]*
mag(PA[q]-CA[q])/Pa[0]);
349 if (alphaTmp > alphaA)
357 scalar alphaTmp = (sH_[q]*
mag(PA[q]-CA[q])/Pa[1]);
358 if (alphaTmp > alphaA)
366 scalar alphaTmp = (sO_[q]*
mag(PA[q]-CA[q])/Pa[2]);
367 if (alphaTmp > alphaA)
375 scalar alphaTmp = (sN_[q]*
mag(PA[q]-CA[q])/Pa[3]);
376 if (alphaTmp > alphaA)
381 if (alphaA > this->tolerance())
383 this->activeSpecies_[q] =
true;
404 if (Rvalue[SIS[i]] > Rmax)
406 Rmax = Rvalue[SIS[i]];
411 QStart.append(specID);
414 Rvalue[specID] = 1.0;
415 this->activeSpecies_[specID] =
true;
422 scalar Den =
max(PA[u],CA[u]);
425 for (
label v=0; v<NbrABInit[u]; v++)
427 label otherSpec = rABOtherSpec(u, v);
428 scalar rAB =
mag(rABNum(u, v))/Den;
434 scalar Rtemp = Rvalue[u]*rAB;
436 if (Rvalue[otherSpec] < Rtemp)
438 Rvalue[otherSpec] = Rtemp;
440 if (Rtemp >= this->tolerance())
443 if (!this->activeSpecies_[otherSpec])
445 this->activeSpecies_[otherSpec] =
true;
456 label NDisabledSpecies(this->nSpecie_-speciesNumber);
463 while(NDisabledSpecies > NGroupBased_)
470 forAll(disabledSpecies, i)
473 if (!this->activeSpecies_[i] && !disabledSpecies[i])
476 Rdisabled[nD] = Rvalue[i];
485 for (
label i=0; i<NGroupBased_; i++)
487 disabledSpecies[Rindex[tmpIndex[i]]] =
true;
489 NDisabledSpecies -= NGroupBased_;
495 for (
label v=0; v<NbrABInit[i]; v++)
500 forAll(this->chemistry_.reactions(), i)
504 scalar omegai = omegaV[i];
509 scalar sl = -R.
lhs()[
s].stoichCoeff;
511 bool alreadyDisabled(
false);
518 if (disabledSpecies[sj])
520 alreadyDisabled=
true;
528 if (disabledSpecies[sj])
530 alreadyDisabled=
true;
540 for (
label v=0; v<NbrABInit[ss]; v++)
542 rABNum(ss, v) += sl*omegai;
547 while(!usedIndex.empty())
550 if (deltaBi[curIndex])
553 deltaBi[curIndex] =
false;
554 rABNum(ss, rABPos(ss, curIndex)) += sl*omegai;
563 scalar sl = R.
rhs()[
s].stoichCoeff;
565 bool alreadyDisabled(
false);
572 if (disabledSpecies[sj])
574 alreadyDisabled=
true;
582 if (disabledSpecies[sj])
584 alreadyDisabled=
true;
594 for (
label v=0; v<NbrABInit[ss]; v++)
596 rABNum(ss, v) += sl*omegai;
601 while(!usedIndex.empty())
604 if (deltaBi[curIndex])
606 deltaBi[curIndex] =
false;
607 rABNum(ss, rABPos(ss, curIndex)) += sl*omegai;
616 label u = QStart[qi];
623 scalar Den =
max(PA[u],CA[u]);
626 for (
label v=0; v<NbrABInit[u]; v++)
628 label otherSpec = rABOtherSpec(u, v);
629 if (!disabledSpecies[otherSpec])
631 scalar rAB =
mag(rABNum(u, v))/Den;
637 scalar Rtemp = Rvalue[u]*rAB;
639 if (Rvalue[otherSpec] < Rtemp)
641 Rvalue[otherSpec] = Rtemp;
642 if (Rtemp >= this->tolerance())
645 if (!this->activeSpecies_[otherSpec])
647 this->activeSpecies_[otherSpec] =
true;
662 forAll(this->chemistry_.reactions(), i)
665 this->chemistry_.reactionsDisabled()[i] =
false;
669 if (!this->activeSpecies_[ss])
671 this->chemistry_.reactionsDisabled()[i] =
true;
675 if (!this->chemistry_.reactionsDisabled()[i])
680 if (!this->activeSpecies_[ss])
682 this->chemistry_.reactionsDisabled()[i] =
true;
689 this->NsSimp_ = speciesNumber;
690 scalarField& simplifiedC(this->chemistry_.simplifiedC());
691 simplifiedC.
setSize(this->NsSimp_+2);
694 Field<label>& c2s(this->chemistry_.completeToSimplifiedIndex());
697 for (
label i=0; i<this->nSpecie_; i++)
699 if (this->activeSpecies_[i])
702 simplifiedC[j] = c[i];
704 if (!this->chemistry_.active(i))
706 this->chemistry_.setActive(i);
714 simplifiedC[this->NsSimp_] =
T;
715 simplifiedC[this->NsSimp_+1] =
p;
716 this->chemistry_.setNsDAC(this->NsSimp_);
719 this->chemistry_.setNSpecie(this->NsSimp_);
A FIFO stack based on a singly-linked list.
Extends standardChemistryModel by adding the TDAC method.
A HashTable with keys but without contents.
#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.
virtual ~DRGEP()
Destructor.
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
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.
Ostream & endl(Ostream &os)
Add newline and flush stream.
A list that is sorted upon construction or when explicitly requested with the sort() method...
const List< specieCoeffs > & lhs() const
Return the components of the left hand side.
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.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
const dimensionedScalar c1
First radiation constant: default SI units: [W/m^2].
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 setSize(const label)
Alter the addressed list size.
const word & name() const
Return the name of the element.
label nAtoms() const
Return the number of atoms of this element in the specie.
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
basicChemistryModel & chemistry
void setSize(const label)
Reset size of List.
const List< specieCoeffs > & rhs() const
Return the components of the right hand side.
#define R(A, B, C, D, E, F, K, M)
virtual void reduceMechanism(const scalar p, const scalar T, const scalarField &c, const label li)
Reduce the mechanism.
void push(const T &a)
Push an element onto the stack.
const labelList & indices() const
Return the list of sorted indices. Updated every sort.
const multiComponentMixture< ThermoType > & mixture() const
Return reference to the mixture.
dimensioned< scalar > mag(const dimensioned< Type > &)
T pop()
Pop the bottom element off the stack.
An abstract class for methods of chemical mechanism reduction.
void partialSort(int M)
Partial sort the list (if changed after construction time)
DRGEP(const IOdictionary &dict, TDACChemistryModel< ThermoType > &chemistry)
Construct from components.