Cantera  2.0
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Attributes | Friends | List of all members
Elements Class Reference

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

#include <Elements.h>

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)
 Assignment 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.
 
int elementType (int m) const
 Return the element constraint type.
 
int changeElementType (int m, int elem_type)
 Change the element type of the mth constraint.
 
const vector_fpatomicWeights () 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, int elem_type=CT_ELEM_TYPE_ABSPOS)
 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 () const
 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.
 
vector_int m_elem_type
 Vector of element types.
 
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 114 of file Elements.h.

Constructor & Destructor Documentation

Elements ( )

Default constructor for the elements class.

Definition at line 215 of file Elements.cpp.

~Elements ( )

Default destructor for the elements class.

Definition at line 230 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
rightReference to the object to be copied.

Definition at line 237 of file Elements.cpp.

References Elements::operator=().

Member Function Documentation

Elements & operator= ( const Elements right)

Assignment 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
rightReference to the object to be copied.

Definition at line 245 of file Elements.cpp.

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

Referenced by Elements::Elements().

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
enameString, 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
CanteraErrorIf a match is not found, a CanteraError is thrown as well

Definition at line 164 of file Elements.cpp.

References Cantera::aWTable.

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

doublereal atomicWeight ( int  m) const
inline

Atomic weight of element m.

Parameters
melement index

Definition at line 172 of file Elements.h.

References Elements::m_atomicWeights.

int atomicNumber ( int  m) const
inline

Atomic number of element m.

Parameters
melement index

Definition at line 180 of file Elements.h.

References Elements::m_atomicNumbers.

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
mElement index

Definition at line 310 of file Elements.cpp.

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

int elementType ( int  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

Parameters
mElement index
Returns
Returns the element 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

Definition at line 334 of file Elements.cpp.

References Elements::m_elem_type.

int changeElementType ( int  m,
int  elem_type 
)

Change the element type of the mth constraint.

Reassigns an element type

Parameters
mElement index
elem_typeNew elem type to be assigned
Returns
Returns the old element type

Definition at line 348 of file Elements.cpp.

References Elements::m_elem_type.

const vector_fp& atomicWeights ( ) const
inline

vector of element atomic weights

Definition at line 225 of file Elements.h.

References Elements::m_atomicWeights.

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 234 of file Elements.h.

References Elements::m_mm.

Referenced by Elements::elementName().

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
nameString containing the index.

Definition at line 286 of file Elements.cpp.

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

string elementName ( int  m) const

Name of the element with index m.

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

Definition at line 301 of file Elements.cpp.

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

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 262 of file Elements.h.

References Elements::m_elementNames.

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
symbolstring symbol for the element.
weightAtomic weight of the element. If no argument is provided, a lookup is attempted.

Definition at line 369 of file Elements.cpp.

References CT_ELEM_TYPE_ABSPOS, CT_ELEM_TYPE_ELECTRONCHARGE, Elements::LookupWtElements(), Elements::m_atomicWeights, Elements::m_elem_type, Elements::m_elementNames, Elements::m_elementsFrozen, and Elements::m_mm.

Referenced by Elements::addElement().

void addElement ( const XML_Node e)

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

Parameters
eReference 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 393 of file Elements.cpp.

References Elements::addElement().

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 only if the element hasn't been added before.

This is accomplished via a string match on symbol.

Parameters
symbolstring symbol for the element.
weightAtomic weight of the element. If no argument is provided, a lookup is attempted.
atomicNumberdefaults to 0
entropy298Value 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.
elem_typeNew elem type to be assigned. The default is a regular element, CT_ELEM_TYPE_ABSPOS

Definition at line 414 of file Elements.cpp.

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

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

void addUniqueElement ( const XML_Node e)

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

Parameters
eReference 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 466 of file Elements.cpp.

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

void addElementsFromXML ( const XML_Node phase)

Add multiple elements from a XML_Node phase description.

Parameters
phaseXML_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().

void freezeElements ( )

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

Definition at line 271 of file Elements.cpp.

References Elements::m_elementsFrozen.

bool elementsFrozen ( ) const

True if freezeElements has been called.

Definition at line 492 of file Elements.cpp.

References Elements::m_elementsFrozen.

void clear ( )
bool ready ( ) const

True if both elements and species have been frozen.

Definition at line 517 of file Elements.cpp.

References Elements::m_elementsFrozen.

void subscribe ( )

subscribe to this object

Increment by one the number of subscriptions to this object.

Definition at line 582 of file Elements.cpp.

References Elements::numSubscribers.

int unsubscribe ( )

unsubscribe to this object

decrement by one the number of subscriptions to this object.

Definition at line 586 of file Elements.cpp.

References Elements::numSubscribers.

int reportSubscriptions ( ) const

report the number of subscriptions

Definition at line 591 of file Elements.cpp.

References Elements::numSubscribers.

Member Data Documentation

int m_mm
protected
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 365 of file Elements.h.

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

vector_fp m_atomicWeights
protected

Vector of element atomic weights:

units = kg / kmol

Definition at line 372 of file Elements.h.

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

vector_int m_atomicNumbers
protected

Vector of element atomic numbers:

Definition at line 378 of file Elements.h.

Referenced by Elements::addUniqueElement(), Elements::atomicNumber(), 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 384 of file Elements.h.

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

vector_fp m_entropy298
protected

Entropy at 298.15 K and 1 bar of stable state.

units J kmol-1

Definition at line 390 of file Elements.h.

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

vector_int m_elem_type
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 402 of file Elements.h.

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

vector< Elements * > Global_Elements_List
static

Vector of pointers to Elements Objects.

Definition at line 410 of file Elements.h.


The documentation for this class was generated from the following files: