From eb129e8f00a7c2ea0ab355b5a9ac841ed21aed2d Mon Sep 17 00:00:00 2001 From: Harry Moffat Date: Mon, 2 Oct 2006 19:10:53 +0000 Subject: [PATCH] In the init() routine, I set the initial mass fraction vector so that it sums to one. Previously, it was set uniformly to zero. The mass fraction of species 0 is set to 1. This was noticed by a user, and may have resulted in seg faults before the ThermoPhase object was properly initialized. --- Cantera/src/State.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Cantera/src/State.cpp b/Cantera/src/State.cpp index 4218ae735..9ec05ebe2 100644 --- a/Cantera/src/State.cpp +++ b/Cantera/src/State.cpp @@ -164,8 +164,6 @@ namespace Cantera { scale(m_ym.begin(), m_ym.end(), c, m_dens); } - - doublereal State::mean_Y(const doublereal* Q) const { return dot(m_y.begin(), m_y.end(), Q); } @@ -199,6 +197,17 @@ namespace Cantera { if (m_molwts[k] < Tiny) m_molwts[k] = Tiny; m_rmolwts[k] = 1.0/m_molwts[k]; } + + /* + * Now that we have resized the State object, let's fill it with + * a valid mass fraction vector that sums to one. The State object + * should never have a mass fraction vector that doesn't sum to one. + * We will assume that species 0 has a mass fraction of 1.0 and + * mass fraction of all other species is 0.0. + */ + m_y[0] = 1.0; + m_ym[0] = m_y[0] * m_rmolwts[0]; + m_mmw = 1.0 / m_ym[0]; } }