diff --git a/Cantera/src/ThermoPhase.h b/Cantera/src/ThermoPhase.h
index 7b5dd3297..cfdb8a3b7 100755
--- a/Cantera/src/ThermoPhase.h
+++ b/Cantera/src/ThermoPhase.h
@@ -1058,141 +1058,142 @@ namespace Cantera {
}
- //@}
+ //@}
- /// @name For Internal Use
+ //! @name Initialization Methods - For Internal Use (%ThermoPhase)
+ /*!
+ * The following methods are used in the process of constructing
+ * the phase and setting its parameters from a specification in an
+ * input file. They are not normally used in application programs.
+ * To see how they are used,
+ * see files importCTML.cpp and ThermoFactory.cpp.
+ */
+ //@{
- /// The following methods are used in the process of constructing
- /// the phase and setting its parameters from a specification in an
- /// input file. They are not normally used in application programs.
- /// To see how they are used, see files importCTML.cpp and
- /// ThermoFactory.cpp.
- //@{
-
- //! Store a reference to the XML tree containing the species data for this phase.
- /*!
- * This is used to access data needed to construct transport manager later.
- * @internal
- *
- * @param data Pointer to the XML_Node data containing
- * information about the species in the phase.
- */
- void saveSpeciesData(const XML_Node* data) {
- m_speciesData = data;
- }
+ //! Store a reference to the XML tree containing the species data for this phase.
+ /*!
+ * This is used to access data needed to construct transport manager later.
+ * @internal
+ *
+ * @param data Pointer to the XML_Node data containing
+ * information about the species in the phase.
+ */
+ void saveSpeciesData(const XML_Node* data) {
+ m_speciesData = data;
+ }
- /// Return a pointer to the XML tree containing the species
- /// data for this phase.
- const XML_Node* speciesData() {
- if (!m_speciesData) {
- throw CanteraError("ThermoPhase::speciesData",
- "m_speciesData is NULL");
- }
- return m_speciesData;
- }
+ /// Return a pointer to the XML tree containing the species
+ /// data for this phase.
+ const XML_Node* speciesData() {
+ if (!m_speciesData) {
+ throw CanteraError("ThermoPhase::speciesData",
+ "m_speciesData is NULL");
+ }
+ return m_speciesData;
+ }
- /**
- * @internal Install a species thermodynamic property
- * manager. The species thermodynamic property manager
- * computes properties of the pure species for use in
- * constructing solution properties. It is meant for internal
- * use, and some classes derived from ThermoPhase may not use
- * any species thermodynamic property manager. This method is
- * called by function importPhase() in importCTML.cpp.
- *
- * @param spthermo input pointer to the species thermodynamic property
- * manager.
- */
- void setSpeciesThermo(SpeciesThermo* spthermo)
- { m_spthermo = spthermo; }
+ /**
+ * @internal Install a species thermodynamic property
+ * manager. The species thermodynamic property manager
+ * computes properties of the pure species for use in
+ * constructing solution properties. It is meant for internal
+ * use, and some classes derived from ThermoPhase may not use
+ * any species thermodynamic property manager. This method is
+ * called by function importPhase() in importCTML.cpp.
+ *
+ * @param spthermo input pointer to the species thermodynamic property
+ * manager.
+ */
+ void setSpeciesThermo(SpeciesThermo* spthermo)
+ { m_spthermo = spthermo; }
- /**
- * @internal Return a reference to the species thermodynamic property
- * manager. @todo This method will fail if no species thermo
- * manager has been installed.
- */
- SpeciesThermo& speciesThermo() { return *m_spthermo; }
+ /**
+ * @internal Return a reference to the species thermodynamic property
+ * manager. @todo This method will fail if no species thermo
+ * manager has been installed.
+ */
+ SpeciesThermo& speciesThermo() { return *m_spthermo; }
- /**
- * @internal
- * Initialization of a ThermoPhase object using an
- * ctml file.
- *
- * This routine is a precursor to initThermoXML(XML_Node*)
- * routine, which does most of the work.
- * Here we read extra information about the XML description
- * of a phase. Regular information about elements and species
- * and their reference state thermodynamic information
- * have already been read at this point.
- * For example, we do not need to call this function for
- * ideal gas equations of state.
- *
- * @param inputFile XML file containing the description of the
- * phase
- *
- * @param id Optional parameter identifying the name of the
- * phase. If none is given, the first XML
- * phase element encountered will be used.
- */
- virtual void initThermoFile(std::string inputFile, std::string id);
+ /**
+ * @internal
+ * Initialization of a ThermoPhase object using an
+ * ctml file.
+ *
+ * This routine is a precursor to initThermoXML(XML_Node*)
+ * routine, which does most of the work.
+ * Here we read extra information about the XML description
+ * of a phase. Regular information about elements and species
+ * and their reference state thermodynamic information
+ * have already been read at this point.
+ * For example, we do not need to call this function for
+ * ideal gas equations of state.
+ *
+ * @param inputFile XML file containing the description of the
+ * phase
+ *
+ * @param id Optional parameter identifying the name of the
+ * phase. If none is given, the first XML
+ * phase element encountered will be used.
+ */
+ virtual void initThermoFile(std::string inputFile, std::string id);
- /**
- * @internal
- * Import and initialize a ThermoPhase object
- * using an XML tree.
- * Here we read extra information about the XML description
- * of a phase. Regular information about elements and species
- * and their reference state thermodynamic information
- * have already been read at this point.
- * For example, we do not need to call this function for
- * ideal gas equations of state.
- * This function is called from importPhase()
- * after the elements and the
- * species are initialized with default ideal solution
- * level data.
- *
- * @param phaseNode This object must be the phase node of a
- * complete XML tree
- * description of the phase, including all of the
- * species data. In other words while "phase" must
- * point to an XML phase object, it must have
- * sibling nodes "speciesData" that describe
- * the species in the phase.
- * @param id ID of the phase. If nonnull, a check is done
- * to see if phaseNode is pointing to the phase
- * with the correct id.
- */
- virtual void initThermoXML(XML_Node& phaseNode, std::string id);
+ /**
+ * @internal
+ * Import and initialize a ThermoPhase object
+ * using an XML tree.
+ * Here we read extra information about the XML description
+ * of a phase. Regular information about elements and species
+ * and their reference state thermodynamic information
+ * have already been read at this point.
+ * For example, we do not need to call this function for
+ * ideal gas equations of state.
+ * This function is called from importPhase()
+ * after the elements and the
+ * species are initialized with default ideal solution
+ * level data.
+ *
+ * @param phaseNode This object must be the phase node of a
+ * complete XML tree
+ * description of the phase, including all of the
+ * species data. In other words while "phase" must
+ * point to an XML phase object, it must have
+ * sibling nodes "speciesData" that describe
+ * the species in the phase.
+ * @param id ID of the phase. If nonnull, a check is done
+ * to see if phaseNode is pointing to the phase
+ * with the correct id.
+ */
+ virtual void initThermoXML(XML_Node& phaseNode, std::string id);
- /**
- * @internal Initialize. This method is provided to allow
- * subclasses to perform any initialization required after all
- * species have been added. For example, it might be used to
- * resize internal work arrays that must have an entry for
- * each species. The base class implementation does nothing,
- * and subclasses that do not require initialization do not
- * need to overload this method. When importing a CTML phase
- * description, this method is called just prior to returning
- * from function importPhase.
- *
- * @see importCTML.cpp
- */
- virtual void initThermo();
+ /**
+ * @internal Initialize. This method is provided to allow
+ * subclasses to perform any initialization required after all
+ * species have been added. For example, it might be used to
+ * resize internal work arrays that must have an entry for
+ * each species. The base class implementation does nothing,
+ * and subclasses that do not require initialization do not
+ * need to overload this method. When importing a CTML phase
+ * description, this method is called just prior to returning
+ * from function importPhase.
+ *
+ * @see importCTML.cpp
+ */
+ virtual void initThermo();
- // The following methods are used by the clib interface
- // library, and should not be used by application programs.
+ // The following methods are used by the clib interface
+ // library, and should not be used by application programs.
- /**
- * @internal
- * Index number. This method can be used to identify the
- * location of a phase object in a list, and is used by the
- * interface library (clib) routines for this purpose.
- */
- int index() { return m_index; }
+ /**
+ * @internal
+ * Index number. This method can be used to identify the
+ * location of a phase object in a list, and is used by the
+ * interface library (clib) routines for this purpose.
+ */
+ int index() { return m_index; }
/**
diff --git a/Cantera/src/thermo/VPStandardStateTP.cpp b/Cantera/src/thermo/VPStandardStateTP.cpp
index c3a4e193f..27de64bc9 100644
--- a/Cantera/src/thermo/VPStandardStateTP.cpp
+++ b/Cantera/src/thermo/VPStandardStateTP.cpp
@@ -25,257 +25,275 @@ using namespace std;
namespace Cantera {
- /*
- * Default constructor
- */
- VPStandardStateTP::VPStandardStateTP() :
- ThermoPhase(),
- m_tlast(-1.0),
- m_plast(-1.0)
- {
+ /*
+ * Default constructor
+ */
+ VPStandardStateTP::VPStandardStateTP() :
+ ThermoPhase(),
+ m_tlast(-1.0),
+ m_plast(-1.0)
+ {
+ }
+
+ /*
+ * Copy Constructor:
+ *
+ * Note this stuff will not work until the underlying phase
+ * has a working copy constructor.
+ *
+ * The copy constructor just calls the assignment operator
+ * to do the heavy lifting.
+ */
+ VPStandardStateTP::VPStandardStateTP(const VPStandardStateTP &b) :
+ ThermoPhase(),
+ m_tlast(-1.0),
+ m_plast(-1.0)
+ {
+ *this = b;
+ }
+
+ /*
+ * operator=()
+ *
+ * Note this stuff will not work until the underlying phase
+ * has a working assignment operator
+ */
+ VPStandardStateTP& VPStandardStateTP::
+ operator=(const VPStandardStateTP &b) {
+ if (&b != this) {
+ /*
+ * Mostly, this is a passthrough to the underlying
+ * assignment operator for the ThermoPhae parent object.
+ */
+ ThermoPhase::operator=(b);
+ /*
+ * However, we have to handle data that we own.
+ */
+ m_tlast = b.m_tlast;
+ m_plast = b.m_plast;
+ m_h0_RT = b.m_h0_RT;
+ m_cp0_R = b.m_cp0_R;
+ m_g0_RT = b.m_g0_RT;
+ m_s0_R = b.m_s0_R;
+ m_V0 = b.m_V0;
+ m_hss_RT = b.m_hss_RT;
+ m_cpss_R = b.m_cpss_R;
+ m_gss_RT = b.m_gss_RT;
+ m_sss_R = b.m_sss_R;
+ m_Vss = b.m_Vss;
}
+ return *this;
+ }
- /*
- * Copy Constructor:
- *
- * Note this stuff will not work until the underlying phase
- * has a working copy constructor.
- *
- * The copy constructor just calls the assignment operator
- * to do the heavy lifting.
- */
- VPStandardStateTP::VPStandardStateTP(const VPStandardStateTP &b) :
- ThermoPhase(),
- m_tlast(-1.0),
- m_plast(-1.0)
- {
- *this = b;
- }
+ /*
+ * ~VPStandardStateTP(): (virtual)
+ *
+ * This destructor does nothing. All of the owned objects
+ * handle themselves.
+ */
+ VPStandardStateTP::~VPStandardStateTP() {
+ }
- /*
- * operator=()
- *
- * Note this stuff will not work until the underlying phase
- * has a working assignment operator
- */
- VPStandardStateTP& VPStandardStateTP::
- operator=(const VPStandardStateTP &b) {
- if (&b != this) {
- /*
- * Mostly, this is a passthrough to the underlying
- * assignment operator for the ThermoPhae parent object.
- */
- ThermoPhase::operator=(b);
- /*
- * However, we have to handle data that we own.
- */
- m_tlast = b.m_tlast;
- m_plast = b.m_plast;
- m_h0_RT = b.m_h0_RT;
- m_cp0_R = b.m_cp0_R;
- m_g0_RT = b.m_g0_RT;
- m_s0_R = b.m_s0_R;
- m_hss_RT = b.m_hss_RT;
- m_cpss_R = b.m_cpss_R;
- m_gss_RT = b.m_gss_RT;
- m_sss_R = b.m_sss_R;
- }
- return *this;
- }
-
- /*
- * ~VPStandardStateTP(): (virtual)
- *
- * This destructor does nothing. All of the owned objects
- * handle themselves.
- */
- VPStandardStateTP::~VPStandardStateTP() {
- }
-
- /*
- * Duplication function.
- * This calls the copy constructor for this object.
- */
- ThermoPhase* VPStandardStateTP::duplMyselfAsThermoPhase() {
- VPStandardStateTP* vptp = new VPStandardStateTP(*this);
- return (ThermoPhase *) vptp;
- }
-
- /*
- * -------------- Utilities -------------------------------
- */
-
-
- /*
- * ------------Molar Thermodynamic Properties -------------------------
- */
-
-
- doublereal VPStandardStateTP::err(std::string msg) const {
- throw CanteraError("VPStandardStateTP","Base class method "
- +msg+" called. Equation of state type: "+int2str(eosType()));
- return 0;
- }
-
- /**
- * Returns the units of the standard and general concentrations
- * Note they have the same units, as their divisor is
- * defined to be equal to the activity of the kth species
- * in the solution, which is unitless.
- *
- * This routine is used in print out applications where the
- * units are needed. Usually, MKS units are assumed throughout
- * the program and in the XML input files.
- *
- * On return uA contains the powers of the units (MKS assumed)
- * of the standard concentrations and generalized concentrations
- * for the kth species.
- *
- * uA[0] = kmol units - default = 1
- * uA[1] = m units - default = -nDim(), the number of spatial
- * dimensions in the Phase class.
- * uA[2] = kg units - default = 0;
- * uA[3] = Pa(pressure) units - default = 0;
- * uA[4] = Temperature units - default = 0;
- * uA[5] = time units - default = 0
- */
- void VPStandardStateTP::
- getUnitsStandardConc(double *uA, int k, int sizeUA) {
- for (int i = 0; i < sizeUA; i++) {
- if (i == 0) uA[0] = 1.0;
- if (i == 1) uA[1] = -nDim();
- if (i == 2) uA[2] = 0.0;
- if (i == 3) uA[3] = 0.0;
- if (i == 4) uA[4] = 0.0;
- if (i == 5) uA[5] = 0.0;
- }
- }
-
- /*
- * ---- Partial Molar Properties of the Solution -----------------
- */
-
- /**
- * Get the array of non-dimensional species chemical potentials
- * These are partial molar Gibbs free energies.
- * \f$ \mu_k / \hat R T \f$.
- * Units: unitless
- *
- * We close the loop on this function, here, calling
- * getChemPotentials() and then dividing by RT.
- */
- void VPStandardStateTP::getChemPotentials_RT(doublereal* muRT) const{
- getChemPotentials(muRT);
- doublereal invRT = 1.0 / _RT();
- for (int k = 0; k < m_kk; k++) {
- muRT[k] *= invRT;
- }
- }
+ /*
+ * Duplication function.
+ * This calls the copy constructor for this object.
+ */
+ ThermoPhase* VPStandardStateTP::duplMyselfAsThermoPhase() {
+ VPStandardStateTP* vptp = new VPStandardStateTP(*this);
+ return (ThermoPhase *) vptp;
+ }
+
+ /*
+ * ------------Molar Thermodynamic Properties -------------------------
+ */
+
+
+ doublereal VPStandardStateTP::err(std::string msg) const {
+ throw CanteraError("VPStandardStateTP","Base class method "
+ +msg+" called. Equation of state type: "+int2str(eosType()));
+ return 0;
+ }
+
+ /*
+ * ---- Partial Molar Properties of the Solution -----------------
+ */
+
+ /*
+ * Get the array of non-dimensional species chemical potentials
+ * These are partial molar Gibbs free energies.
+ * \f$ \mu_k / \hat R T \f$.
+ * Units: unitless
+ *
+ * We close the loop on this function, here, calling
+ * getChemPotentials() and then dividing by RT.
+ */
+ void VPStandardStateTP::getChemPotentials_RT(doublereal* muRT) const{
+ getChemPotentials(muRT);
+ doublereal invRT = 1.0 / _RT();
+ for (int k = 0; k < m_kk; k++) {
+ muRT[k] *= invRT;
+ }
+ }
+
+ /*
+ * ----- Thermodynamic Values for the Species Standard States States ----
+ */
+ void VPStandardStateTP::getStandardChemPotentials(doublereal* g) const {
+ getGibbs_RT(g);
+ doublereal RT = _RT();
+ for (int k = 0; k < m_kk; k++) {
+ g[k] *= RT;
+ }
+ }
+
+ void VPStandardStateTP::getEnthalpy_RT(doublereal* hrt) const {
+ _updateStandardStateThermo();
+ copy(m_hss_RT.begin(), m_hss_RT.end(), hrt);
+ }
+
+ void VPStandardStateTP::getEntropy_R(doublereal* srt) const {
+ _updateStandardStateThermo();
+ copy(m_sss_R.begin(), m_sss_R.end(), srt);
+ }
+
+ void VPStandardStateTP::getGibbs_RT(doublereal* grt) const {
+ _updateStandardStateThermo();
+ copy(m_gss_RT.begin(), m_gss_RT.end(), grt);
+ }
+
+ void VPStandardStateTP::getPureGibbs(doublereal* g) const {
+ getGibbs_RT(g);
+ doublereal RT = _RT();
+ for (int k = 0; k < m_kk; k++) {
+ g[k] *= RT;
+ }
+ }
+
+ void VPStandardStateTP::getIntEnergy_RT(doublereal* urt) const {
+ _updateStandardStateThermo();
+ copy(m_hss_RT.begin(), m_hss_RT.end(), urt);
+ doublereal RT = _RT();
+ doublereal tmp = pressure() / RT;
+ for (int k = 0; k < m_kk; k++) {
+ urt[k] -= tmp * m_Vss[k];
+ }
+ }
+
+ void VPStandardStateTP::getCp_R(doublereal* cpr) const {
+ _updateStandardStateThermo();
+ copy(m_cpss_R.begin(), m_cpss_R.end(), cpr);
+ }
+
+ void VPStandardStateTP::getStandardVolumes(doublereal *vol) const {
+ _updateStandardStateThermo();
+ copy(m_Vss.begin(), m_Vss.end(), vol);
+ }
+
+ /*
+ * ----- 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.
+ */
+ void VPStandardStateTP::getEnthalpy_RT_ref(doublereal *hrt) const {
/*
- * ----- Thermodynamic Values for the Species Reference States ----
+ * Call the function that makes sure the local copy of the
+ * species reference thermo functions are up to date for the
+ * current temperature.
*/
-
- /**
- * Returns the vector of nondimensional enthalpies of the
- * reference state at the current temperature of the solution and
- * the reference pressure for the species.
+ _updateRefStateThermo();
+ /*
+ * Copy the enthalpy function into return vector.
*/
- void VPStandardStateTP::getEnthalpy_RT_ref(doublereal *hrt) const {
- /*
- * Call the function that makes sure the local copy of the
- * species reference thermo functions are up to date for the
- * current temperature.
- */
- _updateRefStateThermo();
- /*
- * Copy the enthalpy function into return vector.
- */
- copy(m_h0_RT.begin(), m_h0_RT.end(), hrt);
- }
+ copy(m_h0_RT.begin(), m_h0_RT.end(), hrt);
+ }
- /**
- * 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.
+ */
+ void VPStandardStateTP::getGibbs_RT_ref(doublereal *grt) const {
+ /*
+ * Call the function that makes sure the local copy of
+ * the species reference thermo functions are up to date
+ * for the current temperature.
*/
- void VPStandardStateTP::getGibbs_RT_ref(doublereal *grt) const {
- /*
- * Call the function that makes sure the local copy of
- * the species reference thermo functions are up to date
- * for the current temperature.
- */
- _updateRefStateThermo();
- /*
- * Copy the gibbs function into return vector.
- */
- copy(m_g0_RT.begin(), m_g0_RT.end(), grt);
- }
+ _updateRefStateThermo();
+ /*
+ * Copy the gibbs function into return vector.
+ */
+ copy(m_g0_RT.begin(), m_g0_RT.end(), grt);
+ }
- /**
- * 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
- *
- * This is filled in here so that derived classes don't have to
- * take care of it.
- */
- void VPStandardStateTP::getGibbs_ref(doublereal *g) const {
- getGibbs_RT_ref(g);
- double RT = _RT();
- for (int k = 0; k < m_kk; k++) {
- g[k] *= 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
+ *
+ * This is filled in here so that derived classes don't have to
+ * take care of it.
+ */
+ void VPStandardStateTP::getGibbs_ref(doublereal *g) const {
+ getGibbs_RT_ref(g);
+ double RT = _RT();
+ for (int k = 0; k < m_kk; k++) {
+ g[k] *= RT;
}
+ }
- /**
- * Returns the vector of nondimensional
- * entropies of the reference state at the current temperature
- * of the solution and the reference pressure for the species.
+ /*
+ * Returns the vector of nondimensional
+ * entropies of the reference state at the current temperature
+ * of the solution and the reference pressure for the species.
+ */
+ void VPStandardStateTP::getEntropy_R_ref(doublereal *er) const {
+ /*
+ * Call the function that makes sure the local copy of
+ * the species reference thermo functions are up to date
+ * for the current temperature.
*/
- void VPStandardStateTP::getEntropy_R_ref(doublereal *er) const {
- /*
- * Call the function that makes sure the local copy of
- * the species reference thermo functions are up to date
- * for the current temperature.
- */
- _updateRefStateThermo();
- /*
- * Copy the gibbs function into return vector.
- */
- copy(m_s0_R.begin(), m_s0_R.end(), er);
- }
+ _updateRefStateThermo();
+ /*
+ * Copy the gibbs function into return vector.
+ */
+ copy(m_s0_R.begin(), m_s0_R.end(), er);
+ }
- /**
- * Returns the vector of nondimensional
- * constant pressure heat capacities of the reference state
- * at the current temperature of the solution
- * and reference pressure for the 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 the species.
+ */
+ void VPStandardStateTP::getCp_R_ref(doublereal *cpr) const {
+ /*
+ * Call the function that makes sure the local copy of
+ * the species reference thermo functions are up to date
+ * for the current temperature.
*/
- void VPStandardStateTP::getCp_R_ref(doublereal *cpr) const {
- /*
- * Call the function that makes sure the local copy of
- * the species reference thermo functions are up to date
- * for the current temperature.
- */
- _updateRefStateThermo();
- /*
- * Copy the gibbs function into return vector.
- */
- copy(m_cp0_R.begin(), m_cp0_R.end(), cpr);
- }
-
- /**
- * Perform initializations after all species have been
- * added.
+ _updateRefStateThermo();
+ /*
+ * Copy the gibbs function into return vector.
*/
- void VPStandardStateTP::initThermo() {
- initLengths();
- ThermoPhase::initThermo();
- }
+ copy(m_cp0_R.begin(), m_cp0_R.end(), cpr);
+ }
- /**
+ /*
+ * Perform initializations after all species have been
+ * added.
+ */
+ void VPStandardStateTP::initThermo() {
+ initLengths();
+ ThermoPhase::initThermo();
+ }
+
+ /*
* Initialize the internal lengths.
* (this is not a virtual function)
*/
@@ -286,19 +304,25 @@ namespace Cantera {
m_g0_RT.resize(leng);
m_cp0_R.resize(leng);
m_s0_R.resize(leng);
+ m_V0.resize(leng);
+ m_hss_RT.resize(leng);
+ m_gss_RT.resize(leng);
+ m_cpss_R.resize(leng);
+ m_sss_R.resize(leng);
+ m_Vss.resize(leng);
}
- /**
+ /*
* Import and initialize a ThermoPhase object
*
- * @param phaseNode This object must be the phase node of a
+ * param phaseNode This object must be the phase node of a
* complete XML tree
* description of the phase, including all of the
* species data. In other words while "phase" must
* point to an XML phase object, it must have
* sibling nodes "speciesData" that describe
* the species in the phase.
- * @param id ID of the phase. If nonnull, a check is done
+ * param id ID of the phase. If nonnull, a check is done
* to see if phaseNode is pointing to the phase
* with the correct id.
*
@@ -310,42 +334,45 @@ namespace Cantera {
ThermoPhase::initThermoXML(phaseNode, id);
}
- /**
- * void _updateRefStateThermo() (private, const)
- *
- * This function gets called for every call to functions in this
- * class. It checks to see whether the temperature has changed and
- * thus the reference thermodynamics functions for all of the species
- * must be recalculated.
- * If the temperature has changed, the species thermo manager is called
- * to recalculate G, Cp, H, and S at the current temperature.
- */
- void VPStandardStateTP::_updateRefStateThermo() const {
- doublereal tnow = temperature();
- if (m_tlast != tnow) {
- m_spthermo->update(tnow, DATA_PTR(m_cp0_R), DATA_PTR(m_h0_RT),
- DATA_PTR(m_s0_R));
- m_tlast = tnow;
- for (int k = 0; k < m_kk; k++) {
- m_g0_RT[k] = m_h0_RT[k] - m_s0_R[k];
- }
- }
+ /*
+ * void _updateRefStateThermo() (protected, virtual, const)
+ *
+ * This function gets called for every call to functions in this
+ * class. It checks to see whether the temperature has changed and
+ * thus the reference thermodynamics functions for all of the species
+ * must be recalculated.
+ * If the temperature has changed, the species thermo manager is called
+ * to recalculate G, Cp, H, and S at the current temperature.
+ */
+ void VPStandardStateTP::_updateRefStateThermo() const {
+ doublereal tnow = temperature();
+ if (m_tlast != tnow) {
+ m_spthermo->update(tnow, DATA_PTR(m_cp0_R), DATA_PTR(m_h0_RT),
+ DATA_PTR(m_s0_R));
+ m_tlast = tnow;
+ for (int k = 0; k < m_kk; k++) {
+ m_g0_RT[k] = m_h0_RT[k] - m_s0_R[k];
+ }
}
-
- /**
- * void _updateStandardStateThermo() (private, const)
- *
- * This function gets called for every call to functions in this
- * class. It checks to see whether the temperature has changed and
- * thus the ss thermodynamics functions for all of the species
- * must be recalculated.
- */
- void VPStandardStateTP::_updateStandardStateThermo() const {
- doublereal tnow = temperature();
- if (m_tlast != tnow) {
- _updateRefStateThermo();
- }
+ }
+
+ /*
+ * void _updateStandardStateThermo() (protected, virtual, const)
+ *
+ * This function gets called for every call to functions in this
+ * class. It checks to see whether the temperature has changed and
+ * thus the ss thermodynamics functions for all of the species
+ * must be recalculated.
+ */
+ void VPStandardStateTP::_updateStandardStateThermo() const {
+ doublereal tnow = temperature();
+ doublereal pnow = pressure();
+ if (m_tlast != tnow || m_plast != pnow) {
+ err("getStandardVolumes");
+ m_tlast = tnow;
+ m_plast = pnow;
}
+ }
}
diff --git a/Cantera/src/thermo/VPStandardStateTP.h b/Cantera/src/thermo/VPStandardStateTP.h
index 586a21233..d05069be6 100644
--- a/Cantera/src/thermo/VPStandardStateTP.h
+++ b/Cantera/src/thermo/VPStandardStateTP.h
@@ -29,24 +29,31 @@ namespace Cantera {
/**
* @ingroup thermoprops
*
- * This is a filter class for ThermoPhase that implements
- * a variable pressure standard state for ThermoPhase objects.
+ * This is a filter class for ThermoPhase that implements some prepatory
+ * steps for efficiently handling
+ * a variable pressure standard state for species.
*
- * In addition support for the molality unit scale is provided.
+ * Several concepts are introduced. The first concept is there are temporary
+ * variables for holding the species standard values of Cp, H, S, and V at the
+ * last temperature and pressure called. These functions are not recalculated
+ * if a new call is made using the previous temperature and pressure.
*
- * Currently, it really is just a shell. The ThermoPhase object
- * itself is based around the general concepts of
- * VPStandardStateTP. Therefore, there really isn't much going
- * on here. However, this may change. The ThermoPhase object
- * itself could change. Additionally, this object may revolve
- * around the molality unit scale in the near future. We will
- * have to see how things fare.
+ * There are also temporary
+ * variables for holding the species reference-state values of Cp, H, S, and V at the
+ * last temperature and reference pressure called. These functions are not recalculated
+ * if a new call is made using the previous temperature.
+ *
+ * @nosubgrouping
*/
-
class VPStandardStateTP : public ThermoPhase {
public:
-
+
+ /*!
+ *
+ * @name Constructors and Duplicators for %VPStandardStateTP
+ *
+ */
/// Constructor.
VPStandardStateTP();
@@ -64,12 +71,12 @@ namespace Cantera {
*/
virtual ThermoPhase *duplMyselfAsThermoPhase();
- /**
- *
- * @name Utilities
- * @{
- */
+ //@}
+ /**
+ * @name Utilities (VPStandardStateTP)
+ */
+ //@{
/**
* Equation of state type flag. The base class returns
* zero. Subclasses should define this to return a unique
@@ -78,88 +85,10 @@ namespace Cantera {
*/
virtual int eosType() const { return 0; }
-
- /**
- * @}
- * @name Molar Thermodynamic Properties of the Solution
- * @{
- */
-
- /*
- * These are handled by inherited objects. At this level,
- * this pass-through routine doesn't add anything to the
- * ThermoPhase description.
- */
-
-
- /**
- * @}
- * @name Mechanical Properties
- * @{
- */
-
- /*
- * These are handled by inherited objects. At this level,
- * this pass-through routine doesn't add anything to the
- * ThermoPhase description.
- */
-
- /**
- * @}
- * @name Electric Potential
- *
- * The phase may be at some non-zero electrical
- * potential. These methods set or get the value of the
- * electric potential.
- * @{
- */
-
- /*
- * These are handled by inherited objects. At this level,
- * this pass-through routine doesn't add anything to the
- * ThermoPhase description.
- */
-
- /**
- * @}
- * @name Activities and Activity Concentrations
- *
- * The activity \f$a_k\f$ of a species in solution is
- * related to the chemical potential by \f[ \mu_k = \mu_k^0(T)
- * + \hat R T \log a_k. \f] The quantity \f$\mu_k^0(T)\f$ is
- * the chemical potential at unit activity, which depends only
- * on temperature.
- * @{
- */
-
-
- /**
- * Returns the units of the standard and generalized
- * concentrations Note they have the same units, as their
- * ratio is defined to be equal to the activity of the kth
- * species in the solution, which is unitless.
- *
- * This routine is used in print out applications where the
- * units are needed. Usually, MKS units are assumed throughout
- * the program and in the XML input files.
- *
- * @param uA Output vector containing the units
- * uA[0] = kmol units - default = 1
- * uA[1] = m units - default = -nDim(), the number of spatial
- * dimensions in the Phase class.
- * uA[2] = kg units - default = 0;
- * uA[3] = Pa(pressure) units - default = 0;
- * uA[4] = Temperature units - default = 0;
- * uA[5] = time units - default = 0
- * @param k species index. Defaults to 0.
- * @param sizeUA output int containing the size of the vector.
- * Currently, this is equal to 6.
- */
- virtual void getUnitsStandardConc(double *uA, int k = 0,
- int sizeUA = 6);
-
//@}
- /// @name Partial Molar Properties of the Solution
+
+
+ /// @name Partial Molar Properties of the Solution (VPStandardStateTP)
//@{
/**
@@ -175,21 +104,18 @@ namespace Cantera {
* Length: m_kk.
*/
virtual void getChemPotentials_RT(doublereal* mu) const;
-
//@}
- /// @name Properties of the Standard State of the Species in the Solution
- //@{
- /*
- * These are handled by inherited objects. At this level,
- * this pass-through routine doesn't add anything to the
- * ThermoPhase description.
+ /*!
+ * @name Properties of the Standard State of the Species in the Solution (VPStandardStateTP)
*
- * However, we assume these methods exist for inherited objects.
- * Therefore, we will bring the error routines up to this object
+ * Within VPStandardStateTP, these properties are calculated via a common routine, _updateStandardStateThermo(),
+ * which must be overloaded in inherited objects.
+ * The values are cached within this object, and are not recalculated unless
+ * the temperature or pressure changes.
*/
-
+ //@{
//!Get the array of chemical potentials at unit activity.
/*!
@@ -199,9 +125,7 @@ namespace Cantera {
* @param mu Output vector of standard state chemical potentials.
* length = m_kk. units are J / kmol.
*/
- virtual void getStandardChemPotentials(doublereal* mu) const {
- err("getStandardChemPotentials");
- }
+ virtual void getStandardChemPotentials(doublereal* mu) const;
/**
* Get the nondimensional Enthalpy functions for the species
@@ -211,9 +135,7 @@ namespace Cantera {
* @param hrt Output vector of standard state enthalpies.
* length = m_kk. units are unitless.
*/
- virtual void getEnthalpy_RT(doublereal* hrt) const {
- err("getEnthalpy_RT");
- }
+ virtual void getEnthalpy_RT(doublereal* hrt) const;
/**
* Get the array of nondimensional Enthalpy functions for the
@@ -223,9 +145,7 @@ namespace Cantera {
* @param sr Output vector of nondimensional standard state
* entropies. length = m_kk.
*/
- virtual void getEntropy_R(doublereal* sr) const {
- err("getEntropy_R");
- }
+ virtual void getEntropy_R(doublereal* sr) const;
/**
* Get the nondimensional Gibbs functions for the species
@@ -235,9 +155,7 @@ namespace Cantera {
* @param grt Output vector of nondimensional standard state
* Gibbs free energies. length = m_kk.
*/
- virtual void getGibbs_RT(doublereal* grt) const {
- err("getGibbs_RT");
- }
+ virtual void getGibbs_RT(doublereal* grt) const;
/**
* Get the nondimensional Gibbs functions for the standard
@@ -247,35 +165,35 @@ namespace Cantera {
* Gibbs free energies. length = m_kk.
* units are J/kmol.
*/
- virtual void getPureGibbs(doublereal* gpure) const {
- err("getPureGibbs");
- }
+ virtual void getPureGibbs(doublereal* gpure) const;
/**
* Returns the vector of nondimensional
* internal Energies of the standard state at the current temperature
* and pressure of the solution for each species.
+ * \f[
+ * u^{ss}_k(T,P) = h^{ss}_k(T) - P * V^{ss}_k
+ * \f]
*
* @param urt Output vector of nondimensional standard state
* internal energies. length = m_kk.
*/
- virtual void getIntEnergy_RT(doublereal *urt) const {
- err("getIntEnergy_RT");
- }
+ virtual void getIntEnergy_RT(doublereal *urt) const;
/**
* Get the nondimensional Heat Capacities at constant
* pressure for the standard state of the species
* at the current T and P.
*
+ * This is redefined here to call the internal function, _updateStandardStateThermo(),
+ * which calculates all standard state properties at the same time.
+ *
* @param cpr Output vector containing the
* the nondimensional Heat Capacities at constant
* pressure for the standard state of the species.
* Length: m_kk.
*/
- virtual void getCp_R(doublereal* cpr) const {
- err("getCp_R");
- }
+ virtual void getCp_R(doublereal* cpr) const;
/**
* Get the molar volumes of each species in their standard
@@ -283,15 +201,47 @@ namespace Cantera {
* T and P of the solution.
* units = m^3 / kmol
*
+ * This is redefined here to call the internal function, _updateStandardStateThermo(),
+ * which calculates all standard state properties at the same time.
+ *
* @param vol Output vector of species volumes. length = m_kk.
* units = m^3 / kmol
*/
- virtual void getStandardVolumes(doublereal *vol) const {
- err("getStandardVolumes");
- }
+ virtual void getStandardVolumes(doublereal *vol) const;
+ protected:
+
+ //! Updates the standard state thermodynamic functions at the current T and P of the solution.
+ /*!
+ * @internal
+ *
+ * This function gets called for every call to functions in this
+ * class. It checks to see whether the temperature or pressure has changed and
+ * thus the ss thermodynamics functions for all of the species
+ * must be recalculated.
+ *
+ * This function is responsible for updating the following internal members:
+ *
+ * m_hss_RT;
+ * m_cpss_R;
+ * m_gss_RT;
+ * m_sss_R;
+ * m_Vss
+ *
+ * Note, this will throw an error. It must be reimplemented in derived classes.
+ */
+ virtual void _updateStandardStateThermo() const;
+
+ public:
//@}
- /// @name Thermodynamic Values for the Species Reference States --------------------
+ /// @name Thermodynamic Values for the Species Reference States (VPStandardStateTP)
+ /*!
+ * There are also temporary
+ * variables for holding the species reference-state values of Cp, H, S, and V at the
+ * last temperature and reference pressure called. These functions are not recalculated
+ * if a new call is made using the previous temperature.
+ * All calculations are done within the routine _updateRefStateThermo().
+ */
//@{
/*!
@@ -351,38 +301,44 @@ namespace Cantera {
*/
virtual void getCp_R_ref(doublereal *cprt) const;
- ///////////////////////////////////////////////////////
- //
- // The methods below are not virtual, and should not
- // be overloaded.
- //
- //////////////////////////////////////////////////////
-
- /**
- * @name Specific Properties
- * @{
+ //! Recalculate the Reference state thermo functions
+ /*!
+ * This function checks to see whether the temperature has changed and
+ * thus the reference thermodynamics functions for all of the species
+ * must be recalculated.
+ * If the temperature has changed, the species thermo manager is called
+ * to recalculate G, Cp, H, and S at the current temperature and at
+ * the reference pressure.
*/
+ protected:
- /**
- * @name Setting the State
- *
- * These methods set all or part of the thermodynamic
- * state.
- * @{
+ //! Recalculate the Reference state thermo functions
+ /*!
+ * This function checks to see whether the temperature has changed and
+ * thus the reference thermodynamics functions for all of the species
+ * must be recalculated.
+ * If the temperature has changed, the species thermo manager is called
+ * to recalculate G, Cp, H, and S at the current temperature and at
+ * the reference pressure.
*/
-
- //@}
-
- /**
- * @name Chemical Equilibrium
- * Chemical equilibrium.
- * @{
- */
-
+ virtual void _updateRefStateThermo() const;
+
//@}
+ public:
+
+ //! @name Initialization Methods - For Internal use (VPStandardState)
+ /*!
+ * The following methods are used in the process of constructing
+ * the phase and setting its parameters from a specification in an
+ * input file. They are not normally used in application programs.
+ * To see how they are used, see files importCTML.cpp and
+ * ThermoFactory.cpp.
+ */
+ //@{
+
/**
* Set equation of state parameter values from XML
* entries. This method is called by function importPhase in
@@ -396,31 +352,9 @@ namespace Cantera {
*/
virtual void setParametersFromXML(const XML_Node& eosdata) {}
-
- //---------------------------------------------------------
- /// @name Critical state properties.
- /// These methods are only implemented by some subclasses.
-
- //@{
-
- //@}
-
- /// @name Saturation properties.
- /// These methods are only implemented by subclasses that
- /// implement full liquid-vapor equations of state.
- ///
-
-
- //@}
-
- /// The following methods are used in the process of constructing
- /// the phase and setting its parameters from a specification in an
- /// input file. They are not normally used in application programs.
- /// To see how they are used, see files importCTML.cpp and
- /// ThermoFactory.cpp.
-
- /**
- * @internal Initialize. This method is provided to allow
+ //! @internal Initialize the object
+ /*!
+ * This method is provided to allow
* subclasses to perform any initialization required after all
* species have been added. For example, it might be used to
* resize internal work arrays that must have an entry for
@@ -428,14 +362,27 @@ namespace Cantera {
* and subclasses that do not require initialization do not
* need to overload this method. When importing a CTML phase
* description, this method is called just prior to returning
- * from function importPhase.
+ * from function importPhase().
*
* @see importCTML.cpp
*/
virtual void initThermo();
- /**
- * Import and initialize a ThermoPhase object
+ //! Initialize a ThermoPhase object, potentially reading activity
+ //! coefficient information from an XML database.
+ /*!
+ *
+ * This routine initializes the lengths in the current object and
+ * then calls the parent routine.
+ * This method is provided to allow
+ * subclasses to perform any initialization required after all
+ * species have been added. For example, it might be used to
+ * resize internal work arrays that must have an entry for
+ * each species. The base class implementation does nothing,
+ * and subclasses that do not require initialization do not
+ * need to overload this method. When importing a CTML phase
+ * description, this method is called just prior to returning
+ * from function importPhase().
*
* @param phaseNode This object must be the phase node of a
* complete XML tree
@@ -448,11 +395,17 @@ namespace Cantera {
* to see if phaseNode is pointing to the phase
* with the correct id.
*/
- void initThermoXML(XML_Node& phaseNode, std::string id);
+ virtual void initThermoXML(XML_Node& phaseNode, std::string id);
private:
+ //! @internal Initialize the internal lengths in this object.
+ /*!
+ * Note this is not a virtual function.
+ */
void initLengths();
+ //@}
+
protected:
//! The last temperature at which the reference thermodynamic properties were calculated at.
@@ -485,6 +438,12 @@ namespace Cantera {
*/
mutable vector_fp m_s0_R;
+ /**
+ * Vector containing the species reference volumes
+ * at T = m_tlast and P = p_ref
+ */
+ mutable vector_fp m_V0;
+
/**
* Vector containing the species Standard State enthalpies at T = m_tlast
* and P = m_plast.
@@ -509,38 +468,21 @@ namespace Cantera {
*/
mutable vector_fp m_sss_R;
+ /**
+ * Vector containing the species standard state volumes
+ * at T = m_tlast and P = m_plast
+ */
+ mutable vector_fp m_Vss;
private:
- /**
+ /*!
* VPStandardStateTP has its own err routine
- *
*/
doublereal err(std::string msg) const;
- /**
- * This function gets called for every call to functions in this
- * class. It checks to see whether the temperature has changed and
- * thus the reference thermodynamics functions for all of the species
- * must be recalculated.
- * If the temperature has changed, the species thermo manager is called
- * to recalculate G, Cp, H, and S at the current temperature.
- */
- void _updateRefStateThermo() const;
-
- /**
- * void _updateStandardStateThermo() (private, const)
- *
- * This function gets called for every call to functions in this
- * class. It checks to see whether the temperature has changed and
- * thus the ss thermodynamics functions for all of the species
- * must be recalculated.
- */
- void _updateStandardStateThermo() const;
-
- };
-
- }
+ };
+}
#endif