161 string s3 = ename.substr(0,3);
162 for (
int i = 0; i < num; i++) {
167 throw CanteraError(
"LookupWtElements",
"element not found");
174 string s3 = ename.substr(0,3);
175 for (
int i = 0; i < num; i++) {
180 throw CanteraError(
"LookupWtElements",
"element not found");
198 "elements cannot be added after species.") {}
205 Elements::Elements() :
207 m_elementsFrozen(false),
212 "Functionality is now part of class Phase. "
213 "To be removed after Cantera 2.2.");
226 throw CanteraError(
"~Elements",
"numSubscribers not zero");
232 m_elementsFrozen(false),
240 if (&right ==
this) {
281 for (
int i = 0; i <
m_mm; i++) {
306 "Elements::entropy298",
307 "Entropy at 298 K of element is unknown");
363 if (weight == -12345.0) {
386 doublereal weight =
fpValue(e[
"atomicWt"]);
387 string symbol = e[
"name"];
405 int atomicNumber_, doublereal entropy298,
408 if (weight == -12345.0) {
446 "Duplicate Elements (" + symbol +
") have different weights");
457 doublereal weight = 0.0;
463 anum = atoi(
stripws(e[
"atomicNumber"]).c_str());
465 string symbol = e[
"name"];
516 if (! phase.
hasChild(
"elementArray")) {
518 "phase XML node doesn't have \"elementArray\" XML Node");
521 vector<string> enames;
525 string element_database =
"elements.xml";
527 element_database = elements[
"datasrc"];
536 local_db = &root.
child(
"elementData");
539 int nel =
static_cast<int>(enames.size());
543 for (i = 0; i < nel; i++) {
554 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.
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.
double atomicWeight
atomic weight in kg / kg-mol
void getStringArray(const XML_Node &node, std::vector< std::string > &v)
This function interprets the value portion of an XML element as a string.
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.
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.