From 1687ecaf1b3e22c162d4ceef848974c3e9ee8b0b Mon Sep 17 00:00:00 2001 From: Harry Moffat Date: Wed, 9 Dec 2009 16:52:16 +0000 Subject: [PATCH] Bug fix involving kinetics operators that use HMWSoln. The member function getActivityConcentration() calculated the standard concentrations for solute species incorrectly. This caused the reaction rates of progress for kinetics operations involving HMWSoln to be calculated incorrectly. In particular, equilibrium constants (which were and are correct) were not compatible with forward vs. reverse ROP's. I fixed this error, and worked on more documentation of generalized activity concentrations. --- Cantera/src/thermo/HMWSoln.cpp | 10 ++- Cantera/src/thermo/HMWSoln.h | 135 +++++++++++++++++++++++++++------ 2 files changed, 118 insertions(+), 27 deletions(-) diff --git a/Cantera/src/thermo/HMWSoln.cpp b/Cantera/src/thermo/HMWSoln.cpp index 073eeaddf..8e30b0ac5 100644 --- a/Cantera/src/thermo/HMWSoln.cpp +++ b/Cantera/src/thermo/HMWSoln.cpp @@ -917,10 +917,14 @@ namespace Cantera { * reaction rate expressions within the phase. */ void HMWSoln::getActivityConcentrations(doublereal* c) const { - double c_solvent = standardConcentration(); + double cs_solvent = standardConcentration(); getActivities(c); - for (int k = 0; k < m_kk; k++) { - c[k] *= c_solvent; + c[0] *= cs_solvent; + if (m_kk > 1) { + double cs_solute = standardConcentration(1); + for (int k = 1; k < m_kk; k++) { + c[k] *= cs_solute; + } } } diff --git a/Cantera/src/thermo/HMWSoln.h b/Cantera/src/thermo/HMWSoln.h index 40cce6f86..f174a9469 100644 --- a/Cantera/src/thermo/HMWSoln.h +++ b/Cantera/src/thermo/HMWSoln.h @@ -1027,10 +1027,12 @@ namespace Cantera { * this phase equal to the default concentration of the solvent at the system temperature * and pressure multiplied by Mnaught (kg solvent / gmol solvent). The solvent * standard concentration is just equal to its standard state concentration. + * + * * This means that the - * kinetics operator essentially works on an generalized concentration basis (kg / m3), + * kinetics operator essentially works on an generalized concentration basis (kmol / m3), * with units for the kinetic rate constant specified - * as if all reactants (solvent or solute) are on a concentration basis (kg /m3). + * as if all reactants (solvent or solute) are on a concentration basis (kmol /m3). * The concentration will be modified by the activity coefficients. * * For example, a bulk-phase binary reaction between liquid solute species @@ -1039,39 +1041,50 @@ namespace Cantera { * following equation for its rate of progress variable, \f$ R^1 \f$, which has * units of kmol m-3 s-1. * + * \f[ + * R^1 = k^1 C_j^a C_k^a = k^1 (C^o_o \tilde{M}_o a_j) (C^o_o \tilde{M}_o a_k) + * \f] + * + * where * * \f[ - * R^1 = k^1 C_j^a C_k^a = k^1 (C_o \tilde{M}_o a_j) (C_o \tilde{M}_o a_k) - * \f] - * where - * \f[ - * C_j^a = C_o \tilde{M}_o a_j \quad and \quad C_k^a = C_o \tilde{M}_o a_k + * C_j^a = C^o_o \tilde{M}_o a_j \quad and \quad C_k^a = C^o_o \tilde{M}_o a_k * \f] * * \f$ C_j^a \f$ is the activity concentration of species j, and - * \f$ C_k^a \f$ is the activity concentration of species k. \f$ C_o \f$ - * is the concentration of water at 298 K and 1 atm. \f$ \tilde{M}_o \f$ is + * \f$ C_k^a \f$ is the activity concentration of species k. \f$ C^o_o \f$ + * is the concentration of water at 298 K and 1 atm. \f$ \tilde{M}_o \f$ * has units of kg solvent per gmol solvent and is equal to * * \f[ * \tilde{M}_o = \frac{M_o}{1000} * \f] * - * * \f$ a_j \f$ is * the activity of species j at the current temperature and pressure * and concentration of the liquid phase is given by the molality based * activity coefficient multiplied by the molality of the jth species. * * \f[ - * a_j = \gamma_j^\triangle m_j + * a_j = \gamma_j^\triangle m_j = \gamma_j^\triangle \frac{n_j}{\tilde{M}_o n_o} * \f] * * \f$k^1 \f$ has units of m3 kmol-1 s-1. * + * Therefore the generalized activity concentration of a solute species has the following form + * + * \f[ + * C_j^a = C^o_o \frac{\gamma_j^\triangle n_j}{n_o} + * \f] + * + * The generalized activity concentration of the solvent has the same units, but its a simpler form + * + * \f[ + * C_o^a = C^o_o a_o + * \f] * * The reverse rate constant can then be obtained from the law of microscopic reversibility - * and the equilibrium expression for the system. + * and the equilibrium expression for the system. * * \f[ * \frac{a_j a_k}{ a_l} = K^{o,1} = \exp(\frac{\mu^o_l - \mu^o_j - \mu^o_k}{R T} ) @@ -1587,18 +1600,31 @@ namespace Cantera { * @{ */ - /** - * This method returns an array of generalized concentrations - * \f$ C_k\f$ that are defined such that - * \f$ a_k = C_k / C^0_k, \f$ where \f$ C^0_k \f$ + + //! This method returns an array of generalized activity concentrations + /*! + * The generalized activity concentrations, \f$ C_k^a\f$, are defined such that + * \f$ a_k = C^a_k / C^0_k, \f$ where \f$ C^0_k \f$ * is a standard concentration * defined below. These generalized concentrations are used * by kinetics manager classes to compute the forward and * reverse rates of elementary reactions. * + * The generalized activity concentration of a solute species has the following form + * + * \f[ + * C_j^a = C^o_o \frac{\gamma_j^\triangle n_j}{n_o} + * \f] + * + * The generalized activity concentration of the solvent has the same units, but its a simpler form + * + * \f[ + * C_o^a = C^o_o a_o + * \f] + * + * * @param c Array of generalized concentrations. The - * units depend upon the implementation of the - * reaction rate expressions within the phase. + * units are kmol m-3 for both the solvent and the solute species */ virtual void getActivityConcentrations(doublereal* c) const; @@ -1607,12 +1633,73 @@ namespace Cantera { * The standard concentration \f$ C^0_k \f$ used to normalize * the activity (i.e., generalized) concentration for use * - * For the time being, we will use the concentration of pure - * solvent at the temperature and pressure of the solution - * for the the standard concentration of all species. - * This has the effect of making mass-action reaction rates - * based on the molality of species proportional to the - * molality of the species. + * We have set the standard concentration for all solute species in + * this phase equal to the default concentration of the solvent at the system temperature + * and pressure multiplied by Mnaught (kg solvent / gmol solvent). The solvent + * standard concentration is just equal to its standard state concentration. + * + * \f[ + * C_j^0 = C^o_o \tilde{M}_o \quad and C_o^0 = C^o_o + * \f] + * + * The consequence of this is that the standard concentrations have unequal units + * between the solvent and the solute. However, both the solvent and the solute + * activity concentrations will have the same units of kmol kg-3. + * + * This means that the + * kinetics operator essentially works on an generalized concentration basis (kmol / m3), + * with units for the kinetic rate constant specified + * as if all reactants (solvent or solute) are on a concentration basis (kmol /m3). + * The concentration will be modified by the activity coefficients. + * + * For example, a bulk-phase binary reaction between liquid solute species + * j and k, producing + * a new liquid solute species l would have the + * following equation for its rate of progress variable, \f$ R^1 \f$, which has + * units of kmol m-3 s-1. + * + * \f[ + * R^1 = k^1 C_j^a C_k^a = k^1 (C^o_o \tilde{M}_o a_j) (C^o_o \tilde{M}_o a_k) + * \f] + * + * where + * + * \f[ + * C_j^a = C^o_o \tilde{M}_o a_j \quad and \quad C_k^a = C^o_o \tilde{M}_o a_k + * \f] + * + * \f$ C_j^a \f$ is the activity concentration of species j, and + * \f$ C_k^a \f$ is the activity concentration of species k. \f$ C^o_o \f$ + * is the concentration of water at 298 K and 1 atm. \f$ \tilde{M}_o \f$ + * has units of kg solvent per gmol solvent and is equal to + * + * \f[ + * \tilde{M}_o = \frac{M_o}{1000} + * \f] + * + * \f$ a_j \f$ is + * the activity of species j at the current temperature and pressure + * and concentration of the liquid phase is given by the molality based + * activity coefficient multiplied by the molality of the jth species. + * + * \f[ + * a_j = \gamma_j^\triangle m_j = \gamma_j^\triangle \frac{n_j}{\tilde{M}_o n_o} + * \f] + * + * \f$k^1 \f$ has units of m3 kmol-1 s-1. + * + * Therefore the generalized activity concentration of a solute species has the following form + * + * \f[ + * C_j^a = C^o_o \frac{\gamma_j^\triangle n_j}{n_o} + * \f] + * + * The generalized activity concentration of the solvent has the same units, but its a simpler form + * + * \f[ + * C_o^a = C^o_o a_o + * \f] + * * * @param k Optional parameter indicating the species. The default * is to assume this refers to species 0.