@@ -37,6 +37,7 @@ Foam::combustionModels::PaSR<ReactionThermo>::PaSR
3737)
3838:
3939 laminar < ReactionThermo > (modelType , thermo , turb , combustionProperties ),
40+ mixture_ (dynamic_cast < CanteraMixture & > (thermo )),
4041 // mu_(const_cast<volScalarField&>(dynamic_cast<psiThermo&>(thermo).mu()())),
4142 mu_ (const_cast < volScalarField & > (dynamic_cast < rhoThermo & > (thermo ).mu ()())),
4243 p_ (this -> thermo ().p ()),
@@ -274,54 +275,118 @@ void Foam::combustionModels::PaSR<ReactionThermo>::correct()
274275 const volScalarField & YCO2 = this -> chemistryPtr_ -> Y ()[specieCO2 ];
275276 const volScalarField & YH2 = this -> chemistryPtr_ -> Y ()[specieH2 ];
276277
277- //- initialize fuel and oxidizer chemitry time scale
278+ //- initialize fuel and oxidizer chemistry time scale
278279 volScalarField t_fuel = tc_ ;
279- volScalarField t_oxidizer = tc_ ;
280- volScalarField t_CO2 = tc_ ;
281- volScalarField t_H2 = tc_ ;
282-
283- forAll (rho ,cellI )
284- {
285-
286- scalar RR_fuel = this -> chemistryPtr_ -> RR (specieFuel )[cellI ];
287- scalar RR_oxidizer = this -> chemistryPtr_ -> RR (specieOxidizer )[cellI ];
288- scalar RR_CO2 = this -> chemistryPtr_ -> RR (specieCO2 )[cellI ];
289- scalar RR_H2 = this -> chemistryPtr_ -> RR (specieH2 )[cellI ];
290-
291- if ( (RR_oxidizer < 0.0 ) && (Yoxidizer [cellI ] > 1e-10 ) )
292- {
293- t_oxidizer [cellI ] = - rho [cellI ] * Yoxidizer [cellI ]/(RR_oxidizer );
294- }
280+ volScalarField t_oxidizer = tc_ ;
281+ volScalarField t_CO2 = tc_ ;
282+ volScalarField t_H2 = tc_ ;
283+
284+ forAll (rho ,cellI )
285+ {
286+
287+ scalar RR_fuel = this -> chemistryPtr_ -> RR (specieFuel )[cellI ];
288+ scalar RR_oxidizer = this -> chemistryPtr_ -> RR (specieOxidizer )[cellI ];
289+ scalar RR_CO2 = this -> chemistryPtr_ -> RR (specieCO2 )[cellI ];
290+ scalar RR_H2 = this -> chemistryPtr_ -> RR (specieH2 )[cellI ];
291+
292+ if ( (RR_oxidizer < 0.0 ) && (Yoxidizer [cellI ] > 1e-10 ) )
293+ {
294+ t_oxidizer [cellI ] = - rho [cellI ] * Yoxidizer [cellI ]/(RR_oxidizer );
295+ }
295296
296- if ( (RR_fuel < 0.0 ) && (Yfuel [cellI ] > 1e-10 ))
297- {
298- t_fuel [cellI ] = - rho [cellI ] * Yfuel [cellI ]/(RR_fuel );
299- }
297+ if ( (RR_fuel < 0.0 ) && (Yfuel [cellI ] > 1e-10 ))
298+ {
299+ t_fuel [cellI ] = - rho [cellI ] * Yfuel [cellI ]/(RR_fuel );
300+ }
300301
301- if ( (RR_CO2 > 0.0 ) && (YCO2 [cellI ] > 1e-10 ))
302- {
303- t_CO2 [cellI ] = rho [cellI ] * YCO2 [cellI ]/(RR_CO2 );
304- }
302+ if ( (RR_CO2 > 0.0 ) && (YCO2 [cellI ] > 1e-10 ))
303+ {
304+ t_CO2 [cellI ] = rho [cellI ] * YCO2 [cellI ]/(RR_CO2 );
305+ }
305306
306- if ( (RR_H2 < 0.0 ) && (YH2 [cellI ] > 1e-10 ))
307- {
308- t_H2 [cellI ] = - rho [cellI ] * YH2 [cellI ]/(RR_H2 );
309- }
307+ if ( (RR_H2 < 0.0 ) && (YH2 [cellI ] > 1e-10 ))
308+ {
309+ t_H2 [cellI ] = - rho [cellI ] * YH2 [cellI ]/(RR_H2 );
310+ }
310311
311- tc_ [cellI ] = max (t_oxidizer [cellI ],t_fuel [cellI ]);
312+ tc_ [cellI ] = max (t_oxidizer [cellI ],t_fuel [cellI ]);
312313
313- tc_ [cellI ] = max (t_CO2 [cellI ],tc_ [cellI ]);
314+ tc_ [cellI ] = max (t_CO2 [cellI ],tc_ [cellI ]);
314315
315- tc_ [cellI ] = max (t_H2 [cellI ],tc_ [cellI ]);
316+ tc_ [cellI ] = max (t_H2 [cellI ],tc_ [cellI ]);
316317 }
317318
318319 }
319320
320- if (chemistryScaleType_ == "formationRate" )
321+ else if (chemistryScaleType_ == "formationRate" )
321322 {
322323 tc_ = this -> tc ();
323324 }
324325
326+ else if (chemistryScaleType_ == "reactionRate" )
327+ {
328+ PtrList < volScalarField > & Y = this -> chemistryPtr_ -> Y ();
329+
330+ doublereal fwdRate [mixture_ .nReactions ()];
331+ doublereal revRate [mixture_ .nReactions ()];
332+ doublereal X [mixture_ .nSpecies ()];
333+
334+ forAll (rho , celli )
335+ {
336+ const scalar rhoi = rho [celli ];
337+ const scalar Ti = T_ [celli ];
338+ const scalar pi = p_ [celli ];
339+
340+ scalar cSum = 0 ;
341+
342+ for (label i = 0 ; i < mixture_ .nSpecies (); i ++ )
343+ {
344+ X [i ] = rhoi * Y [i ][celli ]/mixture_ .CanteraGas ()-> molecularWeight (i );
345+ cSum += X [i ];
346+ }
347+
348+ mixture_ .CanteraGas ()-> setState_TPX (Ti , pi , X );
349+ mixture_ .CanteraKinetics ()-> getFwdRatesOfProgress (fwdRate );
350+ mixture_ .CanteraKinetics ()-> getRevRatesOfProgress (revRate );
351+
352+ scalar sumW = 0 , sumWRateByCTot = 0 ;
353+
354+ for (label i = 0 ; i < mixture_ .nReactions (); i ++ )
355+ {
356+
357+ std ::shared_ptr < Cantera ::Reaction > R (mixture_ .CanteraKinetics ()-> reaction (i ));
358+
359+ scalar wf = 0 ;
360+ for (const auto& sp : R -> products )
361+ {
362+ wf += sp .second * fwdRate [i ];
363+ }
364+ sumW += wf ;
365+ sumWRateByCTot += sqr (wf );
366+
367+ scalar wr = 0 ;
368+ for (const auto & sp : R -> reactants )
369+ {
370+ wr += sp .second * revRate [i ];
371+ }
372+ sumW += wr ;
373+ sumWRateByCTot += sqr (wr );
374+ }
375+
376+ tc_ [celli ] = sumWRateByCTot == 0 ? vGreat : sumW /sumWRateByCTot * cSum ;
377+ }
378+
379+ tc_ .correctBoundaryConditions ();
380+ }
381+
382+ else
383+ {
384+ FatalErrorInFunction
385+ << "Unknown chemicalScaleType type "
386+ << chemistryScaleType_
387+ << ", not in table" << nl << nl
388+ << exit (FatalError );
389+ }
325390
326391 forAll (kappa_ , cellI )
327392 {
0 commit comments