From 3c9bbc4ec92cb8a0bbe0a127575bcc7af5e063e0 Mon Sep 17 00:00:00 2001 From: Steven DeCaluwe Date: Sun, 18 Nov 2018 08:56:13 -0700 Subject: [PATCH] Fix IdealMolalSolution::standardConcentration Standard concentrations in the IdealMolalSolution phase depend on a user-specified m_formGC parameter, where m_formGC=0 results in a standard concentration of 1.0, m_formGC = 1 is supposed to result in a standard concentration for species k equal to 1 divided by the molar volume of species k, and m_formGC = 2 is supposed to result in a standard concentration equal to 1 divided by the molar volume of the solvent species (which is species 0). Current behavior is that m_formGC = 1 and m_formGC = 2 *both* result in a standard concentration of 1 divided by molar vlume of the solvent. This commit fixes how this is handled, cleans up the switch statement (the three cases were written somewhat inconsistently), and throws an error if m_formGC is set < 0 or > 2. --- src/thermo/IdealMolalSoln.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/thermo/IdealMolalSoln.cpp b/src/thermo/IdealMolalSoln.cpp index 2086c7883..702b77d64 100644 --- a/src/thermo/IdealMolalSoln.cpp +++ b/src/thermo/IdealMolalSoln.cpp @@ -176,18 +176,18 @@ void IdealMolalSoln::getActivityConcentrations(doublereal* c) const doublereal IdealMolalSoln::standardConcentration(size_t k) const { - double c0 = 1.0; switch (m_formGC) { case 0: - break; + return 1.0; case 1: - return c0 = 1.0 /m_speciesMolarVolume[0]; - break; + return 1.0 / m_speciesMolarVolume[k]; case 2: - c0 = 1.0 / m_speciesMolarVolume[0]; - break; + return 1.0 / m_speciesMolarVolume[0]; + default: + throw CanteraError("IdealMolalSoln::standardConcentration", + "m_formGC is set to an incorrect value. \ + Allowed values are 0, 1, and 2"); } - return c0; } void IdealMolalSoln::getActivities(doublereal* ac) const