CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Pre-Processing

chemkinToFoam parsing issues? (v19)

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By HPE

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 9, 2020, 00:34
Default chemkinToFoam parsing issues? (v19)
  #1
Member
 
Patti Michelle Sheaffer
Join Date: Sep 2018
Posts: 55
Rep Power: 8
pattim is on a distinguished road
Does anyone know of specific limitations of the chemkinToFoam parsing utility? It throws very unhelpful errors. This is the chemistry suite I'm trying to use:
https://combustion.llnl.gov/mechanis...-pah-formation
The chemkin and thermo files are available.


I was trying to troubleshoot this using the OF tutorial DLR_A_LTS which imports GRIMech 3.0 correctly. So it seems, at least in principle, that the chemkinToFoam utility should work. Is there any way to get support from OF on these types of issues?



Thank You Very Much,
Patricia
pattim is offline   Reply With Quote

Old   February 9, 2020, 12:37
Default
  #2
HPE
Senior Member
 
HPE's Avatar
 
Herpes Free Engineer
Join Date: Sep 2019
Location: The Home Under The Ground with the Lost Boys
Posts: 931
Rep Power: 13
HPE is on a distinguished road
Why not? OpenFOAM is open. It would even better if you come up with your own code with your own suggestions.

I would create a feature request in OpenFOAM's issue tracker.
ajithnair likes this.
HPE is offline   Reply With Quote

Old   February 9, 2020, 12:48
Default
  #3
Member
 
Patti Michelle Sheaffer
Join Date: Sep 2018
Posts: 55
Rep Power: 8
pattim is on a distinguished road
Thanks - I didn't know they had an issue tracker. I could try reading the C code, but I never learnt C.
pattim is offline   Reply With Quote

Old   February 9, 2020, 13:02
Default
  #4
HPE
Senior Member
 
HPE's Avatar
 
Herpes Free Engineer
Join Date: Sep 2019
Location: The Home Under The Ground with the Lost Boys
Posts: 931
Rep Power: 13
HPE is on a distinguished road
Raise your concerns there then. Might the maintainers try to help you out?

As a side note, OpenFOAM is C++11. There is no C inside.

Hope you find a solution.
HPE is offline   Reply With Quote

Old   February 9, 2020, 13:33
Default
  #5
Member
 
Patti Michelle Sheaffer
Join Date: Sep 2018
Posts: 55
Rep Power: 8
pattim is on a distinguished road
Thank you - I do also. There are very powerful chemical mechanisms which are unavailable to OpenFOAM at the present time, even though they are in chemkin format.


EDIT: issue tracker https://bugs.openfoam.org/view.php?id=3450

Last edited by pattim; February 9, 2020 at 17:12. Reason: added info
pattim is offline   Reply With Quote

Old   February 10, 2020, 12:50
Default
  #6
Member
 
Patti Michelle Sheaffer
Join Date: Sep 2018
Posts: 55
Rep Power: 8
pattim is on a distinguished road
Quote:
Originally Posted by pattim View Post
Thank you - I do also. There are very powerful chemical mechanisms which are unavailable to OpenFOAM at the present time, even though they are in chemkin format.
EDIT: issue tracker https://bugs.openfoam.org/view.php?id=3450

