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

A trial of implementing of CVODE as ODESolver

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 2 Post By luiscardona

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 11, 2012, 05:06
Default A trial of implementing of CVODE as ODESolver
  #1
Member
 
Aleksey Rukhlenko
Join Date: Nov 2009
Location: Moscow
Posts: 55
Rep Power: 17
Aleksey_R is on a distinguished road
Send a message via ICQ to Aleksey_R
Greetings, dear colleagues.

I tried to implement CVODE solver (from sundials-2.3) as ODESolver in OF-1.6-ext. In CVODE I used backward differencing (BDF). The library compiled successfully but when I try to compile some chemistry solver with BDF support I have an error on linking stage (undefined reference to ODESolver constructor).

I post the code just in case. If someone will handle with the error, I hope, the library could be useful for community.


Best regards, Aleksey.
Attached Files
File Type: gz BDF.tar.gz (4.1 KB, 76 views)
Aleksey_R is offline   Reply With Quote

Old   February 11, 2012, 16:52
Default
  #2
Senior Member
 
Adhiraj
Join Date: Sep 2010
Location: Karnataka, India
Posts: 187
Rep Power: 16
adhiraj is on a distinguished road
I have incorporated the CVODE stiff ODE solver into the ODESolvers in OpenFOAM 1.7, and it is very similar to your code. (It is based on the sample provided with sundials).
I think you are trying to make the BDF a library separate from the ODE library.
Why is this?
Why don't you add the BDF stuff to the ODESolvers directory,(similar to say RK4, so that under ODESolvers we have ODESolvers, RK,KRR4,SIBS and BDF) as it is based on ODESolver?
Then just edit the file named "files" and add the file $FOAM_SRC/ODE/ODESolvers/BDF/BDF.C" ?

Last edited by adhiraj; February 11, 2012 at 16:54. Reason: explained more clearly
adhiraj is offline   Reply With Quote

Old   February 11, 2012, 17:30
Default
  #3
Member
 
Aleksey Rukhlenko
Join Date: Nov 2009
Location: Moscow
Posts: 55
Rep Power: 17
Aleksey_R is on a distinguished road
Send a message via ICQ to Aleksey_R
I tried to copy BDF to ODESolvers folder (which contains KRR4, SIBS, RK) and I've got the same result - the library libODE compiled successfully but when I tried to compile any solver I got an error on linking stage.
Aleksey_R is offline   Reply With Quote

Old   February 11, 2012, 19:48
Default
  #4
Senior Member
 
Adhiraj
Join Date: Sep 2010
Location: Karnataka, India
Posts: 187
Rep Power: 16
adhiraj is on a distinguished road
Try putting the BDF under the ODESolvers directory, and remove the Make directory under BDF.
Edit the Make directory of ODE to add entries for BDF.
This means that there will only be one library built, and that will have SIBS+RK+BDF+KRR4, all selectable at runtime.
adhiraj is offline   Reply With Quote

Old   February 12, 2012, 08:17
Default
  #5
Member
 
Aleksey Rukhlenko
Join Date: Nov 2009
Location: Moscow
Posts: 55
Rep Power: 17
Aleksey_R is on a distinguished road
Send a message via ICQ to Aleksey_R
Thank you for advise. I did it. And the compilation of libODE was successful, but the compilation of solvers wasn't. The same error on linking stage - undefined reference to ODESolver constructor.

Anyway, I managed to use CVODE in OpenFoam without using ODESolver.

Best regards, Aleksey.
Aleksey_R is offline   Reply With Quote

Old   February 12, 2012, 10:50
Default
  #6
Senior Member
 
Adhiraj
Join Date: Sep 2010
Location: Karnataka, India
Posts: 187
Rep Power: 16
adhiraj is on a distinguished road
I am a bit confused now; what solver are you trying to build? Did you specify the libODE for each solver's Make directory?
adhiraj is offline   Reply With Quote

Old   February 14, 2012, 17:12
Default
  #7
New Member
 
Joseph Urich
Join Date: Mar 2009
Location: Pittsburgh, PA
Posts: 21
Rep Power: 17
jurich is on a distinguished road
Aleksey,

I've been looking into implementing CVODE or LSODE in OF 2.0.x, and came across your post. In yours, the line in BDF.C:

f_data = new BDF(*this);

tries to implement BDF using a copy constructor, which you didn't implement. That should be why the linker complains "undefined reference to ODESolver constructor" when you try to build an application.

I think you should just be able to use:

f_data = this;

to get it working, but haven't tried it (I'm not running 1.6ext at the moment).

Also, I hope you're aware of alternateChemistryModel, which implements Cantera and sundials/cvode? If not, it might be worth looking for.

Regards.
jurich is offline   Reply With Quote

Old   February 14, 2012, 17:43
Default
  #8
Senior Member
 
Adhiraj
Join Date: Sep 2010
Location: Karnataka, India
Posts: 187
Rep Power: 16
adhiraj is on a distinguished road
Quote:
Originally Posted by jurich View Post
Aleksey,

I've been looking into implementing CVODE or LSODE in OF 2.0.x, and came across your post. In yours, the line in BDF.C:

f_data = new BDF(*this);

tries to implement BDF using a copy constructor, which you didn't implement. That should be why the linker complains "undefined reference to ODESolver constructor" when you try to build an application.

I think you should just be able to use:

f_data = this;

