36template<
class ReactionThermo,
class ThermoType>
37Foam::StandardChemistryModel<ReactionThermo, ThermoType>::StandardChemistryModel
42 BasicChemistryModel<ReactionThermo>(
thermo),
52 (this->
thermo()).speciesData()
59 BasicChemistryModel<ReactionThermo>::template
getOrDefault<scalar>
91 Info<<
"StandardChemistryModel: Number of species = " <<
nSpecie_
98template<
class ReactionThermo,
class ThermoType>
106template<
class ReactionThermo,
class ThermoType>
115 scalar pf, cf, pr, cr;
124 scalar omegai = omega
126 R, c,
T,
p, pf, cf, lRef, pr, cr, rRef
131 const label si =
R.lhs()[
s].index;
132 const scalar sl =
R.lhs()[
s].stoichCoeff;
133 dcdt[si] -= sl*omegai;
138 const label si =
R.rhs()[
s].index;
139 const scalar sr =
R.rhs()[
s].stoichCoeff;
140 dcdt[si] += sr*omegai;
146template<
class ReactionThermo,
class ThermoType>
162 scalar w =
omega(
R, c,
T,
p, pf, cf, lRef, pr, cr, rRef);
167template<
class ReactionThermo,
class ThermoType>
182 const scalar kf =
R.kf(
p,
T, c);
183 const scalar kr =
R.kr(kf,
p,
T, c);
188 const label Nl =
R.lhs().size();
189 const label Nr =
R.rhs().size();
192 lRef =
R.lhs()[slRef].index;
195 for (label
s = 1;
s < Nl;
s++)
197 const label si =
R.lhs()[
s].index;
201 const scalar
exp =
R.lhs()[slRef].exponent;
208 const scalar
exp =
R.lhs()[
s].exponent;
212 cf =
max(c[lRef], 0.0);
215 const scalar
exp =
R.lhs()[slRef].exponent;
234 rRef =
R.rhs()[srRef].index;
238 for (label
s = 1;
s < Nr;
s++)
240 const label si =
R.rhs()[
s].index;
243 const scalar
exp =
R.rhs()[srRef].exponent;
250 const scalar
exp =
R.rhs()[
s].exponent;
254 cr =
max(c[rRef], 0.0);
257 const scalar
exp =
R.rhs()[srRef].exponent;
275 return pf*cf - pr*cr;
279template<
class ReactionThermo,
class ThermoType>
292 c_[i] =
max(c[i], 0.0);
300 for (label i = 0; i <
nSpecie_; i++)
313 for (label i = 0; i <
nSpecie_; i++)
320 dcdt[nSpecie_] = -dT;
327template<
class ReactionThermo,
class ThermoType>
341 c_[i] =
max(c[i], 0.0);
353 const scalar kf0 =
R.kf(
p,
T,
c_);
354 const scalar kr0 =
R.kr(kf0,
p,
T,
c_);
358 const label sj =
R.lhs()[j].index;
362 const label si =
R.lhs()[i].index;
363 const scalar el =
R.lhs()[i].exponent;
370 kf *= el*
pow(
c_[si], el - 1.0);
379 kf *= el*
pow(
c_[si], el - 1.0);
384 kf *=
pow(
c_[si], el);
390 const label si =
R.lhs()[i].index;
391 const scalar sl =
R.lhs()[i].stoichCoeff;
392 dfdc(si, sj) -= sl*kf;
396 const label si =
R.rhs()[i].index;
397 const scalar sr =
R.rhs()[i].stoichCoeff;
398 dfdc(si, sj) += sr*kf;
404 const label sj =
R.rhs()[j].index;
408 const label si =
R.rhs()[i].index;
409 const scalar er =
R.rhs()[i].exponent;
416 kr *= er*
pow(
c_[si], er - 1.0);
425 kr *= er*
pow(
c_[si], er - 1.0);
430 kr *=
pow(
c_[si], er);
436 const label si =
R.lhs()[i].index;
437 const scalar sl =
R.lhs()[i].stoichCoeff;
438 dfdc(si, sj) += sl*kr;
442 const label si =
R.rhs()[i].index;
443 const scalar sr =
R.rhs()[i].stoichCoeff;
444 dfdc(si, sj) -= sr*kr;
450 const scalar
delta = 1.0e-3;
469template<
class ReactionThermo,
class ThermoType>
489 const label nReaction = reactions_.
size();
491 scalar pf, cf, pr, cr;
494 if (this->chemistry_)
498 const scalar rhoi =
rho[celli];
499 const scalar Ti =
T[celli];
500 const scalar
pi =
p[celli];
504 for (label i=0; i<nSpecie_; i++)
506 c_[i] = rhoi*Y_[i][celli]/specieThermo_[i].W();
514 omega(
R, c_, Ti,
pi, pf, cf, lRef, pr, cr, rRef);
518 tc[celli] +=
R.rhs()[
s].stoichCoeff*pf*cf;
522 tc[celli] = nReaction*cSum/tc[celli];
526 ttc.ref().correctBoundaryConditions();
532template<
class ReactionThermo,
class ThermoType>
544 if (this->chemistry_)
552 const scalar hi = specieThermo_[i].Hc();
553 Qdot[celli] -= hi*RR_[i][celli];
556 tQdot.ref().correctBoundaryConditions();
563template<
class ReactionThermo,
class ThermoType>
571 scalar pf, cf, pr, cr;
581 auto& RR = tRR.ref();
591 const scalar rhoi =
rho[celli];
592 const scalar Ti =
T[celli];
593 const scalar
pi =
p[celli];
595 for (label i=0; i<nSpecie_; i++)
597 const scalar Yi = Y_[i][celli];
598 c_[i] = rhoi*Yi/specieThermo_[i].W();
601 const scalar w = omegaI
615 RR[celli] = w*specieThermo_[si].W();
622template<
class ReactionThermo,
class ThermoType>
625 if (!this->chemistry_)
638 const scalar rhoi =
rho[celli];
639 const scalar Ti =
T[celli];
640 const scalar
pi =
p[celli];
642 for (label i=0; i<nSpecie_; i++)
644 const scalar Yi = Y_[i][celli];
645 c_[i] = rhoi*Yi/specieThermo_[i].W();
648 omega(c_, Ti,
pi, dcdt_);
650 for (label i=0; i<nSpecie_; i++)
652 RR_[i][celli] = dcdt_[i]*specieThermo_[i].W();
658template<
class ReactionThermo,
class ThermoType>
659template<
class DeltaTType>
660Foam::scalar Foam::StandardChemistryModel<ReactionThermo, ThermoType>::solve
662 const DeltaTType& deltaT
667 scalar deltaTMin = GREAT;
669 if (!this->chemistry_)
684 scalar Ti =
T[celli];
688 const scalar rhoi =
rho[celli];
689 scalar
pi =
p[celli];
691 for (label i=0; i<nSpecie_; i++)
693 c_[i] = rhoi*Y_[i][celli]/specieThermo_[i].W();
698 scalar timeLeft = deltaT[celli];
701 while (timeLeft > SMALL)
703 scalar dt = timeLeft;
704 this->
solve(c_, Ti,
pi, dt, this->deltaTChem_[celli]);
708 deltaTMin =
min(this->deltaTChem_[celli], deltaTMin);
710 this->deltaTChem_[celli] =
711 min(this->deltaTChem_[celli], this->deltaTChemMax_);
713 for (label i=0; i<nSpecie_; i++)
716 (c_[i] - c0[i])*specieThermo_[i].W()/deltaT[celli];
721 for (label i=0; i<nSpecie_; i++)
732template<
class ReactionThermo,
class ThermoType>
733Foam::scalar Foam::StandardChemistryModel<ReactionThermo, ThermoType>::solve
747template<
class ReactionThermo,
class ThermoType>
748Foam::scalar Foam::StandardChemistryModel<ReactionThermo, ThermoType>::solve
constexpr scalar pi(M_PI)
#define R(A, B, C, D, E, F, K, M)
ReactionThermo & thermo()
Return access to the thermo package.
label size() const noexcept
The number of elements in list.
static tmp< GeometricField< scalar, fvPatchField, volMesh > > New(const word &name, IOobjectOption::registerOption regOpt, const Mesh &mesh, const dimensionSet &dims, const word &patchFieldType=fvPatchField< scalar >::calculatedType())
DimensionedField< scalar, volMesh > Internal
@ NO_REGISTER
Do not request registration (bool: false).
@ NO_READ
Nothing to be read.
@ NO_WRITE
Ignore writing from objectRegistry::writeObject().
Defines the attributes of an object for which implicit objectRegistry management is supported,...
const Time & time() const noexcept
Return Time associated with the objectRegistry.
ODESystem()
Construct null.
Simple extension of ReactionThermo to handle reaction kinetics in addition to the equilibrium thermod...
scalarField c_
Temporary concentration field.
virtual tmp< volScalarField > tc() const
Return the chemical time scale.
scalarField dcdt_
Temporary rate-of-change of concentration field.
virtual tmp< volScalarField::Internal > calculateRR(const label reactionI, const label speciei) const
Return reaction rate of the speciei in reactionI.
PtrList< volScalarField::Internal > & RR()
Write access to chemical source terms.
const PtrList< ThermoType > & specieThermo_
Thermodynamic data of the species.
label nSpecie_
Number of species.
PtrList< volScalarField > & Y_
Reference to the field of specie mass fractions.
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
virtual void derivatives(const scalar t, const scalarField &c, scalarField &dcdt) const
Calculate the derivatives in dydx.
virtual ~StandardChemistryModel()
Destructor.
const PtrList< Reaction< ThermoType > > & reactions_
Reactions.
virtual scalar omegaI(label iReaction, const scalarField &c, const scalar T, const scalar p, scalar &pf, scalar &cf, label &lRef, scalar &pr, scalar &cr, label &rRef) const
Return the reaction rate for iReaction and the reference.
virtual label nReaction() const
The number of reactions.
scalar Treact_
Temperature below which the reaction rates are assumed 0.
PtrList< volScalarField::Internal > RR_
List of reaction rate per specie [kg/m3/s].
label nReaction_
Number of reactions.
virtual tmp< volScalarField > Qdot() const
Return the heat release rate [kg/m/s3].
virtual void jacobian(const scalar t, const scalarField &c, scalarField &dcdt, scalarSquareMatrix &dfdc) const
Calculate the Jacobian of the system.
virtual void calculate()
Calculates the reaction rates.
void size(const label n)
Older name for setAddressableSize.
const fvMesh & mesh_
Reference to the mesh database.
void correct()
Correct function - updates due to mesh changes.
Switch chemistry_
Chemistry activation switch.
const fvMesh & mesh() const
Return const access to the mesh database.
const scalar deltaTChemMax_
Maximum chemical time step.
volScalarField::Internal deltaTChem_
Latest estimation of integration step.
virtual const volScalarField & T() const
Temperature [K].
virtual volScalarField & p()
Pressure [Pa].
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T, or return the given default value. FatalIOError if it is found and the number of...
static const word & extrapolatedCalculatedType() noexcept
The type name for extrapolatedCalculated patch fields combines zero-gradient and calculated.
A class for managing temporary objects.
static const word null
An empty word.
basicSpecieMixture & composition
PtrList< volScalarField > & Y
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.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))
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
dimensionedScalar exp(const dimensionedScalar &ds)
const dimensionSet dimEnergy
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
messageStream Info
Information stream (stdout output on master, null elsewhere).
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
Ostream & endl(Ostream &os)
Add newline and flush stream.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
SquareMatrix< scalar > scalarSquareMatrix
static constexpr const zero Zero
Global zero (0).
bool cp(const fileName &src, const fileName &dst, const bool followLink=true)
Copy the source to the destination (recursively if necessary).
const dimensionSet dimVolume(pow3(dimLength))
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
const dimensionSet dimMass(1, 0, 0, 0, 0, 0, 0)
tmp< volScalarField > trho
const volScalarField & cp
psiReactionThermo & thermo
#define forAll(list, i)
Loop across all elements in list.