@@ -58,6 +58,7 @@ Foam::dfChemistryModel<ThermoType>::dfChemistryModel
5858 Y_ (mixture_ .Y ()),
5959 rhoD_ (mixture_ .nSpecies ()),
6060 hai_ (mixture_ .nSpecies ()),
61+ hc_ (mixture_ .nSpecies ()),
6162 yTemp_ (mixture_ .nSpecies ()),
6263 dTemp_ (mixture_ .nSpecies ()),
6364 hrtTemp_ (mixture_ .nSpecies ()),
@@ -190,6 +191,11 @@ Foam::dfChemistryModel<ThermoType>::dfChemistryModel
190191 Info <<"--- I am here in Cantera-construct ---" <<endl ;
191192 Info <<"relTol_ === " <<relTol_ <<endl ;
192193 Info <<"absTol_ === " <<absTol_ <<endl ;
194+
195+ forAll (hc_ , i )
196+ {
197+ hc_ [i ] = CanteraGas_ -> Hf298SS (i )/CanteraGas_ -> molecularWeight (i );
198+ }
193199}
194200
195201
@@ -278,7 +284,7 @@ Foam::scalar Foam::dfChemistryModel<ThermoType>::canteraSolve
278284 scalar pi = p_ [cellI ];
279285 try
280286 {
281- for (size_t i = 0 ; i < CanteraGas_ -> nSpecies (); i ++ )
287+ for (size_t i = 0 ; i < CanteraGas_ -> nSpecies (); ++ i )
282288 {
283289 yTemp_ [i ] = Y_ [i ][cellI ];
284290 }
@@ -298,16 +304,15 @@ Foam::scalar Foam::dfChemistryModel<ThermoType>::canteraSolve
298304
299305 CanteraGas_ -> getConcentrations (cTemp_ .begin ()); // value --> cTemp_
300306
301- for (size_t i = 0 ; i < CanteraGas_ -> nSpecies (); i ++ )
307+ for (size_t i = 0 ; i < CanteraGas_ -> nSpecies (); ++ i )
302308 {
303309 RR_ [i ][cellI ] = (cTemp_ [i ] - c0 [i ])* CanteraGas_ -> molecularWeight (i )/deltaT [cellI ];
304310 }
305311 // CanteraGas_->molecularWeight(i) kg/kmol
306312
307313 forAll (Y_ , i )
308314 {
309- const scalar hc = CanteraGas_ -> Hf298SS (i )/CanteraGas_ -> molecularWeight (i ); // J/kg
310- Qdot_ [cellI ] -= hc * RR_ [i ][cellI ];
315+ Qdot_ [cellI ] -= hc_ [i ]* RR_ [i ][cellI ];
311316 }
312317 }
313318 catch (Cantera ::CanteraError & err )
@@ -380,7 +385,7 @@ Foam::scalar Foam::dfChemistryModel<ThermoType>::torchSolve
380385 }
381386 torch ::jit ::script ::Module torchModel_ = torch ::jit ::load (torchModelName_ , device );
382387
383- std ::vector < size_t > torch_cell ;
388+ std ::vector < label > torch_cell ;
384389 label torch_cellname = 0 ;
385390
386391 // obtain the number of DNN cells
@@ -408,12 +413,12 @@ Foam::scalar Foam::dfChemistryModel<ThermoType>::torchSolve
408413 std ::vector < double > inputs_ ;
409414 inputs_ .push_back ((Ti - Xmu_ [0 ])/Xstd_ [0 ]);
410415 inputs_ .push_back ((pi / 101325 - Xmu_ [1 ])/Xstd_ [1 ]);
411- for (size_t i = 0 ; i < CanteraGas_ -> nSpecies (); i ++ )
416+ for (size_t i = 0 ; i < CanteraGas_ -> nSpecies (); ++ i )
412417 {
413418 yPre_ [i ] = Y_ [i ][cellI ];
414419 yBCT_ [i ] = (pow (yPre_ [i ],lambda ) - 1 ) / lambda ; // function BCT
415420 }
416- for (size_t i = 0 ; i < CanteraGas_ -> nSpecies (); i ++ )
421+ for (size_t i = 0 ; i < CanteraGas_ -> nSpecies (); ++ i )
417422 {
418423 inputs_ .push_back ((yBCT_ [i ] - Xmu_ [i + 2 ]) / Xstd_ [i + 2 ]);
419424 }
@@ -424,7 +429,7 @@ Foam::scalar Foam::dfChemistryModel<ThermoType>::torchSolve
424429 else
425430 {
426431 Qdot_ [cellI ] = 0.0 ;
427- for (size_t i = 0 ; i < CanteraGas_ -> nSpecies (); i ++ )
432+ for (size_t i = 0 ; i < CanteraGas_ -> nSpecies (); ++ i )
428433 {
429434 yPre_ [i ] = Y_ [i ][cellI ];
430435 }
@@ -440,11 +445,10 @@ Foam::scalar Foam::dfChemistryModel<ThermoType>::torchSolve
440445
441446 CanteraGas_ -> getMassFractions (yTemp_ .begin ());
442447
443- for (size_t i = 0 ; i < CanteraGas_ -> nSpecies (); i ++ )
448+ for (size_t i = 0 ; i < CanteraGas_ -> nSpecies (); ++ i )
444449 {
445450 RR_ [i ][cellI ] = (yTemp_ [i ] - yPre_ [i ])* rhoi /deltaT ;
446- const scalar hc = CanteraGas_ -> Hf298SS (i )/CanteraGas_ -> molecularWeight (i ); // J/kg
447- Qdot_ [cellI ] -= hc * RR_ [i ][cellI ];
451+ Qdot_ [cellI ] -= hc_ [i ]* RR_ [i ][cellI ];
448452 }
449453 }
450454 }
@@ -457,24 +461,23 @@ Foam::scalar Foam::dfChemistryModel<ThermoType>::torchSolve
457461 {
458462 // update y
459463 scalar Yt = 0 ;
460- for (size_t i = 0 ; i < CanteraGas_ -> nSpecies (); i ++ )
464+ for (size_t i = 0 ; i < CanteraGas_ -> nSpecies (); ++ i )
461465 {
462466 yPre_ [i ] = Y_ [i ][torch_cell [cellI ]];
463467 yTemp_ [i ] = Y_ [i ][torch_cell [cellI ]];
464468 yBCT_ [i ] = (pow (yPre_ [i ],lambda ) - 1 ) / lambda ; // function BCT
465469 }
466- for (size_t i = 0 ; i < (CanteraGas_ -> nSpecies ()); i ++ )//
470+ for (size_t i = 0 ; i < (CanteraGas_ -> nSpecies ()); ++ i )//
467471 {
468472 u_ [i + 2 ] = outputs [cellI ][i + 2 ].item ().to < double > ( )* Ystd_ [i + 2 ]+ Ymu_ [i + 2 ];
469473 yTemp_ [i ] = pow ((yBCT_ [i ] + u_ [i + 2 ]* deltaT )* lambda + 1 ,1 /lambda );
470474 Yt += yTemp_ [i ];
471475 }
472- for (size_t i = 0 ; i < CanteraGas_ -> nSpecies (); i ++ )
476+ for (size_t i = 0 ; i < CanteraGas_ -> nSpecies (); ++ i )
473477 {
474478 yTemp_ [i ] = yTemp_ [i ] / Yt ;
475479 RR_ [i ][torch_cell [cellI ]] = (yTemp_ [i ] - Y_ [i ][torch_cell [cellI ]])* rho_ [torch_cell [cellI ]]/deltaT ;
476- const scalar hc = CanteraGas_ -> Hf298SS (i )/CanteraGas_ -> molecularWeight (i ); // J/kg
477- Qdot_ [torch_cell [cellI ]] -= hc * RR_ [i ][torch_cell [cellI ]];
480+ Qdot_ [torch_cell [cellI ]] -= hc_ [i ]* RR_ [i ][torch_cell [cellI ]];
478481 }
479482 }
480483
0 commit comments