From 03b7e6b5d4c27c7dad9a955b301c1a65f693ade3 Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Mon, 27 Feb 2023 23:20:29 -0500 Subject: [PATCH] Protect against inf in SurfPhase::getChemPotentials Fixes #1314 --- src/thermo/SurfPhase.cpp | 2 +- test/data/consistency-cases.yaml | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/thermo/SurfPhase.cpp b/src/thermo/SurfPhase.cpp index deb9212ee..9ae814444 100644 --- a/src/thermo/SurfPhase.cpp +++ b/src/thermo/SurfPhase.cpp @@ -108,7 +108,7 @@ void SurfPhase::getChemPotentials(doublereal* mu) const copy(m_mu0.begin(), m_mu0.end(), mu); getActivityConcentrations(m_work.data()); for (size_t k = 0; k < m_kk; k++) { - mu[k] += RT() * (log(m_work[k]) - logStandardConc(k)); + mu[k] += RT() * (log(std::max(m_work[k], SmallNumber)) - logStandardConc(k)); } } diff --git a/test/data/consistency-cases.yaml b/test/data/consistency-cases.yaml index b84a8a843..58e7bda45 100644 --- a/test/data/consistency-cases.yaml +++ b/test/data/consistency-cases.yaml @@ -267,8 +267,6 @@ ideal-surface: "Implementation of s_k is incorrect. See GitHub Issue #1313" s_eq_sum_sk_Xk: "Implementation of s_k is incorrect. See GitHub Issue #1313" - g_eq_sum_gk_Xk: - "chemPotentials does not protect against inf. See GitHub Issue #1314" states: - {T: 800, P: 1 atm, coverages: {Pt(s): 0.5, H(s): 0.4, O(s): 0.1}} - {T: 800, P: 5 atm, coverages: {H(s): 1.0}}