to get it working, but haven't tried it (I'm not running 1.6ext at the moment).

Also, I hope you're aware of alternateChemistryModel, which implements Cantera and sundials/cvode? If not, it might be worth looking for.

Regards.
I am not sure of this. I have the same kind of new statement in my implementation and I get no errors, and the results also seem good.
Also, the error is about the ODESolver constructor, not the BDF constructor.
adhiraj is offline   Reply With Quote

Old   April 14, 2012, 04:59
Default
  #9
New Member
 
Luis Cardona
Join Date: Mar 2011
Location: Medellin, Colombia
Posts: 6
Rep Power: 15
luiscardona is on a distinguished road
Dear foamers,

After many failed attempts, I finally managed to implement BDF (CVODE solver) in OF-1.7.1 selectable at runTime like SIBS, RK and KRR4 based on the code posted before by Aleksey_R.

In order to use it please take into account that in the chemistryProperties dictionary in constant folder, you must set the inverse of eps (for example 20 for a eps of 0.05) so in ODESolver.C file the whole time step can be sent to CVODE solver. This happens because CVODE has its own way to calculate internal time step, so OpenFOAM time stepping routine must be overridden somehow. It is probably not the best way to achieve it... but it works!

In order to install this library just merge the content of the attached file the src/ODE folder and recompile using wmake libso. It is known to work with sundials 2.3.0 (the instructions about compiling sundials can be easily found in the forum)- In my case, I installed sundials on home folder-

Please try the solver and make your own tests (for example running ODETest app). So far in my tests, SIBS seems to be faster for my problem (chemical kinetics). Also if you can make a better-cleaner version of this solver, you can upload it and share it back with the community.
Attached Files
File Type: gz ODE.tar.gz (5.6 KB, 98 views)
JBUNSW and randolph like this.
luiscardona is offline   Reply With Quote

Old   April 14, 2012, 10:37
Default
  #10
Senior Member
 
Adhiraj
Join Date: Sep 2010
Location: Karnataka, India
Posts: 187
Rep Power: 16
adhiraj is on a distinguished road
Quote:
In order to use it please take into account that in the chemistryProperties dictionary in constant folder, you must set the inverse of eps (for example 20 for a eps of 0.05) so in ODESolver.C file the whole time step can be sent to CVODE solver. This happens because CVODE has its own way to calculate internal time step, so OpenFOAM time stepping routine must be overridden somehow.
I override that by specifying the initial chemical time scale as unity in the chemistryProperties file.
Quote:
So far in my tests, SIBS seems to be faster for my problem (chemical kinetics)
That is consistent with my observations. But for some problems SIBS crashes while solving the ODE.
adhiraj is offline   Reply With Quote

Old   February 27, 2014, 06:00
Default
  #11
New Member
 
James Behzadi
Join Date: Oct 2011
Location: Sydney, Australia
Posts: 27
Rep Power: 15
JBUNSW is on a distinguished road
Dear all,

I implemented SUNDIALS CVODE 2.7 in OpenFOAM 2.0.x. I pretty much followed the instructions given at this thread. However, my implementation is very slow when I use the built-in numerical jacobian feature of CVODE. I have explained the details here.

Any help is highly appreciated.

Jalal
JBUNSW is offline   Reply With Quote

Old   March 6, 2014, 20:53
Default
  #12
New Member
 
James Behzadi
Join Date: Oct 2011
Location: Sydney, Australia
Posts: 27
Rep Power: 15
JBUNSW is on a distinguished road
Any help is highly appreciated.
JBUNSW is offline   Reply With Quote

Old   September 9, 2020, 00:32
Default
  #13
Senior Member
 
Reviewer #2
Join Date: Jul 2015
Location: Knoxville, TN
Posts: 141
Rep Power: 11
randolph is on a distinguished road
Quote:
Originally Posted by luiscardona View Post
Dear foamers,

After many failed attempts, I finally managed to implement BDF (CVODE solver) in OF-1.7.1 selectable at runTime like SIBS, RK and KRR4 based on the code posted before by Aleksey_R.

In order to use it please take into account that in the chemistryProperties dictionary in constant folder, you must set the inverse of eps (for example 20 for a eps of 0.05) so in ODESolver.C file the whole time step can be sent to CVODE solver. This happens because CVODE has its own way to calculate internal time step, so OpenFOAM time stepping routine must be overridden somehow. It is probably not the best way to achieve it... but it works!

In order to install this library just merge the content of the attached file the src/ODE folder and recompile using wmake libso. It is known to work with sundials 2.3.0 (the instructions about compiling sundials can be easily found in the forum)- In my case, I installed sundials on home folder-

Please try the solver and make your own tests (for example running ODETest app). So far in my tests, SIBS seems to be faster for my problem (chemical kinetics). Also if you can make a better-cleaner version of this solver, you can upload it and share it back with the community.

Luis,

Can CVODE handle fractional exponent reaction?

Thanks,
Rdf
randolph is offline   Reply With Quote

Reply

Tags
cvode, odesolver, sundials


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
OpenFOAM 1.7 and CVODE adhiraj OpenFOAM 6 May 22, 2011 01:01
Problem implementing CVODE ODE solver markusrehm OpenFOAM 20 October 13, 2010 18:02
CVODE Error message Robert FLUENT 2 February 12, 2003 19:28


All times are GMT -4. The time now is 13:53.