From 471041a27aef094caf6b76fab293a0d428a5dfd4 Mon Sep 17 00:00:00 2001 From: g3bk47 Date: Thu, 28 Feb 2019 17:52:16 +0100 Subject: [PATCH] Additional check for Troe coefficients being zero 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. --- src/kinetics/Falloff.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/kinetics/Falloff.cpp b/src/kinetics/Falloff.cpp index 9e84775d3..3c83c5582 100644 --- a/src/kinetics/Falloff.cpp +++ b/src/kinetics/Falloff.cpp @@ -30,8 +30,18 @@ void Troe::init(const vector_fp& c) c.size()); } m_a = c[0]; - m_rt3 = 1.0/c[1]; - m_rt1 = 1.0/c[2]; + if (std::abs(c[1]) < SmallNumber) { + m_rt3 = std::numeric_limits::infinity(); + } else { + m_rt3 = 1.0 / c[1]; + } + + if (std::abs(c[2]) < SmallNumber) { + m_rt1 = std::numeric_limits::infinity(); + } else { + m_rt1 = 1.0 / c[2]; + } + if (c.size() == 4) { m_t2 = c[3]; }