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

Extracting Reaction Rates OF20x

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

Reply
 
LinkBack Thread Tools Display Modes
Old   January 11, 2014, 03:10
Default Extracting Reaction Rates OF20x
  #1
New Member
 
Ah Cai
Join Date: Dec 2010
Location: Malaysia
Posts: 16
Rep Power: 6
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, 5 views)
File Type: txt log.txt (50.8 KB, 6 views)
ahcai007 is offline   Reply With Quote

Old   January 13, 2014, 15:09
Default
  #2
Senior Member
 
mturcios777's Avatar
 
Marco A. Turcios
Join Date: Mar 2009
Location: Vancouver, BC, Canada
Posts: 719
Rep Power: 18
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, 05:07
Default
  #3
New Member
 
Ah Cai
Join Date: Dec 2010
Location: Malaysia
Posts: 16
Rep Power: 6
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

Reply

Tags
dieselfoam, reaction rate

Thread Tools
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 On
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 17:55
combustion - reaction rates - urgent help needed siri Main CFD Forum 2 March 3, 2007 13: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 03:56.