Fortran Cantera: error while reading DME mechanism with floating-point exception flag

41 views
Skip to first unread message

Solal Amouyal

unread,
Oct 25, 2017, 10:23:31 AM10/25/17
to Cantera Users' Group
I am using cantera-2.4.0a1 so this might be a bug. I initially got this error from a very large code, it took me a while to figure out what was the issue.

I have written a very simple program in Fortran that reads a DME mechanism. If I add the floating-point exception flag -ffpe-trap=zero, the code throws an exception. 
I have attached the program, mechanism and Makefile used to produce the error. Simply turn on or off the DEBUG variable in the Makefile in order to produce the error or not.

Note that I have added a test case with a Hydrogen-air mechanism which works perfectly with the flag in question.

Thanks,
DME_39species.xml
h2air.xml
main.f90
Makefile

Ray Speth

unread,
Oct 25, 2017, 12:56:39 PM10/25/17
to Cantera Users' Group

Hi Solal,

This floating point exception is triggered by the use of 0 as the value for one of the falloff coefficients in one reaction (CH3 + CH3 (+ M) [=] C2H6 (+ M)). The value T_1 is used in a term computed as \exp(-T/T1). Since T is always positive, -T/T1 will evaluate to -\infty and the term will evaluate to 0. This is a case where the floating point rules for division by zero give exactly the desired limiting behavior, and trapping floating point exceptions leads to false identification of an error.

Regards,
Ray

Solal Amouyal

unread,
Oct 26, 2017, 2:05:13 AM10/26/17
to Cantera Users' Group
Hi Ray,

Thanks for your rapid answer.

I located the reaction (#48) you mentioned in the xml file. Although not imperative, I do like to use floating-point exception when debugging my code. I changed to 0 falloff coefficients to a small value, 1e-10. Is that all right? Not being familiar with what happens under the hood, I want to make sure I do not get any unwanted effects down the line.

Sincerely,

Solal

Reply all
Reply to author
Forward
0 new messages