Also in the spirit of that, I am taking some classes on c++ - it's not that different from other programming languages I've used. I was able to import OpenFOAM source tree into code::blocks - it searched the /opt/OpenFOAM directory tree for all the files. I'm not sure that's the best way to go, but at least I can search through all the related header and .C files and begin to understand the code hierarchy so I can begin to read through and look for whatever errors may be responsible for not importing chemkin mech/thermo files.
EDIT: This is going to take a LONG time. :^(
pattim is offline   Reply With Quote

Old   February 10, 2020, 15:11
Default
  #7
Senior Member
 
Adhiraj
Join Date: Sep 2010
Location: Karnataka, India
Posts: 187
Rep Power: 16
adhiraj is on a distinguished road
Please see if you can use these two files. They work with the chemkinToFoam utility in OpenFOAM 2.3.1.

The following changes were made to the original files downloaded from the link you provided:

1. The files are converted from lower to upper case. Fortran is case insensitive, whereas C++ is case sensitive.

2. I prefer to run dos2unix on these files before using them on Linux.

3. In the chem.inp file the elements, species, and reactions blocks are retained while the thermo block (which was empty) was removed. The blocks are also formatted in this way as shown for the elements block (notice the line breaks):
Code:
ELEMENTS
H   O    C  AR N
END
4. In the therm.dat file the first uncommented line is changed from
Code:
THERMO
to
Code:
THERMO ALL
5. For each species there are four lines in the therm.dat file, and the lines are supposed to end with 1, 2, 3, or 4, as shown below:
Code:
AR                120186AR  1               G  0300.00   5000.00  1000.00      1
 0.02500000E+02 0.00000000E+00 0.00000000E+00 0.00000000E+00 0.00000000E+00    2
-0.07453750E+04 0.04366001E+02 0.02500000E+02 0.00000000E+00 0.00000000E+00    3
 0.00000000E+00 0.00000000E+00-0.07453750E+04 0.04366001E+02                   4
For a number of species the first line ends in 01, 21, 11, or so, which is tripping up the parser. I edited the file to correct this issue.

Hope that helps a bit.
Attached Files
File Type: gz mechLLNL.tar.gz (120.9 KB, 19 views)
adhiraj is offline   Reply With Quote

Old   February 10, 2020, 20:59
Smile
  #8
Member
 
Patti Michelle Sheaffer
Join Date: Sep 2018
Posts: 55
Rep Power: 8
pattim is on a distinguished road
Thank you very much! It's really remarkable you could figure that all out so easily. Many of the errors chemkinToFoam gives aren't very helpful, apparently.

I was feeling very overwhelmed trying to read and understand all the separate files that go into the chemkinToFoam parser - it's difficult to maintain as the code is in many different files. (Since it is *only* used once in the code suite to translate files, I don't understand why chemkinToFoam isn't just a single flat file - it would be more immune to version upgrades/changes.)

I tried your files but received an error. Luckily, it was easy to guess a fix from that error - just by removing the first two species from the therm.dat file. You said v2.3.1 OpenFOAM was able to parse these two species? I guess they lost that capability during maintenance of OF.

Error:
Code:
bash@OpenFoam >>> chemkinToFoam chem.inp therm.dat transportProperties chem thermo
/*---------------------------------------------------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  1912                                  |
|   \\  /    A nd           | Website:  www.openfoam.com                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
Build  : _e53419c0-20200203 OPENFOAM=1912 patch=200129
Arch   : "LSB;label=32;scalar=64"
Exec   : chemkinToFoam chem.inp therm.dat transportProperties chem thermo
Date   : Feb 10 2020
Time   : 17:43:30
Host   : linux-lhkc
PID    : 14597
I/O    : uncollated
Case   : /home/patti/OpenFOAM/tutorials/combustion/reactingFoam/RAS/DLR_A_LTS/chemkin
nProcs : 1
trapFpe: Floating point exception trapping enabled (FOAM_SIGFPE).
fileModificationChecking : Monitoring run-time modified files using timeStampMaster (fileModificationSkew 10)
allowSystemOperations : Allowing user-supplied system call operations

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //


--> FOAM FATAL IO ERROR:
Unexpected token encountered for CH2O - on line 10460: punctuation ')'

file: input at line 10460.

    From function static bool Foam::entry::New(Foam::dictionary&, Foam::Istream&, Foam::entry::inputMode, int)
    in file db/dictionary/entry/entryIO.C at line 291.

FOAM exiting

 bash@OpenFoam >>>
Luckily, I had come across that before. The Fix: I just deleted the first two species in therm.dat...

Code:
(CH2O)3            70590C   3H   6O   3     G  0300.00   4000.00  1500.00      1
 0.01913678E+03 0.08578044E-01-0.08882060E-05-0.03574819E-08 0.06605143E-12    2
-0.06560876E+06-0.08432507E+03-0.04662286E+02 0.06091547E+00-0.04710536E-03    3
 0.01968843E-06-0.03563271E-10-0.05665404E+06 0.04525265E+03                   4
(CH3)2SICH2        61991H   8C   3SI  1     G  0300.00   2500.00  1500.00      1
 0.01547852E+03 0.01065700E+00-0.01234345E-05-0.01293352E-07 0.02528715E-11    2
-0.06693076E+04-0.05358884E+03 0.02027522E+02 0.04408673E+00-0.03370024E-03    3
 0.01484466E-06-0.02830898E-10 0.03931454E+05 0.01815821E+03                   4
It seemed to run correctly and generated OF-formatted chem and thermo files. Thanks again.

I don't believe the LLNL mechanism uses those first two species - that thermo file is a very comprehensive file (all available species, including metals). There are comprehensive thermo files on Burcat's web page, containing all known species for which thermo data exists. I don't see why OpenFOAM doesn't just maintain a comprehensive thermo file in native OF format. If someone needed to add a couple of species, the OF format is easy to deal with - easier than a complex c++ code interpreter! I noticed also comments in the c++ code saying that bits of chemkinToFoam were "hacks" until someone could "figure out chemkin formatting." So it might be worthwhile to translate the LLNL mechanisms and keep them in OF (they already have several in v19.12). Maybe I'll make tutorials using LLNL and send to OF folks?


I realized that the thermo files had odd 2-digit endings for many species - I had assumed that was chemkin-III formatting. But I didn't try fixing that. Also, I found a couple of lines in the chem mech file that didn't have "!" preceding a reaction's references/comments, but I guess the chemkinToFoam code is robust enough to not be fooled by random text at the end of mech file reaction lines.


Also, thank you very much for the reminder about dos2unix - I had forgotten about that utility.

Patricia

PS: I meant to ask if the version of OF you're using has TDAC chemistry reduction built into it? I wonder if v19.12 is really that much better than v2.3.1?
pattim is offline   Reply With Quote

Old   February 13, 2020, 13:48
Default
  #9
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 pattim View Post
It's really remarkable you could figure that all out so easily.
Not easily my friend, years of frustration and yelling at the monitor.

Quote:
Originally Posted by pattim View Post
Code:
--> FOAM FATAL IO ERROR:
Unexpected token encountered for CH2O - on line 10460: punctuation ')'
If the parser is complaining about parentheses in a name that is a serious bug, and should be reported. By the way, please make sure that you are reporting a bug for the correct version and series of OpenFOAM releases.

Quote:
Originally Posted by pattim View Post
Also, I found a couple of lines in the chem mech file that didn't have "!" preceding a reaction's references/comments, but I guess the chemkinToFoam code is robust enough to not be fooled by random text at the end of mech file reaction lines.
Just out of curiosity, can you point me to such a line in the mechanism file?

Quote:
Originally Posted by pattim View Post
I don't see why OpenFOAM doesn't just maintain a comprehensive thermo file in native OF format.
A wise colleague with experience in modeling reacting flows once told me that the thermodynamic parameters you find in the therm.dat file are not necessarily universal; people who design and come up with these chemical mechanisms can and do optimize the thermo data as well. In short, it is not a good idea to take a chem.inp file from one source and use it with a therm.dat file from another source.

Quote:
Originally Posted by pattim View Post
PS: I meant to ask if the version of OF you're using has TDAC chemistry reduction built into it?
I don't believe the stock version of OpenFOAM 2.3.x has TDAC built into it. If I recall correctly, I obtained some libraries from the work of Francesco Contino that provided the functionality. The files can be obtained from the following link.

https://github.com/fcontino/TDAC


Quote:
Originally Posted by pattim View Post
I wonder if v19.12 is really that much better than v2.3.1?
That I don't know, since I have never used version 19.12. But I think they are not part of the same series of OpenFOAM releases, so there may be differences because of that.
adhiraj is offline   Reply With Quote

Old   February 15, 2020, 18:46
Default
  #10
Member
 
Patti Michelle Sheaffer
Join Date: Sep 2018
Posts: 55
Rep Power: 8
pattim is on a distinguished road
Lots of time yelling at computers, yes!


About "(" - I agree it's a serious bug, but I've not received positive feedback any time I've contacted the developers (other than requests for funding), so I'm going to let this slide.


About the "missing !'s" - I looked again at the original files but couldn't find the missing ones. Apparently I was mistaken - I was laboriously trying to remove all comments in case *that* was the problem with chemkinToFoam not working. I must have deleted them myself.


I agree about the THERMO data. Now that I recall, I've seen publications where they modified that data as an integral part of their combustion suite.


I see FreeFOAM has been disbanded. I guess CFD Online is now the repository of knowledge? I'm glad you uploaded those LLNL mechanism files. I want to try the other mechanisms on LLNL and see if I can upload them somewhere useful.
pattim is offline   Reply With Quote

Old   February 15, 2020, 18:53
Default
  #11
HPE
Senior Member
 
HPE's Avatar
 
Herpes Free Engineer
Join Date: Sep 2019
Location: The Home Under The Ground with the Lost Boys
Posts: 931
Rep Power: 13
HPE is on a distinguished road
Quote:
Originally Posted by pattim View Post
Thank you - I do also. There are very powerful chemical mechanisms which are unavailable to OpenFOAM at the present time, even though they are in chemkin format.


EDIT: issue tracker https://bugs.openfoam.org/view.php?id=3450
I meant GitLab, not Mantis. It seems that you have opened a ticket in the Foundation tracker rather than OpenCFD's.
HPE is offline   Reply With Quote

Old   February 20, 2020, 15:16
Default
  #12
Member
 
Patti Michelle Sheaffer
Join Date: Sep 2018
Posts: 55
Rep Power: 8
pattim is on a distinguished road
Oh, is that the wrong place? I know they closed the issue I added. What's the right place to put that? EDIT: I found https://develop.openfoam.com/Development/openfoam/issues


EDIT2: Is there a tool for coordinating all the input species in OF? It seems like a GUI tool or even a script might help all species mass fractions to sum to 1.0. I wonder if Qt or Gambas or Python could do that. I don't know if c++ has a gui creator.
pattim is offline   Reply With Quote

Old   February 20, 2020, 15:39
Default
  #13
HPE
Senior Member
 
HPE's Avatar
 
Herpes Free Engineer
Join Date: Sep 2019
Location: The Home Under The Ground with the Lost Boys
Posts: 931
Rep Power: 13
HPE is on a distinguished road
Oh no no nothing wrong with Mantis! Mantis is good! I just meant GitLab, that was it. Funding of maintenance of OpenFOAM is limited; OpenFOAM is free, but not its maintenance! They don't have time for the feature request there, I believe. That's why they had to close it I think. Try with GitLab as well.
HPE is offline   Reply With Quote

Old   December 21, 2021, 05:17
Default
  #14
Member
 
Amirreza Niazmehr
Join Date: Nov 2018
Posts: 40
Rep Power: 8
Amirreza_pro is on a distinguished road
Hi guys, I hope you are doing well
I'm going to use one of the tutorial of OpenFoam which is concerned with cumbustion (SandiaD_LTS), but I want to change the chemical mechanism of cumbustion in this tutorial.
I changed these two files: "grimech30.dat" and "thermo30.dat" in the Chemkin folder according to my mechanism but after running OpenFoam, I undestood that my changes has not been compiled and OpenFoam did not notice my changes.
Can you help me to resolve this problem?
Amirreza_pro is offline   Reply With Quote

Old   December 21, 2021, 11:39
Default
  #15
Member
 
Patti Michelle Sheaffer
Join Date: Sep 2018
Posts: 55
Rep Power: 8
pattim is on a distinguished road
Quote:
Originally Posted by Amirreza_pro View Post
Hi guys, I hope you are doing well
I'm going to use one of the tutorial of OpenFoam which is concerned with cumbustion (SandiaD_LTS), but I want to change the chemical mechanism of cumbustion in this tutorial.
I changed these two files: "grimech30.dat" and "thermo30.dat" in the Chemkin folder according to my mechanism but after running OpenFoam, I undestood that my changes has not been compiled and OpenFoam did not notice my changes.
Can you help me to resolve this problem?
The OpenFoam Chemkin parser is picky, so it's possible your changes busted something, or else you're still referencing the old files? Also, there are lots of related files in other directories which reference the chemistry. You have to go through all the files in the tutorial directory and look for the references. Did you first get very familiar with the tutorial workflow (Allclean/Allrun, etc.)?
pattim is offline   Reply With Quote

Old   January 29, 2023, 12:26
Default density-based solvers?
  #16
Member
 
Patti Michelle Sheaffer
Join Date: Sep 2018
Posts: 55
Rep Power: 8
pattim is on a distinguished road
Quote:
Originally Posted by adhiraj View Post
Please see if you can use these two files. They work with the chemkinToFoam utility in OpenFOAM 2.3.1.

The following changes were made to the original files downloaded from the link you provided:

1. The files are converted from lower to upper case. Fortran is case insensitive, whereas C++ is case sensitive.

2. I prefer to run dos2unix on these files before using them on Linux.

3. In the chem.inp file the elements, species, and reactions blocks are retained while the thermo block (which was empty) was removed. The blocks are also formatted in this way as shown for the elements block (notice the line breaks):

Hope that helps a bit.
Thanks for the help - that helped a LOT. Sorry for how late this bump/question is, but I was curious about rhoReactingFoam - which claims to want thermo data in "density" units. I've never heard of that for CHEMKIN use. Do you know of any such? I've been happily using reactingFoam with the LLNL mechanism, BTW.

Best Regards,

PattiM
pattim 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
question about chemkinToFoam asakusa OpenFOAM 15 October 6, 2019 05:01
chtMultiRegionSimpleFoam issues - non-conformal meshes & residual handling... manalis OpenFOAM Running, Solving & CFD 3 October 10, 2018 19:53
Convergence issues for Flat plate with sharp edge rajnarayang FLUENT 3 June 20, 2017 13:02
[ANSYS Meshing] Multizone issues (on my project) crenaudo ANSYS Meshing & Geometry 8 April 13, 2016 03:59
Multigrid Stability Issues ThomasHermann SU2 1 November 5, 2014 17:18


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