Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional check for Troe coefficients being zero #601

Merged
merged 1 commit into from
Mar 18, 2019

Conversation

g3bk47
Copy link
Contributor

@g3bk47 g3bk47 commented Feb 28, 2019

I encountered the problem that the "init" function of Troe reactions generates a floating point exception due to division by zero. I am using the FORCE Caltech mechanism from here:
http://www.theforce.caltech.edu/CaltechMech/
In the mechanism file
http://cvs.theforce.caltech.edu/cgi-bin/viewvc.cgi/CaltechMech/CaltechMech.chmech?view=co
there is the following reaction:

H+O2(+M) = HO2(+M) 5.590e+13 0.200 0.00
O2/0.89/ H2/1.50/ H2O/11.70/ CO2/2.18/ AR/0.52/ CO/1.09/
LOW / 2.650e+19 -1.300 0.00 /
TROE/ 0.7 0.00 10000000000.00 10000000000.00 /

The second Troe parameter is zero. According to the Chemkin Format
http://akrmys.com/public/chemkin/CKm_inp.html.en
this corresponds to T*** or "m_rt3" in Cantera:

m_rt3 = 1.0/c[1];

Using the standard installation of Cantera, this does not generate any errors. But in my case, I use Cantera together with another program (OpenFOAM), which throws hardware exceptions if this occurs. Of course, I could change this by hand in the mechanism file itself, but maybe it is nicer to handle this in the code.
This was actually handled in previous versions, but was removed in this commit:
84e6775#diff-4210fe882743537c1bb1cacdbe10255b
and this issue:
#404
I would argue to include a special treatment for zero in case Cantera is used together with programs like OpenFOAM which will trigger hardware exceptions if division by zero occurs.

Because this part of the code is not relevant to performance, I introduced an additional check. This will prevent hardware exceptions in case c[1] or c[2] are zero but will exactly keep the current behaviour if c[1] and c[2] are not zero.

@codecov
Copy link

codecov bot commented Feb 28, 2019

Codecov Report

Merging #601 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #601      +/-   ##
=========================================
+ Coverage    68.5%   68.5%   +<.01%     
=========================================
  Files         363     363              
  Lines       39957   39961       +4     
=========================================
+ Hits        27374   27377       +3     
- Misses      12583   12584       +1
Impacted Files Coverage Δ
src/kinetics/Falloff.cpp 74.19% <100%> (+1.77%) ⬆️
src/transport/GasTransport.cpp 90.77% <0%> (-0.21%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 540777c...7a8ab02. Read the comment docs.

@codecov
Copy link

codecov bot commented Feb 28, 2019

Codecov Report

Merging #601 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #601      +/-   ##
==========================================
+ Coverage   68.52%   68.52%   +<.01%     
==========================================
  Files         363      363              
  Lines       39953    39957       +4     
==========================================
+ Hits        27378    27381       +3     
- Misses      12575    12576       +1
Impacted Files Coverage Δ
src/kinetics/Falloff.cpp 74.19% <100%> (+1.77%) ⬆️
src/transport/GasTransport.cpp 90.77% <0%> (-0.21%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4026c17...05ef02d. Read the comment docs.

src/kinetics/Falloff.cpp Outdated Show resolved Hide resolved
This will prevent floating point exceptions (sometimes enabled by third-party
codes) in case c[1] or c[2] are zero but will not change the current behaviour
if c[1] and c[2] are not zero.
@speth
Copy link
Member

speth commented Mar 18, 2019

Just pushed an updated version to fix some formatting issues (trailing whitespace and placement of curly braces). Good to merge once the CI completes.

@speth speth merged commit 471041a into Cantera:master Mar 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants