diff --git a/include/cantera/thermo/Elements.h b/include/cantera/thermo/Elements.h
index e9269e340..412b91cdd 100644
--- a/include/cantera/thermo/Elements.h
+++ b/include/cantera/thermo/Elements.h
@@ -1,26 +1,18 @@
/**
* @file Elements.h
- * Header file for class, Elements, which contains the elements that
- * make up species (see \ref phases and \link Cantera::Elements Elements\endlink).
- *
- * This file contains the declarations for the elements class.
+ * Contains the LookupWtElements function and the definitions of element
+ * constraint types.
*/
// Copyright 2001 California Institute of Technology
#ifndef CT_ELEMENTS_H
#define CT_ELEMENTS_H
-#undef USE_DGG_CODE
-
#include "cantera/base/ct_defs.h"
-
namespace Cantera
{
-class XML_Node;
-class ElementRangeError;
-
/*!
* @name Types of Element Constraint Equations
*
@@ -87,330 +79,21 @@ class ElementRangeError;
#define CT_ELEM_TYPE_OTHERCONSTRAINT 6
//@}
-
-//! Positive number indicating we don't know the gibbs free energy
-//! of the element in its most stable state at 298.15 K and 1 bar.
+//! Number indicating we don't know the entropy of the element in its most
+//! stable state at 298.15 K and 1 bar.
#define ENTROPY298_UNKNOWN -123456789.
-//! Object containing the elements that make up species in a phase.
-/*!
- * Class %Elements manages the elements that are part of a
- * chemistry specification. This class may support calculations
- * employing Multiple phases. In this case, a single Elements object may
- * be shared by more than one Constituents class. Reactions between
- * the phases may then be described using stoichiometry base on the
- * same Elements class object.
- *
- * The member functions return information about the elements described
- * in a particular instantiation of the class.
- *
- * @ingroup phases
- */
-class Elements
-{
-
-public:
-
- //! Default constructor for the elements class
- Elements();
-
- //! Default destructor for the elements class
- ~Elements();
-
-
- //! copy constructor
- /*!
- * This copy constructor just calls the assignment operator for this
- * class. It sets the number of subscribers to zer0.
- *
- * @param right Reference to the object to be copied.
- */
- Elements(const Elements& right);
-
- //! Assigntment operator
- /*!
- * This is the assignment operator for the Elements class.
- * Right now we pretty much do a straight uncomplicated
- * assignment. However, subscribers are not mucked with, as they
- * have to do with the address of the object to be subscribed to
- *
- * @param right Reference to the object to be copied.
- */
- Elements& operator=(const Elements& right);
-
-
- //! Static function to look up an atomic weight
- /*!
- * This static function looks up the argument string in the
- * database above and returns the associated molecular weight.
- * The data are from the periodic table.
- *
- * Note: The idea behind this function is to provide a unified
- * source for the element atomic weights. This helps to
- * ensure that mass is conserved.
- *
- * @param ename String, Only the first 3 characters are significant
- *
- * @return
- * Return value contains the atomic weight of the element
- * If a match for the string is not found, a value of -1.0 is
- * returned.
- *
- * @exception CanteraError
- * If a match is not found, a CanteraError is thrown as well
- */
- static double LookupWtElements(const std::string& ename);
-
- /// Atomic weight of element m.
- /*!
- * @param m element index
- */
- doublereal atomicWeight(size_t m) const {
- return m_atomicWeights[m];
- }
-
- /// Atomic number of element m.
- /*!
- * @param m element index
- */
- int atomicNumber(size_t m) const {
- return m_atomicNumbers[m];
- }
-
- //! Entropy at 298.15 K and 1 bar of stable state
- //! of the element
- /*!
- * units J kmol-1 K-1
- *
- * @param m Element index
- */
- doublereal entropyElement298(size_t m) const;
-
- //! Return the element constraint type
- /*!
- * Possible types include:
- *
- * CT_ELEM_TYPE_ABSPOS 0
- * CT_ELEM_TYPE_ELECTRONCHARGE 1
- * CT_ELEM_TYPE_CHARGENEUTRALITY 2
- * CT_ELEM_TYPE_LATTICERATIO 3
- * CT_ELEM_TYPE_KINETICFROZEN 4
- * CT_ELEM_TYPE_SURFACECONSTRAINT 5
- * CT_ELEM_TYPE_OTHERCONSTRAINT 6
- *
- * The default is CT_ELEM_TYPE_ABSPOS
- *
- * @param m Element index
- *
- * @return Returns the element type
- */
- int elementType(size_t m) const;
-
- //! Change the element type of the mth constraint
- /*!
- * Reassigns an element type
- *
- * @param m Element index
- * @param elem_type New elem type to be assigned
- *
- * @return Returns the old element type
- */
- int changeElementType(int m, int elem_type);
-
- /// vector of element atomic weights
- const vector_fp& atomicWeights() const {
- return m_atomicWeights;
- }
-
- /**
- * Inline function that returns the number of elements in the object.
- *
- * @return
- * \c int: The number of elements in the object.
- */
- size_t nElements() const {
- return m_mm;
- }
-
- //! Function that returns the index of an element.
- /*!
- * Index of element named \c name. The index is an integer
- * assigned to each element in the order it was added,
- * beginning with 0 for the first element. If \c name is not
- * the name of an element in the set, then the value -1 is
- * returned.
- *
- * @param name String containing the index.
- */
- size_t elementIndex(std::string name) const;
-
- //! Name of the element with index \c m.
- /*!
- * @param m Element index. If m < 0 or m >= nElements() an exception is thrown.
- */
- std::string elementName(size_t m) const;
-
- //! Returns a string vector containing the element names
- /*!
- * Returns a read-only reference to the vector of element names.
- * @return const vector& : The vector contains
- * the element names in their indexed order.
- */
- const std::vector& elementNames() const {
- return m_elementNames;
- }
-
- //! Add an element to the current set of elements in the current object.
- /*!
- * The default weight is a special value, which will cause the
- * routine to look up the actual weight via a string lookup.
- *
- * There are two interfaces to this routine. The XML interface
- * looks up the required parameters for the regular interface
- * and then calls the base routine.
- *
- * @param symbol string symbol for the element.
- * @param weight Atomic weight of the element. If no argument
- * is provided, a lookup is attempted.
- */
- void addElement(const std::string& symbol,
- doublereal weight = -12345.0);
-
- //! Add an element to the current set of elements in the current object.
- /*!
- * @param e Reference to the XML_Node containing the element information
- * The node name is the element symbol and the atomWt attribute
- * is used as the atomic weight.
- */
- void addElement(const XML_Node& e);
-
- //! Add an element only if the element hasn't been added before.
- /*!
- * This is accomplished via a string match on symbol.
- *
- * @param symbol string symbol for the element.
- * @param weight Atomic weight of the element. If no argument
- * is provided, a lookup is attempted.
- * @param atomicNumber defaults to 0
- * @param entropy298 Value of the entropy at 298 and 1 bar of the
- * element in its most stable form.
- * The default is to specify an ENTROPY298_UNKNOWN value,
- * which will cause a throw error if it's ever
- * needed.
- * @param elem_type New elem type to be assigned.
- * The default is a regular element, CT_ELEM_TYPE_ABSPOS
- */
- void addUniqueElement(const std::string& symbol,
- doublereal weight = -12345.0, int atomicNumber = 0,
- doublereal entropy298 = ENTROPY298_UNKNOWN, int elem_type = CT_ELEM_TYPE_ABSPOS);
-
- //! Add an element to the current set of elements in the current object.
- /*!
- * @param e Reference to the XML_Node containing the element information
- * The node name is the element symbol and the atomWt attribute
- * is used as the atomic weight.
- */
- void addUniqueElement(const XML_Node& e);
-
- //! Add multiple elements from a XML_Node phase description
- /*!
- * @param phase XML_Node reference to a phase
- */
- void addElementsFromXML(const XML_Node& phase);
-
- //! Prohibit addition of more elements, and prepare to add species.
- void freezeElements();
-
- //! True if freezeElements has been called.
- bool elementsFrozen() const;
-
- /// Remove all elements
- void clear();
-
- /// True if both elements and species have been frozen
- bool ready() const;
-
-
- //! subscribe to this object
- /*!
- * Increment by one the number of subscriptions to this object.
- */
- void subscribe();
-
- //! unsubscribe to this object
- /*!
- * decrement by one the number of subscriptions to this object.
- */
- int unsubscribe();
-
- //! report the number of subscriptions
- int reportSubscriptions() const;
-
-protected:
-
- /******************************************************************/
- /* Description of DATA in the Object */
- /******************************************************************/
-
- //! Number of elements.
- size_t m_mm;
-
- /* m_elementsFrozen: */
- /** boolean indicating completion of object
- *
- * If this is true, then no elements may be added to the
- * object.
- */
- bool m_elementsFrozen;
-
- /**
- * Vector of element atomic weights:
- *
- * units = kg / kmol
- */
- vector_fp m_atomicWeights;
-
- /**
- * Vector of element atomic numbers:
- *
- */
- vector_int m_atomicNumbers;
-
- /** Vector of strings containing the names of the elements
- *
- * Note, a string search is the primary way to identify elements.
- */
- std::vector m_elementNames;
-
- //! Entropy at 298.15 K and 1 bar of stable state
- /*!
- * units J kmol-1
- */
- vector_fp m_entropy298;
-
- //! Vector of element types
- vector_int m_elem_type;
-
- /**
- * Number of Constituents Objects that use this object
- *
- * Number of Constituents Objects that require this Elements object
- * to complete its definition.
- * The destructor checks to see that this is equal to zero.
- * when the element object is released.
- */
- int numSubscribers;
-
- /********* GLOBAL STATIC SECTION *************/
-
-public:
- /** Vector of pointers to Elements Objects
- *
- */
- static std::vector Global_Elements_List;
-
- friend class Phase;
-};
+//! Function to look up an atomic weight
+//! This function looks up the argument string in the database above and
+//! returns the associated molecular weight.
+//! The data are from the periodic table.
+//!
+//! Note: The idea behind this function is to provide a unified source for the
+//! element atomic weights. This helps to ensure that mass is conserved.
+//! @param ename String, Only the first 3 characters are significant
+//! @return The atomic weight of the element
+//! @exception CanteraError If a match is not found, throws a CanteraError
+double LookupWtElements(const std::string& ename);
} // namespace
diff --git a/include/cantera/thermo/Phase.h b/include/cantera/thermo/Phase.h
index 04af40c9f..c2e079f36 100644
--- a/include/cantera/thermo/Phase.h
+++ b/include/cantera/thermo/Phase.h
@@ -15,6 +15,20 @@ namespace Cantera
{
class SpeciesThermo;
+//! Exception class to indicate a fixed set of elements.
+/*!
+ * This class is used to warn the user when the number of elements
+ * are changed after at least one species is defined.
+ */
+class ElementsFrozen : public CanteraError
+{
+public:
+ //! Constructor for class
+ //! @param func Function where the error occurred.
+ ElementsFrozen(std::string func)
+ : CanteraError(func, "Elements cannot be added after species.") {}
+};
+
//! Base class for phases of matter
/*!
* Class Phase manages the species and elements in a phase, as well as the
@@ -149,8 +163,30 @@ public:
//! @param m Element index
int atomicNumber(size_t m) const;
+ //! Return the element constraint type
+ //! Possible types include:
+ //!
+ //! CT_ELEM_TYPE_TURNEDOFF -1
+ //! CT_ELEM_TYPE_ABSPOS 0
+ //! CT_ELEM_TYPE_ELECTRONCHARGE 1
+ //! CT_ELEM_TYPE_CHARGENEUTRALITY 2
+ //! CT_ELEM_TYPE_LATTICERATIO 3
+ //! CT_ELEM_TYPE_KINETICFROZEN 4
+ //! CT_ELEM_TYPE_SURFACECONSTRAINT 5
+ //! CT_ELEM_TYPE_OTHERCONSTRAINT 6
+ //!
+ //! The default is CT_ELEM_TYPE_ABSPOS.
+ //! @param m Element index
+ //! @return Returns the element type
int elementType(size_t m) const;
+ //! Change the element type of the mth constraint
+ //! Reassigns an element type.
+ //! @param m Element index
+ //! @param elem_type New elem type to be assigned
+ //! @return Returns the old element type
+ int changeElementType(int m, int elem_type);
+
//! Return a read-only reference to the vector of atomic weights.
const vector_fp& atomicWeights() const;
@@ -547,7 +583,7 @@ public:
//! Add an element.
//! @param symbol Atomic symbol std::string.
//! @param weight Atomic mass in amu.
- void addElement(const std::string& symbol, doublereal weight);
+ void addElement(const std::string& symbol, doublereal weight=-12345.0);
//! Add an element from an XML specification.
//! @param e Reference to the XML_Node where the element is described.
@@ -565,7 +601,7 @@ public:
//! error.
//! @param elem_type Specifies the type of the element constraint
//! equation. This defaults to CT_ELEM_TYPE_ABSPOS, i.e., an element.
- void addUniqueElement(const std::string& symbol, doublereal weight,
+ void addUniqueElement(const std::string& symbol, doublereal weight=-12345.0,
int atomicNumber = 0,
doublereal entropy298 = ENTROPY298_UNKNOWN,
int elem_type = CT_ELEM_TYPE_ABSPOS);
@@ -629,9 +665,6 @@ public:
virtual bool ready() const;
- //! Remove all elements and species
- void clear();
-
//! Return the State Mole Fraction Number
DEPRECATED(int stateMFNumber() const) {
return m_stateNum;
@@ -717,12 +750,21 @@ private:
//! of the the phase, this is true.
bool m_speciesFrozen;
- //! Pointer to the element object corresponding to this phase. Normally,
- //! this will be the default Element object common to all phases.
- Elements* m_Elements;
+ //! If this is true, then no elements may be added to the object.
+ bool m_elementsFrozen;
//! Vector of the species names
std::vector m_speciesNames;
+
+ size_t m_mm; //!< Number of elements.
+ vector_fp m_atomicWeights; //!< element atomic weights (kg kmol-1)
+ vector_int m_atomicNumbers; //!< element atomic numbers
+ std::vector m_elementNames; //!< element names
+ vector_int m_elem_type; //!< Vector of element types
+
+ //! Entropy at 298.15 K and 1 bar of stable state pure elements (J kmol-1)
+ vector_fp m_entropy298;
+
};
//! typedef for the base Phase class
diff --git a/src/thermo/Elements.cpp b/src/thermo/Elements.cpp
index b8d1d8fb9..1b99cb27a 100644
--- a/src/thermo/Elements.cpp
+++ b/src/thermo/Elements.cpp
@@ -9,27 +9,16 @@
// Copyright 2003 California Institute of Technology
#include "cantera/thermo/Elements.h"
-#include "cantera/base/xml.h"
-#include "cantera/base/ctml.h"
#include "cantera/base/ctexceptions.h"
-#include "cantera/base/stringUtils.h"
-using namespace ctml;
using namespace std;
-#ifdef USE_DGG_CODE
-#include