From ad82628b14856addbffe2dd018c3c6d998067ddc Mon Sep 17 00:00:00 2001 From: Will Bainbridge Date: Thu, 22 Apr 2021 11:36:54 +0100 Subject: [PATCH] Reaction: Simplified rate methods The linearisation of the reaction rate relative to the concentration of a reference specie is not required anywhere. This data has been removed from the rate method's output and the internals of the rate method simplified accordingly. The clipping in the rate methods has also been simplified and made consistent across the different rate and rate derivative methods. --- .../StandardChemistryModel.C | 20 +- .../TDACChemistryModel/TDACChemistryModel.C | 34 ++-- .../TDACChemistryModel/reduction/DAC/DAC.C | 5 +- .../TDACChemistryModel/reduction/DRG/DRG.C | 5 +- .../reduction/DRGEP/DRGEP.C | 5 +- .../TDACChemistryModel/reduction/EFA/EFA.C | 7 +- .../TDACChemistryModel/reduction/PFA/PFA.C | 5 +- .../reaction/Reactions/Reaction/Reaction.C | 173 ++++-------------- .../reaction/Reactions/Reaction/Reaction.H | 8 +- 9 files changed, 68 insertions(+), 194 deletions(-) diff --git a/src/thermophysicalModels/chemistryModel/chemistryModel/StandardChemistryModel/StandardChemistryModel.C b/src/thermophysicalModels/chemistryModel/chemistryModel/StandardChemistryModel/StandardChemistryModel.C index a8864b5256..9308097051 100644 --- a/src/thermophysicalModels/chemistryModel/chemistryModel/StandardChemistryModel/StandardChemistryModel.C +++ b/src/thermophysicalModels/chemistryModel/chemistryModel/StandardChemistryModel/StandardChemistryModel.C @@ -255,8 +255,7 @@ Foam::StandardChemistryModel::tc() const const label nReaction = reactions_.size(); - scalar pf, cf, pr, cr; - label lRef, rRef; + scalar omegaf, omegar; if (this->chemistry_) { @@ -279,12 +278,11 @@ Foam::StandardChemistryModel::tc() const forAll(reactions_, i) { const Reaction& R = reactions_[i]; - - R.omega(pi, Ti, c_, celli, pf, cf, lRef, pr, cr, rRef); + R.omega(pi, Ti, c_, celli, omegaf, omegar); forAll(R.rhs(), s) { - tc[celli] += R.rhs()[s].stoichCoeff*pf*cf; + tc[celli] += R.rhs()[s].stoichCoeff*omegaf; } } @@ -360,8 +358,7 @@ Foam::StandardChemistryModel::calculateRR reactionEvaluationScope scope(*this); - scalar pf, cf, pr, cr; - label lRef, rRef; + scalar omegaf, omegar; forAll(rho, celli) { @@ -376,16 +373,13 @@ Foam::StandardChemistryModel::calculateRR } const Reaction& R = reactions_[ri]; - const scalar omegai = R.omega - ( - pi, Ti, c_, celli, pf, cf, lRef, pr, cr, rRef - ); + const scalar omegaI = R.omega(pi, Ti, c_, celli, omegaf, omegar); forAll(R.lhs(), s) { if (si == R.lhs()[s].index) { - RR[celli] -= R.lhs()[s].stoichCoeff*omegai; + RR[celli] -= R.lhs()[s].stoichCoeff*omegaI; } } @@ -393,7 +387,7 @@ Foam::StandardChemistryModel::calculateRR { if (si == R.rhs()[s].index) { - RR[celli] += R.rhs()[s].stoichCoeff*omegai; + RR[celli] += R.rhs()[s].stoichCoeff*omegaI; } } diff --git a/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/TDACChemistryModel.C b/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/TDACChemistryModel.C index dd14ae8e29..4d51cf081b 100644 --- a/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/TDACChemistryModel.C +++ b/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/TDACChemistryModel.C @@ -135,8 +135,7 @@ void Foam::TDACChemistryModel::omega { const bool reduced = mechRed_->active(); - scalar pf, cf, pr, cr; - label lRef, rRef; + scalar omegaf, omegar; dcdt = Zero; @@ -145,33 +144,26 @@ void Foam::TDACChemistryModel::omega if (!reactionsDisabled_[i]) { const Reaction& R = this->reactions_[i]; - - scalar omegai = R.omega - ( - p, T, c, li, pf, cf, lRef, pr, cr, rRef - ); + const scalar omegaI = R.omega(p, T, c, li, omegaf, omegar); forAll(R.lhs(), s) { - label si = R.lhs()[s].index; - if (reduced) - { - si = completeToSimplifiedIndex_[si]; - } - + const label si = + reduced + ? completeToSimplifiedIndex_[R.lhs()[s].index] + : R.lhs()[s].index; const scalar sl = R.lhs()[s].stoichCoeff; - dcdt[si] -= sl*omegai; + dcdt[si] -= sl*omegaI; } + forAll(R.rhs(), s) { - label si = R.rhs()[s].index; - if (reduced) - { - si = completeToSimplifiedIndex_[si]; - } - + const label si = + reduced + ? completeToSimplifiedIndex_[R.rhs()[s].index] + : R.rhs()[s].index; const scalar sr = R.rhs()[s].stoichCoeff; - dcdt[si] += sr*omegai; + dcdt[si] += sr*omegaI; } } } diff --git a/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/reduction/DAC/DAC.C b/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/reduction/DAC/DAC.C index 68f179e2c3..a4dc6fc309 100644 --- a/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/reduction/DAC/DAC.C +++ b/src/thermophysicalModels/chemistryModel/chemistryModel/TDACChemistryModel/reduction/DAC/DAC.C @@ -263,14 +263,13 @@ void Foam::chemistryReductionMethods::DAC::reduceMechanism // Index of the other species involved in the rABNum RectangularMatrix