CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Running, Solving & CFD

Extracting Reaction Rates OF20x

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree1Likes
  • 1 Post By ahcai007

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 11, 2014, 02:10
Default Extracting Reaction Rates OF20x
  #1
New Member
 
Ah Cai
Join Date: Dec 2010
Location: Malaysia
Posts: 16
Rep Power: 15
ahcai007 is on a distinguished road
Hi,

I am using the tutorial dieselFoam with its global n-heptane mechanism to simulate diesel combustion. I wanted to output the reaction rates for CO2 as the fuel combusts. I checked that in basicChemistryModel.H and found that RR() refers to Reaction rates. However, when I type "chemistry.RR()" it does not work.

If I write it this way where I include the chemistry.RR() in a for loop.

PHP Code:
forAll (celli)
{
       
scalarField rr=chemistry.RR(celli);
       
Info<< "Reaction rate = " << rr << endl << endl;

it will produce a results as seen in log.txt.

If I were to write it as such:
PHP Code:
forAll (celli)
{
       
scalarField rr=chemistry.RR(celli);
       
Info<< "Reaction rate = " << rr[3] << endl << endl;

it will produce an output as seen in log2.txt.

My guess is that "rr" will output the reaction rates of ALL the species at ALL the cells while "rr[3]" will only output the reaction rates of ALL the species at cell[3].

What I had in mind is to extract only the RR for one of the species (for my case, CO2) over all the cells.

Thanks.


Ahcai
Attached Files
File Type: txt log2.txt (17.1 KB, 54 views)
File Type: txt log.txt (50.8 KB, 52 views)
Kummi likes this.
ahcai007 is offline   Reply With Quote

Old   January 13, 2014, 14:09
Default
  #2
Senior Member
 
mturcios777's Avatar
 
Marco A. Turcios
Join Date: Mar 2009
Location: Vancouver, BC, Canada
Posts: 740
Rep Power: 28
mturcios777 will become famous soon enough
The RR in basicChemistryModel is a virtual function and is implemented later, in ODEChemistry (this isn't immediately obvious, but by looking at the thermyphysicalType in the thermphysicalProperties file you can see it). It also returns a scalar field, which is why you are able to initialize rr in both cases. If you look at ODEChemistryModelI.H at line 71, what RR(const label i) actually does is return the reation rate for species i.

In both cases, rr contains the entire RR field for whatever species happens to be in index cellI. Since Y is a PtrList for scalarfields, what you are actually doing is stepping through all 5 species. Have a look at YEqn.H to see what I mean. In the first case, you are returning the entire RR field for each species (for each iteration, you should see 5 outputs of "Reaction Rate". In the second, you are obtaining the reation rate for each species at cell index 3 (again, you have 5 outputs corresponding to the 5 species).

What you need to find is the index of CO2 in your thermo setup, then call chemistry.RR(CO2 index), which will give what you are looking for.
mturcios777 is offline   Reply With Quote

Old   January 27, 2014, 04:07
Default
  #3
New Member
 
Ah Cai
Join Date: Dec 2010
Location: Malaysia
Posts: 16
Rep Power: 15
ahcai007 is on a distinguished road
Quote:
Originally Posted by mturcios777 View Post
The RR in basicChemistryModel is a virtual function and is implemented later, in ODEChemistry (this isn't immediately obvious, but by looking at the thermyphysicalType in the thermphysicalProperties file you can see it). It also returns a scalar field, which is why you are able to initialize rr in both cases. If you look at ODEChemistryModelI.H at line 71, what RR(const label i) actually does is return the reation rate for species i.

In both cases, rr contains the entire RR field for whatever species happens to be in index cellI. Since Y is a PtrList for scalarfields, what you are actually doing is stepping through all 5 species. Have a look at YEqn.H to see what I mean. In the first case, you are returning the entire RR field for each species (for each iteration, you should see 5 outputs of "Reaction Rate". In the second, you are obtaining the reation rate for each species at cell index 3 (again, you have 5 outputs corresponding to the 5 species).

What you need to find is the index of CO2 in your thermo setup, then call chemistry.RR(CO2 index), which will give what you are looking for.
Hi Marco,

Thanks for the explanation. It helped a lot and I manage to make it work =)

Cheers~
ahcai007 is offline   Reply With Quote

Old   June 2, 2016, 12:01
Default
  #4
New Member
 
Mr.liu
Join Date: Sep 2012
Posts: 27
Rep Power: 13
lx882211 is on a distinguished road
Quote:
Originally Posted by ahcai007 View Post
Hi Marco,

Thanks for the explanation. It helped a lot and I manage to make it work =)

Cheers~
I meet a problem in Openfoam 2.3.0, reactingFoam, i need the data of CH4 reaction rate in contour(figure), but i failed to autowrite it like U or Yi.

First i added this code in the CreatField.H,

volScalarField Rrate
(
IOobject
(
"Rrate",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh,
dimensionedScalar("Rrate", dimMass/dimVolume/dimTime, 0.0)
);

Then, i added this code in YEqn,

forAll(Y, i)
{
if (Y[i].name() != "CH4")
RR = reaction->R(Yi);
}

After wmake, it shows

YEqn.H:26:14: error: no match for ‘operator=’ (operand types are ‘Foam::volScalarField {aka Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>}’ and ‘Foam::tmp<Foam::fvMatrix<double> >’)
Rrate = reaction->R(Yi);

Can you tell me how to do that? Thank you very much.
lx882211 is offline   Reply With Quote

Reply

Tags
dieselfoam, reaction rate

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Segmentation fault in running alternateSteadyReactingFoam,why? NewKid OpenFOAM 18 January 20, 2011 16:55
combustion - reaction rates - urgent help needed siri Main CFD Forum 2 March 3, 2007 12:25
EDC l- Reaction Rates are Zero for some Reactions Atul FLUENT 2 October 7, 2005 10:38
chemical reaction - decompostition La S. Hyuck CFX 1 May 23, 2001 00:07
Reaction rates Szasz Robert FLUENT 1 May 10, 2000 06:06


All times are GMT -4. The time now is 22:27.