32 template<
class ThermoType>
42 specieThermos_(mixture_.specieThermos()),
43 reactions_(mixture_.species(), specieThermos_, this->
mesh(), *
this),
45 nReaction_(reactions_.size()),
46 Treact_(basicChemistryModel::template lookupOrDefault<scalar>(
"Treact", 0)),
61 "RR." + Y_[fieldi].
name(),
73 Info<<
"standardChemistryModel: Number of species = " << nSpecie_
74 <<
" and reactions = " << nReaction_ <<
endl;
80 template<
class ThermoType>
87 template<
class ThermoType>
103 R.
omega(p, T, c, li, dcdt);
108 template<
class ThermoType>
117 const scalar T = c[nSpecie_];
118 const scalar p = c[nSpecie_ + 1];
122 c_[i] =
max(c[i], 0);
128 omega(p, T, c_, li, dcdt);
134 for (
label i = 0; i < nSpecie_; i++)
136 ccp += c_[i]*specieThermos_[i].cp(p, T);
140 scalar& dTdt = dcdt[nSpecie_];
141 for (
label i = 0; i < nSpecie_; i++)
143 dTdt -= dcdt[i]*specieThermos_[i].ha(p, T);
151 template<
class ThermoType>
161 const scalar T = c[nSpecie_];
162 const scalar p = c[nSpecie_ + 1];
166 c_[i] =
max(c[i], 0);
176 scalar omegaI, kfwd, kbwd;
178 R.
dwdc(p, T, c_, li, J, dcdt, omegaI, kfwd, kbwd,
false, null);
179 R.
dwdT(p, T, c_, li, omegaI, kfwd, kbwd, J,
false, null, nSpecie_);
185 scalar ccp = 0, dccpdT = 0;
186 for (
label i = 0; i < nSpecie_; i++)
188 ccp += c_[i]*specieThermos_[i].cp(p, T);
189 dccpdT += c_[i]*specieThermos_[i].dcpdT(p, T);
193 scalar& dTdt = dcdt[nSpecie_];
194 for (
label i = 0; i < nSpecie_; i++)
196 dTdt -= dcdt[i]*specieThermos_[i].ha(p, T);
203 for (
label i = 0; i < nSpecie_; i++)
205 scalar& d2Tdtdci = J(nSpecie_, i);
206 for (
label j = 0; j < nSpecie_; j++)
208 const scalar d2cjdtdci = J(j, i);
209 d2Tdtdci -= d2cjdtdci*specieThermos_[j].ha(p, T);
211 d2Tdtdci -= specieThermos_[i].cp(p, T)*dTdt;
216 scalar& d2TdtdT = J(nSpecie_, nSpecie_);
217 for (
label i = 0; i < nSpecie_; i++)
219 const scalar d2cidtdT = J(i, nSpecie_);
221 dcdt[i]*specieThermos_[i].cp(p, T)
222 + d2cidtdT*specieThermos_[i].ha(p, T);
224 d2TdtdT -= dTdt*dccpdT;
233 template<
class ThermoType>
244 extrapolatedCalculatedFvPatchScalarField::typeName
255 if (this->chemistry_)
261 const scalar rhoi = rho[celli];
262 const scalar Ti = T[celli];
263 const scalar
pi = p[celli];
265 for (
label i=0; i<nSpecie_; i++)
267 c_[i] = rhoi*Y_[i][celli]/specieThermos_[i].W();
287 scalar sumW = 0, sumWRateByCTot = 0;
291 scalar omegaf, omegar;
292 R.
omega(pi, Ti, c_, celli, omegaf, omegar);
297 wf += R.
rhs()[
s].stoichCoeff*omegaf;
300 sumWRateByCTot +=
sqr(wf);
305 wr += R.
lhs()[
s].stoichCoeff*omegar;
308 sumWRateByCTot +=
sqr(wr);
312 sumWRateByCTot == 0 ? vGreat : sumW/sumWRateByCTot*
sum(c_);
316 ttc.
ref().correctBoundaryConditions();
322 template<
class ThermoType>
336 if (this->chemistry_)
346 const scalar hi = specieThermos_[i].Hf();
347 Qdot[celli] -= hi*RR_[i][celli];
356 template<
class ThermoType>
384 scalar omegaf, omegar;
388 const scalar rhoi = rho[celli];
389 const scalar Ti = T[celli];
390 const scalar
pi = p[celli];
392 for (
label i=0; i<nSpecie_; i++)
394 const scalar Yi = Y_[i][celli];
395 c_[i] = rhoi*Yi/specieThermos_[i].W();
399 const scalar omegaI = R.
omega(pi, Ti, c_, celli, omegaf, omegar);
403 if (si == R.
lhs()[
s].index)
405 RR[celli] -= R.
lhs()[
s].stoichCoeff*omegaI;
411 if (si == R.
rhs()[
s].index)
413 RR[celli] += R.
rhs()[
s].stoichCoeff*omegaI;
417 RR[celli] *= specieThermos_[si].W();
424 template<
class ThermoType>
427 if (!this->chemistry_)
442 const scalar rhoi = rho[celli];
443 const scalar Ti = T[celli];
444 const scalar
pi = p[celli];
446 for (
label i=0; i<nSpecie_; i++)
448 const scalar Yi = Y_[i][celli];
449 c_[i] = rhoi*Yi/specieThermos_[i].W();
452 omega(pi, Ti, c_, celli, dcdt_);
454 for (
label i=0; i<nSpecie_; i++)
456 RR_[i][celli] = dcdt_[i]*specieThermos_[i].W();
462 template<
class ThermoType>
463 template<
class DeltaTType>
466 const DeltaTType& deltaT
471 scalar deltaTMin = great;
473 if (!this->chemistry_)
490 scalar Ti = T[celli];
494 const scalar rhoi = rho[celli];
495 scalar
pi = p[celli];
497 for (
label i=0; i<nSpecie_; i++)
499 c_[i] = rhoi*Y_[i].oldTime()[celli]/specieThermos_[i].W();
504 scalar timeLeft = deltaT[celli];
507 while (timeLeft > small)
509 scalar dt = timeLeft;
510 this->
solve(pi, Ti, c_, celli, dt, this->deltaTChem_[celli]);
514 deltaTMin =
min(this->deltaTChem_[celli], deltaTMin);
516 this->deltaTChem_[celli] =
517 min(this->deltaTChem_[celli], this->deltaTChemMax_);
519 for (
label i=0; i<nSpecie_; i++)
522 (c_[i] - c0[i])*specieThermos_[i].
W()/deltaT[celli];
527 for (
label i=0; i<nSpecie_; i++)
538 template<
class ThermoType>
553 template<
class ThermoType>
559 return this->solve<scalarField>(deltaT);
#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.
fluidReactionThermo & thermo
virtual tmp< volScalarField > Qdot() const
Return the heat release rate [kg/m/s^3].
Abstract base class for the systems of ordinary differential equations.
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
basicSpecieMixture & composition
T & ref() const
Return non-const reference or generate a fatal error.
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.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
To & refCast(From &r)
Reference type cast template function.
virtual void jacobian(const scalar t, const scalarField &c, const label li, scalarField &dcdt, scalarSquareMatrix &J) const
Calculate the Jacobian of the system.
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
Ostream & endl(Ostream &os)
Add newline and flush stream.
tmp< volScalarField > trho
Base-class for multi-component fluid thermodynamic properties.
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.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
const dimensionSet dimTime
const dimensionedScalar RR
Universal gas constant: default SI units: [J/kmol/K].
virtual void calculate()
Calculates the reaction rates.
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()
Foam::multiComponentMixture.
standardChemistryModel(const fluidReactionThermo &thermo)
Construct from thermo.
Extends base chemistry model by adding a thermo package, and ODE functions. Introduces chemistry equa...
const Mesh & mesh() const
Return mesh.
virtual void derivatives(const scalar t, const scalarField &c, const label li, scalarField &dcdt) const
Calculate the derivatives in dydx.
const dimensionSet dimEnergy
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
const dimensionSet dimMass
word name(const complex &)
Return a string representation of a complex.
virtual tmp< volScalarField::Internal > calculateRR(const label reactionI, const label speciei) const
Return reaction rate of the speciei in reactionI.
virtual tmp< volScalarField > tc() const
Return the chemical time scale.
const List< specieCoeffs > & rhs() const
Return the components of the right hand side.
#define R(A, B, C, D, E, F, K, M)
virtual const volScalarField & T() const =0
Temperature [K].
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
const scalarList W(::W(thermo))
Class to define scope of reaction evaluation. Runs pre-evaluate.
PtrList< volScalarField > & Y
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
const dimensionSet dimVolume
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.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
virtual ~standardChemistryModel()
Destructor.
Base class for chemistry models.