Cantera
2.2.1
|
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... | |
Elements & | operator= (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_fp & | atomicWeights () 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 |
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 116 of file Elements.h.
Elements | ( | ) |
Default constructor for the elements class.
Definition at line 205 of file Elements.cpp.
References Cantera::warn_deprecated().
~Elements | ( | ) |
Default destructor for the elements class.
Definition at line 223 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 230 of file Elements.cpp.
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 238 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.
|
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 158 of file Elements.cpp.
References awData::atomicWeight, and Cantera::aWTable.
Referenced by Elements::addElement(), and Elements::addUniqueElement().
|
inline |
Atomic weight of element m.
m | element index |
Definition at line 174 of file Elements.h.
References Elements::m_atomicWeights.
|
inline |
Atomic number of element m.
m | element 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
m | Element index |
Definition at line 303 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 327 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 341 of file Elements.cpp.
References Elements::m_elem_type.
|
inline |
vector of element atomic weights
Definition at line 227 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 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.
name | String containing the index. |
Definition at line 279 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 294 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 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.
symbol | string symbol for the element. |
weight | Atomic weight of the element. If no argument is provided, a lookup is attempted. |
Definition at line 361 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 384 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.
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 404 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 455 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.
phase | XML_Node reference to a phase |
Definition at line 512 of file Elements.cpp.
References Elements::addUniqueElement(), XML_Node::child(), XML_Node::findByAttr(), Cantera::get_XML_File(), Cantera::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 264 of file Elements.cpp.
References Elements::m_elementsFrozen.
bool elementsFrozen | ( | ) | const |
True if freezeElements has been called.
Definition at line 481 of file Elements.cpp.
References Elements::m_elementsFrozen.
void clear | ( | ) |
Remove all elements.
Definition at line 491 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 506 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 567 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 571 of file Elements.cpp.
References Elements::numSubscribers.
int reportSubscriptions | ( | ) | const |
report the number of subscriptions
Definition at line 576 of file Elements.cpp.
References Elements::numSubscribers.
|
protected |
Number of elements.
Definition at line 359 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 367 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 374 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 380 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 386 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 392 of file Elements.h.
Referenced by Elements::addUniqueElement(), Elements::clear(), Elements::entropyElement298(), and Elements::operator=().
|
protected |
Vector of element types.
Definition at line 395 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 404 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 412 of file Elements.h.