diff --git a/Cantera/src/IdealGasPhase.cpp b/Cantera/src/IdealGasPhase.cpp index 8572dd82e..ae42627f9 100644 --- a/Cantera/src/IdealGasPhase.cpp +++ b/Cantera/src/IdealGasPhase.cpp @@ -18,162 +18,226 @@ using namespace std; namespace Cantera { + // Empty Constructor + IdealGasPhase::IdealGasPhase(): + m_mm(0), + m_tmin(0.0), + m_tmax(0.0), + m_p0(-1.0), + m_tlast(0.0), + m_logc0(0.0) + { + } - // Molar Thermodynamic Properties of the Solution ---------- - // Mechanical Equation of State ---------------------------- - // Chemical Potentials and Activities ---------------------- + // Molar Thermodynamic Properties of the Solution ---------- + // Mechanical Equation of State ---------------------------- + // Chemical Potentials and Activities ---------------------- - /** - * Get the array of non-dimensional activity coefficients - */ - void IdealGasPhase::getActivityCoefficients(doublereal *ac) const { - for (int k = 0; k < m_kk; k++) { - ac[k] = 1.0; - } + /* + * Returns the standard concentration \f$ C^0_k \f$, which is used to normalize + * the generalized concentration. + */ + doublereal IdealGasPhase::standardConcentration(int k) const { + double p = pressure(); + return p/(GasConstant * temperature()); + } + + /* + * Returns the natural logarithm of the standard + * concentration of the kth species + */ + doublereal IdealGasPhase::logStandardConc(int k) const { + _updateThermo(); + double p = pressure(); + double lc = std::log (p / (GasConstant * temperature())); + return lc; + } + + /* + * Get the array of non-dimensional activity coefficients + */ + void IdealGasPhase::getActivityCoefficients(doublereal *ac) const { + for (int k = 0; k < m_kk; k++) { + ac[k] = 1.0; } + } - /** - * Get the array of chemical potentials at unit activity \f$ - * \mu^0_k(T,P) \f$. - */ - void IdealGasPhase::getStandardChemPotentials(doublereal* muStar) const { - const array_fp& gibbsrt = gibbs_RT_ref(); - scale(gibbsrt.begin(), gibbsrt.end(), muStar, _RT()); - double tmp = log (pressure() /m_spthermo->refPressure()); - tmp *= GasConstant * temperature(); - for (int k = 0; k < m_kk; k++) { - muStar[k] += tmp; // add RT*ln(P/P_0) - } + /* + * Get the array of chemical potentials at unit activity \f$ + * \mu^0_k(T,P) \f$. + */ + void IdealGasPhase::getStandardChemPotentials(doublereal* muStar) const { + const array_fp& gibbsrt = gibbs_RT_ref(); + scale(gibbsrt.begin(), gibbsrt.end(), muStar, _RT()); + double tmp = log (pressure() /m_spthermo->refPressure()); + tmp *= GasConstant * temperature(); + for (int k = 0; k < m_kk; k++) { + muStar[k] += tmp; // add RT*ln(P/P_0) } + } - // Partial Molar Properties of the Solution -------------- + // Partial Molar Properties of the Solution -------------- - void IdealGasPhase::getChemPotentials(doublereal* mu) const { - getStandardChemPotentials(mu); - //doublereal logp = log(pressure()/m_spthermo->refPressure()); - doublereal xx; - doublereal rt = temperature() * GasConstant; - //const array_fp& g_RT = gibbs_RT_ref(); - for (int k = 0; k < m_kk; k++) { - xx = fmaxx(SmallNumber, moleFraction(k)); - mu[k] += rt*(log(xx)); - } + void IdealGasPhase::getChemPotentials(doublereal* mu) const { + getStandardChemPotentials(mu); + //doublereal logp = log(pressure()/m_spthermo->refPressure()); + doublereal xx; + doublereal rt = temperature() * GasConstant; + //const array_fp& g_RT = gibbs_RT_ref(); + for (int k = 0; k < m_kk; k++) { + xx = fmaxx(SmallNumber, moleFraction(k)); + mu[k] += rt*(log(xx)); } + } + + /* + * Get the array of partial molar enthalpies of the species + * units = J / kmol + */ + void IdealGasPhase::getPartialMolarEnthalpies(doublereal* hbar) const { + const array_fp& _h = enthalpy_RT_ref(); + doublereal rt = GasConstant * temperature(); + scale(_h.begin(), _h.end(), hbar, rt); + } - /** - * Get the array of partial molar enthalpies of the species - * units = J / kmol - */ - void IdealGasPhase::getPartialMolarEnthalpies(doublereal* hbar) const { - const array_fp& _h = enthalpy_RT_ref(); - doublereal rt = GasConstant * temperature(); - scale(_h.begin(), _h.end(), hbar, rt); + /* + * Get the array of partial molar entropies of the species + * units = J / kmol / K + */ + void IdealGasPhase::getPartialMolarEntropies(doublereal* sbar) const { + const array_fp& _s = entropy_R_ref(); + doublereal r = GasConstant; + scale(_s.begin(), _s.end(), sbar, r); + doublereal logp = log(pressure()/m_spthermo->refPressure()); + for (int k = 0; k < m_kk; k++) { + doublereal xx = fmaxx(SmallNumber, moleFraction(k)); + sbar[k] += r * (- logp - log(xx)); } + } - /** - * Get the array of partial molar entropies of the species - * units = J / kmol / K - */ - void IdealGasPhase::getPartialMolarEntropies(doublereal* sbar) const { - const array_fp& _s = entropy_R_ref(); - doublereal r = GasConstant; - scale(_s.begin(), _s.end(), sbar, r); - doublereal logp = log(pressure()/m_spthermo->refPressure()); - for (int k = 0; k < m_kk; k++) { - doublereal xx = fmaxx(SmallNumber, moleFraction(k)); - sbar[k] += r * (- logp - log(xx)); - } + /* + * Get the array of partial molar internal energies of the species + * units = J / kmol + */ + void IdealGasPhase::getPartialMolarIntEnergies(doublereal* ubar) const { + const array_fp& _h = enthalpy_RT_ref(); + doublereal rt = GasConstant * temperature(); + for (int k = 0; k < m_kk; k++) { + ubar[k] = rt * (_h[k] - 1.0); } + } - /** - * Get the array of partial molar volumes - * units = m^3 / kmol - */ - void IdealGasPhase::getPartialMolarVolumes(doublereal* vbar) const { - double vol = 1.0 / molarDensity(); - for (int k = 0; k < m_kk; k++) { - vbar[k] = vol; - } + /* + * Get the array of partial molar heat capacities + */ + void IdealGasPhase::getPartialMolarCp(doublereal* cpbar) const { + const array_fp& _cp = cp_R_ref(); + scale(_cp.begin(), _cp.end(), cpbar, GasConstant); + } + + /* + * Get the array of partial molar volumes + * units = m^3 / kmol + */ + void IdealGasPhase::getPartialMolarVolumes(doublereal* vbar) const { + double vol = 1.0 / molarDensity(); + for (int k = 0; k < m_kk; k++) { + vbar[k] = vol; } + } - // Properties of the Standard State of the Species in the Solution -- + // Properties of the Standard State of the Species in the Solution -- - /** - * Get the nondimensional Enthalpy functions for the species - * at their standard states at the current T and P of the - * solution - */ - void IdealGasPhase::getEnthalpy_RT(doublereal* hrt) const { - const array_fp& _h = enthalpy_RT_ref(); - copy(_h.begin(), _h.end(), hrt); + /* + * Get the nondimensional Enthalpy functions for the species + * at their standard states at the current T and P of the + * solution + */ + void IdealGasPhase::getEnthalpy_RT(doublereal* hrt) const { + const array_fp& _h = enthalpy_RT_ref(); + copy(_h.begin(), _h.end(), hrt); + } + + /* + * Get the array of nondimensional entropy functions for the + * standard state species + * at the current T and P of the solution. + */ + void IdealGasPhase::getEntropy_R(doublereal* sr) const { + const array_fp& _s = entropy_R_ref(); + copy(_s.begin(), _s.end(), sr); + double tmp = log (pressure() /m_spthermo->refPressure()); + for (int k = 0; k < m_kk; k++) { + sr[k] -= tmp; } + } - /** - * Get the array of nondimensional entropy functions for the - * standard state species - * at the current T and P of the solution. - */ - void IdealGasPhase::getEntropy_R(doublereal* sr) const { - const array_fp& _s = entropy_R_ref(); - copy(_s.begin(), _s.end(), sr); - double tmp = log (pressure() /m_spthermo->refPressure()); - for (int k = 0; k < m_kk; k++) { - sr[k] -= tmp; - } + /* + * Get the nondimensional gibbs function for the species + * standard states at the current T and P of the solution. + */ + void IdealGasPhase::getGibbs_RT(doublereal* grt) const { + const array_fp& gibbsrt = gibbs_RT_ref(); + copy(gibbsrt.begin(), gibbsrt.end(), grt); + double tmp = log (pressure() /m_spthermo->refPressure()); + for (int k = 0; k < m_kk; k++) { + grt[k] += tmp; } + } - /** - * Get the nondimensional gibbs function for the species - * standard states at the current T and P of the solution. - */ - void IdealGasPhase::getGibbs_RT(doublereal* grt) const { - const array_fp& gibbsrt = gibbs_RT_ref(); - copy(gibbsrt.begin(), gibbsrt.end(), grt); - double tmp = log (pressure() /m_spthermo->refPressure()); - for (int k = 0; k < m_kk; k++) { - grt[k] += tmp; - } + /* + * get the pure Gibbs free energies of each species assuming + * it is in its standard state. This is the same as + * getStandardChemPotentials(). + */ + void IdealGasPhase::getPureGibbs(doublereal* gpure) const { + const array_fp& gibbsrt = gibbs_RT_ref(); + scale(gibbsrt.begin(), gibbsrt.end(), gpure, _RT()); + double tmp = log (pressure() /m_spthermo->refPressure()); + tmp *= _RT(); + for (int k = 0; k < m_kk; k++) { + gpure[k] += tmp; } + } - /** - * get the pure Gibbs free energies of each species assuming - * it is in its standard state. This is the same as - * getStandardChemPotentials(). - */ - void IdealGasPhase::getPureGibbs(doublereal* gpure) const { - const array_fp& gibbsrt = gibbs_RT_ref(); - scale(gibbsrt.begin(), gibbsrt.end(), gpure, _RT()); - double tmp = log (pressure() /m_spthermo->refPressure()); - tmp *= _RT(); - for (int k = 0; k < m_kk; k++) { - gpure[k] += tmp; - } - } - - /** - * Returns the vector of nondimensional - * internal Energies of the standard state at the current temperature - * and pressure of the solution for each species. - */ - void IdealGasPhase::getIntEnergy_RT(doublereal *urt) const { - const array_fp& _h = enthalpy_RT_ref(); - for (int k = 0; k < m_kk; k++) { - urt[k] = _h[k] - 1.0; - } + /* + * Returns the vector of nondimensional + * internal Energies of the standard state at the current temperature + * and pressure of the solution for each species. + */ + void IdealGasPhase::getIntEnergy_RT(doublereal *urt) const { + const array_fp& _h = enthalpy_RT_ref(); + for (int k = 0; k < m_kk; k++) { + urt[k] = _h[k] - 1.0; } + } - /** - * Get the nondimensional heat capacity at constant pressure - * function for the species - * standard states at the current T and P of the solution. - */ - void IdealGasPhase::getCp_R(doublereal* cpr) const { - const array_fp& _cpr = cp_R_ref(); - copy(_cpr.begin(), _cpr.end(), cpr); + /* + * Get the nondimensional heat capacity at constant pressure + * function for the species + * standard states at the current T and P of the solution. + */ + void IdealGasPhase::getCp_R(doublereal* cpr) const { + const array_fp& _cpr = cp_R_ref(); + copy(_cpr.begin(), _cpr.end(), cpr); + } + + /* + * Get the molar volumes of the species standard states at the current + * T and P of the solution. + * units = m^3 / kmol + * + * @param vol Output vector containing the standard state volumes. + * Length: m_kk. + */ + void IdealGasPhase::getStandardVolumes(doublereal *vol) const { + doublereal tmp = _RT() / pressure(); + for (int k = 0; k < m_kk; k++) { + vol[k] = tmp; } + } - - // Thermodynamic Values for the Species Reference States --------- + // Thermodynamic Values for the Species Reference States --------- /** * Returns the vector of nondimensional @@ -243,7 +307,7 @@ namespace Cantera { void IdealGasPhase::initThermo() { - m_kk = nSpecies(); + m_mm = nElements(); doublereal tmin = m_spthermo->minTemp(); doublereal tmax = m_spthermo->maxTemp(); @@ -261,11 +325,11 @@ namespace Cantera { m_pp.resize(leng); } - /** - * Set mixture to an equilibrium state consistent with specified - * chemical potentials and temperature. This method is needed by - * the ChemEquil equillibrium solver. - */ + /* + * Set mixture to an equilibrium state consistent with specified + * chemical potentials and temperature. This method is needed by + * the ChemEquil equillibrium solver. + */ void IdealGasPhase::setToEquilState(const doublereal* mu_RT) { double tmp, tmp2; diff --git a/Cantera/src/IdealGasPhase.h b/Cantera/src/IdealGasPhase.h index e59486214..35eaa1b59 100644 --- a/Cantera/src/IdealGasPhase.h +++ b/Cantera/src/IdealGasPhase.h @@ -25,440 +25,575 @@ namespace Cantera { - /** - * Class IdealGasPhase represents low-density gases that obey the - * ideal gas equation of state. - * - * IdealGasPhase derives from class ThermoPhase, - * and overloads the virtual methods defined there with ones that - * use expressions appropriate for ideal gas mixtures. - * @ingroup thermoprops + + //!Class IdealGasPhase represents low-density gases that obey the + //! ideal gas equation of state. + /*! + * + * %IdealGasPhase derives from class ThermoPhase, + * and overloads the virtual methods defined there with ones that + * use expressions appropriate for ideal gas mixtures. + * + * This class is optimized for speed of execution. + * + * @ingroup thermoprops + */ + class IdealGasPhase : public ThermoPhase { + + public: + + //! Empty Constructor + IdealGasPhase(); + + //! Destructor + virtual ~IdealGasPhase() {} + + //! Equation of state flag. + /*! + * Returns the value cIdealGas, defined in mix_defs.h. */ - class IdealGasPhase : public ThermoPhase { + virtual int eosType() const { return cIdealGas; } - public: + /** + * @name Molar Thermodynamic Properties of the Solution ------------------------------ + * @{ + */ - IdealGasPhase(): m_tlast(0.0) {} + /** + * Molar enthalpy. Units: J/kmol. + * For an ideal gas mixture, + * \f[ + * \hat h(T) = \sum_k X_k \hat h^0_k(T), + * \f] + * and is a function only of temperature. + * The standard-state pure-species enthalpies + * \f$ \hat h^0_k(T) \f$ are computed by the species thermodynamic + * property manager. + * \see SpeciesThermo + */ + virtual doublereal enthalpy_mole() const { + return GasConstant * temperature() * + mean_X(&enthalpy_RT_ref()[0]); + } - virtual ~IdealGasPhase() {} + /** + * Molar internal energy. J/kmol. For an ideal gas mixture, + * \f[ + * \hat u(T) = \sum_k X_k \hat h^0_k(T) - \hat R T, + * \f] + * and is a function only of temperature. + * The reference-state pure-species enthalpies + * \f$ \hat h^0_k(T) \f$ are computed by the species thermodynamic + * property manager. + * @see SpeciesThermo + */ + virtual doublereal intEnergy_mole() const { + return GasConstant * temperature() + * ( mean_X(&enthalpy_RT_ref()[0]) - 1.0); + } - /** - * Equation of state flag. Returns the value cIdealGas, defined - * in mix_defs.h. - */ - virtual int eosType() const { return cIdealGas; } + /** + * Molar entropy. Units: J/kmol/K. + * For an ideal gas mixture, + * \f[ + * \hat s(T, P) = \sum_k X_k \hat s^0_k(T) - \hat R \log (P/P^0). + * \f] + * The reference-state pure-species entropies + * \f$ \hat s^0_k(T) \f$ are computed by the species thermodynamic + * property manager. + * @see SpeciesThermo + */ + virtual doublereal entropy_mole() const { + return GasConstant * (mean_X(&entropy_R_ref()[0]) - + sum_xlogx() - std::log(pressure()/m_spthermo->refPressure())); + } + + /** + * Molar Gibbs free Energy for an ideal gas. + * Units = J/kmol. + */ + virtual doublereal gibbs_mole() const { + return enthalpy_mole() - temperature() * entropy_mole(); + } - /** - * @name Molar Thermodynamic Properties of the Solution ------------------------------ - * @{ - */ + /** + * Molar heat capacity at constant pressure. Units: J/kmol/K. + * For an ideal gas mixture, + * \f[ + * \hat c_p(t) = \sum_k \hat c^0_{p,k}(T). + * \f] + * The reference-state pure-species heat capacities + * \f$ \hat c^0_{p,k}(T) \f$ are computed by the species thermodynamic + * property manager. + * @see SpeciesThermo + */ + virtual doublereal cp_mole() const { + return GasConstant * mean_X(&cp_R_ref()[0]); + } - /** - * Molar enthalpy. Units: J/kmol. - * For an ideal gas mixture, - * \f[ - * \hat h(T) = \sum_k X_k \hat h^0_k(T), - * \f] - * and is a function only of temperature. - * The standard-state pure-species enthalpies - * \f$ \hat h^0_k(T) \f$ are computed by the species thermodynamic - * property manager. - * \see SpeciesThermo - */ - virtual doublereal enthalpy_mole() const { - return GasConstant * temperature() * - mean_X(&enthalpy_RT_ref()[0]); - } + /** + * Molar heat capacity at constant volume. Units: J/kmol/K. + * For an ideal gas mixture, + * \f[ \hat c_v = \hat c_p - \hat R. \f] + */ + virtual doublereal cv_mole() const { + return cp_mole() - GasConstant; + } - /** - * Molar internal energy. J/kmol. For an ideal gas mixture, - * \f[ - * \hat u(T) = \sum_k X_k \hat h^0_k(T) - \hat R T, - * \f] - * and is a function only of temperature. - * The reference-state pure-species enthalpies - * \f$ \hat h^0_k(T) \f$ are computed by the species thermodynamic - * property manager. - * @see SpeciesThermo - */ - virtual doublereal intEnergy_mole() const { - return GasConstant * temperature() - * ( mean_X(&enthalpy_RT_ref()[0]) - 1.0); - } + //@} - /** - * Molar entropy. Units: J/kmol/K. - * For an ideal gas mixture, - * \f[ - * \hat s(T, P) = \sum_k X_k \hat s^0_k(T) - \hat R \log (P/P^0). - * \f] - * The reference-state pure-species entropies - * \f$ \hat s^0_k(T) \f$ are computed by the species thermodynamic - * property manager. - * @see SpeciesThermo - */ - virtual doublereal entropy_mole() const { - return GasConstant * (mean_X(&entropy_R_ref()[0]) - - sum_xlogx() - std::log(pressure()/m_spthermo->refPressure())); - } + /** + * @name Mechanical Equation of State ------------------------------------------------ + * @{ + */ - /** - * Molar Gibbs free Energy for an ideal gas. - * Units = J/kmol. - */ - virtual doublereal gibbs_mole() const { - return enthalpy_mole() - temperature() * entropy_mole(); - } + /** + * Pressure. Units: Pa. + * For an ideal gas mixture, + * \f[ P = n \hat R T. \f] + */ + virtual doublereal pressure() const { + return GasConstant * molarDensity() * temperature(); + } + + + //! Set the pressure at constant temperature and composition. + /*! + * Units: Pa. + * This method is implemented by setting the mass density to + * \f[ + * \rho = \frac{P \overline W}{\hat R T }. + * \f] + * + * @param p Pressure (Pa) + */ + virtual void setPressure(doublereal p) { + setDensity(p * meanMolecularWeight() + /(GasConstant * temperature())); + } + + //! Returns the isothermal compressibility. Units: 1/Pa. + /** + * The isothermal compressibility is defined as + * \f[ + * \kappa_T = -\frac{1}{v}\left(\frac{\partial v}{\partial P}\right)_T + * \f] + * For ideal gases it's equal to the negative of the inverse of the pressure + */ + virtual doublereal isothermalCompressibility() const { + return -1.0/pressure(); + } + + //! Return the volumetric thermal expansion coefficient. Units: 1/K. + /*! + * The thermal expansion coefficient is defined as + * \f[ + * \beta = \frac{1}{v}\left(\frac{\partial v}{\partial T}\right)_P + * \f] + * For ideal gases, it's equal to the inverse of the temperature. + */ + virtual doublereal thermalExpansionCoeff() const { + return 1.0/temperature(); + } + + //@} + + /** + * @name Chemical Potentials and Activities ------------------------------------------ + * + * + * The activity \f$a_k\f$ of a species in solution is + * related to the chemical potential by + * \f[ + * \mu_k(T,P,X_k) = \mu_k^0(T,P) + * + \hat R T \log a_k. + * \f] + * The quantity \f$\mu_k^0(T,P)\f$ is + * the standard state chemical potential at unit activity. + * It may depend on the pressure and the temperature. However, + * it may not depend on the mole fractions of the species + * in the solution. + * + * The activities are related to the generalized + * concentrations, \f$\tilde C_k\f$, and standard + * concentrations, \f$C^0_k\f$, by the following formula: + * + * \f[ + * a_k = \frac{\tilde C_k}{C^0_k} + * \f] + * The generalized concentrations are used in the kinetics classes + * to describe the rates of progress of reactions involving the + * species. Their formulation depends upons the specification + * of the rate constants for reaction, especially the units used + * in specifying the rate constants. The bridge between the + * thermodynamic equilibrium expressions that use a_k and the + * kinetics expressions which use the generalized concentrations + * is provided by the multiplicative factor of the + * standard concentrations. + * @{ + */ + + //! This method returns the array of generalized concentrations. + /*! + * For an ideal gas mixture, these are simply the actual concentrations. + * + * @param c Output array of generalized concentrations. The + * units depend upon the implementation of the + * reaction rate expressions within the phase. + */ + virtual void getActivityConcentrations(doublereal* c) const { + getConcentrations(c); + } + + //! Returns the standard concentration \f$ C^0_k \f$, which is used to normalize + //! the generalized concentration. + /*! + * This is defined as the concentration by which the generalized + * concentration is normalized to produce the activity. + * In many cases, this quantity will be the same for all species in a phase. + * Since the activity for an ideal gas mixture is + * simply the mole fraction, for an ideal gas \f$ C^0_k = P/\hat R T \f$. + * + * @param k Optional parameter indicating the species. The default + * is to assume this refers to species 0. + * @return + * Returns the standard Concentration in units of m3 kmol-1. + */ + virtual doublereal standardConcentration(int k=0) const; + + //! Returns the natural logarithm of the standard + //! concentration of the kth species + /*! + * @param k index of the species. (defaults to zero) + */ + virtual doublereal logStandardConc(int k=0) const; + + //! Get the array of non-dimensional activity coefficients at + //! the current solution temperature, pressure, and solution concentration. + /*! + * For ideal gases, the activity coefficients are all equal to one. + * + * @param ac Output vector of activity coefficients. Length: m_kk. + */ + virtual void getActivityCoefficients(doublereal* ac) const; - /** - * Molar heat capacity at constant pressure. Units: J/kmol/K. - * For an ideal gas mixture, - * \f[ - * \hat c_p(t) = \sum_k \hat c^0_{p,k}(T). - * \f] - * The reference-state pure-species heat capacities - * \f$ \hat c^0_{p,k}(T) \f$ are computed by the species thermodynamic - * property manager. - * @see SpeciesThermo - */ - virtual doublereal cp_mole() const { - return GasConstant * mean_X(&cp_R_ref()[0]); - } + //@} + /// @name Partial Molar Properties of the Solution ---------------------------------- + //@{ - /** - * Molar heat capacity at constant volume. Units: J/kmol/K. - * For an ideal gas mixture, - * \f[ \hat c_v = \hat c_p - \hat R. \f] - */ - virtual doublereal cv_mole() const { - return cp_mole() - GasConstant; - } - - //@} - - /** - * @name Mechanical Equation of State ------------------------------------------------ - * @{ - */ - - /** - * Pressure. Units: Pa. - * For an ideal gas mixture, - * \f[ P = n \hat R T. \f] - */ - virtual doublereal pressure() const { - return GasConstant * molarDensity() * temperature(); - } - - /** - * Set the pressure at constant temperature. Units: Pa. - * This method is implemented by setting the mass density to - * \f[ - * \rho = \frac{P \overline W}{\hat R T }. - * \f] - */ - virtual void setPressure(doublereal p) { - setDensity(p * meanMolecularWeight() - /(GasConstant * temperature())); - } - - virtual doublereal isothermalCompressibility() const { - return -1.0/pressure(); - } - - virtual doublereal thermalExpansionCoeff() const { - return 1.0/temperature(); - } - - //@} - /** - * @name Chemical Potentials and Activities ------------------------------------------ - * - * - * The activity \f$a_k\f$ of a species in solution is - * related to the chemical potential by - * \f[ - * \mu_k(T,P,X_k) = \mu_k^0(T,P) - * + \hat R T \log a_k. - * \f] - * The quantity \f$\mu_k^0(T,P)\f$ is - * the standard state chemical potential at unit activity. - * It may depend on the pressure and the temperature. However, - * it may not depend on the mole fractions of the species - * in the solution. - * - * The activities are related to the generalized - * concentrations, \f$\tilde C_k\f$, and standard - * concentrations, \f$C^0_k\f$, by the following formula: - * - * \f[ - * a_k = \frac{\tilde C_k}{C^0_k} - * \f] - * The generalized concentrations are used in the kinetics classes - * to describe the rates of progress of reactions involving the - * species. Their formulation depends upons the specification - * of the rate constants for reaction, especially the units used - * in specifying the rate constants. The bridge between the - * thermodynamic equilibrium expressions that use a_k and the - * kinetics expressions which use the generalized concentrations - * is provided by the multiplicative factor of the - * standard concentrations. - * @{ - */ - - /** - * This method returns the array of generalized - * concentrations. For an ideal gas mixture, these are simply - * the actual concentrations. - */ - virtual void getActivityConcentrations(doublereal* c) const { - getConcentrations(c); - } - - /** - * The standard concentration. This is defined as the concentration - * by which the generalized concentration is normalized to produce - * the activity. Since the activity for an ideal gas mixture is - * simply the mole fraction, the standard concentration is - * \f$ P / R T \f$. - */ - virtual doublereal standardConcentration(int k=0) const { - double p = pressure(); - return p/(GasConstant * temperature()); - } - - /** - * Returns the natural logarithm of the standard - * concentration of the kth species - */ - virtual doublereal logStandardConc(int k=0) const { - _updateThermo(); - double p = pressure(); - double lc = std::log (p / (GasConstant * temperature())); - return lc; - } - - /** - * Get the array of non-dimensional activity coefficients at - * the current solution temperature, pressure, and - * solution concentration. - * For ideal gases, the activity coefficients are all equal - * to one. - */ - virtual void getActivityCoefficients(doublereal* ac) const; - - /** - * Get the array of chemical potentials at unit activity \f$ - * \mu^0_k \f$ at the current temperature and pressure of the - * solution. - * These are the standard state chemical potentials. - */ - virtual void getStandardChemPotentials(doublereal* muStar) const; - - - //@} - /// @name Partial Molar Properties of the Solution ---------------------------------- - //@{ - - /** - * Get the species chemical potentials. Units: J/kmol. - * - * This function returns a vector of chemical potentials of the - * species in solution at the current temperature, pressure - * and mole fraction of the solution. - */ - virtual void getChemPotentials(doublereal* mu) const; + + //! Get the species chemical potentials. Units: J/kmol. + /*! + * This function returns a vector of chemical potentials of the + * species in solution at the current temperature, pressure + * and mole fraction of the solution. + * + * @param mu Output vector of species chemical + * potentials. Length: m_kk. Units: J/kmol + */ + virtual void getChemPotentials(doublereal* mu) const; - /** - * Get the array of partial molar enthalpies - * units = J / kmol - */ - virtual void getPartialMolarEnthalpies(doublereal* hbar) const; + //! Get the species partial molar enthalpies. Units: J/kmol. + /*! + * @param hbar Output vector of species partial molar enthalpies. + * Length: m_kk. units are J/kmol. + */ + virtual void getPartialMolarEnthalpies(doublereal* hbar) const; - /** - * Returns an array of partial molar entropies of the species in the - * solution. Units: J/kmol. - */ - virtual void getPartialMolarEntropies(doublereal* sbar) const; + //! Get the species partial molar entropies. Units: J/kmol/K. + /*! + * @param sbar Output vector of species partial molar entropies. + * Length = m_kk. units are J/kmol/K. + */ + virtual void getPartialMolarEntropies(doublereal* sbar) const; - /** - * Get the array of partial molar volumes - * units = m^3 / kmol - */ - virtual void getPartialMolarVolumes(doublereal* vbar) const; + //! Get the species partial molar enthalpies. Units: J/kmol. + /*! + * @param ubar Output vector of speciar partial molar internal energies. + * Length = m_kk. units are J/kmol. + */ + virtual void getPartialMolarIntEnergies(doublereal* ubar) const; - //@} - /// @name Properties of the Standard State of the Species in the Solution ---------- - //@{ + //! Get the partial molar heat capacities Units: J/kmol/K + /*! + * @param cpbar Output vector of species partial molar heat capacities at constant pressure. + * Length = m_kk. units are J/kmol/K. + */ + virtual void getPartialMolarCp(doublereal* cpbar) const; - /** - * Get the nondimensional Enthalpy functions for the species - * at their standard states at the current - * T and P of the solution. - */ - virtual void getEnthalpy_RT(doublereal* hrt) const; + //! Get the species partial molar volumes. Units: m^3/kmol. + /*! + * @param vbar Output vector of speciar partial molar volumes. + * Length = m_kk. units are m^3/kmol. + */ + virtual void getPartialMolarVolumes(doublereal* vbar) const; - /** - * Get the array of nondimensional Enthalpy functions for the - * standard state species - * at the current T and P of the solution. - */ - virtual void getEntropy_R(doublereal* sr) const; + //@} + /// @name Properties of the Standard State of the Species in the Solution ---------- + //@{ - /** - * Get the nondimensional gibbs function for the species - * standard states at the current T and P of the solution. - */ - virtual void getGibbs_RT(doublereal* grt) const; + //! Get the array of chemical potentials at unit activity for the + //! standard state species at the current T and P of the solution. + /*! + * These are the standard state chemical potentials \f$ \mu^0_k(T,P) + * \f$. The values are evaluated at the current + * temperature and pressure of the solution + * + * @param mu Output vector of chemical potentials. + * Length: m_kk. + */ + virtual void getStandardChemPotentials(doublereal* mu) const; - /** - * Get the Gibbs functions for the pure species - * at the current T and P of the solution. - */ - virtual void getPureGibbs(doublereal* gpure) const; + //! Get the nondimensional Enthalpy functions for the species + //! at their standard states at the current T and P of the solution. + /*! + * @param hrt Output vector of nondimensional standard state enthalpies. + * Length: m_kk. + */ + virtual void getEnthalpy_RT(doublereal* hrt) const; - /** - * Returns the vector of nondimensional - * internal Energies of the standard state at the current temperature - * and pressure of the solution for each species. - */ - virtual void getIntEnergy_RT(doublereal *urt) const; + //! Get the array of nondimensional Enthalpy functions for the + //! standard state species at the current T and P of the solution. + /*! + * @param sr Output vector of nondimensional standard state entropies. + * Length: m_kk. + */ + virtual void getEntropy_R(doublereal* sr) const; - /** - * Get the nondimensional heat capacity at constant pressure - * function for the species - * standard states at the current T and P of the solution. - */ - virtual void getCp_R(doublereal* cpr) const; + //! Get the nondimensional Gibbs functions for the species + //! in their standard states at the current T and P of the solution. + /*! + * @param grt Output vector of nondimensional standard state gibbs free energies + * Length: m_kk. + */ + virtual void getGibbs_RT(doublereal* grt) const; - //@} - /// @name Thermodynamic Values for the Species Reference States --------------------- - //@{ + //! Get the Gibbs functions for the standard + //! state of the species at the current T and P of the solution + /*! + * Units are Joules/kmol + * @param gpure Output vector of standard state gibbs free energies + * Length: m_kk. + */ + virtual void getPureGibbs(doublereal* gpure) const; - /** - * Returns the vector of nondimensional - * enthalpies of the reference state at the current temperature - * and reference presssure for the species - */ - virtual void getEnthalpy_RT_ref(doublereal *hrt) const; - /** - * Returns the vector of nondimensional - * enthalpies of the reference state at the current temperature - * and reference pressure for the species. - */ - virtual void getGibbs_RT_ref(doublereal *grt) const; + //! Returns the vector of nondimensional Internal Energies of the standard + //! state species at the current T and P of the solution + /*! + * @param urt output vector of nondimensional standard state internal energies + * of the species. Length: m_kk. + */ + virtual void getIntEnergy_RT(doublereal *urt) const; - /** - * Returns the vector of the - * gibbs function of the reference state at the current temperature - * and reference pressure for the species. - * units = J/kmol - */ - virtual void getGibbs_ref(doublereal *g) const; + //! Get the nondimensional Heat Capacities at constant + //! pressure for the species standard states + //! at the current T and P of the solution + /*! + * @param cpr Output vector of nondimensional standard state heat capacities + * Length: m_kk. + */ + virtual void getCp_R(doublereal* cpr) const; - /** - * Returns the vector of nondimensional - * entropies of the reference state at the current temperature - * and reference pressure for the species. - */ - virtual void getEntropy_R_ref(doublereal *er) const; + //! Get the molar volumes of the species standard states at the current + //! T and P of the solution. + /*! + * units = m^3 / kmol + * + * @param vol Output vector containing the standard state volumes. + * Length: m_kk. + */ + virtual void getStandardVolumes(doublereal *vol) const; - /** - * Returns the vector of nondimensional - * internal Energies of the reference state at the current temperature - * of the solution and the reference pressure for each species. - */ - virtual void getIntEnergy_RT_ref(doublereal *urt) const; - /** - * Returns the vector of nondimensional - * constant pressure heat capacities of the reference state - * at the current temperature and reference pressure - * for the species. - */ - virtual void getCp_R_ref(doublereal *cprt) const; + //@} + /// @name Thermodynamic Values for the Species Reference States --------------------- + //@{ - //@} - /// @name New Methods Defined Here ------------------------------------------------- - //@{ + //! Returns the vector of nondimensional + //! enthalpies of the reference state at the current temperature + //! of the solution and the reference pressure for the species. + /*! + * @param hrt Output vector containing the nondimensional reference state + * enthalpies. Length: m_kk. + */ + virtual void getEnthalpy_RT_ref(doublereal *hrt) const; - const array_fp& enthalpy_RT_ref() const { - _updateThermo(); - return m_h0_RT; - } + //! Returns the vector of nondimensional + //! Gibbs Free Energies of the reference state at the current temperature + //! of the solution and the reference pressure for the species. + /*! + * @param grt Output vector containing the nondimensional reference state + * Gibbs Free energies. Length: m_kk. + */ + virtual void getGibbs_RT_ref(doublereal *grt) const; - const array_fp& gibbs_RT_ref() const { - _updateThermo(); - return m_g0_RT; - } + //! Returns the vector of the + //! gibbs function of the reference state at the current temperature + //! of the solution and the reference pressure for the species. + /*! + * units = J/kmol + * + * @param g Output vector containing the reference state + * Gibbs Free energies. Length: m_kk. Units: J/kmol. + */ + virtual void getGibbs_ref(doublereal *g) const; - const array_fp& expGibbs_RT_ref() const { - _updateThermo(); - int k; - for (k = 0; k != m_kk; k++) m_expg0_RT[k] = std::exp(m_g0_RT[k]); - return m_expg0_RT; - } + //! Returns the vector of nondimensional + //! entropies of the reference state at the current temperature + //! of the solution and the reference pressure for each species. + /*! + * @param er Output vector containing the nondimensional reference state + * entropies. Length: m_kk. + */ + virtual void getEntropy_R_ref(doublereal *er) const; - const array_fp& entropy_R_ref() const { - _updateThermo(); - return m_s0_R; - } - - const array_fp& cp_R_ref() const { - _updateThermo(); - return m_cp0_R; - } - - // @} - - virtual void initThermo(); + //! Returns the vector of nondimensional + //! internal Energies of the reference state at the current temperature + //! of the solution and the reference pressure for each species. + /*! + * @param urt Output vector of nondimensional reference state + * internal energies of the species. + * Length: m_kk + */ + virtual void getIntEnergy_RT_ref(doublereal *urt) const; + + //! Returns the vector of nondimensional + //! constant pressure heat capacities of the reference state + //! at the current temperature of the solution + //! and reference pressure for each species. + /*! + * @param cprt Output vector of nondimensional reference state + * heat capacities at constant pressure for the species. + * Length: m_kk + */ + virtual void getCp_R_ref(doublereal *cprt) const; - /** - * @internal - * @name Chemical Equilibrium - * @{ - * - * Set mixture to an equilibrium state consistent with specified - * element potentials and temperature. - * - * @param lambda_RT vector of non-dimensional element potentials - * \f[ \lambda_m/RT \f]. - * @param t temperature in K. - * @param work. Temporary work space. Must be dimensioned at least - * as large as the number of species. - * - */ - virtual void setToEquilState(const doublereal* lambda_RT); + //@} + /// @name New Methods Defined Here ------------------------------------------------- + //@{ - // @} + const array_fp& enthalpy_RT_ref() const { + _updateThermo(); + return m_h0_RT; + } + const array_fp& gibbs_RT_ref() const { + _updateThermo(); + return m_g0_RT; + } - protected: + const array_fp& expGibbs_RT_ref() const { + _updateThermo(); + int k; + for (k = 0; k != m_kk; k++) m_expg0_RT[k] = std::exp(m_g0_RT[k]); + return m_expg0_RT; + } - int m_kk, m_mm; - doublereal m_tmin, m_tmax, m_p0; + const array_fp& entropy_R_ref() const { + _updateThermo(); + return m_s0_R; + } - mutable doublereal m_tlast, m_logc0; - mutable array_fp m_h0_RT; - mutable array_fp m_cp0_R; - mutable array_fp m_g0_RT; - mutable array_fp m_s0_R; - mutable array_fp m_expg0_RT; - mutable array_fp m_pe; - mutable array_fp m_pp; + const array_fp& cp_R_ref() const { + _updateThermo(); + return m_cp0_R; + } - private: + // @} - void _updateThermo() const; - }; + virtual void initThermo(); + + //!This method is used by the ChemEquil equilibrium solver. + /*! + * @internal + * @name Chemical Equilibrium + * @{ + * + * Set mixture to an equilibrium state consistent with specified + * element potentials and temperature. + * It sets the state such that the chemical potentials satisfy + * \f[ \frac{\mu_k}{\hat R T} = \sum_m A_{k,m} + * \left(\frac{\lambda_m} {\hat R T}\right) \f] where + * \f$ \lambda_m \f$ is the element potential of element m. The + * temperature is unchanged. Any phase (ideal or not) that + * implements this method can be equilibrated by ChemEquil. + * + * @param lambda_RT vector of non-dimensional element potentials + * \f[ \lambda_m/RT \f]. + */ + virtual void setToEquilState(const doublereal* lambda_RT); + + //@} + + protected: + + //! Number of Elements in the phase + /*! + * This member is defined here, from a call to the Elements ojbect, for speed. + */ + int m_mm; + + //! Minimum temperature for valid species standard state thermo props + /*! + * This is the minimum temperature at which all species have valid standard + * state thermo props defined. + */ + doublereal m_tmin; + + //! Maximum temperature for valid species standard state thermo props + /*! + * This is the maximum temperature at which all species have valid standard + * state thermo props defined. + */ + doublereal m_tmax; + + //! Reference state pressure + /*! + * Value of the reference state pressure in Pascals. + * All species must have the same reference state pressure. + */ + doublereal m_p0; + + //! last value of the temperature processed by reference state + mutable doublereal m_tlast; + + //! Temporary storage for log of p/rt + mutable doublereal m_logc0; + + //! Temporary storage for dimensionless reference state enthalpies + mutable array_fp m_h0_RT; + + //! Temporary storage for dimensionless reference state heat capacities + mutable array_fp m_cp0_R; + + //! Temporary storage for dimensionless reference state gibbs energies + mutable array_fp m_g0_RT; + + //! Temporary storage for dimensionless reference state entropies + mutable array_fp m_s0_R; + + //! currently unsed + /*! + * @deprecated + */ + mutable array_fp m_expg0_RT; + + //! Currently unused + /* + * @deprecated + */ + mutable array_fp m_pe; + + //! Temporary array containing internally calculated partial pressures + mutable array_fp m_pp; + + private: + + void _updateThermo() const; + }; } #endif - - - - - diff --git a/Cantera/src/ShomateThermo.h b/Cantera/src/ShomateThermo.h index 811799edd..98d8603ea 100755 --- a/Cantera/src/ShomateThermo.h +++ b/Cantera/src/ShomateThermo.h @@ -19,12 +19,11 @@ namespace Cantera { + //! A species thermodynamic property manager for the Shomate polynomial parameterization. /*! - * A species thermodynamic property manager for the Shomate - * polynomial parameterization. This is the parameterization used - * in the NIST Chemistry WebBook (http://webbook.nist.gov/chemistry) - * - * This parameterization assumes there are two temperature regions + * This is the parameterization used + * in the NIST Chemistry WebBook (http://webbook.nist.gov/chemistry) + * The parameterization assumes there are two temperature regions * each with its own Shomate polynomial representation, for each * species in the phase. * diff --git a/Cantera/src/SpeciesThermo.h b/Cantera/src/SpeciesThermo.h index d3db2fd3f..e95cc5012 100755 --- a/Cantera/src/SpeciesThermo.h +++ b/Cantera/src/SpeciesThermo.h @@ -127,17 +127,16 @@ namespace Cantera { //////////////////////// class SpeciesThermo //////////////////// + + //! Pure Virtual base class for the species thermo manager classes. /*! - * Pure Virtual base class for the species thermo manager classes. This - * class defines the interface which all subclasses must - * implement. + * This class defines the interface which all subclasses must implement. * - * Class SpeciesThermo is the base class + * Class %SpeciesThermo is the base class * for a family of classes that compute properties of a set of * species in their reference state at a range of temperatures. * Note, the pressure dependence of the reference state is not * handled by this particular species standard state model. - * */ class SpeciesThermo { diff --git a/Cantera/src/SpeciesThermoInterpType.h b/Cantera/src/SpeciesThermoInterpType.h index f8104dc02..f515db63a 100644 --- a/Cantera/src/SpeciesThermoInterpType.h +++ b/Cantera/src/SpeciesThermoInterpType.h @@ -15,9 +15,10 @@ namespace Cantera { - /** - * Virtual Base class for individual species reference state - * themodynamic managers. This differs from the SpeciesThermo virtual + //! Pure Virtual Base class for individual species reference state + //! themodynamic managers. + /*! + * This differs from the SpeciesThermo virtual * base class in the sense that this class is meant to handle only * one species. The speciesThermo class is meant to handle the * calculation of all the species (or a large subset) in a phase. diff --git a/Cantera/src/SpeciesThermoMgr.h b/Cantera/src/SpeciesThermoMgr.h index b653237c3..da093c71e 100755 --- a/Cantera/src/SpeciesThermoMgr.h +++ b/Cantera/src/SpeciesThermoMgr.h @@ -96,8 +96,8 @@ namespace Cantera { /////////////////////// Exceptions ////////////////////////////// + //! Exception thrown if species reference pressures don't match. /*! - * Exception thrown if species reference pressures don't match. * @ingroup spthermo */ class RefPressureMismatch : public CanteraError { @@ -117,8 +117,8 @@ namespace Cantera { virtual ~RefPressureMismatch() {} }; + //! Unknown species thermo manager string error /*! - * Unknown species thermo manager string error * @ingroup spthermo */ class UnknownSpeciesThermo : public CanteraError { diff --git a/Cantera/src/ThermoPhase.h b/Cantera/src/ThermoPhase.h index 3692d10d7..c611d5fdd 100755 --- a/Cantera/src/ThermoPhase.h +++ b/Cantera/src/ThermoPhase.h @@ -34,19 +34,37 @@ namespace Cantera { class XML_Node; - /** - * @defgroup thermoprops Thermodynamic Properties - * - * These classes are used to compute thermodynamic properties of - * phases of matter. - * - * @see newPhase(std::string file, std::string id) Description for how to read ThermoPhases from XML files. - * @see newPhase(XML_Node &phase) How to call the Factory routine to create and initialize ThermoPhase objects. - */ + /** + * @defgroup thermoprops Thermodynamic Properties + * + * These classes are used to compute the thermodynamic properties of + * phases of matter. The main base class for describing thermodynamic + * properties of phases within %Cantera is called ThermoPhase. %ThermoPhase + * is a large class that describes the interface within Cantera to Thermodynamic + * functions for a phase. + * + * Mechanical properties + * + * Standard state properties + * + * Instantiation of ThermoPhase properties occurs via the following path. + * + * The following Objects inherit from ThermoPhase. These are known to the + * internal factory methods + * + * + * The following additional objects inherit from ThermoPhase. Most of these + * are associated with an electrochemistry capability that is under construction. + * + * + * + * @see newPhase(std::string file, std::string id) Description for how to read ThermoPhases from XML files. + * @see newPhase(XML_Node &phase) How to call the Factory routine to create and initialize ThermoPhase objects. + */ /** * A phase with thermodynamic properties. - * Class ThermoPhase is the base class for the family of classes + * Class %ThermoPhase is the base class for the family of classes * that represent phases of matter of any type. It defines a * common public interface, and implements a few methods. Most of * the methods, however, are declared virtual and are meant to be @@ -55,7 +73,7 @@ namespace Cantera { * through pointers of type ThermoPhase* that point to objects of * subclasses of ThermoPhase. * - * Class ThermoPhase + * Class %ThermoPhase * extends class Phase by adding methods to compute thermodynamic * properties in addition to the ones (temperature, density, * composition) that class Phase provides. The distinction is that @@ -64,7 +82,7 @@ namespace Cantera { * those of class Phase do not, since they only involve data values * stored within the object. * - * Instances of subclasses of ThermoPhase should be created using + * Instances of subclasses of %ThermoPhase should be created using * the factory class ThermoFactory, not by calling the constructor * directly. This allows new classes to be used with the various * Cantera language interfaces. @@ -74,6 +92,7 @@ namespace Cantera { * ThermoPhase. Methods that are not needed can be left * unimplimented, which will cause an exception to be thrown if it * is called. + * * @ingroup thermoprops * @ingroup phases */ @@ -93,13 +112,13 @@ namespace Cantera { delete m_spthermo; } - /** - * Copy Constructor for the thermophase object. - * - * Currently, this is not fully implemented. If called it will - * throw an exception. - */ - ThermoPhase(const ThermoPhase &); + /** + * Copy Constructor for the %ThermoPhase object. + * + * Currently, this is not fully implemented. If called it will + * throw an exception. + */ + ThermoPhase(const ThermoPhase &); //! Assignment operator @@ -194,10 +213,10 @@ namespace Cantera { return err("intEnergy_mole"); } - /// Molar entropy. Units: J/kmol/K. - virtual doublereal entropy_mole() const { - return err("entropy_mole"); - } + /// Molar entropy. Units: J/kmol/K. + virtual doublereal entropy_mole() const { + return err("entropy_mole"); + } /// Molar Gibbs function. Units: J/kmol. virtual doublereal gibbs_mole() const { @@ -234,7 +253,8 @@ namespace Cantera { } - //! Set the internally storred pressure (Pa) + //! Set the internally storred pressure (Pa) at constant + //! temperature and composition /*! * This method must be reimplemented in derived classes, where it * may involve the solution of a nonlinear equation. Within %Cantera, @@ -250,22 +270,20 @@ namespace Cantera { err("setPressure"); } - /** - * The isothermal compressibility. Units: 1/Pa. + //! Returns the isothermal compressibility. Units: 1/Pa. + /*! * The isothermal compressibility is defined as * \f[ * \kappa_T = -\frac{1}{v}\left(\frac{\partial v}{\partial P}\right)_T * \f] - * This method may optionally be defined in derived classes. */ virtual doublereal isothermalCompressibility() const { err("isothermalCompressibility"); return -1.0; } - - /** - * The volumetric thermal expansion coefficient. Units: 1/K. + + //! Return the volumetric thermal expansion coefficient. Units: 1/K. + /*! * The thermal expansion coefficient is defined as - * * \f[ * \beta = \frac{1}{v}\left(\frac{\partial v}{\partial T}\right)_P * \f] @@ -344,51 +362,51 @@ namespace Cantera { */ virtual int activityConvention() const; - /** - * 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$ 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. Note that they may - * or may not have units of concentration --- they might be - * partial pressures, mole fractions, or surface coverages, - * for example. - * - * @param c Output array of generalized concentrations. The - * units depend upon the implementation of the - * reaction rate expressions within the phase. - */ - virtual void getActivityConcentrations(doublereal* c) const { - err("getActivityConcentrations"); - } - - - /** - * The standard concentration \f$ C^0_k \f$ used to normalize - * the generalized concentration. In many cases, this quantity - * will be the same for all species in a phase - for example, - * for an ideal gas \f$ C^0_k = P/\hat R T \f$. For this - * reason, this method returns a single value, instead of an - * array. However, for phases in which the standard - * concentration is species-specific (e.g. surface species of - * different sizes), this method may be called with an - * optional parameter indicating the species. - * - * @param k Optional parameter indicating the species. The default - * is to assume this refers to species 0. - * @return - * Returns the standard Concentration in units of m3 kmol-1. - */ - virtual doublereal standardConcentration(int k=0) const { - err("standardConcentration"); - return -1.0; - } + + //! 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$ 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. Note that they may + * or may not have units of concentration --- they might be + * partial pressures, mole fractions, or surface coverages, + * for example. + * + * @param c Output array of generalized concentrations. The + * units depend upon the implementation of the + * reaction rate expressions within the phase. + */ + virtual void getActivityConcentrations(doublereal* c) const { + err("getActivityConcentrations"); + } + /** + * The standard concentration \f$ C^0_k \f$ used to normalize + * the generalized concentration. In many cases, this quantity + * will be the same for all species in a phase - for example, + * for an ideal gas \f$ C^0_k = P/\hat R T \f$. For this + * reason, this method returns a single value, instead of an + * array. However, for phases in which the standard + * concentration is species-specific (e.g. surface species of + * different sizes), this method may be called with an + * optional parameter indicating the species. + * + * @param k Optional parameter indicating the species. The default + * is to assume this refers to species 0. + * @return + * Returns the standard Concentration in units of m3 kmol-1. + */ + virtual doublereal standardConcentration(int k=0) const { + err("standardConcentration"); + return -1.0; + } + //! Natural logarithm of the standard concentration of the kth species. /*! - * @param k index of the species + * @param k index of the species (defaults to zero) */ virtual doublereal logStandardConc(int k=0) const { err("logStandardConc"); @@ -472,10 +490,12 @@ namespace Cantera { err("getChemPotentials_RT"); } - /** - * Get the species chemical potentials in the solution - * These are partial molar Gibbs free energies. - * Units: J/kmol. + + //! Get the species chemical potentials. Units: J/kmol. + /*! + * This function returns a vector of chemical potentials of the + * species in solution at the current temperature, pressure + * and mole fraction of the solution. * * @param mu Output vector of species chemical * potentials. Length: m_kk. Units: J/kmol @@ -518,7 +538,7 @@ namespace Cantera { err("getPartialMolarEntropies"); } - //! Get the species partial molar enthalpies. Units: J/kmol. + //! Get the species partial molar internal energies. Units: J/kmol. /*! * @param ubar Output vector of speciar partial molar internal energies. * Length = m_kk. units are J/kmol. @@ -529,7 +549,8 @@ namespace Cantera { //! Get the partial molar heat capacities Units: J/kmol/K /*! - * @param cpbar Output vector of species partial molar heat capacities at constant pressure. + * @param cpbar Output vector of species partial molar heat + * capacities at constant pressure. * Length = m_kk. units are J/kmol/K. */ virtual void getPartialMolarCp(doublereal* cpbar) const { @@ -545,12 +566,12 @@ namespace Cantera { err("getPartialMolarVolumes"); } - //@} - /// @name Properties of the Standard State of the Species in the Solution - //@{ - + //@} + /// @name Properties of the Standard State of the Species in the Solution + //@{ - //! Get the array of chemical potentials at unit activity. + //! Get the array of chemical potentials at unit activity for the species + //! at their standard states at the current T and P of the solution. /*! * These are the standard state chemical potentials \f$ \mu^0_k(T,P) * \f$. The values are evaluated at the current @@ -562,11 +583,9 @@ namespace Cantera { virtual void getStandardChemPotentials(doublereal* mu) const { err("getStandardChemPotentials"); } - - + //! Get the nondimensional Enthalpy functions for the species - //! at their standard states at the current - //! T and P of the solution. + //! at their standard states at the current T and P of the solution. /*! * @param hrt Output vector of nondimensional standard state enthalpies. * Length: m_kk. @@ -575,11 +594,9 @@ namespace Cantera { err("getEnthalpy_RT"); } + //! Get the array of nondimensional Enthalpy functions for the + //! standard state species at the current T and P of the solution. /*! - * Get the array of nondimensional Enthalpy functions for the - * standard state species - * at the current T and P of the solution. - * * @param sr Output vector of nondimensional standard state entropies. * Length: m_kk. */ @@ -587,11 +604,9 @@ namespace Cantera { err("getEntropy_R"); } + //! Get the nondimensional Gibbs functions for the species + //! in their standard states at the current T and P of the solution. /*! - * Get the nondimensional Gibbs functions for the species - * at their standard states of solution at the current T and P - * of the solution. - * * @param grt Output vector of nondimensional standard state gibbs free energies * Length: m_kk. */ @@ -599,22 +614,20 @@ namespace Cantera { err("getGibbs_RT"); } - /** - * Get the nondimensional Gibbs functions for the standard - * state of the species at the current T and P. - * - * @param gpure Output vector of standard state gibbs free energies - * Length: m_kk. + //! Get the Gibbs functions for the standard + //! state of the species at the current T and P of the solution + /*! + * Units are Joules/kmol + * @param gpure Output vector of standard state gibbs free energies + * Length: m_kk. */ virtual void getPureGibbs(doublereal* gpure) const { err("getPureGibbs"); } + //! Returns the vector of nondimensional Internal Energies of the standard + //! state species at the current T and P of the solution /*! - * Returns the vector of nondimensional - * Internal Energies of the standard state at the current temperature - * and pressure of the solution for each species. - * * @param urt output vector of nondimensional standard state internal energies * of the species. Length: m_kk. */ @@ -622,19 +635,18 @@ namespace Cantera { err("getIntEnergy_RT"); } - /** - * Get the nondimensional Heat Capacities at constant - * pressure for the standard state of the species - * at the current T and P. - * + //! Get the nondimensional Heat Capacities at constant + //! pressure for the species standard states + //! at the current T and P of the solution + /*! * @param cpr Output vector of nondimensional standard state heat capacities - * Length: m_kk. + * Length: m_kk. */ virtual void getCp_R(doublereal* cpr) const { err("getCp_R"); } - //! Get the molar volumes of each species in their standard states at the current + //! Get the molar volumes of the species standard states at the current //! T and P of the solution. /*! * units = m^3 / kmol @@ -650,26 +662,26 @@ namespace Cantera { /// @name Thermodynamic Values for the Species Reference States //@{ + + //! Returns the vector of nondimensional + //! enthalpies of the reference state at the current temperature + //! of the solution and the reference pressure for the species. /*! - * Returns the vector of nondimensional - * enthalpies of the reference state at the current temperature - * of the solution and the reference pressure for the species. - * * This base function will throw a CanteraException unless * it is overwritten in a derived class. * - * @param hrt Output vector containing the nondimensional reference state enthalpies + * @param hrt Output vector containing the nondimensional reference state + * enthalpies * Length: m_kk. */ virtual void getEnthalpy_RT_ref(doublereal *hrt) const { err("getEnthalpy_RT_ref"); } + //! Returns the vector of nondimensional + //! Gibbs Free Energies of the reference state at the current temperature + //! of the solution and the reference pressure for the species. /*! - * Returns the vector of nondimensional - * enthalpies of the reference state at the current temperature - * of the solution and the reference pressure for the species. - * * @param grt Output vector containing the nondimensional reference state * Gibbs Free energies. Length: m_kk. */ @@ -677,10 +689,10 @@ namespace Cantera { err("getGibbs_RT_ref"); } + //! Returns the vector of the + //! gibbs function of the reference state at the current temperature + //! of the solution and the reference pressure for the species. /*! - * Returns the vector of the - * gibbs function of the reference state at the current temperature - * of the solution and the reference pressure for the species. * units = J/kmol * * @param g Output vector containing the reference state @@ -690,11 +702,10 @@ namespace Cantera { err("getGibbs_ref"); } + //! Returns the vector of nondimensional + //! entropies of the reference state at the current temperature + //! of the solution and the reference pressure for each species. /*! - * Returns the vector of nondimensional - * entropies of the reference state at the current temperature - * of the solution and the reference pressure for each species. - * * @param er Output vector containing the nondimensional reference state * entropies. Length: m_kk. */ @@ -702,11 +713,10 @@ namespace Cantera { err("getEntropy_R_ref"); } + //! Returns the vector of nondimensional + //! internal Energies of the reference state at the current temperature + //! of the solution and the reference pressure for each species. /*! - * Returns the vector of nondimensional - * internal Energies of the reference state at the current temperature - * of the solution and the reference pressure for each species. - * * @param urt Output vector of nondimensional reference state * internal energies of the species. * Length: m_kk @@ -714,13 +724,12 @@ namespace Cantera { virtual void getIntEnergy_RT_ref(doublereal *urt) const { err("getIntEnergy_RT_ref"); } - + + //! Returns the vector of nondimensional + //! constant pressure heat capacities of the reference state + //! at the current temperature of the solution + //! and reference pressure for each species. /*! - * Returns the vector of nondimensional - * constant pressure heat capacities of the reference state - * at the current temperature of the solution - * and reference pressure for each species. - * * @param cprt Output vector of nondimensional reference state * heat capacities at constant pressure for the species. * Length: m_kk @@ -730,18 +739,18 @@ namespace Cantera { } - /////////////////////////////////////////////////////// - // - // The methods below are not virtual, and should not - // be overloaded. - // - ////////////////////////////////////////////////////// - - /** - * @} - * @name Specific Properties - * @{ - */ + /////////////////////////////////////////////////////// + // + // The methods below are not virtual, and should not + // be overloaded. + // + ////////////////////////////////////////////////////// + + /** + * @} + * @name Specific Properties + * @{ + */ /** * Specific enthalpy. Units: J/kg. diff --git a/Cantera/src/global.h b/Cantera/src/global.h index 0fc7464af..e9c6ced82 100755 --- a/Cantera/src/global.h +++ b/Cantera/src/global.h @@ -318,6 +318,7 @@ namespace Cantera { /// Return a pointer to the XML tree for a Cantera input file. /*! * @param file String containing the relative or absolute file name + * @param debug Debug flag */ XML_Node* get_XML_File(std::string file, int debug = 0); diff --git a/test_problems/Makefile.in b/test_problems/Makefile.in index 400127940..dc8c242e6 100644 --- a/test_problems/Makefile.in +++ b/test_problems/Makefile.in @@ -65,6 +65,7 @@ clean: cd ChemEquil_gri_matrix; @MAKE@ clean cd ChemEquil_gri_pairs; @MAKE@ clean cd ChemEquil_ionizedGas; @MAKE@ clean + cd ChemEquil_red1; @MAKE@ clean cd ck2cti_test; @MAKE@ clean cd min_python; @MAKE@ clean cd python; @MAKE@ clean diff --git a/test_problems/python/Makefile.in b/test_problems/python/Makefile.in index 44f4d2b5a..b76d11d07 100644 --- a/test_problems/python/Makefile.in +++ b/test_problems/python/Makefile.in @@ -8,3 +8,5 @@ test: clean: ../../bin/rm_cvsignore +depends: + diff --git a/tools/doc/Cantera.cfg.in b/tools/doc/Cantera.cfg.in index 21fb76914..59a77a715 100755 --- a/tools/doc/Cantera.cfg.in +++ b/tools/doc/Cantera.cfg.in @@ -101,6 +101,7 @@ FILE_PATTERNS = Kinetics.h Kinetics.cpp \ Elements.h Elements.cpp \ importCTML.cpp importCTML.h \ ThermoFactory.h ThermoFactory.cpp \ + IdealGasPhase.h IdealGasPhase.cpp \ SpeciesThermoFactory.h SpeciesThermoFactory.cpp \ speciesThermoTypes.h SpeciesThermoMgr.h SpeciesThermo.h SpeciesThermoInterpTypes.h \ NasaThermo.h NasaPoly1.h NasaPoly2.h \