specieThermo: Add guard in K(T) to protect against 0 moles in composition

This commit is contained in:
Henry
2012-10-04 18:10:26 +01:00
parent e9e09f11dc
commit c6eea6990f

View File

@ -298,15 +298,22 @@ template<class Thermo, template<class> class Type>
inline Foam::scalar inline Foam::scalar
Foam::species::thermo<Thermo, Type>::K(const scalar p, const scalar T) const Foam::species::thermo<Thermo, Type>::K(const scalar p, const scalar T) const
{ {
scalar arg = -this->nMoles()*this->g(p, T)/(this->RR*T); if (equal(this->nMoles(), SMALL))
if (arg < 600.0)
{ {
return ::exp(arg); return 1.0;
} }
else else
{ {
return VGREAT; scalar arg = -this->nMoles()*this->g(p, T)/(this->RR*T);
if (arg < 600.0)
{
return exp(arg);
}
else
{
return VGREAT;
}
} }
} }