@@ -59,8 +59,7 @@ Foam::dfChemistryModel<ThermoType>::dfChemistryModel
5959 Y_ (mixture_ .Y ()),
6060 rhoD_ (mixture_ .nSpecies ()),
6161 hai_ (mixture_ .nSpecies ()),
62- hc_ (mixture_ .nSpecies ()),
63- c_ (mixture_ .nSpecies ()),
62+ hc_ (mixture_ .nSpecies ()),
6463 yTemp_ (mixture_ .nSpecies ()),
6564 dTemp_ (mixture_ .nSpecies ()),
6665 hrtTemp_ (mixture_ .nSpecies ()),
@@ -729,20 +728,23 @@ Foam::dfChemistryModel<ThermoType>::calculateRR
729728 const label speciei
730729) const
731730{
732- tmp < volScalarField ::Internal > tRR
733- (
734- volScalarField ::Internal ::New
735- (
731+ tmp < volScalarField ::Internal > tRR
732+ (
733+ volScalarField ::Internal ::New
734+ (
736735 "RR" ,
737736 mesh_ ,
738737 dimensionedScalar (dimMass /dimVolume /dimTime , 0 )
739- )
740- );
738+ )
739+ );
741740
742- volScalarField ::Internal & RR = tRR .ref ();
741+ volScalarField ::Internal & RR = tRR .ref ();
742+
743+ // mole fraction
744+ mutable scalarList c [mixture_ .nSpecies ()];
743745
744- doublereal netRate [mixture_ .nReactions ()];
745- doublereal X [mixture_ .nSpecies ()];
746+ doublereal netRate [mixture_ .nReactions ()];
747+ doublereal X [mixture_ .nSpecies ()];
746748
747749 forAll (rho_ , celli )
748750 {
@@ -754,35 +756,35 @@ Foam::dfChemistryModel<ThermoType>::calculateRR
754756 {
755757 const scalar Yi = Y_ [i ][celli ];
756758
757- c_ [i ] = rhoi * Yi /CanteraGas_ -> molecularWeight (i );
759+ c [i ] = rhoi * Yi /CanteraGas_ -> molecularWeight (i );
758760 }
759761
760- for (label i = 0 ; i < mixture_ .nSpecies (); i ++ )
761- {
762- X [i ] = c_ [i ];
763- }
762+ for (label i = 0 ; i < mixture_ .nSpecies (); i ++ )
763+ {
764+ X [i ] = c [i ];
765+ }
764766
765- CanteraGas_ -> setState_TPX (Ti , pi , X );
767+ CanteraGas_ -> setState_TPX (Ti , pi , X );
766768
767- CanteraKinetics_ -> getNetRatesOfProgress (netRate );
769+ CanteraKinetics_ -> getNetRatesOfProgress (netRate );
768770
769- auto R = CanteraKinetics_ -> reaction (reactionI );
771+ auto R = CanteraKinetics_ -> reaction (reactionI );
770772
771- for (const auto& sp : R -> reactants )
773+ for (const auto& sp : R -> reactants )
774+ {
775+ if (speciei == static_cast < int > (CanteraGas_ -> speciesIndex (sp .first )))
772776 {
773- if (speciei == static_cast < int > (CanteraGas_ -> speciesIndex (sp .first )))
774- {
775- RR [celli ] -= sp .second * netRate [reactionI ];
776- }
777+ RR [celli ] -= sp .second * netRate [reactionI ];
778+ }
777779
778- }
779- for (const auto & sp : R -> products )
780+ }
781+ for (const auto & sp : R -> products )
782+ {
783+ if (speciei == static_cast < int > (CanteraGas_ -> speciesIndex (sp .first )))
780784 {
781- if (speciei == static_cast < int > (CanteraGas_ -> speciesIndex (sp .first )))
782- {
783- RR [celli ] += sp .second * netRate [reactionI ];
784- }
785- }
785+ RR [celli ] += sp .second * netRate [reactionI ];
786+ }
787+ }
786788
787789 RR [celli ] *= CanteraGas_ -> molecularWeight (speciei );
788790 }
0 commit comments