diff --git a/Cantera/src/thermo/DebyeHuckel.h b/Cantera/src/thermo/DebyeHuckel.h index 7a411f182..63d043e47 100644 --- a/Cantera/src/thermo/DebyeHuckel.h +++ b/Cantera/src/thermo/DebyeHuckel.h @@ -7,11 +7,13 @@ * Class %DebyeHuckel represents a dilute liquid electrolyte phase which * obeys the Debye Huckel formulation for nonideality. */ + /* * Copywrite (2006) Sandia Corporation. Under the terms of * Contract DE-AC04-94AL85000 with Sandia Corporation, the * U.S. Government retains certain rights in this software. */ + /* * $Id$ */ diff --git a/Cantera/src/thermo/MineralEQ3.h b/Cantera/src/thermo/MineralEQ3.h index cfc130d7f..f75f28a9e 100644 --- a/Cantera/src/thermo/MineralEQ3.h +++ b/Cantera/src/thermo/MineralEQ3.h @@ -6,9 +6,11 @@ */ /* - * Copywrite (2005) Sandia Corporation. Under the terms of + * Copywrite (2006) Sandia Corporation. Under the terms of * Contract DE-AC04-94AL85000 with Sandia Corporation, the * U.S. Government retains certain rights in this software. + * + * Copyright 2001 California Institute of Technology */ /* diff --git a/Cantera/src/thermo/Nasa9Poly1.h b/Cantera/src/thermo/Nasa9Poly1.h index a44dae6e6..2b8bd5244 100644 --- a/Cantera/src/thermo/Nasa9Poly1.h +++ b/Cantera/src/thermo/Nasa9Poly1.h @@ -9,18 +9,20 @@ * * This parameterization has one NASA temperature region. */ - +/* + * Copywrite (2006) Sandia Corporation. Under the terms of + * Contract DE-AC04-94AL85000 with Sandia Corporation, the + * U.S. Government retains certain rights in this software. + */ #ifndef CT_NASA9POLY1_H #define CT_NASA9POLY1_H - -/* $Author$ +/* * $Revision$ * $Date$ */ -// Copyright 2007 Sandia National Laboratories #include "global.h" diff --git a/Cantera/src/thermo/NasaThermo.h b/Cantera/src/thermo/NasaThermo.h index 704ee5730..46cf02a71 100755 --- a/Cantera/src/thermo/NasaThermo.h +++ b/Cantera/src/thermo/NasaThermo.h @@ -7,11 +7,11 @@ */ /* - * $Author$ * $Revision$ * $Date$ */ +// Copyright 2003 California Institute of Technology #ifndef CT_NASATHERMO_H #define CT_NASATHERMO_H diff --git a/Cantera/src/thermo/PDSS.h b/Cantera/src/thermo/PDSS.h index 7a183148a..1ebb4b412 100644 --- a/Cantera/src/thermo/PDSS.h +++ b/Cantera/src/thermo/PDSS.h @@ -600,7 +600,7 @@ namespace Cantera { //! species, index. /*! * - * @param index Species index + * @param kindex Species index * @param type Integer type of the standard type * @param c Vector of coefficients used to set the * parameters for the standard state. @@ -609,10 +609,8 @@ namespace Cantera { * @param refPressure output - reference pressure (Pa). * */ - virtual void reportParams(int &kindex, int &type, - doublereal * const c, - doublereal &minTemp, - doublereal &maxTemp, + virtual void reportParams(int &kindex, int &type, doublereal * const c, + doublereal &minTemp, doublereal &maxTemp, doublereal &refPressure) const; diff --git a/Cantera/src/thermo/PDSS_HKFT.cpp b/Cantera/src/thermo/PDSS_HKFT.cpp index cf704673b..e69eaaa35 100644 --- a/Cantera/src/thermo/PDSS_HKFT.cpp +++ b/Cantera/src/thermo/PDSS_HKFT.cpp @@ -1,23 +1,33 @@ +/** + * @file PDSS_HKFT.cpp + * Definitions for the class PDSS_HKFT (pressure dependent standard state) + * which handles calculations for a single species in a phase using the + * HKFT standard state + * (see \ref pdssthermo and class \link Cantera::PDSS_HKFT PDSS_HKFT\endlink). + */ + /* * $Id$ */ -#include "ct_defs.h" -#include "xml.h" + +/* + * Copywrite (2006) Sandia Corporation. Under the terms of + * Contract DE-AC04-94AL85000 with Sandia Corporation, the + * U.S. Government retains certain rights in this software. + */ + #include "ctml.h" #include "PDSS_HKFT.h" #include "WaterProps.h" #include "PDSS_Water.h" -#include "Elements.h" - -#include "VPStandardStateTP.h" using namespace std; namespace Cantera { - /** + + /* * Basic list of constructors and duplicators */ - PDSS_HKFT::PDSS_HKFT(VPStandardStateTP *tp, int spindex) : PDSS(tp, spindex), m_waterSS(0), @@ -200,11 +210,10 @@ namespace Cantera { return (PDSS *) idg; } - /** + /* * Return the molar enthalpy in units of J kmol-1 */ - doublereal - PDSS_HKFT::enthalpy_mole() const { + doublereal PDSS_HKFT::enthalpy_mole() const { // Ok we may change this evaluation method in the future. doublereal GG = gibbs_mole(); doublereal SS = entropy_mole(); @@ -213,51 +222,49 @@ namespace Cantera { #ifdef DEBUG_MODE_NOT doublereal h2 = enthalpy_mole2(); if (fabs(h - h2) > 1.0E-1) { - printf("we are here, h = %g, h2 = %g, k = %d, T = %g, P = %g p0 = %g\n", h, h2, m_spindex, m_temp, m_pres, + printf("we are here, h = %g, h2 = %g, k = %d, T = %g, P = %g p0 = %g\n", + h, h2, m_spindex, m_temp, m_pres, m_p0); } #endif return h; } - doublereal - PDSS_HKFT::enthalpy_RT() const { + doublereal PDSS_HKFT::enthalpy_RT() const { doublereal hh = enthalpy_mole(); doublereal RT = GasConstant * m_temp; return hh / RT; } - doublereal - PDSS_HKFT::enthalpy_mole2() const { +#ifdef DEBUG_MODE + doublereal PDSS_HKFT::enthalpy_mole2() const { doublereal delH = deltaH(); - double enthTRPR = m_Mu0_tr_pr + 298.15*m_Entrop_tr_pr * 1.0E3 * 4.184; + double enthTRPR = m_Mu0_tr_pr + 298.15 * m_Entrop_tr_pr * 1.0E3 * 4.184; double res = delH + enthTRPR; return res; } +#endif - - /** + /* * Calculate the internal energy in mks units of * J kmol-1 */ - doublereal - PDSS_HKFT::intEnergy_mole() const { + doublereal PDSS_HKFT::intEnergy_mole() const { doublereal hh = enthalpy_RT(); doublereal mv = molarVolume(); return (hh - mv * m_pres); } - /** + /* * Calculate the entropy in mks units of * J kmol-1 K-1 */ - doublereal - PDSS_HKFT::entropy_mole() const { + doublereal PDSS_HKFT::entropy_mole() const { doublereal delS = deltaS(); return (m_Entrop_tr_pr * 1.0E3 * 4.184 + delS); } - /** + /* * Calculate the Gibbs free energy in mks units of * J kmol-1 */ @@ -266,7 +273,7 @@ namespace Cantera { return (m_Mu0_tr_pr + delG); } - /** + /* * Calculate the constant pressure heat capacity * in mks units of J kmol-1 K-1 */ @@ -351,7 +358,6 @@ namespace Cantera { // Convert to Joules / kmol doublereal Cp = Cp_calgmol * 1.0E3 * 4.184; - #ifdef DEBUG_MODE_NOT double e1 = enthalpy_mole(); m_temp = m_temp - 0.001; @@ -366,7 +372,7 @@ namespace Cantera { return Cp; } - /** + /* * Calculate the constant volume heat capacity * in mks units of J kmol-1 K-1 */ @@ -376,8 +382,9 @@ namespace Cantera { return (0.0); } - doublereal - PDSS_HKFT::molarVolume() const { + doublereal PDSS_HKFT::molarVolume() const { + + // Initially do all calculations in (cal/gmol/Pa) doublereal a1term = m_a1 * 1.0E-5; @@ -394,19 +401,21 @@ namespace Cantera { domega_jdP = 0.0; } else { doublereal nu = 166027.; - doublereal r_e_j_pr_tr = m_charge_j * m_charge_j / (m_omega_pr_tr/nu + m_charge_j/3.082); + doublereal charge2 = m_charge_j * m_charge_j; + doublereal r_e_j_pr_tr = charge2 / (m_omega_pr_tr/nu + m_charge_j/3.082); doublereal gval = gstar(m_temp, m_pres, 0); doublereal dgvaldP = gstar(m_temp, m_pres, 3); doublereal r_e_j = r_e_j_pr_tr + fabs(m_charge_j) * gval; + doublereal r_e_H = 3.082 + gval; - omega_j = nu * (m_charge_j * m_charge_j / r_e_j - m_charge_j / (3.082 + gval) ); + omega_j = nu * (charge2 / r_e_j - m_charge_j / r_e_H ); doublereal dr_e_jdP = fabs(m_charge_j) * dgvaldP; - domega_jdP = - nu * (m_charge_j * m_charge_j / (r_e_j * r_e_j) * dr_e_jdP) - + nu * m_charge_j / (3.082 + gval) / (3.082 + gval) * dgvaldP; + domega_jdP = - nu * (charge2 / (r_e_j * r_e_j) * dr_e_jdP) + + nu * m_charge_j / (r_e_H * r_e_H) * dgvaldP; } doublereal drelepsilondP = m_waterProps->relEpsilon(m_temp, m_pres, 3); @@ -423,7 +432,7 @@ namespace Cantera { doublereal molVol_calgmolPascal = a1term + a2term + a3term + a4term + wterm + qterm; - // Convert to m**3 / kmol + // Convert to m**3 / kmol from (cal/gmol/Pa) doublereal molVol = molVol_calgmolPascal * 4.184 * 1.0E3; return molVol; } diff --git a/Cantera/src/thermo/PDSS_HKFT.h b/Cantera/src/thermo/PDSS_HKFT.h index feec62513..7449c32c5 100644 --- a/Cantera/src/thermo/PDSS_HKFT.h +++ b/Cantera/src/thermo/PDSS_HKFT.h @@ -5,18 +5,20 @@ * HKFT standard state * (see \ref pdssthermo and class \link Cantera::PDSS_HKFT PDSS_HKFT\endlink). */ -/* $Author$ + +/* * $Date$ * $Revision$ - * - * + */ + +/* + * Copywrite (2006) Sandia Corporation. Under the terms of + * Contract DE-AC04-94AL85000 with Sandia Corporation, the + * U.S. Government retains certain rights in this software. */ #ifndef CT_PDSS_HKFT_H #define CT_PDSS_HKFT_H -#include "ct_defs.h" - - class WaterPropsIAPWS; #include "PDSS.h" @@ -27,7 +29,6 @@ namespace Cantera { class PDSS_Water; class WaterProps; - //! Class for pressure dependent standard states corresponding to //! ionic solutes in electrolyte water. /*! @@ -148,9 +149,20 @@ namespace Cantera { * @return returns the species standard state enthalpy in J kmol-1 */ virtual doublereal enthalpy_mole() const; + #ifdef DEBUG_MODE - virtual doublereal enthalpy_mole2() const; + //! Return the molar enthalpy in units of J kmol-1 + /*! + * Returns the species standard state enthalpy in J kmol-1 at the + * current temperature and pressure. + * + * Note this is just an extra routine to check the arithmetic + * + * @return returns the species standard state enthalpy in J kmol-1 + */ + doublereal enthalpy_mole2() const; #endif + //! Return the standard state molar enthalpy divided by RT /*! * Returns the species standard state enthalpy divided by RT at the @@ -454,7 +466,7 @@ namespace Cantera { * - c[10] = m_omega_pr_tr; * . * - * @param index Species index + * @param kindex Species index * @param type Integer type of the standard type * @param c Vector of coefficients used to set the * parameters for the standard state. @@ -483,12 +495,17 @@ namespace Cantera { //! Main routine that actually calculates the entropy difference //! between the reference state at Tr, Pr and T,P /*! - * This is eEqn. 61 in Johnson et al. (1992). Actually, there appears to + * This is Eqn. 61 in Johnson et al. (1992). Actually, there appears to * be an error in the latter. This is a correction. */ doublereal deltaS() const; #ifdef DEBUG_MODE + //! Routine that actually calculates the enthalpy difference + //! between the reference state at Tr, Pr and T,P + /*! + * This is an extra routine that was added to check the arithmetic + */ doublereal deltaH() const; #endif @@ -560,8 +577,8 @@ namespace Cantera { * - 2 2nd derivative wrt temperature * - 3 derivative wrt pressure */ - doublereal gstar(const doublereal temp, const doublereal pres, const int ifunc = 0) const; - + doublereal gstar(const doublereal temp, const doublereal pres, + const int ifunc = 0) const; //! Function to look up Element Free Energies /*! @@ -582,7 +599,8 @@ namespace Cantera { //! Translate a Gibbs free energy of formation value to a NIST-based Chemical potential /*! - * Internally, this function is used to translate the input value, m_deltaG_formation_tr_pr, + * Internally, this function is used to translate the input value, + * m_deltaG_formation_tr_pr, * to the internally storred value, m_Mu0_tr_pr. */ void convertDGFormation(); @@ -601,20 +619,15 @@ namespace Cantera { */ mutable doublereal m_densWaterSS; - /** - * Pointer to the water property calculator - */ + //! Pointer to the water property calculator WaterProps *m_waterProps; - //! Born coefficient for the current ion or species - doublereal m_born_coeff_j; //! Electrostatic radii doublereal m_r_e_j; - //! Input value of deltaG of Formation at Tr and Pr (cal gmol-1) /*! * Tr = 298.15 Pr = 1 atm diff --git a/Cantera/src/thermo/VPSSMgr.cpp b/Cantera/src/thermo/VPSSMgr.cpp index a53982384..92b9917ba 100644 --- a/Cantera/src/thermo/VPSSMgr.cpp +++ b/Cantera/src/thermo/VPSSMgr.cpp @@ -82,8 +82,6 @@ namespace Cantera { m_kk = right.m_kk; m_vptp_ptr = right.m_vptp_ptr; m_spthermo = right.m_spthermo; - // m_Tnow = right.m_Tnow; - // m_Pnow = right.m_Pnow; m_tlast = -1.0; m_plast = -1.0; m_p0 = right.m_p0; @@ -274,15 +272,15 @@ namespace Cantera { void VPSSMgr::setState_P(doublereal pres) { if (m_plast != pres) { m_plast = pres; - _updateStandardStateThermo(); + updateStandardStateThermo(); } } void VPSSMgr::setState_T(doublereal temp) { if (m_tlast != temp) { m_tlast = temp; - _updateRefStateThermo(); - _updateStandardStateThermo(); + updateRefStateThermo(); + updateStandardStateThermo(); } } @@ -290,11 +288,11 @@ namespace Cantera { if (m_tlast != temp) { m_tlast = temp; m_plast = pres; - _updateRefStateThermo(); - _updateStandardStateThermo(); + updateRefStateThermo(); + updateStandardStateThermo(); } else if (m_plast != pres) { m_plast = pres; - _updateStandardStateThermo(); + updateStandardStateThermo(); } } diff --git a/Cantera/src/thermo/VPSSMgr.h b/Cantera/src/thermo/VPSSMgr.h index e3b555c80..ad5fa49b3 100644 --- a/Cantera/src/thermo/VPSSMgr.h +++ b/Cantera/src/thermo/VPSSMgr.h @@ -688,6 +688,8 @@ namespace Cantera { * as those for ideal gases, require that all species * in the same phase have the same reference state pressures. * + * @param k Species index. Default is -1, which returns + * the generic answer. */ virtual doublereal refPressure(int k = -1) const ; diff --git a/Cantera/src/thermo/VPSSMgr_Water_ConstVol.cpp b/Cantera/src/thermo/VPSSMgr_Water_ConstVol.cpp index fd9793589..daeae2de9 100644 --- a/Cantera/src/thermo/VPSSMgr_Water_ConstVol.cpp +++ b/Cantera/src/thermo/VPSSMgr_Water_ConstVol.cpp @@ -7,13 +7,14 @@ * (see \ref thermoprops and class * \link Cantera::VPSSMgr_Water_ConstVol VPSSMgr_Water_ConstVol\endlink). */ + /* * Copywrite (2005) Sandia Corporation. Under the terms of * Contract DE-AC04-94AL85000 with Sandia Corporation, the * U.S. Government retains certain rights in this software. */ + /* - * $Author$ * $Date$ * $Revision$ */ @@ -25,8 +26,6 @@ #endif #include "VPSSMgr_Water_ConstVol.h" -#include "xml.h" -#include "VPStandardStateTP.h" #include "PDSS_Water.h" #include "PDSS_ConstVol.h" #include "GeneralSpeciesThermo.h" @@ -186,7 +185,7 @@ namespace Cantera { void VPSSMgr_Water_ConstVol::_updateStandardStateThermo() { - // _updateRefStateThermo(); + doublereal RT = GasConstant * m_tlast; doublereal del_pRT = (m_plast - OneAtm) / (RT); @@ -208,11 +207,11 @@ namespace Cantera { m_Vss[0] = (m_vptp_ptr->molecularWeight(0) / m_waterSS->density()); } + void VPSSMgr_Water_ConstVol::initThermo() { VPSSMgr::initThermo(); } - void VPSSMgr_Water_ConstVol::initThermoXML(XML_Node& phaseNode, std::string id) { VPSSMgr::initThermoXML(phaseNode, id); @@ -245,7 +244,8 @@ namespace Cantera { std::string model = (*ss)["model"]; if (model != "constant_incompressible") { throw CanteraError("VPSSMgr_Water_ConstVol::initThermoXML", - "standardState model for species isn't constant_incompressible: " + s->name()); + "standardState model for species isn't " + "constant_incompressible: " + s->name()); } m_Vss[k] = getFloat(*ss, "molarVolume", "toSI"); } diff --git a/Cantera/src/thermo/VPSSMgr_Water_ConstVol.h b/Cantera/src/thermo/VPSSMgr_Water_ConstVol.h index 459cb55ee..dd1dce163 100644 --- a/Cantera/src/thermo/VPSSMgr_Water_ConstVol.h +++ b/Cantera/src/thermo/VPSSMgr_Water_ConstVol.h @@ -9,10 +9,10 @@ */ /* - * $Author$ * $Revision$ * $Date$ */ + /* * Copywrite (2005) Sandia Corporation. Under the terms of * Contract DE-AC04-94AL85000 with Sandia Corporation, the @@ -22,7 +22,6 @@ #ifndef CT_VPSSMGR_WATER_CONSTVOL_H #define CT_VPSSMGR_WATER_CONSTVOL_H -#include "ct_defs.h" #include "VPSSMgr.h" namespace Cantera { @@ -95,10 +94,10 @@ namespace Cantera { * The values are cached within this object, and are not recalculated unless * the temperature or pressure changes. */ - //@{ - + + //@{ - protected: + private: //! Updates the standard state thermodynamic functions at the current T and P of the solution. /*! @@ -111,7 +110,6 @@ namespace Cantera { * must be recalculated. * * This function is responsible for updating the following internal members, - * when m_useTmpStandardStateStorage is true. * * - m_hss_RT; * - m_cpss_R; @@ -130,14 +128,24 @@ namespace Cantera { //! Updates the reference state thermodynamic functions at the //! current T of the solution and the reference pressure /*! - * Underscore updates never check for the state of the system + * Underscore updates never check for the state of the system. * They just do the calculation. + * + * This function is responsible for updating the following internal members + * + * - m_h0_RT; + * - m_cp0_R; + * - m_g0_RT; + * - m_s0_R; + * - m_V0 + * + * This routine also updates all of the thermo to the current temperature */ virtual void _updateRefStateThermo () const; - public: - //@} + + public: /// @name Thermodynamic Values for the Species Reference States (VPStandardStateTP) /*! * There are also temporary @@ -146,8 +154,10 @@ namespace Cantera { * if a new call is made using the previous temperature. * All calculations are done within the routine _updateRefStateThermo(). */ + //@{ - /*! + + /*! * Returns the vector of nondimensional * enthalpies of the reference state at the current temperature * of the solution and the reference pressure for the species. @@ -224,8 +234,8 @@ namespace Cantera { * To see how they are used, see files importCTML.cpp and * ThermoFactory.cpp. */ - //@{ + //@{ //! @internal Initialize the object /*! @@ -242,10 +252,8 @@ namespace Cantera { * @see importCTML.cpp */ - //! Initialize the thermo, after all species have been entered. virtual void initThermo(); - //! Finalize the thermo after all species have been entered /*! @@ -309,6 +317,7 @@ namespace Cantera { * object. */ PDSS_Water *m_waterSS; + }; //@} } diff --git a/Cantera/src/thermo/VPSSMgr_Water_HKFT.cpp b/Cantera/src/thermo/VPSSMgr_Water_HKFT.cpp index b15628dab..bb0549124 100644 --- a/Cantera/src/thermo/VPSSMgr_Water_HKFT.cpp +++ b/Cantera/src/thermo/VPSSMgr_Water_HKFT.cpp @@ -3,7 +3,7 @@ * Definition file for a derived class that handles the calculation * of standard state thermo properties for pure water and * a set of species which obey the HKFT standard state - * dependence + * dependence * (see \ref thermoprops and class * \link Cantera::VPSSMgr_Water_HKFT VPSSMgr_Water_HKFT\endlink). */ @@ -81,30 +81,12 @@ namespace Cantera { void VPSSMgr_Water_HKFT::getEnthalpy_RT_ref(doublereal *hrt) const{ updateRefStateThermo(); - // Everything should be OK except for the water SS - if (m_p0 != m_plast) { - doublereal RT = GasConstant * m_tlast; - m_waterSS->setState_TP(m_tlast, m_p0); - m_h0_RT[0] = (m_waterSS->enthalpy_mole()) / RT; - m_waterSS->setState_TP(m_tlast, m_plast); - } else { - m_h0_RT[0] = m_hss_RT[0]; - } copy(m_h0_RT.begin(), m_h0_RT.end(), hrt); } void VPSSMgr_Water_HKFT::getGibbs_RT_ref(doublereal *grt) const{ updateRefStateThermo(); - // Everything should be OK except for the water SS - if (m_p0 != m_plast) { - doublereal RT = GasConstant * m_tlast; - m_waterSS->setState_TP(m_tlast, m_p0); - m_g0_RT[0] = (m_waterSS->gibbs_mole()) / RT; - m_waterSS->setState_TP(m_tlast, m_plast); - } else { - m_g0_RT[0] = m_gss_RT[0]; - } copy(m_g0_RT.begin(), m_g0_RT.end(), grt); } @@ -120,42 +102,18 @@ namespace Cantera { void VPSSMgr_Water_HKFT::getEntropy_R_ref(doublereal *sr) const{ updateRefStateThermo(); - // Everything should be OK except for the water SS - if (m_p0 != m_plast) { - m_waterSS->setState_TP(m_tlast, m_p0); - m_s0_R[0] = (m_waterSS->entropy_mole()) / GasConstant; - m_waterSS->setState_TP(m_tlast, m_plast); - } else { - m_s0_R[0] = m_sss_R[0]; - } copy(m_s0_R.begin(), m_s0_R.end(), sr); } void VPSSMgr_Water_HKFT::getCp_R_ref(doublereal *cpr) const{ updateRefStateThermo(); - // Everything should be OK except for the water SS - if (m_p0 != m_plast) { - m_waterSS->setState_TP(m_tlast, m_p0); - m_cp0_R[0] = (m_waterSS->cp_mole()) / GasConstant; - m_waterSS->setState_TP(m_tlast, m_plast); - } else { - m_cp0_R[0] = m_cpss_R[0]; - } copy(m_cp0_R.begin(), m_cp0_R.end(), cpr); } void VPSSMgr_Water_HKFT::getStandardVolumes_ref(doublereal *vol) const{ updateRefStateThermo(); - // Everything should be OK except for the water SS - if (m_p0 != m_plast) { - m_waterSS->setState_TP(m_tlast, m_p0); - m_V0[0] = (m_waterSS->density()) / m_vptp_ptr->molecularWeight(0); - m_waterSS->setState_TP(m_tlast, m_plast); - } else { - m_V0[0] = m_Vss[0]; - } copy(m_V0.begin(), m_V0.end(), vol); } @@ -192,7 +150,6 @@ namespace Cantera { } void VPSSMgr_Water_HKFT::_updateRefStateThermo() const { - // Fix up the water m_p0 = m_waterSS->pref_safe(m_tlast); doublereal RT = GasConstant * m_tlast; m_waterSS->setState_TP(m_tlast, m_p0); @@ -201,23 +158,27 @@ namespace Cantera { m_cp0_R[0] = (m_waterSS->cp_mole()) / GasConstant; m_g0_RT[0] = (m_hss_RT[0] - m_sss_R[0]); m_V0[0] = (m_waterSS->density()) / m_vptp_ptr->molecularWeight(0); - m_waterSS->setState_TP(m_tlast, m_plast); - + PDSS_HKFT *ps; for (int k = 1; k < m_kk; k++) { - PDSS_HKFT *ps = (PDSS_HKFT *) m_vptp_ptr->providePDSS(k); + ps = (PDSS_HKFT *) m_vptp_ptr->providePDSS(k); ps->setState_TP(m_tlast, m_p0); m_cp0_R[k] = ps->cp_R(); m_s0_R[k] = ps->entropy_mole() / GasConstant; m_g0_RT[k] = ps->gibbs_RT(); - m_h0_RT[k] = m_g0_RT[k] + m_s0_R[k]; -#ifdef DEBUG_MODE +#ifdef DEBUG_MODE_NOT double h = ps->enthalpy_RT(); if (fabs( m_h0_RT[k] - h) > 1.0E-4) { - printf("we are here\n"); + printf(" VPSSMgr_Water_HKFT::_updateRefStateThermo:: we have a discrepancy\n"); } #endif m_V0[k] = ps->molarVolume(); + + } + m_waterSS->setState_TP(m_tlast, m_plast); + for (int k = 1; k < m_kk; k++) { + ps = (PDSS_HKFT *) m_vptp_ptr->providePDSS(k); + ps->setState_TP(m_tlast, m_plast); } } @@ -240,7 +201,6 @@ namespace Cantera { m_hss_RT[k] = m_gss_RT[k] + m_sss_R[k]; m_Vss[k] = ps->molarVolume(); } - } void VPSSMgr_Water_HKFT::initThermo() { @@ -255,7 +215,7 @@ namespace Cantera { XML_Node& speciesList = phaseNode.child("speciesArray"); XML_Node* speciesDB = get_XML_NameID("speciesData", speciesList["datasrc"], &phaseNode.root()); - const vector&sss = m_vptp_ptr->speciesNames(); + const vector &sss = m_vptp_ptr->speciesNames(); m_waterSS->setState_TP(300., OneAtm); m_Vss[0] = (m_waterSS->density()) / m_vptp_ptr->molecularWeight(0); @@ -282,7 +242,7 @@ namespace Cantera { PDSS * VPSSMgr_Water_HKFT::createInstallPDSS(int k, const XML_Node& speciesNode, const XML_Node *phaseNode_ptr) { - PDSS *kPDSS = 0; + PDSS *kPDSS = 0; const XML_Node *ss = speciesNode.findByName("standardState"); if (!ss) { diff --git a/Cantera/src/thermo/VPSSMgr_Water_HKFT.h b/Cantera/src/thermo/VPSSMgr_Water_HKFT.h index c4f059aa4..6f9c61d2c 100644 --- a/Cantera/src/thermo/VPSSMgr_Water_HKFT.h +++ b/Cantera/src/thermo/VPSSMgr_Water_HKFT.h @@ -6,11 +6,13 @@ * (see \ref mgrpdssthermocalc and * class \link Cantera::VPSSMgr_Water_HKFT VPSSMgr_Water_HKFT\endlink). */ + /* - * $Author$ + * * $Revision$ * $Date$ */ + /* * Copywrite (2006) Sandia Corporation. Under the terms of * Contract DE-AC04-94AL85000 with Sandia Corporation, the @@ -20,7 +22,6 @@ #ifndef CT_VPSSMGR_WATER_HKFT_H #define CT_VPSSMGR_WATER_HKFT_H -#include "ct_defs.h" #include "VPSSMgr.h" namespace Cantera { @@ -225,14 +226,38 @@ namespace Cantera { //! Updates the internal reference state thermodynamic vectors at the //! current T of the solution and the reference pressure. /*! - * If you are to peak internally inside the object, you need to - * call these functions after setState functions in order to be sure - * that the vectors are current. + * This is called to make sure that the internal thermodynamic members + * are up-to-date. It checks against an internal value of m_tempRef + * to see whether the values are current. */ virtual void updateRefStateThermo() const; - protected: + private: + + //! Updates the reference state thermodynamic functions at the current T + //! and a calculated Pref that is safe. + /*! + * + * This function is responsible for updating the following internal members + * + * - m_h0_RT; + * - m_cp0_R; + * - m_g0_RT; + * - m_s0_R; + * - m_V0 + * + * It always does the calculation. No checking is ever done to see + * if the calculation is necessary. + * + * m_p0 is calculated within this routine given the value of the temperature. + * This is necessary because we are using a real equation of state for + * water. + * + * The state of the system is left at (m_tlast, m_plast) at the end + * of the routine. + */ virtual void _updateRefStateThermo() const; + //! Updates the standard state thermodynamic functions at the current T and P of the solution. /*! * @internal @@ -261,7 +286,6 @@ namespace Cantera { virtual void _updateStandardStateThermo(); - public: //@} @@ -351,6 +375,11 @@ namespace Cantera { //! Shallow pointer to the water object PDSS_Water *m_waterSS; + //! Last reference temperature calculated + /*! + * Reference state calculations are totally separated from + * standard state calculations. + */ mutable doublereal m_tlastRef; }; //@}