Elements Class Reference
[Models of Phases of Matter]

Object containing the elements that make up species in a phase. More...

#include <Elements.h>

List of all members.

Public Member Functions

 Elements ()
 Default constructor for the elements class.
 ~Elements ()
 Default destructor for the elements class.
 Elements (const Elements &right)
 copy constructor
Elementsoperator= (const Elements &right)
 Assigntment operator.
doublereal atomicWeight (int m) const
 Atomic weight of element m.
int atomicNumber (int m) const
 Atomic number of element m.
doublereal entropyElement298 (int m) const
 Entropy at 298.15 K and 1 bar of stable state of the element.
const vector_fp & atomicWeights () const
 vector of element atomic weights
int nElements () const
 Inline function that returns the number of elements in the object.
int elementIndex (std::string name) const
 Function that returns the index of an element.
std::string elementName (int m) const
 Name of the element with index m.
const std::vector< std::string > & elementNames () const
 Returns a string vector containing the element names.
void addElement (const std::string &symbol, doublereal weight=-12345.0)
 Add an element to the current set of elements in the current object.
void addElement (const XML_Node &e)
 Add an element to the current set of elements in the current object.
void addUniqueElement (const std::string &symbol, doublereal weight=-12345.0, int atomicNumber=0, doublereal entropy298=ENTROPY298_UNKNOWN)
 Add an element only if the element hasn't been added before.
void addUniqueElement (const XML_Node &e)
 Add an element to the current set of elements in the current object.
void addElementsFromXML (const XML_Node &phase)
 Add multiple elements from a XML_Node phase description.
void freezeElements ()
 Prohibit addition of more elements, and prepare to add species.
bool elementsFrozen ()
 True if freezeElements has been called.
void clear ()
 Remove all elements.
bool ready () const
 True if both elements and species have been frozen.
void subscribe ()
 subscribe to this object
int unsubscribe ()
 unsubscribe to this object
int reportSubscriptions () const
 report the number of subscriptions

Static Public Member Functions

static double LookupWtElements (const std::string &ename)
 Static function to look up an atomic weight.

Static Public Attributes

static std::vector< Elements * > Global_Elements_List
 Vector of pointers to Elements Objects.

Protected Attributes

int m_mm
 Number of elements.
bool m_elementsFrozen
 boolean indicating completion of object
vector_fp m_atomicWeights
 Vector of element atomic weights:
vector_int m_atomicNumbers
 Vector of element atomic numbers:
std::vector< std::string > m_elementNames
 Vector of strings containing the names of the elements.
vector_fp m_entropy298
 Entropy at 298.15 K and 1 bar of stable state.
int numSubscribers
 Number of Constituents Objects that use this object.

Friends

class Constituents

Detailed Description

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.

Definition at line 48 of file Elements.h.


Constructor & Destructor Documentation

Elements (  ) 

Default constructor for the elements class.

Definition at line 222 of file Elements.cpp.

~Elements (  ) 

Default destructor for the elements class.

Definition at line 236 of file Elements.cpp.

References Elements::numSubscribers.

Elements ( const Elements right  ) 

copy constructor

This copy constructor just calls the assignment operator for this class. It sets the number of subscribers to zer0.

Parameters:
right Reference to the object to be copied.

Definition at line 242 of file Elements.cpp.

References Elements::operator=().


Member Function Documentation

void addElement ( const XML_Node e  ) 

Add an element to the current set of elements in the current object.

Parameters:
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.

Definition at line 375 of file Elements.cpp.

References Elements::addElement().

void addElement ( const std::string &  symbol,
doublereal  weight = -12345.0 
)

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.

Parameters:
symbol string symbol for the element.
weight Atomic weight of the element. If no argument is provided, a lookup is attempted.

Definition at line 354 of file Elements.cpp.

References Elements::LookupWtElements(), Elements::m_atomicWeights, Elements::m_elementNames, Elements::m_elementsFrozen, Elements::m_mm, and Elements::nElements().

Referenced by Elements::addElement(), and Constituents::addElement().

void addElementsFromXML ( const XML_Node phase  ) 

Add multiple elements from a XML_Node phase description.

Parameters:
phase XML_Node reference to a phase

