Cantera  2.1.2
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. More...
 
 ~Elements ()
 Default destructor for the elements class. More...
 
 Elements (const Elements &right)
 copy constructor More...
 
Elementsoperator= (const Elements &right)
 Assignment operator. More...
 
doublereal atomicWeight (int m) const
 Atomic weight of element m. More...
 
int atomicNumber (int m) const
 Atomic number of element m. More...
 
doublereal entropyElement298 (int m) const
 Entropy at 298.15 K and 1 bar of stable state of the element. More...
 
int elementType (int m) const
 Return the element constraint type. More...
 
int changeElementType (int m, int elem_type)
 Change the element type of the mth constraint. More...
 
const vector_fpatomicWeights () const
 vector of element atomic weights More...
 
int nElements () const
 Inline function that returns the number of elements in the object. More...
 
int elementIndex (const std::string &name) const
 Function that returns the index of an element. More...
 
std::string elementName (int m) const
 Name of the element with index m. More...
 
const std::vector< std::string > & elementNames () const
 Returns a string vector containing the element names. More...
 
void addElement (const std::string &symbol, doublereal weight=-12345.0)
 Add an element to the current set of elements in the current object. More...
 
void addElement (const XML_Node &e)
 Add an element to the current set of elements in the current object. More...
 
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. More...
 
void addUniqueElement (const XML_Node &e)
 Add an element to the current set of elements in the current object. More...
 
void addElementsFromXML (const XML_Node &phase)
 Add multiple elements from a XML_Node phase description. More...
 
void freezeElements ()
 Prohibit addition of more elements, and prepare to add species. More...
 
bool elementsFrozen () const
 True if freezeElements has been called. More...
 
void clear ()
 Remove all elements. More...
 
bool ready () const
 True if both elements and species have been frozen. More...
 
void subscribe ()
 subscribe to this object More...
 
int unsubscribe ()
 unsubscribe to this object More...
 
int reportSubscriptions () const
 report the number of subscriptions More...
 

Static Public Member Functions

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

Static Public Attributes

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

Protected Attributes

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

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.

Deprecated:
The functionality of this class was merged into class Phase in Cantera 2.0. This class will be removed in Cantera 2.2.

Definition at line 116 of file Elements.h.

Constructor & Destructor Documentation

Elements ( )

Default constructor for the elements class.

Definition at line 213 of file Elements.cpp.

References Cantera::warn_deprecated().

~Elements ( )

Default destructor for the elements class.

Definition at line 229 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 236 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 244 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 162 of file Elements.cpp.

References awData::atomicWeight, and 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 174 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 182 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 309 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 333 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 347 of file Elements.cpp.

References Elements::m_elem_type.

const vector_fp& atomicWeights ( ) const
inline

vector of element atomic weights

Definition at line 227 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 236 of file Elements.h.

References Elements::m_mm.

Referenced by Elements::elementName().

int elementIndex ( const 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 285 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 300 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 264 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 368 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 392 of file Elements.cpp.

References Elements::addElement(), and Cantera::fpValue().

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 413 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 465 of file Elements.cpp.

References Elements::addUniqueElement(), XML_Node::child(), ENTROPY298_UNKNOWN, Cantera::fpValue(), Cantera::fpValueCheck(), 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 522 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 270 of file Elements.cpp.

References Elements::m_elementsFrozen.

bool elementsFrozen ( ) const

True if freezeElements has been called.

Definition at line 491 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 516 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 581 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 585 of file Elements.cpp.

References Elements::numSubscribers.

int reportSubscriptions ( ) const

report the number of subscriptions

Definition at line 590 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 367 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 374 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 380 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 386 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 392 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 404 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 412 of file Elements.h.


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