@@ -51,14 +51,15 @@ Foam::dfChemistryModel<ThermoType>::dfChemistryModel
5151 thermo_ (thermo ),
5252 mixture_ (dynamic_cast < CanteraMixture & > (thermo )),
5353 CanteraGas_ (mixture_ .CanteraGas ()),
54+ CanteraKinetics_ (mixture_ .CanteraKinetics ()),
5455 mesh_ (thermo .p ().mesh ()),
5556 chemistry_ (lookup ("chemistry ")),
5657 relTol_ (this -> subDict ("odeCoeffs ").lookupOrDefault ("relTol ",1e-9 )),
5758 absTol_ (this -> subDict ("odeCoeffs ").lookupOrDefault ("absTol ",1e-15 )),
5859 Y_ (mixture_ .Y ()),
5960 rhoD_ (mixture_ .nSpecies ()),
6061 hai_ (mixture_ .nSpecies ()),
61- hc_ (mixture_ .nSpecies ()),
62+ hc_ (mixture_ .nSpecies ()),
6263 yTemp_ (mixture_ .nSpecies ()),
6364 dTemp_ (mixture_ .nSpecies ()),
6465 hrtTemp_ (mixture_ .nSpecies ()),
@@ -719,7 +720,69 @@ Foam::dfChemistryModel<ThermoType>::updateReactionRates
719720 return deltaTMin ;
720721}
721722
723+ template < class ThermoType >
724+ Foam ::tmp < Foam ::DimensionedField < Foam ::scalar , Foam ::volMesh >>
725+ Foam ::dfChemistryModel < ThermoType > ::calculateRR
726+ (
727+ const label reactionI ,
728+ const label speciei
729+ ) const
730+ {
731+ tmp < volScalarField ::Internal > tRR
732+ (
733+ volScalarField ::Internal ::New
734+ (
735+ "RR" ,
736+ mesh_ ,
737+ dimensionedScalar (dimMass /dimVolume /dimTime , 0 )
738+ )
739+ );
740+
741+ volScalarField ::Internal & RR = tRR .ref ();
742+
743+ doublereal netRate [mixture_ .nReactions ()];
744+ doublereal X [mixture_ .nSpecies ()];
745+
746+ forAll (rho_ , celli )
747+ {
748+ const scalar rhoi = rho_ [celli ];
749+ const scalar Ti = T_ [celli ];
750+ const scalar pi = p_ [celli ];
751+
752+ for (label i = 0 ; i < mixture_ .nSpecies (); i ++ )
753+ {
754+ const scalar Yi = Y_ [i ][celli ];
755+
756+ X [i ] = rhoi * Yi /CanteraGas_ -> molecularWeight (i );
757+ }
758+
759+ CanteraGas_ -> setState_TPX (Ti , pi , X );
760+
761+ CanteraKinetics_ -> getNetRatesOfProgress (netRate );
722762
763+ auto R = CanteraKinetics_ -> reaction (reactionI );
764+
765+ for (const auto& sp : R -> reactants )
766+ {
767+ if (speciei == static_cast < int > (CanteraGas_ -> speciesIndex (sp .first )))
768+ {
769+ RR [celli ] -= sp .second * netRate [reactionI ];
770+ }
771+
772+ }
773+ for (const auto & sp : R -> products )
774+ {
775+ if (speciei == static_cast < int > (CanteraGas_ -> speciesIndex (sp .first )))
776+ {
777+ RR [celli ] += sp .second * netRate [reactionI ];
778+ }
779+ }
780+
781+ RR [celli ] *= CanteraGas_ -> molecularWeight (speciei );
782+ }
783+
784+ return tRR ;
785+ }
723786
724787template < class ThermoType >
725788Foam ::LoadBalancer
0 commit comments