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

How are chemical reactions stored after parsing?

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 20, 2016, 06:04
Default How are chemical reactions stored after parsing?
  #1
New Member
 
Join Date: May 2016
Posts: 2
Rep Power: 0
DanielW is on a distinguished road
Hi everyone,

I'm currently trying to implement an enhancement for the modifiedReactingFoam-Solver to allow it to properly calculate surface reactions defined by the user.
I want the solver to allow for surface reactions to be defined and "attached" to any boundary within the domain and I want them to be proper chemical reactions that can for example create surface adsorbed species that stick to the boundaries or to generate reaction products which go right back into the adjecent fluid domain.

In order to do this, I need to solve some equations to get the reaction rates right and that's where I'm currently running into trouble.

Does somebody, by any chance, know how the chemical reactions and species are stored after parsing? I'm less interested in the storage of arrhenius parameters for now. I rather need to know how and where a chemical reaction and it's stoichometric coefficients are stored, so the solver later knows which of the species actually react within a given reaction.

Let's say I have five species:
A, B, C, D, E

and two reactions:
1) A + B = C
2) A + 2*D = B + E

The best case scenario for me would be if, upon parsing, the reactions from the reactions dictionary would generate a structure looking like this:

lhs (2x5):
Code:
1 1 0 0 0
1 0 0 2 0
rhs (2x5):
Code:
0 0 1 0 0
0 1 0 0 1
with lhs and rhs being matrices that store the left hand sides and right hand sides of reactions, each line corresponding to one reaction (equal to the reactions ID after parsing) and, most importantly, each column corresponding to the species according to some species ID-list.

The key feature I am asking for here is some structure that stores the chemical reactions in a way that has each reaction contain stoichometric coefficients for all species whether they are actually affected by the reaction or not. If a specie doesn't occur in a certain reaction it simply gets stoichometric cofficient 0 as would be the case for specie D in the first reaction in my example above.The first reaction rewritten with what I have in mind would look something like this:
1*A + 1*B + 0*C + 0*D + 0*E = 0*A + 0*B + 1*C + 0*D + 0*E

So if anybody knows whether reactions are already stored like that and where I can find them, that would be really helpful. Otherwise I will implement some code that arranges them in a scheme similar to that myself, but I don't want to implement something that's already there just because I can't find it

Many thanks in advance. Even if somebody can tell me that this is currently not the case, but can tell me how chemical reactions are stored instead, that would be much appreciated.

Thanks to anyone reading the whole post,
Daniel
DanielW is offline   Reply With Quote

Old   May 20, 2016, 12:27
Default
  #2
Senior Member
 
David Gaden
Join Date: Apr 2009
Location: Winnipeg, Canada
Posts: 437
Rep Power: 22
marupio is on a distinguished road
Try looking into the ODE reaction solvers. They need to figure that out. I'm thinking chemistrySolver, chemistryModel. Look for where they implement derivatives and jacobian. Just off the top of my head.
__________________
~~~
Follow me on twitter @DavidGaden
marupio is offline   Reply With Quote

Old   May 20, 2016, 13:05
Default
  #3
New Member
 
Join Date: May 2016
Posts: 2
Rep Power: 0
DanielW is on a distinguished road
Quote:
Originally Posted by marupio View Post
Try looking into the ODE reaction solvers. They need to figure that out. I'm thinking chemistrySolver, chemistryModel. Look for where they implement derivatives and jacobian. Just off the top of my head.
Hi, thanks for the reply.

I did examine the chemistryModel and EulerImplicit, which is used to build and solve the differential equation from the chemical reactions.
The algorithm in place iterates through all the reactions and sorts the coefficients "by hand" on each iteration to build the jacobian however.

From what I saw in the code and found through testing (Info << is my friend) it seems that the reactions are stored in a list and each element of this list has a component "rhs" and "lhs" which in itself is a list (containing the species that are present in this reactions' rhs/lhs), which contains yet another list for each specie appearing on the left/right hand side, which then contains the specie-ID and stoichometric coefficient.

So while I was able to rebuild each chemical reaction from those elements, it was not in a format I'd prefer. The problem I have with this is that I first need to determine whether a reaction affects a certain specie or not, if I want to calculate anything like net consumption rates for individual species.

I decided to build my own function for now, which creates the matrices I described above before any calculations are done at all, so I have to deal with this sorting process only once. So for now I have a solution and can continue my work and if I don't stumble upon something already implemented in OF, I'll just leave it in
DanielW is offline   Reply With Quote

Old   June 7, 2018, 15:39
Default
  #4
Member
 
Raunak Bardia
Join Date: Jan 2015
Posts: 32
Rep Power: 11
raunakbardia is on a distinguished road
Hi,

How were you able to access the information in the reactions() function? Could you share that code? I have not been able to figure out how to access the details stored in the reactions function for quite some time now. I would really appreciate some help.

Thanks.
raunakbardia is offline   Reply With Quote

Reply


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
Chemical reactions in openFOAM nakul OpenFOAM 3 April 4, 2019 19:02
multi phase flow with chemical reactions in one phase Habibfateh OpenFOAM Programming & Development 0 February 10, 2014 08:33
inconsistency in the chemical reactions in Reacting Foam? lfgmarc OpenFOAM Running, Solving & CFD 1 October 10, 2011 12:11
How to specify chemical reactions in certain areas Esti Siemens 0 September 24, 2004 07:03
Finite rate chemical reactions Marc Segovia Siemens 3 November 28, 2001 05:21


All times are GMT -4. The time now is 23:33.