From b44f189569c92ed3646d87b737fb66ae61cf7a57 Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Fri, 9 Aug 2019 13:30:47 -0400 Subject: [PATCH] [Thermo] Avoid NaN in entropy with small negative mass fractions Avoid NaN results in entropy_mole calculations when there are small negative mass fractions. Consistent with the approach used elsewhere, e.g. IdealGasPhase::getPartialMolarEntropies. --- src/thermo/Phase.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/thermo/Phase.cpp b/src/thermo/Phase.cpp index a39cea996..85798d5ec 100644 --- a/src/thermo/Phase.cpp +++ b/src/thermo/Phase.cpp @@ -657,7 +657,7 @@ doublereal Phase::sum_xlogx() const { double sumxlogx = 0; for (size_t k = 0; k < m_kk; k++) { - sumxlogx += m_ym[k] * std::log(m_ym[k] + Tiny); + sumxlogx += m_ym[k] * std::log(std::max(m_ym[k], SmallNumber)); } return m_mmw * sumxlogx + std::log(m_mmw); }