TDACChemistryModel.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2016-2017 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "TDACChemistryModel.H"
27 #include "UniformField.H"
28 #include "localEulerDdtScheme.H"
29 #include "clockTime.H"
30 
31 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32 
33 template<class CompType, class ThermoType>
35 (
36  const fvMesh& mesh,
37  const word& phaseName
38 )
39 :
41  variableTimeStep_
42  (
43  mesh.time().controlDict().lookupOrDefault("adjustTimeStep", false)
44  || fv::localEulerDdt::enabled(mesh)
45  ),
46  timeSteps_(0),
47  NsDAC_(this->nSpecie_),
48  completeC_(this->nSpecie_, 0),
49  reactionsDisabled_(this->reactions_.size(), false),
50  specieComp_(this->nSpecie_),
51  completeToSimplifiedIndex_(this->nSpecie_, -1),
52  simplifiedToCompleteIndex_(this->nSpecie_),
53  tabulationResults_
54  (
55  IOobject
56  (
57  "TabulationResults",
58  this->time().timeName(),
59  this->mesh(),
60  IOobject::NO_READ,
61  IOobject::AUTO_WRITE
62  ),
63  mesh,
64  scalar(0)
65  )
66 {
67  basicMultiComponentMixture& composition = this->thermo().composition();
68 
69  // Store the species composition according to the species index
70  speciesTable speciesTab = composition.species();
71 
72  const HashTable<List<specieElement>>& specComp =
73  dynamicCast<const reactingMixture<ThermoType>&>(this->thermo())
74  .specieComposition();
75 
76  forAll(specieComp_, i)
77  {
78  specieComp_[i] = specComp[this->Y()[i].name()];
79  }
80 
82  (
83  *this,
84  *this
85  );
86 
87  // When the mechanism reduction method is used, the 'active' flag for every
88  // species should be initialized (by default 'active' is true)
89  if (mechRed_->active())
90  {
91  forAll(this->Y(), i)
92  {
93  IOobject header
94  (
95  this->Y()[i].name(),
96  mesh.time().timeName(),
97  mesh,
98  IOobject::NO_READ
99  );
100 
101  // Check if the species file is provided, if not set inactive
102  // and NO_WRITE
103  if (!header.typeHeaderOk<volScalarField>(true))
104  {
105  composition.setInactive(i);
106  this->Y()[i].writeOpt() = IOobject::NO_WRITE;
107  }
108  }
109  }
110 
112  (
113  *this,
114  *this
115  );
116 
117  if (mechRed_->log())
118  {
119  cpuReduceFile_ = logFile("cpu_reduce.out");
120  nActiveSpeciesFile_ = logFile("nActiveSpecies.out");
121  }
122 
123  if (tabulation_->log())
124  {
125  cpuAddFile_ = logFile("cpu_add.out");
126  cpuGrowFile_ = logFile("cpu_grow.out");
127  cpuRetrieveFile_ = logFile("cpu_retrieve.out");
128  }
129 
130  if (mechRed_->log() || tabulation_->log())
131  {
132  cpuSolveFile_ = logFile("cpu_solve.out");
133  }
134 }
135 
136 
137 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
138 
139 template<class CompType, class ThermoType>
141 {}
142 
143 
144 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
145 
146 template<class CompType, class ThermoType>
148 (
149  const scalarField& c, // Contains all species even when mechRed is active
150  const scalar T,
151  const scalar p,
152  scalarField& dcdt
153 ) const
154 {
155  const bool reduced = mechRed_->active();
156 
157  scalar pf, cf, pr, cr;
158  label lRef, rRef;
159 
160  dcdt = Zero;
161 
162  forAll(this->reactions_, i)
163  {
164  if (!reactionsDisabled_[i])
165  {
166  const Reaction<ThermoType>& R = this->reactions_[i];
167 
168  scalar omegai = omega
169  (
170  R, c, T, p, pf, cf, lRef, pr, cr, rRef
171  );
172 
173  forAll(R.lhs(), s)
174  {
175  label si = R.lhs()[s].index;
176  if (reduced)
177  {
178  si = completeToSimplifiedIndex_[si];
179  }
180 
181  const scalar sl = R.lhs()[s].stoichCoeff;
182  dcdt[si] -= sl*omegai;
183  }
184  forAll(R.rhs(), s)
185  {
186  label si = R.rhs()[s].index;
187  if (reduced)
188  {
189  si = completeToSimplifiedIndex_[si];
190  }
191 
192  const scalar sr = R.rhs()[s].stoichCoeff;
193  dcdt[si] += sr*omegai;
194  }
195  }
196  }
197 }
198 
199 
200 template<class CompType, class ThermoType>
202 (
203  const Reaction<ThermoType>& R,
204  const scalarField& c, // Contains all species even when mechRed is active
205  const scalar T,
206  const scalar p,
207  scalar& pf,
208  scalar& cf,
209  label& lRef,
210  scalar& pr,
211  scalar& cr,
212  label& rRef
213 ) const
214 {
215  const scalar kf = R.kf(p, T, c);
216  const scalar kr = R.kr(kf, p, T, c);
217 
218  const label Nl = R.lhs().size();
219  const label Nr = R.rhs().size();
220 
221  label slRef = 0;
222  lRef = R.lhs()[slRef].index;
223 
224  pf = kf;
225  for (label s=1; s<Nl; s++)
226  {
227  const label si = R.lhs()[s].index;
228 
229  if (c[si] < c[lRef])
230  {
231  const scalar exp = R.lhs()[slRef].exponent;
232  pf *= pow(max(0.0, c[lRef]), exp);
233  lRef = si;
234  slRef = s;
235  }
236  else
237  {
238  const scalar exp = R.lhs()[s].exponent;
239  pf *= pow(max(0.0, c[si]), exp);
240  }
241  }
242  cf = max(0.0, c[lRef]);
243 
244  {
245  const scalar exp = R.lhs()[slRef].exponent;
246  if (exp < 1)
247  {
248  if (cf > SMALL)
249  {
250  pf *= pow(cf, exp - 1);
251  }
252  else
253  {
254  pf = 0;
255  }
256  }
257  else
258  {
259  pf *= pow(cf, exp - 1);
260  }
261  }
262 
263  label srRef = 0;
264  rRef = R.rhs()[srRef].index;
265 
266  // Find the matrix element and element position for the rhs
267  pr = kr;
268  for (label s=1; s<Nr; s++)
269  {
270  const label si = R.rhs()[s].index;
271  if (c[si] < c[rRef])
272  {
273  const scalar exp = R.rhs()[srRef].exponent;
274  pr *= pow(max(0.0, c[rRef]), exp);
275  rRef = si;
276  srRef = s;
277  }
278  else
279  {
280  const scalar exp = R.rhs()[s].exponent;
281  pr *= pow(max(0.0, c[si]), exp);
282  }
283  }
284  cr = max(0.0, c[rRef]);
285 
286  {
287  const scalar exp = R.rhs()[srRef].exponent;
288  if (exp < 1)
289  {
290  if (cr>SMALL)
291  {
292  pr *= pow(cr, exp - 1);
293  }
294  else
295  {
296  pr = 0;
297  }
298  }
299  else
300  {
301  pr *= pow(cr, exp - 1);
302  }
303  }
304 
305  return pf*cf - pr*cr;
306 }
307 
308 
309 template<class CompType, class ThermoType>
311 (
312  const scalar time,
313  const scalarField& c,
314  scalarField& dcdt
315 ) const
316 {
317  const bool reduced = mechRed_->active();
318 
319  const scalar T = c[this->nSpecie_];
320  const scalar p = c[this->nSpecie_ + 1];
321 
322  if (reduced)
323  {
324  // When using DAC, the ODE solver submit a reduced set of species the
325  // complete set is used and only the species in the simplified mechanism
326  // are updated
327  this->c_ = completeC_;
328 
329  // Update the concentration of the species in the simplified mechanism
330  // the other species remain the same and are used only for third-body
331  // efficiencies
332  for (label i=0; i<NsDAC_; i++)
333  {
334  this->c_[simplifiedToCompleteIndex_[i]] = max(0.0, c[i]);
335  }
336  }
337  else
338  {
339  for (label i=0; i<this->nSpecie(); i++)
340  {
341  this->c_[i] = max(0.0, c[i]);
342  }
343  }
344 
345  omega(this->c_, T, p, dcdt);
346 
347  // Constant pressure
348  // dT/dt = ...
349  scalar rho = 0;
350  for (label i=0; i<this->c_.size(); i++)
351  {
352  const scalar W = this->specieThermo_[i].W();
353  rho += W*this->c_[i];
354  }
355 
356  scalar cp = 0;
357  for (label i=0; i<this->c_.size(); i++)
358  {
359  // cp function returns [J/(kmol K)]
360  cp += this->c_[i]*this->specieThermo_[i].cp(p, T);
361  }
362  cp /= rho;
363 
364  // When mechanism reduction is active
365  // dT is computed on the reduced set since dcdt is null
366  // for species not involved in the simplified mechanism
367  scalar dT = 0;
368  for (label i=0; i<this->nSpecie_; i++)
369  {
370  label si;
371  if (reduced)
372  {
373  si = simplifiedToCompleteIndex_[i];
374  }
375  else
376  {
377  si = i;
378  }
379 
380  // ha function returns [J/kmol]
381  const scalar hi = this->specieThermo_[si].ha(p, T);
382  dT += hi*dcdt[i];
383  }
384  dT /= rho*cp;
385 
386  dcdt[this->nSpecie_] = -dT;
387 
388  // dp/dt = ...
389  dcdt[this->nSpecie_ + 1] = 0;
390 }
391 
392 
393 template<class CompType, class ThermoType>
395 (
396  const scalar t,
397  const scalarField& c,
398  scalarSquareMatrix& dfdc
399 ) const
400 {
401  const bool reduced = mechRed_->active();
402 
403  // If the mechanism reduction is active, the computed Jacobian
404  // is compact (size of the reduced set of species)
405  // but according to the informations of the complete set
406  // (i.e. for the third-body efficiencies)
407 
408  const scalar T = c[this->nSpecie_];
409  const scalar p = c[this->nSpecie_ + 1];
410 
411  if (reduced)
412  {
413  this->c_ = completeC_;
414  for (label i=0; i<NsDAC_; i++)
415  {
416  this->c_[simplifiedToCompleteIndex_[i]] = max(0.0, c[i]);
417  }
418  }
419  else
420  {
421  forAll(this->c_, i)
422  {
423  this->c_[i] = max(c[i], 0.0);
424  }
425  }
426 
427  dfdc = Zero;
428 
429  forAll(this->reactions_, ri)
430  {
431  if (!reactionsDisabled_[ri])
432  {
433  const Reaction<ThermoType>& R = this->reactions_[ri];
434 
435  const scalar kf0 = R.kf(p, T, this->c_);
436  const scalar kr0 = R.kr(kf0, p, T, this->c_);
437 
438  forAll(R.lhs(), j)
439  {
440  label sj = R.lhs()[j].index;
441  if (reduced)
442  {
443  sj = completeToSimplifiedIndex_[sj];
444  }
445  scalar kf = kf0;
446  forAll(R.lhs(), i)
447  {
448  const label si = R.lhs()[i].index;
449  const scalar el = R.lhs()[i].exponent;
450  if (i == j)
451  {
452  if (el < 1)
453  {
454  if (this->c_[si] > SMALL)
455  {
456  kf *= el*pow(this->c_[si] + VSMALL, el - 1);
457  }
458  else
459  {
460  kf = 0;
461  }
462  }
463  else
464  {
465  kf *= el*pow(this->c_[si], el - 1);
466  }
467  }
468  else
469  {
470  kf *= pow(this->c_[si], el);
471  }
472  }
473 
474  forAll(R.lhs(), i)
475  {
476  label si = R.lhs()[i].index;
477  if (reduced)
478  {
479  si = completeToSimplifiedIndex_[si];
480  }
481  const scalar sl = R.lhs()[i].stoichCoeff;
482  dfdc(si, sj) -= sl*kf;
483  }
484  forAll(R.rhs(), i)
485  {
486  label si = R.rhs()[i].index;
487  if (reduced)
488  {
489  si = completeToSimplifiedIndex_[si];
490  }
491  const scalar sr = R.rhs()[i].stoichCoeff;
492  dfdc(si, sj) += sr*kf;
493  }
494  }
495 
496  forAll(R.rhs(), j)
497  {
498  label sj = R.rhs()[j].index;
499  if (reduced)
500  {
501  sj = completeToSimplifiedIndex_[sj];
502  }
503  scalar kr = kr0;
504  forAll(R.rhs(), i)
505  {
506  const label si = R.rhs()[i].index;
507  const scalar er = R.rhs()[i].exponent;
508  if (i == j)
509  {
510  if (er < 1)
511  {
512  if (this->c_[si] > SMALL)
513  {
514  kr *= er*pow(this->c_[si] + VSMALL, er - 1);
515  }
516  else
517  {
518  kr = 0;
519  }
520  }
521  else
522  {
523  kr *= er*pow(this->c_[si], er - 1);
524  }
525  }
526  else
527  {
528  kr *= pow(this->c_[si], er);
529  }
530  }
531 
532  forAll(R.lhs(), i)
533  {
534  label si = R.lhs()[i].index;
535  if (reduced)
536  {
537  si = completeToSimplifiedIndex_[si];
538  }
539  const scalar sl = R.lhs()[i].stoichCoeff;
540  dfdc(si, sj) += sl*kr;
541  }
542  forAll(R.rhs(), i)
543  {
544  label si = R.rhs()[i].index;
545  if (reduced)
546  {
547  si = completeToSimplifiedIndex_[si];
548  }
549  const scalar sr = R.rhs()[i].stoichCoeff;
550  dfdc(si, sj) -= sr*kr;
551  }
552  }
553  }
554  }
555 
556  // Calculate the dcdT elements numerically
557  const scalar delta = 1e-3;
558 
559  omega(this->c_, T + delta, p, this->dcdt_);
560  for (label i=0; i<this->nSpecie_; i++)
561  {
562  dfdc(i, this->nSpecie_) = this->dcdt_[i];
563  }
564 
565  omega(this->c_, T - delta, p, this->dcdt_);
566  for (label i=0; i<this->nSpecie_; i++)
567  {
568  dfdc(i, this->nSpecie_) =
569  0.5*(dfdc(i, this->nSpecie_) - this->dcdt_[i])/delta;
570  }
571 
572  dfdc(this->nSpecie_, this->nSpecie_) = 0;
573  dfdc(this->nSpecie_ + 1, this->nSpecie_) = 0;
574 }
575 
576 
577 template<class CompType, class ThermoType>
579 (
580  const scalar t,
581  const scalarField& c,
582  scalarField& dcdt,
583  scalarSquareMatrix& dfdc
584 ) const
585 {
586  jacobian(t, c, dfdc);
587 
588  const scalar T = c[this->nSpecie_];
589  const scalar p = c[this->nSpecie_ + 1];
590 
591  // Note: Uses the c_ field initialized by the call to jacobian above
592  omega(this->c_, T, p, dcdt);
593 }
594 
595 
596 template<class CompType, class ThermoType>
597 template<class DeltaTType>
599 (
600  const DeltaTType& deltaT
601 )
602 {
603  // Increment counter of time-step
604  timeSteps_++;
605 
606  const bool reduced = mechRed_->active();
607 
608  label nAdditionalEqn = (tabulation_->variableTimeStep() ? 1 : 0);
609 
610  basicMultiComponentMixture& composition = this->thermo().composition();
611 
612  // CPU time analysis
613  const clockTime clockTime_= clockTime();
614  clockTime_.timeIncrement();
615  scalar reduceMechCpuTime_ = 0;
616  scalar addNewLeafCpuTime_ = 0;
617  scalar growCpuTime_ = 0;
618  scalar solveChemistryCpuTime_ = 0;
619  scalar searchISATCpuTime_ = 0;
620 
621  this->resetTabulationResults();
622 
623  // Average number of active species
624  scalar nActiveSpecies = 0;
625  scalar nAvg = 0;
626 
628 
629  scalar deltaTMin = GREAT;
630 
631  if (!this->chemistry_)
632  {
633  return deltaTMin;
634  }
635 
636  const volScalarField rho
637  (
638  IOobject
639  (
640  "rho",
641  this->time().timeName(),
642  this->mesh(),
643  IOobject::NO_READ,
644  IOobject::NO_WRITE,
645  false
646  ),
647  this->thermo().rho()
648  );
649 
650  const scalarField& T = this->thermo().T();
651  const scalarField& p = this->thermo().p();
652 
653  scalarField c(this->nSpecie_);
654  scalarField c0(this->nSpecie_);
655 
656  // Composition vector (Yi, T, p)
657  scalarField phiq(this->nEqns() + nAdditionalEqn);
658 
659  scalarField Rphiq(this->nEqns() + nAdditionalEqn);
660 
661  forAll(rho, celli)
662  {
663  const scalar rhoi = rho[celli];
664  scalar pi = p[celli];
665  scalar Ti = T[celli];
666 
667  for (label i=0; i<this->nSpecie_; i++)
668  {
669  c[i] = rhoi*this->Y_[i][celli]/this->specieThermo_[i].W();
670  c0[i] = c[i];
671  phiq[i] = this->Y()[i][celli];
672  }
673  phiq[this->nSpecie()]=Ti;
674  phiq[this->nSpecie() + 1]=pi;
675  if (tabulation_->variableTimeStep())
676  {
677  phiq[this->nSpecie() + 2] = deltaT[celli];
678  }
679 
680 
681  // Initialise time progress
682  scalar timeLeft = deltaT[celli];
683 
684  // Not sure if this is necessary
685  Rphiq = Zero;
686 
687  clockTime_.timeIncrement();
688 
689  // When tabulation is active (short-circuit evaluation for retrieve)
690  // It first tries to retrieve the solution of the system with the
691  // information stored through the tabulation method
692  if (tabulation_->active() && tabulation_->retrieve(phiq, Rphiq))
693  {
694  // Retrieved solution stored in Rphiq
695  for (label i=0; i<this->nSpecie(); i++)
696  {
697  c[i] = rhoi*Rphiq[i]/this->specieThermo_[i].W();
698  }
699 
700  searchISATCpuTime_ += clockTime_.timeIncrement();
701  }
702  // This position is reached when tabulation is not used OR
703  // if the solution is not retrieved.
704  // In the latter case, it adds the information to the tabulation
705  // (it will either expand the current data or add a new stored point).
706  else
707  {
708  // Store total time waiting to attribute to add or grow
709  scalar timeTmp = clockTime_.timeIncrement();
710 
711  if (reduced)
712  {
713  // Reduce mechanism change the number of species (only active)
714  mechRed_->reduceMechanism(c, Ti, pi);
715  nActiveSpecies += mechRed_->NsSimp();
716  nAvg++;
717  scalar timeIncr = clockTime_.timeIncrement();
718  reduceMechCpuTime_ += timeIncr;
719  timeTmp += timeIncr;
720  }
721 
722  // Calculate the chemical source terms
723  while (timeLeft > SMALL)
724  {
725  scalar dt = timeLeft;
726  if (reduced)
727  {
728  // completeC_ used in the overridden ODE methods
729  // to update only the active species
730  completeC_ = c;
731 
732  // Solve the reduced set of ODE
733  this->solve
734  (
735  simplifiedC_, Ti, pi, dt, this->deltaTChem_[celli]
736  );
737 
738  for (label i=0; i<NsDAC_; i++)
739  {
740  c[simplifiedToCompleteIndex_[i]] = simplifiedC_[i];
741  }
742  }
743  else
744  {
745  this->solve(c, Ti, pi, dt, this->deltaTChem_[celli]);
746  }
747  timeLeft -= dt;
748  }
749 
750  {
751  scalar timeIncr = clockTime_.timeIncrement();
752  solveChemistryCpuTime_ += timeIncr;
753  timeTmp += timeIncr;
754  }
755 
756  // If tabulation is used, we add the information computed here to
757  // the stored points (either expand or add)
758  if (tabulation_->active())
759  {
760  forAll(c, i)
761  {
762  Rphiq[i] = c[i]/rhoi*this->specieThermo_[i].W();
763  }
764  if (tabulation_->variableTimeStep())
765  {
766  Rphiq[Rphiq.size()-3] = Ti;
767  Rphiq[Rphiq.size()-2] = pi;
768  Rphiq[Rphiq.size()-1] = deltaT[celli];
769  }
770  else
771  {
772  Rphiq[Rphiq.size()-2] = Ti;
773  Rphiq[Rphiq.size()-1] = pi;
774  }
775  label growOrAdd =
776  tabulation_->add(phiq, Rphiq, rhoi, deltaT[celli]);
777  if (growOrAdd)
778  {
779  this->setTabulationResultsAdd(celli);
780  addNewLeafCpuTime_ += clockTime_.timeIncrement() + timeTmp;
781  }
782  else
783  {
784  this->setTabulationResultsGrow(celli);
785  growCpuTime_ += clockTime_.timeIncrement() + timeTmp;
786  }
787  }
788 
789  // When operations are done and if mechanism reduction is active,
790  // the number of species (which also affects nEqns) is set back
791  // to the total number of species (stored in the mechRed object)
792  if (reduced)
793  {
794  this->nSpecie_ = mechRed_->nSpecie();
795  }
796  deltaTMin = min(this->deltaTChem_[celli], deltaTMin);
797  }
798 
799  // Set the RR vector (used in the solver)
800  for (label i=0; i<this->nSpecie_; i++)
801  {
802  this->RR_[i][celli] =
803  (c[i] - c0[i])*this->specieThermo_[i].W()/deltaT[celli];
804  }
805  }
806 
807  if (mechRed_->log() || tabulation_->log())
808  {
809  cpuSolveFile_()
810  << this->time().timeOutputValue()
811  << " " << solveChemistryCpuTime_ << endl;
812  }
813 
814  if (mechRed_->log())
815  {
816  cpuReduceFile_()
817  << this->time().timeOutputValue()
818  << " " << reduceMechCpuTime_ << endl;
819  }
820 
821  if (tabulation_->active())
822  {
823  // Every time-step, look if the tabulation should be updated
824  tabulation_->update();
825 
826  // Write the performance of the tabulation
827  tabulation_->writePerformance();
828 
829  if (tabulation_->log())
830  {
831  cpuRetrieveFile_()
832  << this->time().timeOutputValue()
833  << " " << searchISATCpuTime_ << endl;
834 
835  cpuGrowFile_()
836  << this->time().timeOutputValue()
837  << " " << growCpuTime_ << endl;
838 
839  cpuAddFile_()
840  << this->time().timeOutputValue()
841  << " " << addNewLeafCpuTime_ << endl;
842  }
843  }
844 
845  if (reduced && nAvg && mechRed_->log())
846  {
847  // Write average number of species
848  nActiveSpeciesFile_()
849  << this->time().timeOutputValue()
850  << " " << nActiveSpecies/nAvg << endl;
851  }
852 
853  if (Pstream::parRun())
854  {
855  List<bool> active(composition.active());
856  Pstream::listCombineGather(active, orEqOp<bool>());
857  Pstream::listCombineScatter(active);
858 
859  forAll(active, i)
860  {
861  if (active[i])
862  {
863  composition.setActive(i);
864  }
865  }
866  }
867 
868  forAll(this->Y(), i)
869  {
870  if (composition.active(i))
871  {
872  this->Y()[i].writeOpt() = IOobject::AUTO_WRITE;
873  }
874  }
875 
876  return deltaTMin;
877 }
878 
879 
880 template<class CompType, class ThermoType>
882 (
883  const scalar deltaT
884 )
885 {
886  // Don't allow the time-step to change more than a factor of 2
887  return min
888  (
890  2*deltaT
891  );
892 }
893 
894 
895 template<class CompType, class ThermoType>
897 (
898  const scalarField& deltaT
899 )
900 {
901  return this->solve<scalarField>(deltaT);
902 }
903 
904 
905 template<class CompType, class ThermoType>
907 (
908  const label celli
909 )
910 {
911  tabulationResults_[celli] = 0.0;
912 }
913 
914 
915 template<class CompType, class ThermoType>
917 (
918  const label celli
919 )
920 {
921  tabulationResults_[celli] = 1.0;
922 }
923 
924 
925 template<class CompType, class ThermoType>
928 (
929  const label celli
930 )
931 {
932  tabulationResults_[celli] = 2.0;
933 }
934 
935 
936 // ************************************************************************* //
scalar delta
virtual scalar kr(const scalar kfwd, const scalar p, const scalar T, const scalarField &c) const
Reverse rate constant from the given forward rate constant.
Definition: Reaction.C:404
virtual scalar kf(const scalar p, const scalar T, const scalarField &c) const
Forward rate constant.
Definition: Reaction.C:392
A class representing the concept of a uniform field which stores only the single value and providing ...
Definition: UniformField.H:47
Extends chemistryModel by adding the TDAC method.
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:428
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
bool active(label speciei) const
Return true for active species.
void setTabulationResultsGrow(const label celli)
const List< specieCoeffs > & lhs() const
Definition: ReactionI.H:51
void setTabulationResultsRetrieve(const label celli)
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
basicMultiComponentMixture & composition
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:163
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:253
virtual ~TDACChemistryModel()
Destructor.
const speciesTable & species() const
Return the table of species.
virtual void omega(const scalarField &c, const scalar T, const scalar p, scalarField &dcdt) const
dc/dt = omega, rate of change in concentration, for each species
Simple extension of ReactionThermo to handle reaction kinetics in addition to the equilibrium thermod...
Definition: Reaction.H:53
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
void setInactive(label speciei)
Set speciei inactive.
psiReactionThermo & thermo
Definition: createFields.H:31
label nSpecie
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))
const dimensionedScalar e
Elementary charge.
Definition: doubleFloat.H:78
dynamicFvMesh & mesh
dimensionedScalar exp(const dimensionedScalar &ds)
A class for handling words, derived from string.
Definition: word.H:59
rhoEqn solve()
word timeName
Definition: getTimeIndex.H:3
static const zero Zero
Definition: zero.H:91
An STL-conforming hash table.
Definition: HashTable.H:62
void setTabulationResultsAdd(const label celli)
void jacobian(const scalar t, const scalarField &c, scalarSquareMatrix &dfdc) const
Pure jacobian function for tabulation.
void setActive(label speciei)
Set speciei active.
const volScalarField & cp
virtual void derivatives(const scalar t, const scalarField &c, scalarField &dcdt) const
Calculate the derivatives in dydx.
Info<< "Predicted p max-min : "<< max(p).value()<< " "<< min(p).value()<< endl;rho==max(psi *p+alphal *rhol0+((alphav *psiv+alphal *psil) - psi) *pSat, rhoMin);# 1 "/home/ubuntu/OpenFOAM-5.0/applications/solvers/multiphase/cavitatingFoam/alphavPsi.H" 1{ alphav=max(min((rho - rholSat)/(rhovSat - rholSat), scalar(1)), scalar(0));alphal=1.0 - alphav;Info<< "max-min alphav: "<< max(alphav).value()<< " "<< min(alphav).value()<< endl;psiModel-> correct()
Definition: pEqn.H:72
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
bool active(const label i) const
Extends base chemistry model by adding a thermo package, and ODE functions. Introduces chemistry equa...
A wordList with hashed indices for faster lookup by name.
PtrList< volScalarField > & Y
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
const dimensionedScalar c
Speed of light in a vacuum.
double timeIncrement() const
Return time (in seconds) since last call to timeIncrement()
Definition: clockTime.C:62
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:92
const List< specieCoeffs > & rhs() const
Definition: ReactionI.H:59
Starts timing (using rtc) and returns elapsed time from start. Better resolution (2uSec instead of ~2...
Definition: clockTime.H:49