Reaction rate depending on the temperature field
Hi all,
I am trying to apply a reaction rate depending on the temperature of the solid phase for my new solver. After runnig "wmake" it shows some errors.Can someone help me on finding the error. my code is to calculate the "dryingRate" depending on the temperature.
my code is as follows, forAll(ts,celli) //ts is a volScalarField { if(ts[celli]<hunderdCel.value()) //this is 373K {dimensionedScalar dryingRate[celli]=scalar(6)*massTransCoeff[celli]*(Ymoist[celli]*rhos[celli]-YH2O[celli]*rho)/F; //return dryingRate[celli]; } else if(ts[celli]=(hunderdCel.value())) { dimensionedScalar dryingRate[celli]=scalar(6)*(convectiveHeatTransCoeff[celli] *(tg[celli] -ts[celli] )+scalar(0.9)*stephBoltz*(pow(298.15,4)-pow(ts[celli] ,4)))/(F*VapHeat); //return dryingRate[celli]; } //else(ts[celli]>hunderdCel.value()); else {dimensionedScalar dryingRate=Zero;} //return dryingRate[celli];} } please see whether can someone find the error.The error is as follows, createFields.H:1046:115: error: variable-sized object ‘dryingRate’ may not be initialized {dimensionedScalar dryingRate[celli]=scalar(6)*massTransCoeff[celli]*(Ymoist[celli]*rhos[celli]-YH2O[celli]*rho)/F; ^ createFields.H:1046:21: warning: unused variable ‘dryingRate’ [-Wunused-variable] {dimensionedScalar dryingRate[celli]=scalar(6)*massTransCoeff[celli]*(Ymoist[celli]*rhos[celli]-YH2O[celli]*rho)/F; ^ createFields.H:1049:40: warning: suggest parentheses around assignment used as truth value [-Wparentheses] else if(ts[celli]=(hunderdCel.value())) ^ createFields.H:1052:174: error: variable-sized object ‘dryingRate’ may not be initialized dimensionedScalar dryingRate[celli]=scalar(6)*(convectiveHeatTransCoeff[celli] *(tg[celli] -ts[celli] )+scalar(0.9)*stephBoltz*(pow(298.15,4)-pow(ts[celli] ,4)))/(F*VapHeat); ^ createFields.H:1052:20: warning: unused variable ‘dryingRate’ [-Wunused-variable] dimensionedScalar dryingRate[celli]=scalar(6)*(convectiveHeatTransCoeff[celli] *(tg[celli] -ts[celli] )+scalar(0.9)*stephBoltz*(pow(298.15,4)-pow(ts[celli] ,4)))/(F*VapHeat); ^ Thanks in advance. |
still trying to do the above but not working,I did some amendments to the coding which seemed to me errorneous.
added following internalFields. scalarField& tgCells =tg.internalField(); //scalarField& dryingRateCells =dryingRate.internalField(); scalarField& massTransCoeffCells =massTransCoeff.internalField(); scalarField& YmoistCells =Ymoist.internalField(); scalarField& rhosCells =rhos.internalField(); scalarField& convectiveHeatTransCoeffCells=convectiveHeatTransC oeff.internalField(); scalarField& tsCells =ts.internalField(); scalarField& YH2OCells=YH2O.internalField(); forAll(tgCells,celli) { if (mag(tgCells[celli])<373.15) { dimensionedScalar dryingRateCells[celli]=scalar(6)*massTransCoeffCells[celli]*(YmoistCells[celli]*rhosCells[celli]-YH2OCells[celli]*rho)/F; } else { if (mag(tgCells[celli])==373.15) dimensionedScalar dryingRateCells[celli]=scalar(6)*(convectiveHeatTransCoeffCells[celli] *(tgCells[celli] -tsCells[celli] )+scalar(0.9)*stephBoltz*(pow(298.15,4)-pow(tsCells[celli] ,4)))/(F*VapHeat); else dimensionedScalar dryingRateCells[celli]=Zero; } } But this does not work.Following are the errors.I am struggling to get over with it. createFields.H:1019:139: error: variable-sized object ‘dryingRateCells’ may not be initialized dimensionedScalar dryingRateCells[celli]=scalar(6)*massTransCoeffCells[celli]*(YmoistCells[celli]*rhosCells[celli]-YH2OCells[celli]*rho)/F; ^ createFields.H:1019:20: warning: unused variable ‘dryingRateCells’ [-Wunused-variable] dimensionedScalar dryingRateCells[celli]=scalar(6)*massTransCoeffCells[celli]*(YmoistCells[celli]*rhosCells[celli]-YH2OCells[celli]*rho)/F; ^ createFields.H:1025:201: error: variable-sized object ‘dryingRateCells’ may not be initialized dimensionedScalar dryingRateCells[celli]=scalar(6)*(convectiveHeatTransCoeffCells[celli] *(tgCells[celli] -tsCells[celli] )+scalar(0.9)*stephBoltz*(pow(298.15,4)-pow(tsCells[celli] ,4)))/(F*VapHeat); ^ createFields.H:1025:22: warning: unused variable ‘dryingRateCells’ [-Wunused-variable] dimensionedScalar dryingRateCells[celli]=scalar(6)*(convectiveHeatTransCoeffCells[celli] *(tgCells[celli] -tsCells[celli] )+scalar(0.9)*stephBoltz*(pow(298.15,4)-pow(tsCells[celli] ,4)))/(F*VapHeat); ^ createFields.H:1029:45: error: variable-sized object ‘dryingRateCells’ may not be initialized dimensionedScalar dryingRateCells[celli]=Zero; ^ createFields.H:1029:22: warning: unused variable ‘dryingRateCells’ [-Wunused-variable] dimensionedScalar dryingRateCells[celli]=Zero; ^ createFields.H:1013:19: warning: unused variable ‘dryingRateCells’ [-Wunused-variable] dimensionedScalar dryingRateCells[mesh.nCells()]; ^ If anyone can see where are the errors come from,I am grateful.:) Thanks. |
Answer
Even I did not receive any reply.I would like to mention,how I solved this.(I hope this method is correct:))
Instead of declaring 373.15 or it as a dimensionedScalar,I declared that too as a volScalarField.And directly compared it with ts, volScalarField dryingRate =volScalarField::null(); volScalarField dryingRate1=-scalar(6)*massTransCoeff*(Ymoist*rhos-YH2O*rho)/F; volScalarField dryingRate2=-scalar(6)*(convectiveHeatTransCoeff *(tg -ts)+scalar(0.9)*stephBoltz*(pow(298.15,4)-pow(ts,4)))/(F*VapHeat); //volScalarField dryingRate3=0; const volScalarField hundredCel ( IOobject ( "hundredCel", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::NO_WRITE ), mesh //dimensionedScalar("zero", dimTemperature, 0.0), //zeroGradientFvPatchScalarField::typeName ); if(ts<hundredCel) dryingRate=dryingRate1; else { if(ts<hundredCel) dryingRate=dryingRate2; else dryingRate=volScalarField::null(); } If there is any thing wrong in the coding please let me know. Thamali |
All times are GMT -4. The time now is 08:54. |