Skip to content

Commit 5131144

Browse files
authored
Merge pull request #304 from pkuLmq/master
add calculation of net production rates in dfChemistryModel
2 parents aca64be + 3e912b2 commit 5131144

2 files changed

Lines changed: 55 additions & 1 deletion

File tree

src/dfChemistryModel/dfChemistryModel.C

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ Foam::dfChemistryModel<ThermoType>::dfChemistryModel
6565
hrtTemp_(mixture_.nSpecies()),
6666
cTemp_(mixture_.nSpecies()),
6767
RR_(mixture_.nSpecies()),
68+
wrate_(mixture_.nSpecies()),
6869
alpha_(const_cast<volScalarField&>(thermo.alpha())),
6970
T_(thermo.T()),
7071
p_(thermo.p()),
@@ -231,7 +232,26 @@ Foam::dfChemistryModel<ThermoType>::dfChemistryModel
231232
)
232233
);
233234
}
234-
235+
forAll(wrate_, fieldi)
236+
{
237+
wrate_.set
238+
(
239+
fieldi,
240+
new volScalarField::Internal
241+
(
242+
IOobject
243+
(
244+
"wrate." + Y_[fieldi].name(),
245+
mesh_.time().timeName(),
246+
mesh_,
247+
IOobject::NO_READ,
248+
IOobject::NO_WRITE
249+
),
250+
mesh_,
251+
dimensionedScalar(dimMass/dimVolume/dimTime, 0)
252+
)
253+
);
254+
}
235255
forAll(rhoD_, i)
236256
{
237257
rhoD_.set
@@ -727,6 +747,34 @@ Foam::dfChemistryModel<ThermoType>::updateReactionRates
727747
return deltaTMin;
728748
}
729749

750+
template<class ThermoType>
751+
void Foam::dfChemistryModel<ThermoType>::calculateW()
752+
{
753+
doublereal Yi[mixture_.nSpecies()];
754+
doublereal twrate[mixture_.nSpecies()];
755+
756+
forAll(rho_, celli)
757+
{
758+
const scalar rhoi = rho_[celli];
759+
const scalar Ti = T_[celli];
760+
const scalar pi = p_[celli];
761+
762+
for (label i=0; i<mixture_.nSpecies(); i++)
763+
{
764+
Yi[i] = Y_[i][celli];
765+
}
766+
767+
CanteraGas_->setState_TPY(Ti, pi, Yi);
768+
769+
CanteraKinetics_->getNetProductionRates(twrate);
770+
771+
for (label i=0; i<mixture_.nSpecies(); i++)
772+
{
773+
wrate_[i][celli] = twrate[i]*CanteraGas_->molecularWeight(i);
774+
}
775+
}
776+
}
777+
730778
template<class ThermoType>
731779
Foam::tmp<Foam::DimensionedField<Foam::scalar, Foam::volMesh>>
732780
Foam::dfChemistryModel<ThermoType>::calculateRR

src/dfChemistryModel/dfChemistryModel.H

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ public IOdictionary
119119
mutable scalarList cTemp_;
120120
// mass change rate, [kg/m^3/s]
121121
PtrList<volScalarField::Internal> RR_;
122+
// net production rates, [kg/m^3/s]
123+
PtrList<volScalarField::Internal> wrate_;
122124
hashedWordList species_;
123125
volScalarField& alpha_;
124126
volScalarField& T_;
@@ -285,6 +287,10 @@ public:
285287
//- Return access to chemical source terms [kg/m^3/s]
286288
volScalarField::Internal& RR(const label i) {return RR_[i];}
287289

290+
void calculateW();
291+
292+
volScalarField::Internal& wrate(const label i) {return wrate_[i];}
293+
288294
tmp<volScalarField::Internal> calculateRR
289295
(
290296
const label reactionI,

0 commit comments

Comments
 (0)