Skip to content

Commit

Permalink
Update dfChemistryModel.C
Browse files Browse the repository at this point in the history
  • Loading branch information
minzhang0929 authored May 31, 2023
1 parent 10f001c commit 9fadf6b
Showing 1 changed file with 33 additions and 31 deletions.
64 changes: 33 additions & 31 deletions src/dfChemistryModel/dfChemistryModel.C
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ Foam::dfChemistryModel<ThermoType>::dfChemistryModel
Y_(mixture_.Y()),
rhoD_(mixture_.nSpecies()),
hai_(mixture_.nSpecies()),
hc_(mixture_.nSpecies()),
c_(mixture_.nSpecies()),
hc_(mixture_.nSpecies()),
yTemp_(mixture_.nSpecies()),
dTemp_(mixture_.nSpecies()),
hrtTemp_(mixture_.nSpecies()),
Expand Down Expand Up @@ -729,20 +728,23 @@ Foam::dfChemistryModel<ThermoType>::calculateRR
const label speciei
) const
{
tmp<volScalarField::Internal> tRR
(
volScalarField::Internal::New
(
tmp<volScalarField::Internal> tRR
(
volScalarField::Internal::New
(
"RR",
mesh_,
dimensionedScalar(dimMass/dimVolume/dimTime, 0)
)
);
)
);

volScalarField::Internal& RR = tRR.ref();
volScalarField::Internal& RR = tRR.ref();

// mole fraction
mutable scalarList c[mixture_.nSpecies()];

doublereal netRate[mixture_.nReactions()];
doublereal X[mixture_.nSpecies()];
doublereal netRate[mixture_.nReactions()];
doublereal X[mixture_.nSpecies()];

forAll(rho_, celli)
{
Expand All @@ -754,35 +756,35 @@ Foam::dfChemistryModel<ThermoType>::calculateRR
{
const scalar Yi = Y_[i][celli];

c_[i] = rhoi*Yi/CanteraGas_->molecularWeight(i);
c[i] = rhoi*Yi/CanteraGas_->molecularWeight(i);
}

for(label i=0; i<mixture_.nSpecies(); i++)
{
X[i] = c_[i];
}
for(label i=0; i<mixture_.nSpecies(); i++)
{
X[i] = c[i];
}

CanteraGas_->setState_TPX(Ti, pi, X);
CanteraGas_->setState_TPX(Ti, pi, X);

CanteraKinetics_->getNetRatesOfProgress(netRate);
CanteraKinetics_->getNetRatesOfProgress(netRate);

auto R = CanteraKinetics_->reaction(reactionI);
auto R = CanteraKinetics_->reaction(reactionI);

for (const auto& sp : R->reactants)
for (const auto& sp : R->reactants)
{
if (speciei == static_cast<int>(CanteraGas_->speciesIndex(sp.first)))
{
if (speciei == static_cast<int>(CanteraGas_->speciesIndex(sp.first)))
{
RR[celli] -= sp.second*netRate[reactionI];
}
RR[celli] -= sp.second*netRate[reactionI];
}

}
for (const auto& sp : R->products)
}
for (const auto& sp : R->products)
{
if (speciei == static_cast<int>(CanteraGas_->speciesIndex(sp.first)))
{
if (speciei == static_cast<int>(CanteraGas_->speciesIndex(sp.first)))
{
RR[celli] += sp.second*netRate[reactionI];
}
}
RR[celli] += sp.second*netRate[reactionI];
}
}

RR[celli] *= CanteraGas_->molecularWeight(speciei);
}
Expand Down

0 comments on commit 9fadf6b

Please sign in to comment.