165 string s3 = ename.substr(0,3);
166 for (
int i = 0; i < num; i++) {
171 throw CanteraError(
"LookupWtElements",
"element not found");
178 string s3 = ename.substr(0,3);
179 for (
int i = 0; i < num; i++) {
184 throw CanteraError(
"LookupWtElements",
"element not found");
206 "elements cannot be added after species.") {}
213 Elements::Elements() :
215 m_elementsFrozen(false),
232 throw CanteraError(
"~Elements",
"numSubscribers not zero");
238 m_elementsFrozen(false),
246 if (&right ==
this) {
287 for (
int i = 0; i <
m_mm; i++) {
312 "Elements::entropy298",
313 "Entropy at 298 K of element is unknown");
370 if (weight == -12345.0) {
394 doublereal weight =
fpValue(e[
"atomicWt"]);
395 string symbol = e[
"name"];
414 doublereal weight,
int atomicNumber_, doublereal entropy298,
417 if (weight == -12345.0) {
455 "Duplicate Elements (" + symbol +
") have different weights");
467 doublereal weight = 0.0;
473 anum = atoi(
stripws(e[
"atomicNumber"]).c_str());
475 string symbol = e[
"name"];
526 if (! phase.
hasChild(
"elementArray")) {
528 "phase xml node doesn't have \"elementArray\" XML Node");
531 vector<string> enames;
535 string element_database =
"elements.xml";
537 element_database = elements[
"datasrc"];
547 local_db = &root.
child(
"ctml/elementData");
551 int nel =
static_cast<int>(enames.size());
555 for (i = 0; i < nel; i++) {
568 throw CanteraError(
"addElementsFromXML",
"no data for element "
std::string elementName(int m) const
Name of the element with index m.
doublereal fpValue(const std::string &val)
Translate a string into one doublereal value.
XML_Node * findByAttr(const std::string &attr, const std::string &val, int depth=100000) const
This routine carries out a recursive search for an XML node based on an attribute of each XML node...
std::string int2str(const int n, const std::string &fmt)
Convert an int to a string using a format converter.
doublereal LookupWtElements(const std::string &ename)
Function to look up an atomic weight This function looks up the argument string in the database above...
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.
XML_Node * get_XML_File(const std::string &file, int debug)
Return a pointer to the XML tree for a Cantera input file.
CTML ("Cantera Markup Language") is the variant of XML that Cantera uses to store data...
void clear()
Remove all elements.
void addElement(const std::string &symbol, doublereal weight=-12345.0)
Add an element to the current set of elements in the current object.
Elements()
Default constructor for the elements class.
Class XML_Node is a tree-based representation of the contents of an XML file.
Contains the LookupWtElements function and the definitions of element constraint types.
void warn_deprecated(const std::string &method, const std::string &extra)
Print a warning indicating that method is deprecated.
bool elementsFrozen() const
True if freezeElements has been called.
void subscribe()
subscribe to this object
#define CT_ELEM_TYPE_ABSPOS
Normal element constraint consisting of positive coefficients for the formula matrix.
vector_int m_elem_type
Vector of element types.
#define CT_ELEM_TYPE_ELECTRONCHARGE
This refers to conservation of electrons.
void freezeElements()
Prohibit addition of more elements, and prepare to add species.
int reportSubscriptions() const
report the number of subscriptions
#define AssertThrowMsg(expr, procedure, message)
Assertion must be true or an error is thrown.
bool ready() const
True if both elements and species have been frozen.
XML_Node & child(const size_t n) const
Return a changeable reference to the n'th child of the current node.
bool m_elementsFrozen
boolean indicating completion of object
std::string stripws(const std::string &s)
Strip the leading and trailing white space from a string.
static struct awData aWTable[]
aWTable is a vector containing the atomic weights database.
vector_fp m_atomicWeights
Vector of element atomic weights:
ElementsFrozen(string func)
Constructor for class.
Object containing the elements that make up species in a phase.
Classes providing support for XML data files.
Base class for exceptions thrown by Cantera classes.
int nElements() const
Inline function that returns the number of elements in the object.
Exception class to indicate a fixed set of elements.
bool hasChild(const std::string &ch) const
Tests whether the current node has a child node with a particular name.
static std::vector< Elements * > Global_Elements_List
Vector of pointers to Elements Objects.
#define ENTROPY298_UNKNOWN
Number indicating we don't know the entropy of the element in its most stable state at 298...
#define AssertTrace(expr)
Assertion must be true or an error is thrown.
doublereal entropyElement298(int m) const
Entropy at 298.15 K and 1 bar of stable state of the element.
Elements & operator=(const Elements &right)
Assignment operator.
void getStringArray(const Cantera::XML_Node &node, std::vector< std::string > &v)
This function interprets the value portion of an XML element as a string.
double atomicWeight
atomic weight in kg / kg-mol
std::vector< std::string > m_elementNames
Vector of strings containing the names of the elements.
static double LookupWtElements(const std::string &ename)
Static function to look up an atomic weight.
void addElementsFromXML(const XML_Node &phase)
Add multiple elements from a XML_Node phase description.
Contains declarations for string manipulation functions within Cantera.
vector_int m_atomicNumbers
Vector of element atomic numbers:
int m_mm
Number of elements.
int changeElementType(int m, int elem_type)
Change the element type of the mth constraint.
vector_fp m_entropy298
Entropy at 298.15 K and 1 bar of stable state.
XML_Node & root() const
Return the root of the current XML_Node tree.
int elementIndex(const std::string &name) const
Function that returns the index of an element.
doublereal fpValueCheck(const std::string &val)
Translate a string into one doublereal value, with error checking.
~Elements()
Default destructor for the elements class.
Definitions for the classes that are thrown when Cantera experiences an error condition (also contain...
int numSubscribers
Number of Constituents Objects that use this object.
bool hasAttrib(const std::string &a) const
Tests whether the current node has an attribute with a particular name.
int unsubscribe()
unsubscribe to this object
int elementType(int m) const
Return the element constraint type.