From b20c4174c037f3af219880690c45c7ed22da81b6 Mon Sep 17 00:00:00 2001 From: Harry Moffat Date: Sat, 3 Jan 2009 03:59:38 +0000 Subject: [PATCH] Fixed a big error in the calculation of Cp for the PDSS_HKFT standard state. Added reportParams() for the PDSS object and its children. --- Cantera/src/thermo/HMWSoln.cpp | 1 - Cantera/src/thermo/HMWSoln.h | 2 - Cantera/src/thermo/PDSS.cpp | 21 +++++++++- Cantera/src/thermo/PDSS.h | 24 ++++++++++- Cantera/src/thermo/PDSS_ConstVol.cpp | 3 -- Cantera/src/thermo/PDSS_HKFT.cpp | 62 ++++++++++++++++++++++++---- Cantera/src/thermo/PDSS_HKFT.h | 33 +++++++++++++++ Cantera/src/thermo/PDSS_Water.h | 6 --- 8 files changed, 130 insertions(+), 22 deletions(-) diff --git a/Cantera/src/thermo/HMWSoln.cpp b/Cantera/src/thermo/HMWSoln.cpp index 61f742461..09d399d53 100644 --- a/Cantera/src/thermo/HMWSoln.cpp +++ b/Cantera/src/thermo/HMWSoln.cpp @@ -895,7 +895,6 @@ namespace Cantera { } } - /* * Get the array of non-dimensional activities at * the current solution temperature, pressure, and diff --git a/Cantera/src/thermo/HMWSoln.h b/Cantera/src/thermo/HMWSoln.h index 4252fbcd9..71fd47399 100644 --- a/Cantera/src/thermo/HMWSoln.h +++ b/Cantera/src/thermo/HMWSoln.h @@ -2055,7 +2055,6 @@ namespace Cantera { */ virtual double A_Debye_TP(double temperature = -1.0, double pressure = -1.0) const; - //! Value of the derivative of the Debye Huckel constant with //! respect to temperature as a function of temperature @@ -2113,7 +2112,6 @@ namespace Cantera { double ADebye_L(double temperature = -1.0, double pressure = -1.0) const; - /** * Return Pitzer's definition of A_J. This is basically the * temperature derivative of A_L, and the second derivative diff --git a/Cantera/src/thermo/PDSS.cpp b/Cantera/src/thermo/PDSS.cpp index 93ddbb618..1d464d586 100644 --- a/Cantera/src/thermo/PDSS.cpp +++ b/Cantera/src/thermo/PDSS.cpp @@ -184,7 +184,14 @@ namespace Cantera { PDSS *ip = new PDSS(*this); return ip; } - + + // Returns the type of the standard state parameterization + /* + * @return Returns the integer # of the parameterization + */ + PDSS_enumType PDSS::reportPDSSType() const { + return m_pdssType; + } void PDSS::initThermoXML(const XML_Node& phaseNode, std::string& id) { AssertThrow(m_tp != 0, "PDSS::initThermoXML()"); @@ -476,4 +483,16 @@ namespace Cantera { throw CanteraError("PDSS::" + msg, "unimplemented"); } + + void PDSS::reportParams(int &kindex, int &type, + doublereal * const c, + doublereal &minTemp, + doublereal &maxTemp, + doublereal &refPressure) const { + kindex = m_spindex; + type = m_pdssType; + minTemp = m_minTemp; + maxTemp = m_maxTemp; + refPressure = m_p0; + } } diff --git a/Cantera/src/thermo/PDSS.h b/Cantera/src/thermo/PDSS.h index bb368766d..7a183148a 100644 --- a/Cantera/src/thermo/PDSS.h +++ b/Cantera/src/thermo/PDSS.h @@ -260,7 +260,7 @@ namespace Cantera { /*! * @return Returns the integer # of the parameterization */ - virtual PDSS_enumType reportPDSSType() const { return cPDSS_UNDEF; } + PDSS_enumType reportPDSSType() const; private: @@ -594,6 +594,28 @@ namespace Cantera { */ virtual void initThermoXML(const XML_Node& phaseNode, std::string& id); + + //! This utility function reports back the type of + //! parameterization and all of the parameters for the + //! species, index. + /*! + * + * @param index Species index + * @param type Integer type of the standard type + * @param c Vector of coefficients used to set the + * parameters for the standard state. + * @param minTemp output - Minimum temperature + * @param maxTemp output - Maximum temperature + * @param refPressure output - reference pressure (Pa). + * + */ + virtual void reportParams(int &kindex, int &type, + doublereal * const c, + doublereal &minTemp, + doublereal &maxTemp, + doublereal &refPressure) const; + + private: //! Initialize all of the internal shallow pointers that can be initialized /*! diff --git a/Cantera/src/thermo/PDSS_ConstVol.cpp b/Cantera/src/thermo/PDSS_ConstVol.cpp index c5a9acc7c..d568da921 100644 --- a/Cantera/src/thermo/PDSS_ConstVol.cpp +++ b/Cantera/src/thermo/PDSS_ConstVol.cpp @@ -48,7 +48,6 @@ namespace Cantera { PDSS(tp, spindex) { m_pdssType = cPDSS_CONSTVOL; - constructPDSSXML(tp, spindex, speciesNode, phaseRoot, spInstalled) ; } @@ -69,9 +68,7 @@ namespace Cantera { PDSS_ConstVol& PDSS_ConstVol::operator=(const PDSS_ConstVol&b) { if (&b == this) return *this; PDSS::operator=(b); - m_constMolarVolume = b.m_constMolarVolume; - return *this; } diff --git a/Cantera/src/thermo/PDSS_HKFT.cpp b/Cantera/src/thermo/PDSS_HKFT.cpp index 28ecd9399..df6c9165f 100644 --- a/Cantera/src/thermo/PDSS_HKFT.cpp +++ b/Cantera/src/thermo/PDSS_HKFT.cpp @@ -285,16 +285,22 @@ namespace Cantera { doublereal r_e_j = r_e_j_pr_tr + fabs(m_charge_j) * gval; doublereal dr_e_jdT = fabs(m_charge_j) * dgvaldT; + doublereal d2r_e_jdT2 = fabs(m_charge_j) * d2gvaldT2; - omega_j = nu * (m_charge_j * m_charge_j / r_e_j - m_charge_j / (3.082 + gval) ); + doublereal r_e_j2 = r_e_j * r_e_j; - domega_jdT = - 2.0 * nu * (m_charge_j * m_charge_j * m_charge_j * m_charge_j / (r_e_j * r_e_j* r_e_j) - - m_charge_j / (3.082 + gval) / (3.082 + gval) / (3.082 + gval)) * dgvaldT * dgvaldT - - nu * (m_charge_j * m_charge_j * fabs(m_charge_j) / (r_e_j * r_e_j) - - m_charge_j / (3.082 + gval) / (3.082 + gval)) * d2gvaldT2; - - d2omega_jdT2 = nu * (m_charge_j * m_charge_j / (r_e_j * r_e_j) * dr_e_jdT) - + nu * m_charge_j / (3.082 + gval) / (3.082 + gval) * dgvaldT; + doublereal charge2 = m_charge_j * m_charge_j; + + doublereal r_e_H = 3.082 + gval; + doublereal r_e_H2 = r_e_H * r_e_H; + + omega_j = nu * (charge2 / r_e_j - m_charge_j / r_e_H); + + domega_jdT = nu * (-(charge2 / r_e_j2 * dr_e_jdT) + +(m_charge_j / r_e_H2 * dgvaldT )); + + d2omega_jdT2 = nu * ( 2.0*charge2*dr_e_jdT/(r_e_j2*r_e_j) - charge2*d2r_e_jdT2/r_e_j2 + -2.0 *dgvaldT /(r_e_H2*r_e_H) + charge2*d2gvaldT2 /r_e_H2); } doublereal relepsilon = m_waterProps->relEpsilon(m_temp, m_pres, 0); @@ -1092,6 +1098,46 @@ namespace Cantera { //! Store the result into an internal variable. m_Mu0_tr_pr = dg + totalSum; } + + // This utility function reports back the type of + // parameterization and all of the parameters for the + // species, index. + /* + * + * @param index Species index + * @param type Integer type of the standard type + * @param c Vector of coefficients used to set the + * parameters for the standard state. + * @param minTemp output - Minimum temperature + * @param maxTemp output - Maximum temperature + * @param refPressure output - reference pressure (Pa). + * + */ + void PDSS_HKFT::reportParams(int &kindex, int &type, + doublereal * const c, + doublereal &minTemp, + doublereal &maxTemp, + doublereal &refPressure) const { + + // Fill in the first part + PDSS::reportParams(kindex, type, c, minTemp, maxTemp, + refPressure); + + + c[0] = m_deltaG_formation_tr_pr; + c[1] = m_deltaH_formation_tr_pr; + c[2] = m_Mu0_tr_pr; + c[3] = m_Entrop_tr_pr; + c[4] = m_a1; + c[5] = m_a2; + c[6] = m_a3; + c[7] = m_a4; + c[8] = m_c1; + c[9] = m_c2; + c[10] = m_omega_pr_tr; + + } + } diff --git a/Cantera/src/thermo/PDSS_HKFT.h b/Cantera/src/thermo/PDSS_HKFT.h index 33c4a8ed9..b54fb244d 100644 --- a/Cantera/src/thermo/PDSS_HKFT.h +++ b/Cantera/src/thermo/PDSS_HKFT.h @@ -432,6 +432,39 @@ namespace Cantera { virtual void initAllPtrs(VPStandardStateTP *vptp_ptr, VPSSMgr *vpssmgr_ptr, SpeciesThermo* spthermo_ptr); + //! This utility function reports back the type of + //! parameterization and all of the parameters for the + //! species, index. + /*! + * + * The following parameters are reported + * + * - c[0] = m_deltaG_formation_tr_pr; + * - c[1] = m_deltaH_formation_tr_pr; + * - c[2] = m_Mu0_tr_pr; + * - c[3] = m_Entrop_tr_pr; + * - c[4] = m_a1; + * - c[5] = m_a2; + * - c[6] = m_a3; + * - c[7] = m_a4; + * - c[8] = m_c1; + * - c[9] = m_c2; + * - c[10] = m_omega_pr_tr; + * . + * + * @param index Species index + * @param type Integer type of the standard type + * @param c Vector of coefficients used to set the + * parameters for the standard state. + * @param minTemp output - Minimum temperature + * @param maxTemp output - Maximum temperature + * @param refPressure output - reference pressure (Pa). + * + */ + virtual void reportParams(int &kindex, int &type, doublereal * const c, + doublereal &minTemp, doublereal &maxTemp, + doublereal &refPressure) const; + //@} diff --git a/Cantera/src/thermo/PDSS_Water.h b/Cantera/src/thermo/PDSS_Water.h index 22cb21b3c..b783e7ebb 100644 --- a/Cantera/src/thermo/PDSS_Water.h +++ b/Cantera/src/thermo/PDSS_Water.h @@ -140,12 +140,6 @@ namespace Cantera { * @{ */ - //! Returns the type of the standard state parameterization - /*! - * @return Returns the integer # of the parameterization - */ - virtual PDSS_enumType reportPDSSType() const { return cPDSS_WATER; } - /** * @} * @name Molar Thermodynamic Properties of the Species Standard State