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

Implement code to calculate the reaction rate in reactingFoam

Register Blogs Community New Posts Updated Threads Search

Like Tree10Likes
  • 1 Post By
  • 1 Post By
  • 1 Post By
  • 2 Post By
  • 4 Post By
  • 1 Post By

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 2, 2012, 12:29
Default
  #1
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
Hey Matari,

The forum software says you posted another message, and I read it in my email but don't see it on the thread. Did you sort out the issue with building your new library? From the error messages you posted it seems like you have a typo in the EXE_LIBS entry.

Let me know if you fixed it!
mturcios777 is offline   Reply With Quote

Old   August 3, 2012, 09:19
Default
  #2
New Member
 
Join Date: Jul 2012
Posts: 11
Rep Power: 13
matari is on a distinguished road
Hi,

@mturcios777: Thank you for the reply. I fixed the problem with the library a few minutes after I posted the message. There were some files missing.

In reactingFoam I use the ODEChemistryModel. From Ghassans message I understand that the reactionRate class calculates the first part of the equation. In my example: ak = A*T^b*exp(-Ta/T).
The chemistryModel class then calculates the ReactionRate R = ak * c(CH4)^0.7 * c(O2)^0.8.
My goal is to calculate the reactionRate with the equation R = rA * c(CH4) * c(O2) where rA depends on the temperature, pressure and concentration of CH4, O2, CO2 and H2O. In the ArrheniusReactionRate class ak only depends on T. So I modified the LangmuirHinshelwoodReactionRate instead and called it myLangmuirHinshelwoodReactionRate.
Here is the myLangmuirHinshelwoodReactionRateI.H file:

// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //

double rA;

inline Foam::myLangmuirHinshelwoodReactionRate::myLangmui rHinshelwoodReactionRate
(
const label ch4,
const label o2,
const label co2,
const label h2o
)
:
ch4_(ch4),
o2_(o2),
co2_(co2),
h2o_(h2o)
{}
inline Foam::myLangmuirHinshelwoodReactionRate::myLangmui rHinshelwoodReactionRate
(
const speciesTable& st,
Istream& is
)
:
ch4_(st["CH4"]),
o2_(st["O2"]),
co2_(st["CO2"]),
h2o_(st["H2O"])
{}
inline Foam::myLangmuirHinshelwoodReactionRate::myLangmui rHinshelwoodReactionRate
(
const speciesTable& st,
const dictionary& dict
)
:
ch4_(st["CH4"]),
o2_(st["O2"]),
co2_(st["CO2"]),
h2o_(st["H2O"])
{}

// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //

inline Foam::scalar Foam::myLangmuirHinshelwoodReactionRate:perator( )
(
const scalar T,
const scalar p,
const scalarField& c
) const
{
rA = ... ; //calculation of rA that depends on T, p, c[ch4_], c[co2_], c[h2o_], c[h2o_]
return rA;
}
inline void Foam::myLangmuirHinshelwoodReactionRate::write(Ost ream& os) const
{}


inline Foam::Ostream& Foam:perator<<
(
Ostream& os,
const myLangmuirHinshelwoodReactionRate& lhrr
)
{
return os;
}

The compilation is successful but the calculated reaction rate is too little compared to an ANSYS Fluent simulation with an UDF that calculates the reaction rate using the equation R = rA * c(CH4) * c(O2). Is the reaction rate in my case with ODEChemistryModel really calculated using the equation R = rA * c(CH4) * c(O2) or did I misunderstood that?
matari is offline   Reply With Quote

Old   August 3, 2012, 12:18
Default
  #3
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
You have two options:

1) Compile a debug version of OF and try trace to make sure that your function is being called as it should be

2) Add your own debug messages to make sure the proper reaction rate is being calculated.

A related question: how are you linking your own code to the solver?
mturcios777 is offline   Reply With Quote

Old   August 6, 2012, 05:40
Default
  #4
New Member
 
Join Date: Jul 2012
Posts: 11
Rep Power: 13
matari is on a distinguished road
Hello Marco,

in my Make directory I generated to files:
1. files:

makeLangmuirHinshelwoodReactions.C

LIB = $(FOAM_USER_LIBBIN)/libMyLangmuirHinshelwood


2. options:

EXE_INC = \
-I$(SIB_SRC)/thermophysicalModels/specie/lnInclude

EXE_LIBS = \
-1thermophysicalModels/specie


To link my code to the solver I add libs ("libMyLangmuirHinshelwood.so") to my system/controlDict.

Best regards,

Matari
matari is offline   Reply With Quote

Old   August 7, 2012, 14:43
Default
  #5
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
Sorry its taken a while to respond, I was on vacation. Sounds like everything is linked and working well. From this point in, you will need to monitor the values that are passed to the operator() function and those that the function returns. It may be that your function is doing exactly what you intend it to do based on the inputs it receives, but what OF does with that after is no doubt different than what Fluent does, and may need adjustments down the line.

Good luck!
mturcios777 is offline   Reply With Quote

Old   August 13, 2012, 04:24
Default
  #6
New Member
 
Join Date: Jul 2012
Posts: 11
Rep Power: 13
matari is on a distinguished road
Hi,

the operator() function does what I intend it to do, so I would like to monitor the omega and dQ() that are calculated in the ODEChemistryModel.C file. Therefore I renamed ODEChemistryModel* as myChemistryModel*. I renamed all necessary files and replaced in each file "ODE" with "my". The files in my Make directory is:

makeChemistrySolvers.C
LIB = $(FOAM_USER_LIBBIN)/libmyChemistryModel


and options:

EXE_INC = \
-I$(SIB_SRC)/thermophysicalModels/chemistryModel/lnInclude

