Cantera
2.0
|
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 | |
Elements & | operator= (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_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, 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 |
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.
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.
copy constructor
This copy constructor just calls the assignment operator for this class. It sets the number of subscribers to zer0.
right | Reference to the object to be copied. |
Definition at line 237 of file Elements.cpp.
References Elements::operator=().
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
right | Reference 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().
|
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.
ename | String, Only the first 3 characters are significant |
CanteraError | If 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().
|
inline |
Atomic weight of element m.
m | element index |
Definition at line 172 of file Elements.h.
References Elements::m_atomicWeights.
|
inline |
Atomic number of element m.
m | element 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
m | Element 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
m | Element index |
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
m | Element index |
elem_type | New elem type to be assigned |
Definition at line 348 of file Elements.cpp.
References Elements::m_elem_type.
|
inline |
vector of element atomic weights
Definition at line 225 of file Elements.h.
References Elements::m_atomicWeights.
|
inline |
Inline function that returns the number of elements in the object.
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.
name | String 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
.
m | Element 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().
|
inline |
Returns a string vector containing the element names.
Returns a read-only reference to the vector of element names.
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.
symbol | string symbol for the element. |
weight | Atomic 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.
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 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.
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. |
elem_type | New 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.
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 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.
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().
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 | ( | ) |
Remove all elements.
Definition at line 502 of file Elements.cpp.
References Elements::m_atomicWeights, Elements::m_elem_type, Elements::m_elementNames, Elements::m_elementsFrozen, Elements::m_entropy298, and Elements::m_mm.
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.
|
protected |
Number of elements.
Definition at line 357 of file Elements.h.
Referenced by Elements::addElement(), Elements::addUniqueElement(), Elements::clear(), Elements::elementIndex(), Elements::entropyElement298(), Elements::nElements(), and Elements::operator=().
|
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().
|
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=().
|
protected |
Vector of element atomic numbers:
Definition at line 378 of file Elements.h.
Referenced by Elements::addUniqueElement(), Elements::atomicNumber(), and Elements::operator=().
|
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=().
|
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=().
|
protected |
Vector of element types.
Definition at line 393 of file Elements.h.
Referenced by Elements::addElement(), Elements::addUniqueElement(), Elements::changeElementType(), Elements::clear(), Elements::elementType(), and Elements::operator=().
|
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().
|
static |
Vector of pointers to Elements Objects.
Definition at line 410 of file Elements.h.