From c6eea6990fed7afc82b42f368902898e6dde1ecb Mon Sep 17 00:00:00 2001 From: Henry Date: Thu, 4 Oct 2012 18:10:26 +0100 Subject: [PATCH] specieThermo: Add guard in K(T) to protect against 0 moles in composition --- .../specie/thermo/thermo/thermoI.H | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/thermophysicalModels/specie/thermo/thermo/thermoI.H b/src/thermophysicalModels/specie/thermo/thermo/thermoI.H index b8642e960b..21a58ec779 100644 --- a/src/thermophysicalModels/specie/thermo/thermo/thermoI.H +++ b/src/thermophysicalModels/specie/thermo/thermo/thermoI.H @@ -298,15 +298,22 @@ template class Type> inline Foam::scalar Foam::species::thermo::K(const scalar p, const scalar T) const { - scalar arg = -this->nMoles()*this->g(p, T)/(this->RR*T); - - if (arg < 600.0) + if (equal(this->nMoles(), SMALL)) { - return ::exp(arg); + return 1.0; } else { - return VGREAT; + scalar arg = -this->nMoles()*this->g(p, T)/(this->RR*T); + + if (arg < 600.0) + { + return exp(arg); + } + else + { + return VGREAT; + } } }