libantioch / antioch

C++ Chemical Kinetics, Thermodynaimics, and Transport Library
https://libantioch.github.io/
Other
22 stars 17 forks source link

NaN handling, stage 1 #215

Closed roystgnr closed 8 years ago

roystgnr commented 8 years ago

If we have a ridiculously stiff function, we can get overflow of our reaction rates. This is particularly a concern in reversible reactions where the equilibrium constant underflows at low temperatures - we were actually triggering that in the kinetics_unit tests, but then passing the tests anyway because "if (NaN > tol) error()" doesn't error.

This PR gives us -infinity rather than NaN in overflowing reverse reactions, and adds more testing where appropriate.

I don't think we'll be able to handle infinity smoothly in user code, so stage 2 will be to make that "infinity" user-overrideable.

roystgnr commented 8 years ago

I didn't put in any workarounds for missing isnan(), so this PR requires a C++11 feature. Linking to #206

pbauman commented 8 years ago

This looks good. Do we want to individually check for std::isnan in the configure checks as part of #206?

roystgnr commented 8 years ago

Probably not. IIRC there are lots of C++03 compilers that include isnan() (whether intentionally or inadvertently via C99 headers) but I've never heard of a C++11 compiler that lacked it.