Definition at line 523 of file Elements.cpp.

References Elements::addUniqueElement(), XML_Node::child(), XML_Node::findByAttr(), Cantera::get_XML_File(), ctml::getStringArray(), XML_Node::hasAttrib(), XML_Node::hasChild(), and XML_Node::root().

Referenced by Constituents::addElementsFromXML().

void addUniqueElement ( const XML_Node e  ) 

Add an element to the current set of elements in the current object.

Parameters:
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.

Definition at line 479 of file Elements.cpp.

References Elements::addUniqueElement(), Cantera::atofCheck(), XML_Node::child(), ENTROPY298_UNKNOWN, XML_Node::hasAttrib(), XML_Node::hasChild(), and Cantera::stripws().

void addUniqueElement ( const std::string &  symbol,
doublereal  weight = -12345.0,
int  atomicNumber = 0,
doublereal  entropy298 = ENTROPY298_UNKNOWN 
)

Add an element only if the element hasn't been added before.

This is accomplished via a string match on symbol.

Parameters:
symbol string symbol for the element.
weight Atomic weight of the element. If no argument is provided, a lookup is attempted.
atomicNumber defaults to 0
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 its ever needed.

Definition at line 430 of file Elements.cpp.

References Elements::LookupWtElements(), Elements::m_atomicNumbers, Elements::m_atomicWeights, Elements::m_elementNames, Elements::m_elementsFrozen, Elements::m_entropy298, and Elements::m_mm.

Referenced by Elements::addElementsFromXML(), Elements::addUniqueElement(), and Constituents::addUniqueElement().

int atomicNumber ( int  m  )  const [inline]

Atomic number of element m.

Parameters:
m element index

Definition at line 112 of file Elements.h.

References Elements::m_atomicNumbers.

Referenced by Constituents::atomicNumber().

doublereal atomicWeight ( int  m  )  const [inline]

Atomic weight of element m.

Parameters:
m element index

Definition at line 106 of file Elements.h.

References Elements::m_atomicWeights.

Referenced by Constituents::atomicWeight(), and Elements::LookupWtElements().

const vector_fp& atomicWeights (  )  const [inline]

vector of element atomic weights

Definition at line 124 of file Elements.h.

References Elements::m_atomicWeights.

Referenced by Constituents::atomicWeights().

void clear (  ) 

Remove all elements.

Definition at line 506 of file Elements.cpp.

References Elements::m_atomicWeights, Elements::m_elementNames, Elements::m_elementsFrozen, and Elements::m_mm.

int elementIndex ( std::string  name  )  const

Function that returns the index of an element.

Index of element named name. The index is an integer assigned to each element in the order it was added, beginning with 0 for the first element. If name is not the name of an element in the set, then the value -1 is returned.

Parameters:
name String containing the index.

Definition at line 310 of file Elements.cpp.

References Elements::m_elementNames, and Elements::m_mm.

Referenced by Constituents::elementIndex().

string elementName ( int  m  )  const

Name of the element with index m.

Parameters:
m Element index. If m < 0 or m >= nElements() an exception is thrown.

Definition at line 323 of file Elements.cpp.

References Elements::m_elementNames, and Elements::nElements().

Referenced by Constituents::elementName().

const std::vector<std::string>& elementNames (  )  const [inline]

Returns a string vector containing the element names.

Returns a read-only reference to the vector of element names.

Returns:
const vector<string>& : The vector contains the element names in their indexed order.

Definition at line 158 of file Elements.h.

References Elements::m_elementNames.

Referenced by Constituents::elementNames().

bool elementsFrozen (  )  [inline]

True if freezeElements has been called.

Definition at line 222 of file Elements.h.

References Elements::m_elementsFrozen.

Referenced by Constituents::elementsFrozen(), and Constituents::ready().

doublereal entropyElement298 ( int  m  )  const

Entropy at 298.15 K and 1 bar of stable state of the element.

units J kmol-1 K-1

Parameters:
m Element index

Definition at line 332 of file Elements.cpp.

References AssertThrowMsg, AssertTrace, ENTROPY298_UNKNOWN, Elements::m_entropy298, and Elements::m_mm.

Referenced by Constituents::entropyElement298().

void freezeElements (  ) 

