TDACChemistryModel.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2016-2020 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 ReactionThermo, class ThermoType>
35 (
36  const ReactionThermo& thermo
37 )
38 :
40  variableTimeStep_
41  (
42  this->mesh().time().controlDict().lookupOrDefault
43  (
44  "adjustTimeStep",
45  false
46  )
47  || fv::localEulerDdt::enabled(this->mesh())
48  ),
49  timeSteps_(0),
50  NsDAC_(this->nSpecie_),
51  completeC_(this->nSpecie_, 0),
52  reactionsDisabled_(this->reactions_.size(), false),
53  specieComp_(this->nSpecie_),
54  completeToSimplifiedIndex_(this->nSpecie_, -1),
55  simplifiedToCompleteIndex_(this->nSpecie_),
56  tabulationResults_
57  (
58  IOobject
59  (
60  thermo.phasePropertyName("TabulationResults"),
61  this->time().timeName(),
62  this->mesh(),
63  IOobject::NO_READ,
64  IOobject::AUTO_WRITE
65  ),
66  this->mesh(),
67  scalar(0)
68  )
69 {
70  const basicSpecieMixture& composition = this->thermo().composition();
71 
72  const HashTable<List<specieElement>>& specComp =
73  dynamicCast<const multiComponentMixture<ThermoType>&>(this->thermo())
74  .specieComposition();
75 
76  forAll(specieComp_, i)
77  {
78  specieComp_[i] = specComp[this->Y()[i].member()];
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  this->mesh().time().timeName(),
97  this->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  }
107  }
108  }
109 
111  (
112  *this,
113  *this
114  );
115 
116  if (mechRed_->log())
117  {
118  cpuReduceFile_ = logFile("cpu_reduce.out");
119  nActiveSpeciesFile_ = logFile("nActiveSpecies.out");
120  }
121 
122  if (tabulation_->log())
123  {
124  cpuAddFile_ = logFile("cpu_add.out");
125  cpuGrowFile_ = logFile("cpu_grow.out");
126  cpuRetrieveFile_ = logFile("cpu_retrieve.out");
127  }
128 
129  if (mechRed_->log() || tabulation_->log())
130  {
131  cpuSolveFile_ = logFile("cpu_solve.out");
132  }
133 }
134 
135 
136 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
137 
138 template<class ReactionThermo, class ThermoType>
140 {}
141 
142 
143 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
144 
145 template<class ReactionThermo, class ThermoType>
147 (
148  const scalar p,
149  const scalar T,
150  const scalarField& c, // Contains all species even when mechRed is active
151  const label li,
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 = R.omega
169  (
170  p, T, c, li, 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 ReactionThermo, class ThermoType>
202 (
203  const Reaction<ThermoType>& R,
204  const scalar p,
205  const scalar T,
206  const scalarField& c, // Contains all species even when mechRed is active
207  const label li,
208  scalar& pf,
209  scalar& cf,
210  label& lRef,
211  scalar& pr,
212  scalar& cr,
213  label& rRef
214 ) const
215 {
216  const scalar kf = R.kf(p, T, c, li);
217  const scalar kr = R.kr(kf, p, T, c, li);
218 
219  const label Nl = R.lhs().size();
220  const label Nr = R.rhs().size();
221 
222  label slRef = 0;
223  lRef = R.lhs()[slRef].index;
224 
225  pf = kf;
226  for (label s=1; s<Nl; s++)
227  {
228  const label si = R.lhs()[s].index;
229 
230  if (c[si] < c[lRef])
231  {
232  const scalar exp = R.lhs()[slRef].exponent;
233  pf *= pow(max(c[lRef], 0), exp);
234  lRef = si;
235  slRef = s;
236  }
237  else
238  {
239  const scalar exp = R.lhs()[s].exponent;
240  pf *= pow(max(c[si], 0), exp);
241  }
242  }
243  cf = max(c[lRef], 0);
244 
245  {
246  const scalar exp = R.lhs()[slRef].exponent;
247  if (exp < 1)
248  {
249  if (cf > small)
250  {
251  pf *= pow(cf, exp - 1);
252  }
253  else
254  {
255  pf = 0;
256  }
257  }
258  else
259  {
260  pf *= pow(cf, exp - 1);
261  }
262  }
263 
264  label srRef = 0;
265  rRef = R.rhs()[srRef].index;
266 
267  // Find the matrix element and element position for the rhs
268  pr = kr;
269  for (label s=1; s<Nr; s++)
270  {
271  const label si = R.rhs()[s].index;
272  if (c[si] < c[rRef])
273  {
274  const scalar exp = R.rhs()[srRef].exponent;
275  pr *= pow(max(c[rRef], 0), exp);
276  rRef = si;
277  srRef = s;
278  }
279  else
280  {
281  const scalar exp = R.rhs()[s].exponent;
282  pr *= pow(max(c[si], 0), exp);
283  }
284  }
285  cr = max(c[rRef], 0);
286 
287  {
288  const scalar exp = R.rhs()[srRef].exponent;
289  if (exp < 1)
290  {
291  if (cr > small)
292  {
293  pr *= pow(cr, exp - 1);
294  }
295  else
296  {
297  pr = 0;
298  }
299  }
300  else
301  {
302  pr *= pow(cr, exp - 1);
303  }
304  }
305 
306  return pf*cf - pr*cr;
307 }
308 
309 
310 template<class ReactionThermo, class ThermoType>
312 (
313  const scalar time,
314  const scalarField& c,
315  const label li,
316  scalarField& dcdt
317 ) const
318 {
319  const bool reduced = mechRed_->active();
320 
321  const scalar T = c[this->nSpecie_];
322  const scalar p = c[this->nSpecie_ + 1];
323 
324  if (reduced)
325  {
326  // When using DAC, the ODE solver submit a reduced set of species the
327  // complete set is used and only the species in the simplified mechanism
328  // are updated
329  this->c_ = completeC_;
330 
331  // Update the concentration of the species in the simplified mechanism
332  // the other species remain the same and are used only for third-body
333  // efficiencies
334  for (label i=0; i<NsDAC_; i++)
335  {
336  this->c_[simplifiedToCompleteIndex_[i]] = max(c[i], 0);
337  }
338  }
339  else
340  {
341  for (label i=0; i<this->nSpecie(); i++)
342  {
343  this->c_[i] = max(c[i], 0);
344  }
345  }
346 
347  omega(p, T, this->c_, li, dcdt);
348 
349  // Constant pressure
350  // dT/dt = ...
351  scalar rho = 0;
352  for (label i=0; i<this->c_.size(); i++)
353  {
354  const scalar W = this->specieThermos_[i].W();
355  rho += W*this->c_[i];
356  }
357 
358  scalar cp = 0;
359  for (label i=0; i<this->c_.size(); i++)
360  {
361  // cp function returns [J/kmol/K]
362  cp += this->c_[i]*this->specieThermos_[i].cp(p, T);
363  }
364  cp /= rho;
365 
366  // When mechanism reduction is active
367  // dT is computed on the reduced set since dcdt is null
368  // for species not involved in the simplified mechanism
369  scalar dT = 0;
370  for (label i=0; i<this->nSpecie_; i++)
371  {
372  label si;
373  if (reduced)
374  {
375  si = simplifiedToCompleteIndex_[i];
376  }
377  else
378  {
379  si = i;
380  }
381 
382  // ha function returns [J/kmol]
383  const scalar hi = this->specieThermos_[si].ha(p, T);
384  dT += hi*dcdt[i];
385  }
386  dT /= rho*cp;
387 
388  dcdt[this->nSpecie_] = -dT;
389 
390  // dp/dt = ...
391  dcdt[this->nSpecie_ + 1] = 0;
392 }
393 
394 
395 template<class ReactionThermo, class ThermoType>
397 (
398  const scalar t,
399  const scalarField& c,
400  const label li,
401  scalarField& dcdt,
403 ) const
404 {
405  const bool reduced = mechRed_->active();
406 
407  // If the mechanism reduction is active, the computed Jacobian
408  // is compact (size of the reduced set of species)
409  // but according to the information of the complete set
410  // (i.e. for the third-body efficiencies)
411 
412  const scalar T = c[this->nSpecie_];
413  const scalar p = c[this->nSpecie_ + 1];
414 
415  if (reduced)
416  {
417  this->c_ = completeC_;
418  for (label i=0; i<NsDAC_; i++)
419  {
420  this->c_[simplifiedToCompleteIndex_[i]] = max(c[i], 0);
421  }
422  }
423  else
424  {
425  forAll(this->c_, i)
426  {
427  this->c_[i] = max(c[i], 0);
428  }
429  }
430 
431  J = Zero;
432  dcdt = Zero;
433  scalarField hi(this->c_.size());
434  scalarField cpi(this->c_.size());
435  forAll(hi, i)
436  {
437  hi[i] = this->specieThermos_[i].ha(p, T);
438  cpi[i] = this->specieThermos_[i].cp(p, T);
439  }
440 
441  scalar omegaI = 0;
442 
443  forAll(this->reactions_, ri)
444  {
445  if (!reactionsDisabled_[ri])
446  {
447  const Reaction<ThermoType>& R = this->reactions_[ri];
448  scalar kfwd, kbwd;
449  R.dwdc
450  (
451  p,
452  T,
453  this->c_,
454  li,
455  J,
456  dcdt,
457  omegaI,
458  kfwd,
459  kbwd,
460  reduced,
461  completeToSimplifiedIndex_
462  );
463  R.dwdT
464  (
465  p,
466  T,
467  this->c_,
468  li,
469  omegaI,
470  kfwd,
471  kbwd,
472  J,
473  reduced,
474  completeToSimplifiedIndex_,
475  this->nSpecie_
476  );
477  }
478  }
479 
480  // The species derivatives of the temperature term are partially computed
481  // while computing dwdc, they are completed hereunder:
482  scalar cpMean = 0;
483  scalar dcpdTMean = 0;
484  forAll(this->c_, i)
485  {
486  cpMean += this->c_[i]*cpi[i]; // J/(m^3 K)
487  // Already multiplied by rho
488  dcpdTMean += this->c_[i]*this->specieThermos_[i].dcpdT(p, T);
489  }
490 
491  scalar dTdt = 0;
492  forAll(hi, i)
493  {
494  if (reduced)
495  {
496  const label si = completeToSimplifiedIndex_[i];
497  if (si != -1)
498  {
499  dTdt += hi[i]*dcdt[si]; // J/(m^3 s)
500  }
501  }
502  else
503  {
504  dTdt += hi[i]*dcdt[i]; // J/(m^3 s)
505  }
506  }
507  dTdt /= -cpMean; // K/s
508  dcdt[this->nSpecie_] = dTdt;
509 
510  for (label i = 0; i < this->nSpecie_; i++)
511  {
512  J(this->nSpecie_, i) = 0;
513  for (label j = 0; j < this->nSpecie_; j++)
514  {
515  const label sj = reduced ? simplifiedToCompleteIndex_[j] : j;
516  J(this->nSpecie_, i) += hi[sj]*J(j, i);
517  }
518  const label si = reduced ? simplifiedToCompleteIndex_[i] : i;
519  J(this->nSpecie_, i) += cpi[si]*dTdt; // J/(mol s)
520  J(this->nSpecie_, i) /= -cpMean; // K/s / (mol/m^3)
521  }
522 
523  // ddT of dTdt
524  J(this->nSpecie_, this->nSpecie_) = 0;
525  for (label i = 0; i < this->nSpecie_; i++)
526  {
527  const label si = reduced ? simplifiedToCompleteIndex_[i] : i;
528  J(this->nSpecie_, this->nSpecie_) +=
529  cpi[si]*dcdt[i]
530  + hi[si]*J(i, this->nSpecie_);
531  }
532  J(this->nSpecie_, this->nSpecie_) += dTdt*dcpdTMean;
533  J(this->nSpecie_, this->nSpecie_) /= -cpMean;
534  J(this->nSpecie_, this->nSpecie_) += dTdt/T;
535 }
536 
537 
538 template<class ReactionThermo, class ThermoType>
539 template<class DeltaTType>
541 (
542  const DeltaTType& deltaT
543 )
544 {
545  // Increment counter of time-step
546  timeSteps_++;
547 
548  const bool reduced = mechRed_->active();
549 
550  label nAdditionalEqn = (tabulation_->variableTimeStep() ? 1 : 0);
551 
552  const basicSpecieMixture& composition = this->thermo().composition();
553 
554  // CPU time analysis
555  const clockTime clockTime_= clockTime();
556  clockTime_.timeIncrement();
557  scalar reduceMechCpuTime_ = 0;
558  scalar addNewLeafCpuTime_ = 0;
559  scalar growCpuTime_ = 0;
560  scalar solveChemistryCpuTime_ = 0;
561  scalar searchISATCpuTime_ = 0;
562 
563  this->resetTabulationResults();
564 
565  // Average number of active species
566  scalar nActiveSpecies = 0;
567  scalar nAvg = 0;
568 
570 
571  scalar deltaTMin = great;
572 
573  if (!this->chemistry_)
574  {
575  return deltaTMin;
576  }
577 
578  const volScalarField rho
579  (
580  IOobject
581  (
582  "rho",
583  this->time().timeName(),
584  this->mesh(),
585  IOobject::NO_READ,
586  IOobject::NO_WRITE,
587  false
588  ),
589  this->thermo().rho()
590  );
591 
592  const scalarField& T = this->thermo().T();
593  const scalarField& p = this->thermo().p();
594 
595  scalarField c(this->nSpecie_);
596  scalarField c0(this->nSpecie_);
597 
598  // Composition vector (Yi, T, p)
599  scalarField phiq(this->nEqns() + nAdditionalEqn);
600 
601  scalarField Rphiq(this->nEqns() + nAdditionalEqn);
602 
603  forAll(rho, celli)
604  {
605  const scalar rhoi = rho[celli];
606  scalar pi = p[celli];
607  scalar Ti = T[celli];
608 
609  for (label i=0; i<this->nSpecie_; i++)
610  {
611  c[i] = rhoi*this->Y_[i][celli]/this->specieThermos_[i].W();
612  c0[i] = c[i];
613  phiq[i] = this->Y()[i][celli];
614  }
615  phiq[this->nSpecie()]=Ti;
616  phiq[this->nSpecie() + 1]=pi;
617  if (tabulation_->variableTimeStep())
618  {
619  phiq[this->nSpecie() + 2] = deltaT[celli];
620  }
621 
622 
623  // Initialise time progress
624  scalar timeLeft = deltaT[celli];
625 
626  // Not sure if this is necessary
627  Rphiq = Zero;
628 
629  clockTime_.timeIncrement();
630 
631  // When tabulation is active (short-circuit evaluation for retrieve)
632  // It first tries to retrieve the solution of the system with the
633  // information stored through the tabulation method
634  if (tabulation_->active() && tabulation_->retrieve(phiq, Rphiq))
635  {
636  // Retrieved solution stored in Rphiq
637  for (label i=0; i<this->nSpecie(); i++)
638  {
639  c[i] = rhoi*Rphiq[i]/this->specieThermos_[i].W();
640  }
641 
642  searchISATCpuTime_ += clockTime_.timeIncrement();
643  }
644  // This position is reached when tabulation is not used OR
645  // if the solution is not retrieved.
646  // In the latter case, it adds the information to the tabulation
647  // (it will either expand the current data or add a new stored point).
648  else
649  {
650  // Reset the time
651  clockTime_.timeIncrement();
652 
653  if (reduced)
654  {
655  // Reduce mechanism change the number of species (only active)
656  mechRed_->reduceMechanism(pi, Ti, c, celli);
657  nActiveSpecies += mechRed_->NsSimp();
658  nAvg++;
659  reduceMechCpuTime_ += clockTime_.timeIncrement();
660  }
661 
662  // Calculate the chemical source terms
663  while (timeLeft > small)
664  {
665  scalar dt = timeLeft;
666  if (reduced)
667  {
668  // completeC_ used in the overridden ODE methods
669  // to update only the active species
670  completeC_ = c;
671 
672  // Solve the reduced set of ODE
673  this->solve
674  (
675  pi,
676  Ti,
677  simplifiedC_,
678  celli,
679  dt,
680  this->deltaTChem_[celli]
681  );
682 
683  for (label i=0; i<NsDAC_; i++)
684  {
685  c[simplifiedToCompleteIndex_[i]] = simplifiedC_[i];
686  }
687  }
688  else
689  {
690  this->solve(pi, Ti, c, celli, dt, this->deltaTChem_[celli]);
691  }
692  timeLeft -= dt;
693  }
694 
695  {
696  solveChemistryCpuTime_ += clockTime_.timeIncrement();
697  }
698 
699  // If tabulation is used, we add the information computed here to
700  // the stored points (either expand or add)
701  if (tabulation_->active())
702  {
703  forAll(c, i)
704  {
705  Rphiq[i] = c[i]/rhoi*this->specieThermos_[i].W();
706  }
707  if (tabulation_->variableTimeStep())
708  {
709  Rphiq[Rphiq.size()-3] = Ti;
710  Rphiq[Rphiq.size()-2] = pi;
711  Rphiq[Rphiq.size()-1] = deltaT[celli];
712  }
713  else
714  {
715  Rphiq[Rphiq.size()-2] = Ti;
716  Rphiq[Rphiq.size()-1] = pi;
717  }
718  label growOrAdd =
719  tabulation_->add(phiq, Rphiq, celli, rhoi, deltaT[celli]);
720  if (growOrAdd)
721  {
722  this->setTabulationResultsAdd(celli);
723  addNewLeafCpuTime_ += clockTime_.timeIncrement();
724  }
725  else
726  {
727  this->setTabulationResultsGrow(celli);
728  growCpuTime_ += clockTime_.timeIncrement();
729  }
730  }
731 
732  // When operations are done and if mechanism reduction is active,
733  // the number of species (which also affects nEqns) is set back
734  // to the total number of species (stored in the mechRed object)
735  if (reduced)
736  {
737  this->nSpecie_ = mechRed_->nSpecie();
738  }
739  deltaTMin = min(this->deltaTChem_[celli], deltaTMin);
740 
741  this->deltaTChem_[celli] =
742  min(this->deltaTChem_[celli], this->deltaTChemMax_);
743  }
744 
745  // Set the RR vector (used in the solver)
746  for (label i=0; i<this->nSpecie_; i++)
747  {
748  this->RR_[i][celli] =
749  (c[i] - c0[i])*this->specieThermos_[i].W()/deltaT[celli];
750  }
751  }
752 
753  if (mechRed_->log() || tabulation_->log())
754  {
755  cpuSolveFile_()
756  << this->time().timeOutputValue()
757  << " " << solveChemistryCpuTime_ << endl;
758  }
759 
760  if (mechRed_->log())
761  {
762  cpuReduceFile_()
763  << this->time().timeOutputValue()
764  << " " << reduceMechCpuTime_ << endl;
765  }
766 
767  if (tabulation_->active())
768  {
769  // Every time-step, look if the tabulation should be updated
770  tabulation_->update();
771 
772  // Write the performance of the tabulation
773  tabulation_->writePerformance();
774 
775  if (tabulation_->log())
776  {
777  cpuRetrieveFile_()
778  << this->time().timeOutputValue()
779  << " " << searchISATCpuTime_ << endl;
780 
781  cpuGrowFile_()
782  << this->time().timeOutputValue()
783  << " " << growCpuTime_ << endl;
784 
785  cpuAddFile_()
786  << this->time().timeOutputValue()
787  << " " << addNewLeafCpuTime_ << endl;
788  }
789  }
790 
791  if (reduced && nAvg && mechRed_->log())
792  {
793  // Write average number of species
794  nActiveSpeciesFile_()
795  << this->time().timeOutputValue()
796  << " " << nActiveSpecies/nAvg << endl;
797  }
798 
799  if (Pstream::parRun())
800  {
801  List<bool> active(composition.active());
802  Pstream::listCombineGather(active, orEqOp<bool>());
803  Pstream::listCombineScatter(active);
804 
805  forAll(active, i)
806  {
807  if (active[i])
808  {
809  composition.setActive(i);
810  }
811  }
812  }
813 
814  return deltaTMin;
815 }
816 
817 
818 template<class ReactionThermo, class ThermoType>
820 (
821  const scalar deltaT
822 )
823 {
824  // Don't allow the time-step to change more than a factor of 2
825  return min
826  (
828  2*deltaT
829  );
830 }
831 
832 
833 template<class ReactionThermo, class ThermoType>
835 (
836  const scalarField& deltaT
837 )
838 {
839  return this->solve<scalarField>(deltaT);
840 }
841 
842 
843 template<class ReactionThermo, class ThermoType>
846 (
847  const label celli
848 )
849 {
850  tabulationResults_[celli] = 0;
851 }
852 
853 
854 template<class ReactionThermo, class ThermoType>
857 {
858  tabulationResults_[celli] = 1;
859 }
860 
861 
862 template<class ReactionThermo, class ThermoType>
865 (
866  const label celli
867 )
868 {
869  tabulationResults_[celli] = 2;
870 }
871 
872 
873 // ************************************************************************* //
A class representing the concept of a uniform field which stores only the single value and providing ...
Definition: UniformField.H:47
void setInactive(label speciei) const
Set speciei inactive.
Extends StandardChemistryModel by adding the TDAC method.
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
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 typeHeaderOk(const bool checkType=true)
Read header (uses typeFilePath to find file) and check header.
void setTabulationResultsGrow(const label celli)
void setTabulationResultsRetrieve(const label celli)
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
bool active(label speciei) const
Return true for active species.
basicSpecieMixture & composition
void dwdc(const scalar p, const scalar T, const scalarField &c, const label li, 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.
Definition: Reaction.C:482
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
bool cp(const fileName &src, const fileName &dst, const bool followLink=true)
Copy, recursively if necessary, the source to the destination.
Definition: POSIX.C:753
virtual ~TDACChemistryModel()
Destructor.
const List< specieCoeffs > & lhs() const
Return the components of the left hand side.
Definition: ReactionI.H:57
rhoEqn solve()
rhoReactionThermo & thermo
Definition: createFields.H:28
const label nSpecie
const dimensionedScalar & c
Speed of light in a vacuum.
Specialization of basicMixture for a mixture consisting of a number for molecular species...
Extends base chemistry model by adding a thermo package, and ODE functions. Introduces chemistry equa...
void omega(const scalar p, const scalar T, const scalarField &c, const label li, scalarField &dcdt) const
Net reaction rate for individual species.
Definition: Reaction.C:334
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))
dynamicFvMesh & mesh
dimensionedScalar exp(const dimensionedScalar &ds)
autoPtr< BasicCompressibleMomentumTransportModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const typename BasicCompressibleMomentumTransportModel::transportModel &transport)
virtual scalar kr(const scalar kfwd, const scalar p, const scalar T, const scalarField &c, const label li) const =0
Reverse rate constant from the given forward rate constant.
virtual void omega(const scalar p, const scalar T, const scalarField &c, const label li, scalarField &dcdt) const
dc/dt = omega, rate of change in concentration, for each species
word timeName
Definition: getTimeIndex.H:3
static const zero Zero
Definition: zero.H:97
TDACChemistryModel(const ReactionThermo &thermo)
Construct from thermo.
An STL-conforming hash table.
Definition: HashTable.H:61
void setTabulationResultsAdd(const label celli)
Info<< "Predicted p max-min : "<< max(p).value()<< " "<< min(p).value()<< endl;rho==max(rho0+psi *p, rhoMin);# 1 "/home/ubuntu/OpenFOAM-8/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:68
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
const volScalarField & T
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
const scalarList W(::W(thermo))
PtrList< volScalarField > & Y
virtual void derivatives(const scalar t, const scalarField &c, const label li, scalarField &dcdt) const
Calculate the derivatives in dydx.
double timeIncrement() const
Return time (in seconds) since last call to timeIncrement()
Definition: clockTime.C:62
void setActive(label speciei) const
Set speciei active.
const List< specieCoeffs > & rhs() const
Return the components of the right hand side.
Definition: ReactionI.H:64
void dwdT(const scalar p, const scalar T, const scalarField &c, const label li, 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.
Definition: Reaction.C:646
virtual void jacobian(const scalar t, const scalarField &c, const label li, scalarField &dcdt, scalarSquareMatrix &J) const
Calculate the Jacobian of the system.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:92
virtual scalar kf(const scalar p, const scalar T, const scalarField &c, const label li) const =0
Forward rate constant.
Starts timing (using rtc) and returns elapsed time from start. Better resolution (2uSec instead of ~2...
Definition: clockTime.H:49