|
[Sponsors] |
Why extract Formation Rate term of each species as 'reaction->R(Yi) & Yi'? |
![]() |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
![]() |
![]() |
#1 |
New Member
Harsh Anand
Join Date: May 2024
Posts: 12
Rep Power: 2 ![]() |
I have successfully extracted the Formation Rate term of each species as 'reaction->R(Yi) & Yi', following the instructions on similar threads. (The full YEqn.H file has been given below.)
I also understand that reaction->R(Yi) returns a fvScalarMatrix object instead of volScalarField object and so cannot be directly used while writing the field values to the volScalarField object. What I don't understand is that WHY do we need to take the inner product of reaction->R(Yi) with Yi (mass fraction of the ![]() It makes no intuitive sense to take a dot product of 'reaction->R(Yi)' with the mass fraction of the species ('Yi'), as multiplying the formation rate with something between [0,1] will change its value which we don't want. Someone, please help me understand this complication. I will be grateful for it! Code:
tmp<fv::convectionScheme<scalar>> mvConvection ( fv::convectionScheme<scalar>::New ( mesh, fields, phi, mesh.divScheme("div(phi,Yi_h)") ) ); { reaction->correct(); Qdot = reaction->Qdot(); volScalarField Yt(0.0 * Y[0]); forAll(Y, i) { if (i != inertIndex && composition.active(i)) { volScalarField& Yi = Y[i]; // Assemble the Yi equation fvScalarMatrix YiEqn ( fvm::ddt(rho, Yi) // Unsteady term + mvConvection->fvmDiv(phi, Yi) // Convection term - fvm::laplacian((turbulence->mu() / 1.0 + turbulence->mut() / 0.7), Yi) // Diffusion term == reaction->R(Yi) // Reaction term + fvOptions(rho, Yi) // Additional source terms ); YiEqn.relax(); fvOptions.constrain(YiEqn); YiEqn.solve(mesh.solver("Yi")); fvOptions.correct(Yi); Yi.max(0.0); if (mesh.time().outputTime()) { // Compute each budget term separately (MODIFICATION START) volScalarField unsteadyTerm ( IOobject ( "unsteadyTerm_" + Yi.name(), mesh.time().timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE ), fvc::ddt(rho, Yi) ); volScalarField convectionTerm ( IOobject ( "convectionTerm_" + Yi.name(), mesh.time().timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE ), mvConvection->fvcDiv(phi, Yi) ); volScalarField diffusionTerm ( IOobject ( "diffusionTerm_" + Yi.name(), mesh.time().timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE ), fvc::laplacian((turbulence->mu() / 1.0 + turbulence->mut() / 0.7), Yi) ); volScalarField reactionTerm ( IOobject ( "reactionTerm_" + Yi.name(), mesh.time().timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE ), reaction->R(Yi) & Yi ); // Store terms for visualization unsteadyTerm.write(); convectionTerm.write(); diffusionTerm.write(); reactionTerm.write(); // (MODIFICATION END) } Yt += Yi; } } Y[inertIndex] = scalar(1) - Yt; Y[inertIndex].max(0.0); } ---------------------------- Best Regards, GeekCFD |
|
![]() |
![]() |
![]() |
![]() |
#2 |
Senior Member
Join Date: Apr 2020
Location: UK
Posts: 792
Rep Power: 14 ![]() |
It's because fvScalarMatrix is a matrix of coefficients that act on Yi. Think of each diagonal entry in the fvMatrix as the reaction rate divided by the Yi value for that cell.
The & in code: Code:
volScalarField reactionTerm ( IOobject ( "reactionTerm_" + Yi.name(), mesh.time().timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE ), reaction->R(Yi) & Yi ); Code:
template<class Type> Foam::tmp<Foam::VolField<Type>> Foam::operator& ( const fvMatrix<Type>& M, const DimensionedField<Type, volMesh>& psi ) { tmp<VolField<Type>> tMphi ( VolField<Type>::New ( "M&" + psi.name(), psi.mesh(), M.dimensions()/dimVolume, extrapolatedCalculatedFvPatchScalarField::typeName ) ); VolField<Type>& Mphi = tMphi.ref(); // Loop over field components if (M.hasDiag()) { for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++) { scalarField psiCmpt(psi.primitiveField().component(cmpt)); scalarField boundaryDiagCmpt(M.diag()); M.addBoundaryDiag(boundaryDiagCmpt, cmpt); Mphi.primitiveFieldRef().replace(cmpt, -boundaryDiagCmpt*psiCmpt); } } else { Mphi.primitiveFieldRef() = Zero; } ... return tMphi; } |
|
![]() |
![]() |
![]() |
![]() |
#3 |
Senior Member
Join Date: Apr 2020
Location: UK
Posts: 792
Rep Power: 14 ![]() |
PS if the above is gobbledygook to you (as it was to me, a decade ago), then you'll need to do some research on fvMatrix and how OF solves linear equations. Jasak's thesis (Error analysis & estimation for the FV method) is always a good start. Good luck!
|
|
![]() |
![]() |
![]() |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Error in New Surface reaction model (Having multiple reactions) | surajkvs | OpenFOAM Programming & Development | 2 | May 23, 2023 22:21 |
How to get volumetric reaction rate of each species in species transport model | Yadu krishnan | FLUENT | 0 | November 28, 2021 00:46 |
TUI command to access reaction arrhenuis rate | Brad_rawl | FLUENT | 1 | September 23, 2021 00:35 |
Species Reaction Rate RR() | kaizhangqmul | OpenFOAM | 12 | September 21, 2021 06:16 |
UDF changing the rate exponent of a reaction | Stefan H | Fluent UDF and Scheme Programming | 0 | September 16, 2009 14:20 |