33 template<
class ThermoType>
41 NsDAC_(this->nSpecie_),
42 completeC_(this->nSpecie_, 0),
43 reactionsDisabled_(this->reactions_.size(),
false),
44 completeToSimplifiedIndex_(this->nSpecie_, -1),
45 simplifiedToCompleteIndex_(this->nSpecie_),
51 this->time().timeName(),
70 if (mechRed_->active())
99 cpuReduceFile_ = logFile(
"cpu_reduce.out");
100 nActiveSpeciesFile_ = logFile(
"nActiveSpecies.out");
103 if (tabulation_->log())
105 cpuAddFile_ = logFile(
"cpu_add.out");
106 cpuGrowFile_ = logFile(
"cpu_grow.out");
107 cpuRetrieveFile_ = logFile(
"cpu_retrieve.out");
110 if (mechRed_->log() || tabulation_->log())
112 cpuSolveFile_ = logFile(
"cpu_solve.out");
119 template<
class ThermoType>
126 template<
class ThermoType>
136 const bool reduced = mechRed_->active();
138 scalar omegaf, omegar;
142 forAll(this->reactions_, i)
144 if (!reactionsDisabled_[i])
147 const scalar omegaI = R.
omega(p, T, c, li, omegaf, omegar);
153 ? completeToSimplifiedIndex_[R.
lhs()[
s].index]
155 const scalar sl = R.
lhs()[
s].stoichCoeff;
156 dcdt[si] -= sl*omegaI;
163 ? completeToSimplifiedIndex_[R.
rhs()[
s].index]
165 const scalar sr = R.
rhs()[
s].stoichCoeff;
166 dcdt[si] += sr*omegaI;
173 template<
class ThermoType>
182 const bool reduced = mechRed_->active();
189 this->c_ = completeC_;
194 for (
label i=0; i<NsDAC_; i++)
196 this->c_[simplifiedToCompleteIndex_[i]] =
max(c[i], 0);
203 this->c_[i] =
max(c[i], 0);
207 const scalar T = c[this->nSpecie_];
208 const scalar p = c[this->nSpecie_ + 1];
213 omega(p, T, this->c_, li, dcdt);
219 for (
label i=0; i<this->c_.size(); i++)
221 ccp += this->c_[i]*this->specieThermos_[i].cp(p, T);
225 scalar& dTdt = dcdt[this->nSpecie_];
226 for (
label i=0; i<this->nSpecie_; i++)
228 const label si = reduced ? simplifiedToCompleteIndex_[i] : i;
229 dTdt -= dcdt[i]*this->specieThermos_[si].ha(p, T);
237 template<
class ThermoType>
247 const bool reduced = mechRed_->active();
256 this->c_ = completeC_;
258 for (
label i=0; i<NsDAC_; i++)
260 this->c_[simplifiedToCompleteIndex_[i]] =
max(c[i], 0);
267 this->c_[i] =
max(c[i], 0);
271 const scalar T = c[this->nSpecie_];
272 const scalar p = c[this->nSpecie_ + 1];
278 forAll(this->reactions_, ri)
280 if (!reactionsDisabled_[ri])
283 scalar omegaI, kfwd, kbwd;
296 completeToSimplifiedIndex_
309 completeToSimplifiedIndex_,
318 scalar ccp = 0, dccpdT = 0;
321 ccp += this->c_[i]*this->specieThermos_[i].cp(p, T);
322 dccpdT += this->c_[i]*this->specieThermos_[i].dcpdT(p, T);
326 scalar& dTdt = dcdt[this->nSpecie_];
327 for (
label i=0; i<this->nSpecie_; i++)
329 const label si = reduced ? simplifiedToCompleteIndex_[i] : i;
330 dTdt -= dcdt[i]*this->specieThermos_[si].ha(p, T);
337 for (
label i = 0; i < this->nSpecie_; i++)
339 scalar& d2Tdtdci = J(this->nSpecie_, i);
340 for (
label j = 0; j < this->nSpecie_; j++)
342 const scalar d2cjdtdci = J(j, i);
343 const label sj = reduced ? simplifiedToCompleteIndex_[j] : j;
344 d2Tdtdci -= d2cjdtdci*this->specieThermos_[sj].ha(p, T);
346 const label si = reduced ? simplifiedToCompleteIndex_[i] : i;
347 d2Tdtdci -= this->specieThermos_[si].cp(p, T)*dTdt;
352 scalar& d2TdtdT = J(this->nSpecie_, this->nSpecie_);
353 for (
label i = 0; i < this->nSpecie_; i++)
355 const scalar d2cidtdT = J(i, this->nSpecie_);
356 const label si = reduced ? simplifiedToCompleteIndex_[i] : i;
358 dcdt[i]*this->specieThermos_[si].cp(p, T)
359 + d2cidtdT*this->specieThermos_[si].ha(p, T);
361 d2TdtdT -= dTdt*dccpdT;
370 template<
class ThermoType>
371 template<
class DeltaTType>
374 const DeltaTType& deltaT
380 const bool reduced = mechRed_->
active();
387 scalar reduceMechCpuTime_ = 0;
388 scalar addNewLeafCpuTime_ = 0;
389 scalar growCpuTime_ = 0;
390 scalar solveChemistryCpuTime_ = 0;
391 scalar searchISATCpuTime_ = 0;
393 this->resetTabulationResults();
396 scalar nActiveSpecies = 0;
401 scalar deltaTMin = great;
403 if (!this->chemistry_)
423 const scalar rhoi = rho[celli];
424 scalar
pi = p[celli];
425 scalar Ti = T[celli];
427 for (
label i=0; i<this->nSpecie_; i++)
430 rhoi*this->Y_[i].oldTime()[celli]/this->specieThermos_[i].W();
431 phiq[i] = this->
Y()[i].oldTime()[celli];
435 phiq[this->
nSpecie() + 2] = deltaT[celli];
438 scalar timeLeft = deltaT[celli];
448 if (tabulation_->active() && tabulation_->retrieve(phiq, Rphiq))
453 c[i] = rhoi*Rphiq[i]/this->specieThermos_[i].W();
470 mechRed_->reduceMechanism(pi, Ti, c, celli);
471 nActiveSpecies += mechRed_->NsSimp();
477 while (timeLeft > small)
479 scalar dt = timeLeft;
494 this->deltaTChem_[celli]
497 for (
label i=0; i<NsDAC_; i++)
499 c[simplifiedToCompleteIndex_[i]] = simplifiedC_[i];
504 this->
solve(pi, Ti, c, celli, dt, this->deltaTChem_[celli]);
515 if (tabulation_->active())
519 Rphiq[i] = c[i]/rhoi*this->specieThermos_[i].W();
521 Rphiq[Rphiq.
size()-3] = Ti;
522 Rphiq[Rphiq.
size()-2] =
pi;
523 Rphiq[Rphiq.
size()-1] = deltaT[celli];
526 tabulation_->add(phiq, Rphiq, celli, rhoi, deltaT[celli]);
529 this->setTabulationResultsAdd(celli);
534 this->setTabulationResultsGrow(celli);
544 this->nSpecie_ = mechRed_->nSpecie();
546 deltaTMin =
min(this->deltaTChem_[celli], deltaTMin);
548 this->deltaTChem_[celli] =
549 min(this->deltaTChem_[celli], this->deltaTChemMax_);
553 for (
label i=0; i<this->nSpecie_; i++)
555 this->RR_[i][celli] =
556 (c[i] - c0[i])*this->specieThermos_[i].
W()/deltaT[celli];
560 if (mechRed_->log() || tabulation_->log())
563 << this->time().timeOutputValue()
564 <<
" " << solveChemistryCpuTime_ <<
endl;
570 << this->time().timeOutputValue()
571 <<
" " << reduceMechCpuTime_ <<
endl;
574 if (tabulation_->active())
577 tabulation_->update();
580 tabulation_->writePerformance();
582 if (tabulation_->log())
585 << this->time().timeOutputValue()
586 <<
" " << searchISATCpuTime_ <<
endl;
589 << this->time().timeOutputValue()
590 <<
" " << growCpuTime_ <<
endl;
593 << this->time().timeOutputValue()
594 <<
" " << addNewLeafCpuTime_ <<
endl;
598 if (reduced && nAvg && mechRed_->log())
601 nActiveSpeciesFile_()
602 << this->time().timeOutputValue()
603 <<
" " << nActiveSpecies/nAvg <<
endl;
606 if (Pstream::parRun())
610 Pstream::listCombineScatter(active);
625 template<
class ThermoType>
640 template<
class ThermoType>
646 return this->solve<scalarField>(deltaT);
650 template<
class ThermoType>
657 tabulationResults_[celli] = 0;
661 template<
class ThermoType>
665 tabulationResults_[celli] = 1;
669 template<
class ThermoType>
676 tabulationResults_[celli] = 2;
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.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
bool typeHeaderOk(const bool checkType=true)
Read header (uses typeFilePath to find file) and check header.
fluidReactionThermo & thermo
void setTabulationResultsGrow(const label celli)
static word phasePropertyName(const word &name, const word &phaseName)
Return the name of a property for a given phase.
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.
void size(const label)
Override size to be inconsistent with allocated storage.
Ostream & endl(Ostream &os)
Add newline and flush stream.
tmp< volScalarField > trho
virtual ~TDACChemistryModel()
Destructor.
Base-class for multi-component fluid thermodynamic properties.
const List< specieCoeffs > & lhs() const
Return the components of the left hand side.
Specialisation of basicMixture for a mixture consisting of a number for molecular species...
const dimensionedScalar c
Speed of light in a vacuum.
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.
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))
autoPtr< BasicCompressibleMomentumTransportModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const typename BasicCompressibleMomentumTransportModel::transportModel &transport)
Info<< "Predicted p max-min : "<< max(p).value()<< " "<< min(p).value()<< endl;rho==max(rho0+psi *p, rhoMin);# 1 "/home/ubuntu/OpenFOAM-9/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()
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
TDACChemistryModel(const fluidReactionThermo &thermo)
Construct from thermo.
void setTabulationResultsAdd(const label celli)
Extends base chemistry model by adding a thermo package, and ODE functions. Introduces chemistry equa...
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
word name(const complex &)
Return a string representation of a complex.
bool active(const label i) const
const List< specieCoeffs > & rhs() const
Return the components of the right hand side.
#define R(A, B, C, D, E, F, K, M)
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()
void setActive(label speciei) const
Set speciei active.
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.
A class for managing temporary objects.
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...
Starts timing (using rtc) and returns elapsed time from start. Better resolution (2uSec instead of ~2...