Doxygen update ov VPStandardStateTP. Took out unnecessary member

functions and doxygen documentation.
   Changed _updateStandardStateThermo() and _updateRefStateThermo()
to virtual protected functions, which is a necessary condition for
them to be useful.
This commit is contained in:
Harry Moffat 2007-02-08 16:54:01 +00:00
parent 4d9abd04ae
commit 346eb134bf
3 changed files with 574 additions and 604 deletions

View file

@ -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 //! Store a reference to the XML tree containing the species data for this phase.
/// the phase and setting its parameters from a specification in an /*!
/// input file. They are not normally used in application programs. * This is used to access data needed to construct transport manager later.
/// To see how they are used, see files importCTML.cpp and * @internal
/// ThermoFactory.cpp. *
//@{ * @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. /// Return a pointer to the XML tree containing the species
/*! /// data for this phase.
* This is used to access data needed to construct transport manager later. const XML_Node* speciesData() {
* @internal if (!m_speciesData) {
* throw CanteraError("ThermoPhase::speciesData",
* @param data Pointer to the XML_Node data containing "m_speciesData is NULL");
* information about the species in the phase.
*/
void saveSpeciesData(const XML_Node* data) {
m_speciesData = data;
} }
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 * @internal Install a species thermodynamic property
* manager. The species thermodynamic property manager * manager. The species thermodynamic property manager
* computes properties of the pure species for use in * computes properties of the pure species for use in
* constructing solution properties. It is meant for internal * constructing solution properties. It is meant for internal
* use, and some classes derived from ThermoPhase may not use * use, and some classes derived from ThermoPhase may not use
* any species thermodynamic property manager. This method is * any species thermodynamic property manager. This method is
* called by function importPhase() in importCTML.cpp. * called by function importPhase() in importCTML.cpp.
* *
* @param spthermo input pointer to the species thermodynamic property * @param spthermo input pointer to the species thermodynamic property
* manager. * manager.
*/ */
void setSpeciesThermo(SpeciesThermo* spthermo) void setSpeciesThermo(SpeciesThermo* spthermo)
{ m_spthermo = spthermo; } { m_spthermo = spthermo; }
/** /**
* @internal Return a reference to the species thermodynamic property * @internal Return a reference to the species thermodynamic property
* manager. @todo This method will fail if no species thermo * manager. @todo This method will fail if no species thermo
* manager has been installed. * manager has been installed.
*/ */
SpeciesThermo& speciesThermo() { return *m_spthermo; } SpeciesThermo& speciesThermo() { return *m_spthermo; }
/** /**
* @internal * @internal
* Initialization of a ThermoPhase object using an * Initialization of a ThermoPhase object using an
* ctml file. * ctml file.
* *
* This routine is a precursor to initThermoXML(XML_Node*) * This routine is a precursor to initThermoXML(XML_Node*)
* routine, which does most of the work. * routine, which does most of the work.
* Here we read extra information about the XML description * Here we read extra information about the XML description
* of a phase. Regular information about elements and species * of a phase. Regular information about elements and species
* and their reference state thermodynamic information * and their reference state thermodynamic information
* have already been read at this point. * have already been read at this point.
* For example, we do not need to call this function for * For example, we do not need to call this function for
* ideal gas equations of state. * ideal gas equations of state.
* *
* @param inputFile XML file containing the description of the * @param inputFile XML file containing the description of the
* phase * phase
* *
* @param id Optional parameter identifying the name of the * @param id Optional parameter identifying the name of the
* phase. If none is given, the first XML * phase. If none is given, the first XML
* phase element encountered will be used. * phase element encountered will be used.
*/ */
virtual void initThermoFile(std::string inputFile, std::string id); virtual void initThermoFile(std::string inputFile, std::string id);
/** /**
* @internal * @internal
* Import and initialize a ThermoPhase object * Import and initialize a ThermoPhase object
* using an XML tree. * using an XML tree.
* Here we read extra information about the XML description * Here we read extra information about the XML description
* of a phase. Regular information about elements and species * of a phase. Regular information about elements and species
* and their reference state thermodynamic information * and their reference state thermodynamic information
* have already been read at this point. * have already been read at this point.
* For example, we do not need to call this function for * For example, we do not need to call this function for
* ideal gas equations of state. * ideal gas equations of state.
* This function is called from importPhase() * This function is called from importPhase()
* after the elements and the * after the elements and the
* species are initialized with default ideal solution * species are initialized with default ideal solution
* level data. * level data.
* *
* @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 * complete XML tree
* description of the phase, including all of the * description of the phase, including all of the
* species data. In other words while "phase" must * species data. In other words while "phase" must
* point to an XML phase object, it must have * point to an XML phase object, it must have
* sibling nodes "speciesData" that describe * sibling nodes "speciesData" that describe
* the species in the phase. * 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 * to see if phaseNode is pointing to the phase
* with the correct id. * with the correct id.
*/ */
virtual void initThermoXML(XML_Node& phaseNode, std::string id); virtual void initThermoXML(XML_Node& phaseNode, std::string id);
/** /**
* @internal Initialize. This method is provided to allow * @internal Initialize. This method is provided to allow
* subclasses to perform any initialization required after all * subclasses to perform any initialization required after all
* species have been added. For example, it might be used to * species have been added. For example, it might be used to
* resize internal work arrays that must have an entry for * resize internal work arrays that must have an entry for
* each species. The base class implementation does nothing, * each species. The base class implementation does nothing,
* and subclasses that do not require initialization do not * and subclasses that do not require initialization do not
* need to overload this method. When importing a CTML phase * need to overload this method. When importing a CTML phase
* description, this method is called just prior to returning * description, this method is called just prior to returning
* from function importPhase. * from function importPhase.
* *
* @see importCTML.cpp * @see importCTML.cpp
*/ */
virtual void initThermo(); virtual void initThermo();
// The following methods are used by the clib interface // The following methods are used by the clib interface
// library, and should not be used by application programs. // library, and should not be used by application programs.
/** /**
* @internal * @internal
* Index number. This method can be used to identify the * Index number. This method can be used to identify the
* location of a phase object in a list, and is used by the * location of a phase object in a list, and is used by the
* interface library (clib) routines for this purpose. * interface library (clib) routines for this purpose.
*/ */
int index() { return m_index; } int index() { return m_index; }
/** /**

View file

@ -25,257 +25,275 @@ using namespace std;
namespace Cantera { namespace Cantera {
/*
* 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;
}
/*
* ~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;
}
/*
* ------------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 {
/* /*
* Default constructor * Call the function that makes sure the local copy of the
* species reference thermo functions are up to date for the
* current temperature.
*/ */
VPStandardStateTP::VPStandardStateTP() : _updateRefStateThermo();
ThermoPhase(),
m_tlast(-1.0),
m_plast(-1.0)
{
}
/* /*
* Copy Constructor: * Copy the enthalpy function into return vector.
*
* 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) : copy(m_h0_RT.begin(), m_h0_RT.end(), hrt);
ThermoPhase(), }
m_tlast(-1.0),
m_plast(-1.0)
{
*this = b;
}
/*
* 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 {
/* /*
* operator=() * Call the function that makes sure the local copy of
* * the species reference thermo functions are up to date
* Note this stuff will not work until the underlying phase * for the current temperature.
* has a working assignment operator
*/ */
VPStandardStateTP& VPStandardStateTP:: _updateRefStateThermo();
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) * Copy the gibbs function into return vector.
*
* This destructor does nothing. All of the owned objects
* handle themselves.
*/ */
VPStandardStateTP::~VPStandardStateTP() { 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 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 {
/* /*
* Duplication function. * Call the function that makes sure the local copy of
* This calls the copy constructor for this object. * the species reference thermo functions are up to date
* for the current temperature.
*/ */
ThermoPhase* VPStandardStateTP::duplMyselfAsThermoPhase() { _updateRefStateThermo();
VPStandardStateTP* vptp = new VPStandardStateTP(*this);
return (ThermoPhase *) vptp;
}
/* /*
* -------------- Utilities ------------------------------- * 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.
*/
void VPStandardStateTP::getCp_R_ref(doublereal *cpr) const {
/* /*
* ------------Molar Thermodynamic Properties ------------------------- * Call the function that makes sure the local copy of
* the species reference thermo functions are up to date
* for the current temperature.
*/ */
_updateRefStateThermo();
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 ----------------- * Copy the gibbs function into return vector.
*/ */
copy(m_cp0_R.begin(), m_cp0_R.end(), cpr);
}
/** /*
* Get the array of non-dimensional species chemical potentials * Perform initializations after all species have been
* These are partial molar Gibbs free energies. * added.
* \f$ \mu_k / \hat R T \f$. */
* Units: unitless void VPStandardStateTP::initThermo() {
* initLengths();
* We close the loop on this function, here, calling ThermoPhase::initThermo();
* 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 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 {
/*
* 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);
}
/**
* 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.
*/
_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 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.
*/
_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.
*/
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.
*/
void VPStandardStateTP::initThermo() {
initLengths();
ThermoPhase::initThermo();
}
/**
* Initialize the internal lengths. * Initialize the internal lengths.
* (this is not a virtual function) * (this is not a virtual function)
*/ */
@ -286,19 +304,25 @@ namespace Cantera {
m_g0_RT.resize(leng); m_g0_RT.resize(leng);
m_cp0_R.resize(leng); m_cp0_R.resize(leng);
m_s0_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 * 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 * complete XML tree
* description of the phase, including all of the * description of the phase, including all of the
* species data. In other words while "phase" must * species data. In other words while "phase" must
* point to an XML phase object, it must have * point to an XML phase object, it must have
* sibling nodes "speciesData" that describe * sibling nodes "speciesData" that describe
* the species in the phase. * 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 * to see if phaseNode is pointing to the phase
* with the correct id. * with the correct id.
* *
@ -310,42 +334,45 @@ namespace Cantera {
ThermoPhase::initThermoXML(phaseNode, id); ThermoPhase::initThermoXML(phaseNode, id);
} }
/** /*
* void _updateRefStateThermo() (private, const) * void _updateRefStateThermo() (protected, virtual, const)
* *
* This function gets called for every call to functions in this * This function gets called for every call to functions in this
* class. It checks to see whether the temperature has changed and * class. It checks to see whether the temperature has changed and
* thus the reference thermodynamics functions for all of the species * thus the reference thermodynamics functions for all of the species
* must be recalculated. * must be recalculated.
* If the temperature has changed, the species thermo manager is called * If the temperature has changed, the species thermo manager is called
* to recalculate G, Cp, H, and S at the current temperature. * to recalculate G, Cp, H, and S at the current temperature.
*/ */
void VPStandardStateTP::_updateRefStateThermo() const { void VPStandardStateTP::_updateRefStateThermo() const {
doublereal tnow = temperature(); doublereal tnow = temperature();
if (m_tlast != tnow) { if (m_tlast != tnow) {
m_spthermo->update(tnow, DATA_PTR(m_cp0_R), DATA_PTR(m_h0_RT), m_spthermo->update(tnow, DATA_PTR(m_cp0_R), DATA_PTR(m_h0_RT),
DATA_PTR(m_s0_R)); DATA_PTR(m_s0_R));
m_tlast = tnow; m_tlast = tnow;
for (int k = 0; k < m_kk; k++) { for (int k = 0; k < m_kk; k++) {
m_g0_RT[k] = m_h0_RT[k] - m_s0_R[k]; m_g0_RT[k] = m_h0_RT[k] - m_s0_R[k];
} }
}
} }
}
/** /*
* void _updateStandardStateThermo() (private, const) * void _updateStandardStateThermo() (protected, virtual, const)
* *
* This function gets called for every call to functions in this * This function gets called for every call to functions in this
* class. It checks to see whether the temperature has changed and * class. It checks to see whether the temperature has changed and
* thus the ss thermodynamics functions for all of the species * thus the ss thermodynamics functions for all of the species
* must be recalculated. * must be recalculated.
*/ */
void VPStandardStateTP::_updateStandardStateThermo() const { void VPStandardStateTP::_updateStandardStateThermo() const {
doublereal tnow = temperature(); doublereal tnow = temperature();
if (m_tlast != tnow) { doublereal pnow = pressure();
_updateRefStateThermo(); if (m_tlast != tnow || m_plast != pnow) {
} err("getStandardVolumes");
m_tlast = tnow;
m_plast = pnow;
} }
}
} }

View file

@ -29,24 +29,31 @@ namespace Cantera {
/** /**
* @ingroup thermoprops * @ingroup thermoprops
* *
* This is a filter class for ThermoPhase that implements * This is a filter class for ThermoPhase that implements some prepatory
* a variable pressure standard state for ThermoPhase objects. * 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 * There are also temporary
* itself is based around the general concepts of * variables for holding the species reference-state values of Cp, H, S, and V at the
* VPStandardStateTP. Therefore, there really isn't much going * last temperature and reference pressure called. These functions are not recalculated
* on here. However, this may change. The ThermoPhase object * if a new call is made using the previous temperature.
* itself could change. Additionally, this object may revolve *
* around the molality unit scale in the near future. We will * @nosubgrouping
* have to see how things fare.
*/ */
class VPStandardStateTP : public ThermoPhase { class VPStandardStateTP : public ThermoPhase {
public: public:
/*!
*
* @name Constructors and Duplicators for %VPStandardStateTP
*
*/
/// Constructor. /// Constructor.
VPStandardStateTP(); VPStandardStateTP();
@ -64,12 +71,12 @@ namespace Cantera {
*/ */
virtual ThermoPhase *duplMyselfAsThermoPhase(); virtual ThermoPhase *duplMyselfAsThermoPhase();
/** //@}
*
* @name Utilities
* @{
*/
/**
* @name Utilities (VPStandardStateTP)
*/
//@{
/** /**
* Equation of state type flag. The base class returns * Equation of state type flag. The base class returns
* zero. Subclasses should define this to return a unique * zero. Subclasses should define this to return a unique
@ -78,88 +85,10 @@ namespace Cantera {
*/ */
virtual int eosType() const { return 0; } 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)
//@{ //@{
/** /**
@ -176,20 +105,17 @@ namespace Cantera {
*/ */
virtual void getChemPotentials_RT(doublereal* mu) const; 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, * @name Properties of the Standard State of the Species in the Solution (VPStandardStateTP)
* this pass-through routine doesn't add anything to the
* ThermoPhase description.
* *
* However, we assume these methods exist for inherited objects. * Within VPStandardStateTP, these properties are calculated via a common routine, _updateStandardStateThermo(),
* Therefore, we will bring the error routines up to this object * 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. //!Get the array of chemical potentials at unit activity.
/*! /*!
@ -199,9 +125,7 @@ namespace Cantera {
* @param mu Output vector of standard state chemical potentials. * @param mu Output vector of standard state chemical potentials.
* length = m_kk. units are J / kmol. * length = m_kk. units are J / kmol.
*/ */
virtual void getStandardChemPotentials(doublereal* mu) const { virtual void getStandardChemPotentials(doublereal* mu) const;
err("getStandardChemPotentials");
}
/** /**
* Get the nondimensional Enthalpy functions for the species * Get the nondimensional Enthalpy functions for the species
@ -211,9 +135,7 @@ namespace Cantera {
* @param hrt Output vector of standard state enthalpies. * @param hrt Output vector of standard state enthalpies.
* length = m_kk. units are unitless. * length = m_kk. units are unitless.
*/ */
virtual void getEnthalpy_RT(doublereal* hrt) const { virtual void getEnthalpy_RT(doublereal* hrt) const;
err("getEnthalpy_RT");
}
/** /**
* Get the array of nondimensional Enthalpy functions for the * Get the array of nondimensional Enthalpy functions for the
@ -223,9 +145,7 @@ namespace Cantera {
* @param sr Output vector of nondimensional standard state * @param sr Output vector of nondimensional standard state
* entropies. length = m_kk. * entropies. length = m_kk.
*/ */
virtual void getEntropy_R(doublereal* sr) const { virtual void getEntropy_R(doublereal* sr) const;
err("getEntropy_R");
}
/** /**
* Get the nondimensional Gibbs functions for the species * Get the nondimensional Gibbs functions for the species
@ -235,9 +155,7 @@ namespace Cantera {
* @param grt Output vector of nondimensional standard state * @param grt Output vector of nondimensional standard state
* Gibbs free energies. length = m_kk. * Gibbs free energies. length = m_kk.
*/ */
virtual void getGibbs_RT(doublereal* grt) const { virtual void getGibbs_RT(doublereal* grt) const;
err("getGibbs_RT");
}
/** /**
* Get the nondimensional Gibbs functions for the standard * Get the nondimensional Gibbs functions for the standard
@ -247,35 +165,35 @@ namespace Cantera {
* Gibbs free energies. length = m_kk. * Gibbs free energies. length = m_kk.
* units are J/kmol. * units are J/kmol.
*/ */
virtual void getPureGibbs(doublereal* gpure) const { virtual void getPureGibbs(doublereal* gpure) const;
err("getPureGibbs");
}
/** /**
* Returns the vector of nondimensional * Returns the vector of nondimensional
* internal Energies of the standard state at the current temperature * internal Energies of the standard state at the current temperature
* and pressure of the solution for each species. * 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 * @param urt Output vector of nondimensional standard state
* internal energies. length = m_kk. * internal energies. length = m_kk.
*/ */
virtual void getIntEnergy_RT(doublereal *urt) const { virtual void getIntEnergy_RT(doublereal *urt) const;
err("getIntEnergy_RT");
}
/** /**
* Get the nondimensional Heat Capacities at constant * Get the nondimensional Heat Capacities at constant
* pressure for the standard state of the species * pressure for the standard state of the species
* at the current T and P. * 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 * @param cpr Output vector containing the
* the nondimensional Heat Capacities at constant * the nondimensional Heat Capacities at constant
* pressure for the standard state of the species. * pressure for the standard state of the species.
* Length: m_kk. * Length: m_kk.
*/ */
virtual void getCp_R(doublereal* cpr) const { virtual void getCp_R(doublereal* cpr) const;
err("getCp_R");
}
/** /**
* Get the molar volumes of each species in their standard * Get the molar volumes of each species in their standard
@ -283,15 +201,47 @@ namespace Cantera {
* <I>T</I> and <I>P</I> of the solution. * <I>T</I> and <I>P</I> of the solution.
* units = m^3 / kmol * 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. * @param vol Output vector of species volumes. length = m_kk.
* units = m^3 / kmol * units = m^3 / kmol
*/ */
virtual void getStandardVolumes(doublereal *vol) const { virtual void getStandardVolumes(doublereal *vol) const;
err("getStandardVolumes");
}
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,37 +301,43 @@ namespace Cantera {
*/ */
virtual void getCp_R_ref(doublereal *cprt) const; virtual void getCp_R_ref(doublereal *cprt) const;
/////////////////////////////////////////////////////// //! Recalculate the Reference state thermo functions
// /*!
// The methods below are not virtual, and should not * This function checks to see whether the temperature has changed and
// be overloaded. * 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 Specific Properties
* @{
*/ */
protected:
/** //! Recalculate the Reference state thermo functions
* @name Setting the State /*!
* * This function checks to see whether the temperature has changed and
* These methods set all or part of the thermodynamic * thus the reference thermodynamics functions for all of the species
* state. * 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.
*/ */
virtual void _updateRefStateThermo() const;
//@} //@}
/**
* @name Chemical Equilibrium public:
* Chemical equilibrium.
* @{ //! @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 * Set equation of state parameter values from XML
@ -396,31 +352,9 @@ namespace Cantera {
*/ */
virtual void setParametersFromXML(const XML_Node& eosdata) {} virtual void setParametersFromXML(const XML_Node& eosdata) {}
//! @internal Initialize the object
//--------------------------------------------------------- /*!
/// @name Critical state properties. * This method is provided to allow
/// 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
* subclasses to perform any initialization required after all * subclasses to perform any initialization required after all
* species have been added. For example, it might be used to * species have been added. For example, it might be used to
* resize internal work arrays that must have an entry for * 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 * and subclasses that do not require initialization do not
* need to overload this method. When importing a CTML phase * need to overload this method. When importing a CTML phase
* description, this method is called just prior to returning * description, this method is called just prior to returning
* from function importPhase. * from function importPhase().
* *
* @see importCTML.cpp * @see importCTML.cpp
*/ */
virtual void initThermo(); virtual void initThermo();
/** //! Initialize a ThermoPhase object, potentially reading activity
* Import and initialize a ThermoPhase object //! 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 * @param phaseNode This object must be the phase node of a
* complete XML tree * complete XML tree
@ -448,11 +395,17 @@ namespace Cantera {
* to see if phaseNode is pointing to the phase * to see if phaseNode is pointing to the phase
* with the correct id. * with the correct id.
*/ */
void initThermoXML(XML_Node& phaseNode, std::string id); virtual void initThermoXML(XML_Node& phaseNode, std::string id);
private: private:
//! @internal Initialize the internal lengths in this object.
/*!
* Note this is not a virtual function.
*/
void initLengths(); void initLengths();
//@}
protected: protected:
//! The last temperature at which the reference thermodynamic properties were calculated at. //! The last temperature at which the reference thermodynamic properties were calculated at.
@ -485,6 +438,12 @@ namespace Cantera {
*/ */
mutable vector_fp m_s0_R; 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 * Vector containing the species Standard State enthalpies at T = m_tlast
* and P = m_plast. * and P = m_plast.
@ -509,38 +468,21 @@ namespace Cantera {
*/ */
mutable vector_fp m_sss_R; 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: private:
/** /*!
* VPStandardStateTP has its own err routine * VPStandardStateTP has its own err routine
*
*/ */
doublereal err(std::string msg) const; 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 #endif