Prohibit addition of more elements, and prepare to add species.

Definition at line 273 of file Elements.cpp.

References Elements::m_elementsFrozen.

Referenced by Constituents::freezeElements().

doublereal LookupWtElements ( const std::string &  ename  )  [static]

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.

Parameters:
ename String, Only the first 3 characters are significant
Returns:
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.
Exceptions:
CanteraError If a match is not found, a CanteraError is thrown as well

Definition at line 189 of file Elements.cpp.

References Elements::atomicWeight().

Referenced by Elements::addElement(), and Elements::addUniqueElement().

int nElements (  )  const [inline]

Inline function that returns the number of elements in the object.

Returns:
int: The number of elements in the object.

Definition at line 132 of file Elements.h.

References Elements::m_mm.

Referenced by Elements::addElement(), Constituents::addUniqueSpecies(), Elements::elementName(), Constituents::getAtoms(), Constituents::nAtoms(), and Constituents::nElements().

Elements & operator= ( 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

Parameters:
right Reference to the object to be copied.

Definition at line 250 of file Elements.cpp.

References Elements::m_atomicNumbers, Elements::m_atomicWeights, Elements::m_elementNames, Elements::m_elementsFrozen, Elements::m_entropy298, Elements::m_mm, and Elements::numSubscribers.

Referenced by Elements::Elements().

bool ready (  )  const

True if both elements and species have been frozen.

Definition at line 518 of file Elements.cpp.

References Elements::m_elementsFrozen.

int reportSubscriptions (  )  const

report the number of subscriptions

Definition at line 587 of file Elements.cpp.

References Elements::numSubscribers.

void subscribe (  ) 

subscribe to this object

Increment by one the number of subscriptions to this object.

Definition at line 580 of file Elements.cpp.

References Elements::numSubscribers.

Referenced by Constituents::Constituents(), and Constituents::operator=().

int unsubscribe (  ) 

unsubscribe to this object

decrement by one the number of subscriptions to this object.

Definition at line 583 of file Elements.cpp.

References Elements::numSubscribers.

Referenced by Constituents::operator=(), and Constituents::~Constituents().


Member Data Documentation

vector< Elements * > Global_Elements_List [static]

Vector of pointers to Elements Objects.

Definition at line 304 of file Elements.h.

Referenced by Constituents::operator=(), and Constituents::~Constituents().

vector_int m_atomicNumbers [protected]

Vector of element atomic numbers:

Definition at line 274 of file Elements.h.

Referenced by Elements::addUniqueElement(), Elements::atomicNumber(), and Elements::operator=().

vector_fp m_atomicWeights [protected]

Vector of element atomic weights:

units = kg / kmol

Definition at line 268 of file Elements.h.

Referenced by Elements::addElement(), Elements::addUniqueElement(), Elements::atomicWeight(), Elements::atomicWeights(), Elements::clear(), and Elements::operator=().

std::vector<std::string> m_elementNames [protected]

Vector of strings containing the names of the elements.

Note, a string search is the primary way to identify elements.

Definition at line 280 of file Elements.h.

Referenced by Elements::addElement(), Elements::addUniqueElement(), Elements::clear(), Elements::elementIndex(), Elements::elementName(), Elements::elementNames(), and Elements::operator=().

bool m_elementsFrozen [protected]

boolean indicating completion of object

If this is true, then no elements may be added to the object.

Definition at line 261 of file Elements.h.

Referenced by Elements::addElement(), Elements::addUniqueElement(), Elements::clear(), Elements::elementsFrozen(), Elements::freezeElements(), Elements::operator=(), and Elements::ready().

vector_fp m_entropy298 [protected]

Entropy at 298.15 K and 1 bar of stable state.

units J kmol-1

Definition at line 286 of file Elements.h.

Referenced by Elements::addUniqueElement(), Elements::entropyElement298(), and Elements::operator=().

int m_mm [protected]
int numSubscribers [protected]

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.

Definition at line 296 of file Elements.h.

Referenced by Elements::operator=(), Elements::reportSubscriptions(), Elements::subscribe(), Elements::unsubscribe(), and Elements::~Elements().


The documentation for this class was generated from the following files:
Generated by  doxygen 1.6.3