Cantera
Hello Bernhard & others,
I came across a Cantera + OpenFOAM presentation. http://powerlab.fsb.hr/ped/kturbo/Op...haiderRehm.pdf I am interested in finding more information about the use of Cantera in OpenFOAM. I would like to simulate chemical reactions based on dieselFoam. Googling did not help much... - Are there more documents/tutorials concerning Cantera in OF ? Thank you, Rishi |
Hi Rishi,
the presentation is the only documentation up to now. We need to add something to the Wiki, too. So there are 2 parts: 1.) alternateChemistryModel A Library that allows the inclusion of alternate chemistry engines in solvers (allowing still to use OF chemistryModel) 2.) canteraThermosChemistry A Library that makes it possible to use Cantera in OpenFOAM The libraries can be used by the solvers alternateSteadyReactingFoam and alternateReactingFoam. There are also examples included. We had some issues to get Cantera running properly. I used the 1.7-CVS version. If you encounter problems with the standard version we can put a tarball of a running Cantera version onto the SVN, too. But Cantera 2.0 was announced and so we try to avoid unnecessary work ;) The main reasons for using Cantera are: -easy access to thermochemical data and functions -cantera has an excellent lexer for Chemkin-input -you can use all transport data (viscosity, diffsion, heat transfer) from transport data which is often available with reaction mechanisms (e.g GRI-3.0) -ideal reactor networks can be constructed and solved efficiently and stable with the CVODE stiff ODE solver package I hope that helps and you find the tools valuable. Regards, Markus. Related Links: Cantera: http://sourceforge.net/projects/cantera alternateChemistryModel: https://openfoam-extend.svn.sourcefo...emistryModels/ canteraThermosChemistry: https://openfoam-extend.svn.sourcefo...ermosChemistry Solvers and examples: https://openfoam-extend.svn.sourcefo...nateChemistry/ |
Hi Marcus,
I'm trying to put together the alternateChemistrySolver you provided. However, I'm still missing the CVODE solver you implemented which seems to be needed (or at least useful). Did you provide it anywhere, I could'nt find it in the OF-extend repository? Regards, Kalle |
Hello,
some time ago I implemented the CVODE solver as a new library of OpenFOAM ODE solver using the OpenFOAM chemistry. CANTERA accesses the CVODE solver directly. So the OpenFOAM-CVODE-Link is not necessary anymore. CANTERA comes with a stripped-down CVODE version but you can install the full SUNDIALS package as well which CANTERA can use then. But this is done during the installation procedure of CANTERA. This is configured in the preconfig - file in the section CVODE. Did you compile CANTERA without problems and did you run the cases? Regards, Markus. SUNDIALS Homepage: https://computation.llnl.gov/casc/sundials/main.html |
Hi!
Ok, thank you, I realize that now when I check the code. I have installed sundials 2.3.0 (as 2.6 is not compatible with the cantera 1.7-cvs) which cantera was aware of during it's installation. I'll breif what I did (maybe useful for people, either how to do or how not to do :) 1. Install Sundials 2.3.0 as root using ./configure CFLAGS=-fPIC... else canteraThermosChemistry didn't link. Make sure Sundials knows where to find the openmpi-stuff (or maybe run configure and make as the user with all paths set correctly, then as root run 'make install') 2. Install cantera 1.7-cvs. Check $PYTHONPATH so it can find ctml_writer.py. Run test cases that comes with Cantera. 3a. Create directory ~/OpenFOAM/OpenFOAM-1.5.x/src/thermophysicalModels/chemistryModel/alternateChemistryModels by copying from the svn 3b. In ~/OpenFOAM/OpenFOAM-1.5.x/src/thermophysicalModels/chemistryModel/alternateChemistryModels/Make/options add '-IOpenFOAM' 3c. Enter ~/OpenFOAM/OpenFOAM-1.5.x/src/thermophysicalModels/chemistryModel and run 'wmake libso alternateChemistryModels' 4a Create ~/OpenFOAM/user-1.5.x/applications/canteraThermosChemistry/ by copying from the svn 4b In ~/OpenFOAM/user-1.5.x/applications/canteraThermosChemistry/Make/options make sure that the paths to cantera, sundials, and alternateChemistryModels is correct 4c Enter ~/OpenFOAM/user-1.5.x/applications and run 'wmake libo canteraThermosChemistry' 5a Copy the two solvers from the svn to ~/OpenFOAM/user-1.5.x/applications. Make sure the Make/option file contains a valid link to ~/OpenFOAM/OpenFOAM-1.5.x/src/thermophysicalModels/chemistryModel/alternateChemistryModels/lnInclude 5b wmake both solvers. This gave me the two .so files in ~/OpenFOAM/user-1.5.x/lib/linux64GccDPOpt and two solvers, alternatReactingFoam and alternateSteadyReactingFoam. Then I went on to test the three testcases from the svn. The dual-inlet-trans and the adiabatic-flame-steady cases can run, but is rapidly consuming memory while executing. The dual-inlet-steady crashes when trying to solve h-eqn. I did not yet dig into why I get this behaviour. I'm running 64bit OF 1.5.x from mid-May 2009 on CentOS 5.3 x86_64. Regards, Kalle |
Hi Kalle,
thanks for your effort. So the first problem I can solve immediately. The memory-leak is a CANTERA problem found by Bernhard and can be solved easily: The destructor in the header file %installCantera%/include/cantera/kernel/ReactorNet.h:34 must be changed from Code:
virtual ~ReactorNet() { } Code:
virtual ~ReactorNet() { delete m_integ; } Regards, Markus. |
Ok! Great, now it's steady on memory usage. Did anyone tell the people behind Cantera about this? I saw their 1.8-beta code, which does not include the change you pointed out.
I must have had something wrong in my case directory, when I copied the dual-inlet-steady-case again from the svn it can run. However, I dont have the compressible flux bc's you are using, so I use fixedValue for velocity inlets. The 'flame' is quite cold though ~450K - but maybe that's intended? Now I will try to apply the code to my LES on premixed flames! Regards, Kalle |
Ok, writing the LES solver was easy - my solver is not much different from reactingFoam, just like yours.
However, now I tried it on some one-step methane combustion which seems to run stable with my LES-reactingFoam hybrid... but CVODES fails during the first 'Solving chemistry' for my already developed case, writing: [CVODES ERROR] CVode At t = 3.89908e-08 and h = 1.3536e-14, the error test failed repeatedly or with |h| = hmin. I played around a bit with settings for the ODE solver without success. Any clues? Regards, Kalle |
Hi Kalle,
I have no solution for that Problem - although I tried! It occurs with some mechanisms. What kind of mech do you use? With GRI 3.0 I had no problems. Sometimes it helps to use very coarse ODE tolerances (1e-5) - but only to get a few more iterations. Maybe some stiffness has to be removed from the mech or there is a numerical problem inside CANTERA. If you find a solution to that problem let me know. Regards, Markus. |
Ok, thank you for you answer.... I used a one-step methane mechanism (westbrook&dryer 1980)... which I guess can be stiff even though its simple. I was guessing/hoping cantera could handle stiffness better.
REACTIONS CH4 + 2O2 => CO2 + 2H2O 8.6E+11 0.0 30000.0 FORD / CH4 0.1 / FORD / O2 1.65 / END But, I'll try with other mechanisms and see if I can get anywhere! Regards, Kalle |
Hi again.
Now I've been running some time with other larger mechanisms, and the code seems to work fine! Really nice, I'll try to run some cases and do some validation... I couldn't get it to work with the one-step mech mentioned above though. I'll see if it can run with other one- and few-step mechs. Regards, Kalle |
Hello,
I wrote an install guide for the wiki. See here: http://openfoamwiki.net/index.php/Co...teReactingFoam In Cantera 1.8 quite some bugs are fixed and it works very well for me. Please tell me if there are errors or how it worked out for you. Regards, Markus. |
Hello Markus!
Do you remember me? We met in Dresden during CCT 2009. I'm trying to install the alternateReactingFoam code, but I've a problem with cantera and sundial. I've compiled sundial libraries (version 2.3 as described in the wiki) and cantera. If I run the python test on adiabatic_flame test, I've obtain the following message: Code:
unknown sundials verson Thank you in advance for your attention Michele |
Updating the sundial version to 2.4, now the code works.
I'm trying to understand the program: in thermophysicalProperties file, foamChemistryFile and a foamChemistryThermoFile are defined. The first file defines the reactions and the second the thermodynamical properties. Always in the thermophysicalProperties file a cti file (cantera) is defined, where the thermodynamical and kinetic properties are defined again. Which file describes the reactions and the thermo properties used during the simulation? Thank you for the attention Michele |
Hi Michele,
nice to hear from you again. If you use the Cantera-Chemistry-Library basically only the Cantera-Files (*.cti) are needed. The other ones are for the OpenFoam (or "Proxy")-Chemistry. I think the solver still asks for the files in Cantera-Mode because it is needed for Lagrangian-Particle-Chemistry, where Cantera can not be used up to now. Both files can be created from the Chemkin-Data with the appropriate lexers. The cti-format is not split in different files and everything is included in one file. It is possible to switch off the foam-File-Request if you use Cantera-Chemistry, but I don't remember right now. Tell me if you need it. Regards, Markus. |
Hello Markus,
thank you for your answer and congratulation for the work. If I run the adiabaticFlame with alternateSteadyReactingFoam solver, I obtain the following error: [CODE] Reading from Cantera-File "/home/michele/OpenFOAM/michele-1.5/applications/AlternateChemistry/Steady/adiabatic_flame/constant/gri30.cti" the mixture gri30_mix --> FOAM Warning : From function canteraMixture::canteraMixture in file canteraMixture.C at line 70 The thermophysical properties of CANTERA are currently not converted to OpenFOAM. Instead the properties from "/home/michele/OpenFOAM/michele-1.5/applications/AlternateChemistry/Steady/adiabatic_flame/constant/gasThermo" are used This can lead to errors if the data is inconsistent with the Cantera-data H2 not found in table. Valid entries are 4 ( CO2 C O2 N2 ) /CODE] From the message seems that the cantera gri30 cti files has been read, but the thermophysical properties are not converted to OpenFOAM. Reading the gasThermo file (OpenFOAM mechanism) the solver searches for H2 properties (H2 is defined in gri30.cti), but H2 is not defined in this file. I guess that every species defined in CTI file need to be defined also in the FOAM thermo file. Is it correct? Probably the problem is related to the standinThermoFile dictionary, defined in thermoPhysicalProperties. Regards Michele |
Hello,
you are right. But the foam-Chemistry is only needed for particle thermo calculations. It is possible to create it with the chemkineToFoam utility from the Chemkin data. If you do not need it you can skip the check for the foam data and you may insert the line return ; // the lower part is only needed for particle thermo in canteraMixture.C:66. Then only cantera-data is needed. Regards, Markus. |
Hello again,
I cleaned-up the adiabaticFlame case in the Steady-Directory. Markus |
Ok,
thank you! Now I'm going to update the adiabaticFlame case. Michele |
Hi Markus,
I'm using the alternateSteady code to solve a piloted flame test-case with success, using a skeletal CH4 mechanism with 14 species. The results seems very good. Congratulation again for the work. Michele |
Hello,
has anybody tried linking Cantera 1.8b to OpenFOAM 1.6? |
Hello,
no up to now the library is only available for 1.5.x. An update is planned. Regards, Markus. |
Piloted flame case - question
Hello Michele:
In an earlier post you mentioned (Oct 2009) that you had successfully run a piloted flame test case with the steady solver; is this something you could share? I am trying to implement something similar, and while the reactingFoam solver works, the transient approach is very computationally inefficient. I was able to run the test case with alternateSteadyReactingFoam, and I am struggling to make a CH4 flame case work. Thanks so much! Kind Regards, -aat |
error running alternateSteadyReactingFoam on ubuntu
Hi,
I am using cantera1.8 and sundials2.3.0 as described on the wiki page with OpenFOAM-1.5-dev on Ubuntu operating system. I had problems in getting CanteraThermosChemistry compiled with an error that cantera/kernel/CVodesIntegrator.h not found. I checked the cantera installation and found that there was no file under ..../installCantera/include/cantera/kernel/CVodesIntegrator.h. I could find a different file CVodeInt.h under the same path and therefore changed the filename from CVodesIntegrator.h to CVodeInt.h in the following files. canteraChemistryModel.C canteraLocalTimeChemistryModel.C This allowed me to compile the canteraThrmosChemistry and other solvers. But, when I try to run the example by typing alternateSteadyReactingFoam or alternateReactingFoam, I get the following error. alternateSteadyReactingFoam: symbol lookup error: ....../libcanteraThermosChemistry.so: undefined symbol: N_VNew I couldn't file any variable named N_VNew. Am I missing something while compiling or do I need to make any additional changes to the canteraThermosChemistry source files. Any advice is greatly appreciated. thanks for your time, Bhadraiah. |
Hello,
it seems like there is a problem with the Sundials installation. Check if Cantera uses Sundials correctly by running the demos (e.g Cantera python demos). Markus |
alternateChemistry model works on Ubuntu
Hi Markus,
Many thanks for your inputs. It indeed seems to be an issue with sundials. I did check the demos under Cantera previously and they ran fine. So I was not sure what the issue was. Meanwhile I found your other post at the following URL as well. http://www.cfd-online.com/Forums/ope...de-solver.html Based on the posts in that article, I started from scratch and compiled sundials with --enable-shared option (the wiki only said CFLAGS=-fPIC). I was able to go through the rest of the installation as per wiki without any issues. The alternateSteadyReactingFoam and alternateReactingFoam now run fine without any issues. Thanks again for your inputs. regards, Bhadraiah. |
Cantera Matlab/Python version Documentation
Hi guys,
It would be really helpful if any of you could give me the link to Cantera Matlab/Python version Documentation. Regards Prasanth P |
Quote:
is there a way to use alternateReactingFoam with Openfoam-1.6 yet? I have tried to make it run, but compiling alternateChemistryModels i found that he wants some file only present in the openfoam-1.5. . So I linked it in the options-file but then another error message comes up, with which i can't deal Quote:
have a nice weekend! regards! |
Hello,
no Problem with Cantera-1.8 but some classes changed in OF-1.6 and it is not straight-forward to do the upgrade. As soon as I find some time I will continue the work. Regards, Markus. |
Running the cases
Hello Markus,
thank you for your great work. I tried to install cantera as you showed in your tutorial, but I could not run the cases. Seems to be a conversion problem. Could you give me a hint? Thomas Create time Create mesh for time = 0 Reading chemistry properties Reading environmentalProperties Reading thermophysicalProperties Selecting thermodynamics package hMixtureThermo<canteraMixture> Reading from Cantera-File "/home/thoffman/OpenFOAM/thoffman-1.5/applications/solvers/AlternateChemistry/Steady/dualInlet/constant/mix.cti" the mixture mix sh: source: not found Reading from Cantera-File "/home/thoffman/OpenFOAM/thoffman-1.5/applications/solvers/AlternateChemistry/Steady/dualInlet/constant/mix.cti" the mixture mix --> FOAM Warning : From function canteraMixture::canteraMixture in file canteraMixture.C at line 70 The thermophysical properties of CANTERA are currently not converted to OpenFOAM. Instead the properties from "/home/thoffman/OpenFOAM/thoffman-1.5/applications/solvers/AlternateChemistry/Steady/dualInlet/constant/gasThermo" are used This can lead to errors if the data is inconsistent with the Cantera-data wrong token type - expected Scalar found on line 13 the word 'O2' file: /home/thoffman/OpenFOAM/thoffman-1.5/applications/solvers/AlternateChemistry/Steady/dualInlet/constant/gasThermo at line 13. From function operator>>(Istream&, Scalar&) in file lnInclude/Scalar.C at line 85. FOAM exiting |
Cantera-
Hi,
I would like to add one additional equation in Cantera. Is that possible to add one more additional equation in One D simulations In Cantera? |
Hello All,
While running the transient case that came with AlternateChemistry, I received a warning that reads the following: --> FOAM Warning: From function canteraChemistryModel:: calcDQ(volScalarField &dQ) in file canteraChemistryModel.C at line 321 Calculation of dQ is not yet verified Is this warning expected? Could someone please explain what it means and what are the potential implications? Thanks, Sunny |
Quote:
|
Quote:
some ideas about possible cause? What kind of problems it can give? thanks :) |
Quote:
|
Quote:
Actually I get also this one: --> FOAM Warning : From function dlLibraryTable:: open(const fileName& functionLibName) in file db/dlLibraryTable/dlLibraryTable.C at line 86 could not load libcompressibleFluxBCs.so: cannot open shared object file: No such file or directory Create mesh for time = 0.0255 should I be worried? __________________________ I'm pretty new in CFD so I ask sorry if maybe I do trivial questions. :) Currently I'm doing a case with a premixed flame and I use alternateReactingFoam . It works, but I have some doubts:confused:: -In the file Gri30.cti there a function called "transport" and I can chose to leave it empty, set it "Mix" or "Multi"... but it looks like give the same results even if i set it differently. what does it do? - my case is laminar so I switch turbulence off but I can't really understand how I should set the transport proprieties (mu lambda etc) in the RASProperties file or how OF calculates them. Thank you very much!!! :p |
Hello Silvano,
Quote:
http://sourceforge.net/projects/cant...s.pdf/download For further questions regarding CANTERA please refer to proper forum http://groups.google.com/group/cantera-users Furthermore I suggest you to check out the demos and tutorials provided with CANTERA. 2) If you use the alternateChemistry-library in "CANTERA-mode" (i.e. chemistryEngine canteraChemistryModel) the chemistry, thermodynamical, and transport data is taken from the cti-file. If you use the alternateChemistry-library in OpenFOAM-mode (i.e. chemistryEngine chemistryModelProxy) all the data is obtained as usually done in OpenFOAM. Regards, Markus. |
Quote:
Markus, Thank you very very much! :):) |
Hi, again me... :p
I'm trying to make cantera work whith openfoam on a 64bit, 40 processors server that runs on RHEL5.3. So far sundials2.4 and cantera look like they work ( i don t have any problems with the testProblems in cantera). I followed your web guide to instill the libraries,when i wmake alternateChemistryModels I don t have any problems but when I wmake canteraThermosChemistry I get this error: /share/cantera-1.8/include/cantera/IdealGasMix.h: In copy constructor ‘Cantera_CXX::IdealGasMix::IdealGasMix(const Cantera_CXX::IdealGasMix&)’: /share/cantera-1.8/include/cantera/IdealGasMix.h:40: warning: base class ‘class Cantera::IdealGasPhase’ should be explicitly initialized in the copy constructor /share/cantera-1.8/include/cantera/IdealGasMix.h:40: warning: base class ‘class Cantera::GasKinetics’ should be explicitly initialized in the copy constructor /usr/bin/ld: cannot find -llapack collect2: ld returned 1 exit status make: *** [/home/sahm/OpenFOAM/sahm-1.5/lib/linux64GccDPOpt/libcanteraThermosChemistry.so] Error 1 [sahm@cmtl canteraThermosChemistry]$ actually the llapack lib is in /usr/lib64, i tryed to change the path in canteraThermosChemisty/Make/options like below: LIB_LIBS := $(LIB_LIBS)/../lib64 \ -llapack -lblas \ but I still get some errors. :confused: actualy I don t have a clear idea what above options file does. Do you have some tips? thank you very much :) |
speciesData() - alternateReactinFoam
Hi everybody,
In order to call the "speciesData" I use these lines in reactingFoam. reactingMixture& multiMix = (reactingMixture&) thermo->composition(); PtrList<reactingMixture::reactionThermo> speciesData = multiMix.speciesData(); but I have some troubles to do the same with alternateReactingFoam / cantera solver. Does somebody know how I can access to the "speciesData()" using alternateReactingFoam? Thank you!! Silvano |
All times are GMT -4. The time now is 18:12. |