EXE_LIBS = \
-1thermophysicalModels/chemistryModel


I don't get any errors during the compilation:

options:4:12: warning: backslash-newline at end of file [enabled by default]
wmakeLnInclude: linking include files to ./lnInclude
Making dependency list for source file makeChemistrySolvers.C
SOURCE=makeChemistrySolvers.C ; g++ -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -O3 -DNoRepository -ftemplate-depth-100 -I/thermophysicalModels/chemistryModel/lnInclude -IlnInclude -I. -I/home/fluent/OpenFOAM/OpenFOAM-2.1.x/src/OpenFOAM/lnInclude -I/home/fluent/OpenFOAM/OpenFOAM-2.1.x/src/OSspecific/POSIX/lnInclude -fPIC -c $SOURCE -o Make/linux64Gcc46DPOpt/makeChemistrySolvers.o
'/home/fluent/OpenFOAM/fluent-2.1.x/platforms/linux64Gcc46DPOpt/lib/libmyChemistryModel.so' is up to date.


I included libmyChemistryModel.so in my system/controlDict. In the constant/chemistryProperties file I have:

psiChemistryModel myChemistryModel<gasThermoPhysics>;

chemistry on;

chemistrySolver ode;

initialChemicalTimeStep 1e-07;

sequentialCoeffs
{
cTauChem 0.001;
}

EulerImplicitCoeffs
{
cTauChem 0.05;
equilibriumRateLimiter off;
}

odeCoeffs
{
solver SIBS;
eps 0.05;
scale 1;
}

When I try to run the calculation with reactingFoam it seems like there is something wrong with the library:

Create time

--> FOAM Warning :
From function dlOpen(const fileName&, const bool)
in file POSIX.C at line 1175
dlopen error : /home/fluent/OpenFOAM/fluent-2.1.x/platforms/linux64Gcc46DPOpt/lib/libmyChemistryModel.so: undefined symbol: _ZN4Foam16myChemistryModelINS_17psiChemistryModelE NS_19sutherlandTransportINS_12specieThermoINS_11ja nafThermoINS_18isobaricPerfectGasEEEEEEEE8typeName E
--> FOAM Warning :
From function dlLibraryTable:pen(const fileName&, const bool)
in file db/dynamicLibrary/dlLibraryTable/dlLibraryTable.C at line 96
could not load "libmyChemistryModel.so"

Create mesh for time = 0


Reading g
Creating combustion model

Selecting combustion model PaSR<psiChemistryCombustionModel>
Selecting psiChemistryModel myChemistryModel<gasThermoPhysics>


--> FOAM FATAL ERROR:
Unknown psiChemistryModel type myChemistryModel<gasThermoPhysics>

Valid psiChemistryModel types are:
5
(
ODEChemistryModel<constGasThermoPhysics>
ODEChemistryModel<constIsobaricGasThermoPhysics>
ODEChemistryModel<icoPoly8ThermoPhysics>
ODEChemistryModel<gasThermoPhysics>
ODEChemistryModel<isobaricGasThermoPhysics>
)

From function psiChemistryModel::New(const mesh&)
in file chemistryModel/psiChemistryModel/psiChemistryModelNew.C at line 117.

FOAM exiting


What did I miss?
matari is offline   Reply With Quote

Old   November 6, 2012, 13:44
Default
  #7
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
Sorry I hadn't seen this. Hopefully you got it resolved, but it seems like the linking hasn't been completed.
mturcios777 is offline   Reply With Quote

Old   October 15, 2018, 15:08
Default
  #8
New Member
 
igor
Join Date: Jun 2014
Posts: 7
Rep Power: 11
iiigoriii is on a distinguished road
Dear users,

I really don't understand one thing (maybe more ) and please I need help. I modified both ArrheniusReactionRate.C /.H

Code:
src\thermophysicalModels\specie\reaction\reactionRate\ArrheniusReactionRate
I changed ArrheniusReactionRate.H equation, wmake (also wmake libso) pass without errors. I can also found new libspecie.dll in lib directory. So I guess everything is OK.

But, I have a testing example and I see that nothing changed. My modified Arrhenius equation wont work. Please have you some explanation? I read some general manuals, also try search at forum... (solver modifications works without problems). Thanks, ii
iiigoriii is offline   Reply With Quote

Old   October 16, 2018, 08:50
Default
  #9
New Member
 
igor
Join Date: Jun 2014
Posts: 7
Rep Power: 11
iiigoriii is on a distinguished road
I am a little despairing, I also did Allwmake for whole OpenFOAM-dev and nothing. I have all libraries with new date (today) and nothing. Why changes in reaction rate equation do nothing?

despairing, ii
iiigoriii is offline   Reply With Quote

Old   November 16, 2018, 09:43
Default
  #10
New Member
 
igor
Join Date: Jun 2014
Posts: 7
Rep Power: 11
iiigoriii is on a distinguished road
OK, sorry for desperate last two spams. Problem was, as usual, between monitor and keyboard. I tried whole process under linux and everything works perfectly. My unsuccessful attempts were made under win version....

I created my own reaction rate, and everything works perfectly.
ii
iiigoriii 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
reactingFoam Enthalpy of Reaction Problem Cyberholmes OpenFOAM 1 August 23, 2011 05:23
surface reaction rate with udf yellow-stuff FLUENT 4 January 29, 2010 12:53
help! Creating iso-surface of reaction rate James Willie FLUENT 1 September 28, 2005 21:56
Combustion reaction rate Karthick FLUENT 2 April 22, 2004 05:23
Design Integration with CFD? John C. Chien Main CFD Forum 19 May 17, 2001 15:56


All times are GMT -4. The time now is 11:07.