Cantera
2.1.2
|
The ctml namespace adds functionality to the XML object, by providing standard functions that read, write, and interpret XML files and object trees. More...
Functions | |
static string | pypath () |
return the full path to the Python interpreter. More... | |
void | ct2ctml (const char *file, const int debug=0) |
Convert a cti file into a ctml file. More... | |
void | ck2cti (const std::string &in_file, const std::string &thermo_file="", const std::string &transport_file="", const std::string &id_tag="gas") |
Convert a Chemkin-format mechanism into a CTI file. More... | |
void | get_CTML_Tree (Cantera::XML_Node *node, const std::string &file, const int debug=0) |
Read an ctml file from a file and fill up an XML tree. More... | |
Cantera::XML_Node | getCtmlTree (const std::string &file) |
Read an ctml file from a file and fill up an XML tree. More... | |
void | addInteger (Cantera::XML_Node &node, const std::string &titleString, const int value, const std::string &unitsString="", const std::string &typeString="") |
This function adds a child node with the name, "integer", with a value consisting of a single integer. More... | |
void | addFloat (Cantera::XML_Node &node, const std::string &titleString, const doublereal value, const std::string &unitsString="", const std::string &typeString="", const doublereal minval=Cantera::Undef, const doublereal maxval=Cantera::Undef) |
This function adds a child node with the name, "float", with a value consisting of a single floating point number. More... | |
void | addFloatArray (Cantera::XML_Node &node, const std::string &titleString, const size_t n, const doublereal *const values, const std::string &unitsString="", const std::string &typeString="", const doublereal minval=Cantera::Undef, const doublereal maxval=Cantera::Undef) |
This function adds a child node with the name, "floatArray", with a value consisting of a comma separated list of floats. More... | |
void | addNamedFloatArray (Cantera::XML_Node &parentNode, const std::string &name, const int n, const doublereal *const vals, const std::string units="", const std::string type="", const doublereal minval=Cantera::Undef, const doublereal maxval=Cantera::Undef) |
This function adds a child node with the name given by the first parameter with a value consisting of a comma separated list of floats. More... | |
void | addString (Cantera::XML_Node &node, const std::string &titleString, const std::string &valueString, const std::string &typeString="") |
This function adds a child node with the name string with a string value to the current node. More... | |
XML_Node * | getByTitle (const Cantera::XML_Node &node, const std::string &title) |
Search the child nodes of the current node for an XML Node with a Title attribute of a given name. More... | |
std::string | getChildValue (const Cantera::XML_Node &parent, const std::string &nameString) |
This function reads a child node with the name, nameString, and returns its xml value as the return string. More... | |
void | getString (const Cantera::XML_Node &node, const std::string &titleString, std::string &valueString, std::string &typeString) |
This function reads a child node with the name string with a specific title attribute named titleString. More... | |
void | getNamedStringValue (const Cantera::XML_Node &node, const std::string &nameString, std::string &valueString, std::string &typeString) |
This function attempts to read a named child node and returns with the contents in the value string. More... | |
void | getIntegers (const Cantera::XML_Node &node, std::map< std::string, int > &v) |
Get a vector of integer values from a child element. More... | |
void | getFloats (const Cantera::XML_Node &node, std::map< std::string, double > &v, const bool convert=true) |
Get a vector of floating-point values from a child element. More... | |
doublereal | getFloat (const Cantera::XML_Node &parent, const std::string &name, const std::string &type="") |
Get a floating-point value from a child element. More... | |
doublereal | getFloatCurrent (const Cantera::XML_Node &currXML, const std::string &type="") |
Get a floating-point value from the current XML element. More... | |
bool | getOptionalFloat (const Cantera::XML_Node &parent, const std::string &name, doublereal &fltRtn, const std::string &type="") |
Get an optional floating-point value from a child element. More... | |
doublereal | getFloatDefaultUnits (const Cantera::XML_Node &parent, const std::string &name, const std::string &defaultUnits, const std::string &type="toSI") |
Get a floating-point value from a child element with a defined units field. More... | |
bool | getOptionalModel (const Cantera::XML_Node &parent, const std::string &nodeName, std::string &modelName) |
Get an optional model name from a named child node. More... | |
int | getInteger (const Cantera::XML_Node &parent, const std::string &name) |
Get an integer value from a child element. More... | |
size_t | getFloatArray (const Cantera::XML_Node &node, std::vector< doublereal > &v, const bool convert=true, const std::string &unitsString="", const std::string &nodeName="floatArray") |
This function reads the current node or a child node of the current node with the default name, "floatArray", with a value field consisting of a comma separated list of floats. More... | |
void | getMap (const Cantera::XML_Node &node, std::map< std::string, std::string > &m) |
This routine is used to interpret the value portions of XML elements that contain colon separated pairs. More... | |
int | getPairs (const Cantera::XML_Node &node, std::vector< std::string > &key, std::vector< std::string > &val) |
This function interprets the value portion of an XML element as a series of "Pairs" separated by white space. More... | |
void | getMatrixValues (const Cantera::XML_Node &node, const std::vector< std::string > &keyStringRow, const std::vector< std::string > &keyStringCol, Cantera::Array2D &returnValues, const bool convert=true, const bool matrixSymmetric=false) |
This function interprets the value portion of an XML element as a series of "Matrix ids and entries" separated by white space. More... | |
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. More... | |
Variables | |
std::string | FP_Format = "%23.15E" |
std::string | INT_Format = "%8d" |
const std::string | CTML_Version = "1.4.1" |
const Specifying the CTML version number More... | |
The ctml namespace adds functionality to the XML object, by providing standard functions that read, write, and interpret XML files and object trees.
Standardization of reads and write from Cantera files occur here.
|
static |
return the full path to the Python interpreter.
Use the environment variable PYTHON_CMD if it is set. If not, return the string 'python'.
Note, there are hidden problems here that really direct us to use a full pathname for the location of python. Basically the system call will use the shell /bin/sh, in order to launch python. This default shell may not be the shell that the user is employing. Therefore, the default path to python may be different during a system call than during the default user shell environment. This is quite a headache. The answer is to always set the PYTHON_CMD environmental variable in the user environment to an absolute path to locate the python executable. Then this issue goes away.
Definition at line 41 of file ct2ctml.cpp.
References Cantera::stripws().
void ck2cti | ( | const std::string & | in_file, |
const std::string & | thermo_file = "" , |
||
const std::string & | transport_file = "" , |
||
const std::string & | id_tag = "gas" |
||
) |
Convert a Chemkin-format mechanism into a CTI file.
in_file | input file containing species and reactions |
thermo_file | optional input file containing thermo data |
transport_file | optional input file containing transport parameters |
id_tag | id of the phase |
Definition at line 131 of file ct2ctml.cpp.
References pypath(), Cantera::stripws(), and Cantera::writelog().
void get_CTML_Tree | ( | Cantera::XML_Node * | node, |
const std::string & | file, | ||
const int | debug = 0 |
||
) |
Read an ctml file from a file and fill up an XML tree.
This is the main routine that reads a ctml file and puts it into an XML_Node tree
node | Root of the tree |
file | Name of the file |
debug | Turn on debugging printing |
Definition at line 219 of file ct2ctml.cpp.
References XML_Node::build(), ct2ctml(), Cantera::findInputFile(), Cantera::getBaseName(), Cantera::npos, Cantera::writelog(), and Cantera::writelogf().
Referenced by getCtmlTree().
Cantera::XML_Node getCtmlTree | ( | const std::string & | file | ) |
Read an ctml file from a file and fill up an XML tree.
file | Name of the file |
Definition at line 266 of file ct2ctml.cpp.
References get_CTML_Tree().
void addInteger | ( | Cantera::XML_Node & | node, |
const std::string & | titleString, | ||
const int | value, | ||
const std::string & | unitsString = "" , |
||
const std::string & | typeString = "" |
||
) |
This function adds a child node with the name, "integer", with a value consisting of a single integer.
This function will add a child node to the current XML node, with the name "integer". It will have a title attribute, and the body of the XML node will be filled out with a single integer
Example:
Code snippet:
Creates the following the snippet in the XML file:
<parentNode> <integer title="maxIterations" type="optional"> 100 <\integer> <\parentNode>
node | reference to the XML_Node object of the parent XML element |
titleString | String name of the title attribute |
value | Value - single integer |
unitsString | String name of the Units attribute. The default is to have an empty string. |
typeString | String type. This is an optional parameter. The default is to have an empty string. |
Definition at line 24 of file ctml.cpp.
References XML_Node::addAttribute().
void addFloat | ( | Cantera::XML_Node & | node, |
const std::string & | titleString, | ||
const doublereal | value, | ||
const std::string & | unitsString = "" , |
||
const std::string & | typeString = "" , |
||
const doublereal | minval = Cantera::Undef , |
||
const doublereal | maxval = Cantera::Undef |
||
) |
This function adds a child node with the name, "float", with a value consisting of a single floating point number.
This function will add a child node to the current XML node, with the name "float". It will have a title attribute, and the body of the XML node will be filled out with a single float
Example:
Code snippet:
Creates the following the snippet in the XML file:
<parentNode> <float title="activationEnergy" type="optional" units="kcal/gmol" min="0.0" max="1.0E3"> 50.3 <\float> <\parentNode>
node | reference to the XML_Node object of the parent XML element |
titleString | String name of the title attribute |
value | Value - single integer |
unitsString | String name of the Units attribute. The default is to have an empty string. |
typeString | String type. This is an optional parameter. The default is to have an empty string. |
minval | Minimum allowed value of the float. The default is the special double, Cantera::Undef, which means to ignore the entry. |
maxval | Maximum allowed value of the float. The default is the special double, Cantera::Undef, which means to ignore the entry. |
Definition at line 42 of file ctml.cpp.
References XML_Node::addAttribute(), and Cantera::Undef.
Referenced by StFlow::save(), Inlet1D::save(), OutletRes1D::save(), Surf1D::save(), and ReactingSurf1D::save().
void addFloatArray | ( | Cantera::XML_Node & | node, |
const std::string & | titleString, | ||
const size_t | n, | ||
const doublereal *const | values, | ||
const std::string & | unitsString = "" , |
||
const std::string & | typeString = "" , |
||
const doublereal | minval = Cantera::Undef , |
||
const doublereal | maxval = Cantera::Undef |
||
) |
This function adds a child node with the name, "floatArray", with a value consisting of a comma separated list of floats.
This function will add a child node to the current XML node, with the name "floatArray". It will have a title attribute, and the body of the XML node will be filled out with a comma separated list of doublereals.
Example:
Code snippet:
Creates the following the snippet in the XML file:
<parentNode> <floatArray title="additionalTemperatures" type="optional" units="Kelvin"> 273.15, 298.15, 373.15 <\floatArray> <\parentNode>
node | reference to the XML_Node object of the parent XML element |
titleString | String name of the title attribute |
n | Length of the doubles vector. |
values | Pointer to a vector of doubles |
unitsString | String name of the Units attribute. This is an optional parameter. The default is to have an empty string. |
typeString | String type. This is an optional parameter. The default is to have an empty string. |
minval | Minimum allowed value of the int. This is an optional parameter. The default is the special double, Cantera::Undef, which means to ignore the entry. |
maxval | Maximum allowed value of the int. This is an optional parameter. The default is the special double, Cantera::Undef, which means to ignore the entry. |
Definition at line 68 of file ctml.cpp.
References XML_Node::addAttribute(), Cantera::fp2str(), and Cantera::Undef.
Referenced by StFlow::save(), and Domain1D::save().
void addNamedFloatArray | ( | Cantera::XML_Node & | parentNode, |
const std::string & | name, | ||
const int | n, | ||
const doublereal *const | vals, | ||
const std::string | units = "" , |
||
const std::string | type = "" , |
||
const doublereal | minval = Cantera::Undef , |
||
const doublereal | maxval = Cantera::Undef |
||
) |
This function adds a child node with the name given by the first parameter with a value consisting of a comma separated list of floats.
This function will add a child node to the current XML node, with the name given in the list. It will have a title attribute, and the body of the XML node will be filled out with a comma separated list of integers
Example:
Code snipet:
Creates the following the snippet in the XML file:
<parentNode> <additionalTemperatures type="optional" vtype="floatArray" size = "3" units="Kelvin"> 273.15, 298.15, 373.15 <\additionalTemperatures> <\parentNode>
parentNode | reference to the XML_Node object of the parent XML element |
name | Name of the XML node |
n | Length of the doubles vector. |
vals | Pointer to a vector of doubles |
units | String name of the Units attribute. This is an optional parameter. The default is to have an empty string. |
type | String type. This is an optional parameter. The default is to have an empty string. |
minval | Minimum allowed value of the int. This is an optional parameter. The default is the special double, Cantera::Undef, which means to ignore the entry. |
maxval | Maximum allowed value of the int. This is an optional parameter. The default is the special double, Cantera::Undef, which means to ignore the entry. |
Definition at line 102 of file ctml.cpp.
References XML_Node::addAttribute(), Cantera::fp2str(), and Cantera::Undef.
Referenced by StFlow::save().
void addString | ( | Cantera::XML_Node & | node, |
const std::string & | titleString, | ||
const std::string & | valueString, | ||
const std::string & | typeString = "" |
||
) |
This function adds a child node with the name string with a string value to the current node.
This function will add a child node to the current XML node, with the name "string". It will have a title attribute, and the body of the XML node will be filled out with the valueString argument verbatim.
Example:
Code snippet:
Creates the following the snippet in the XML file:
<string title="titleString" type="typeString"> valueString <\string>
node | reference to the XML_Node object of the parent XML element |
valueString | Value string to be used in the new XML node. |
titleString | String name of the title attribute |
typeString | String type. This is an optional parameter. |
Definition at line 141 of file ctml.cpp.
References XML_Node::addAttribute().
Referenced by StFlow::save().
Cantera::XML_Node * getByTitle | ( | const Cantera::XML_Node & | node, |
const std::string & | title | ||
) |
Search the child nodes of the current node for an XML Node with a Title attribute of a given name.
node | Current node from which to conduct the search |
title | Name of the title attribute |
Definition at line 152 of file ctml.cpp.
References XML_Node::findByAttr(), and XML_Node::parent().
Referenced by getNamedStringValue(), getString(), TransportFactory::getTransportData(), and Cantera::installMu0ThermoFromXML().
std::string getChildValue | ( | const Cantera::XML_Node & | parent, |
const std::string & | nameString | ||
) |
This function reads a child node with the name, nameString, and returns its xml value as the return string.
If the child XML_node named "name" doesn't exist, the empty string is returned.
Code snippet:
returns valueString = "O(V)"
from the following the snippet in the XML file:
<vacancySpecies> O(V) <\vacancySpecies>
parent | parent reference to the XML_Node object of the parent XML element |
nameString | Name of the child XML_Node to read the value from. |
Definition at line 164 of file ctml.cpp.
References XML_Node::hasChild().
Referenced by DebyeHuckel::initThermoXML(), HMWSoln::initThermoXML(), LatticePhase::setParametersFromXML(), SurfPhase::setStateFromXML(), MixtureFugacityTP::setStateFromXML(), MolalityVPSSTP::setStateFromXML(), and ThermoPhase::setStateFromXML().
void getString | ( | const Cantera::XML_Node & | node, |
const std::string & | titleString, | ||
std::string & | valueString, | ||
std::string & | typeString | ||
) |
This function reads a child node with the name string with a specific title attribute named titleString.
This function will read a child node to the current XML node with the name "string". It must have a title attribute, named titleString, and the body of the XML node will be read into the valueString output argument.
If the child node is not found then the empty string is returned.
Example:
Code snipet:
Reads the following the snippet in the XML file:
<string title="titleString" type="typeString"> valueString <\string>
node | Reference to the XML_Node object of the parent XML element |
titleString | String name of the title attribute of the child node |
valueString | Value string that is found in the child node. output variable |
typeString | String type. This is an optional output variable. It is filled with the attribute "type" of the XML entry. |
Definition at line 172 of file ctml.cpp.
References getByTitle(), and XML_Node::name().
void getNamedStringValue | ( | const Cantera::XML_Node & | node, |
const std::string & | nameString, | ||
std::string & | valueString, | ||
std::string & | typeString | ||
) |
This function attempts to read a named child node and returns with the contents in the value string.
title attribute named "titleString"
This function will read a child node to the current XML node, with the name "string". It must have a title attribute, named titleString, and the body of the XML node will be read into the valueString output argument.
If the child node is not found then the empty string is returned.
Example:
Code snippet:
Reads the following the snippet in the XML file:
<nameString type="typeString"> valueString <\nameString>
or alternatively as a retrofit and special case, it also reads the following case:
<string title="nameString" type="typeString"> valueString <\string>
node | Reference to the XML_Node object of the parent XML element | |
[in] | nameString | Name of the XML Node |
[out] | valueString | Value string that is found in the child node. |
[out] | typeString | String type. This is an optional output variable. It is filled with the attribute "type" of the XML entry. |
Definition at line 186 of file ctml.cpp.
References XML_Node::child(), getByTitle(), XML_Node::hasChild(), XML_Node::name(), and XML_Node::value().
void getIntegers | ( | const Cantera::XML_Node & | node, |
std::map< std::string, int > & | v | ||
) |
Get a vector of integer values from a child element.
Returns a std::map containing a keyed values for child XML_Nodes of the current node with the name, "integer". In the keyed mapping there will be a list of titles vs. values for all of the XML nodes. The integer XML_nodes are expected to be in a particular form created by the function addInteger(). One value per XML_node is expected.
Example:
reads the corresponding XML file:
<state> <integer title="i1"> 1 <\integer> <integer title="i2"> 2 <\integer> <integer title="i3"> 3 <\integer> <\state>
Will produce the mapping:
v["i1"] = 1 v["i2"] = 2 v["i3"] = 3
node | Current XML node to get the values from |
v | Output map of the results. |
Definition at line 207 of file ctml.cpp.
References XML_Node::getChildren().
void getFloats | ( | const Cantera::XML_Node & | node, |
std::map< std::string, double > & | v, | ||
const bool | convert = true |
||
) |
Get a vector of floating-point values from a child element.
Returns a std::map containing a keyed values for child XML_Nodes of the current node with the name, "float". In the keyed mapping there will be a list of titles vs. values for all of the XML nodes. The float XML_nodes are expected to be in a particular form created by the function addFloat(). One value per XML_node is expected.
Example:
Code snippet:
reads the corresponding XML file:
<state> <float title="a1" units="m3"> 32.4 <\float> <float title="a2" units="cm3"> 1. <\float> <float title="a3"> 100. <\float> <\state>
Will produce the mapping:
v["a1"] = 32.4 v["a2"] = 1.0E-6 v["a3"] = 100.
node | Current XML node to get the values from |
v | Output map of the results. |
convert | Turn on conversion to SI units |
Definition at line 228 of file ctml.cpp.
References Cantera::fpValue(), XML_Node::getChildren(), Cantera::Tiny, Cantera::toSI(), Cantera::Undef, Cantera::warn_deprecated(), and Cantera::writelog().
doublereal getFloat | ( | const Cantera::XML_Node & | parent, |
const std::string & | name, | ||
const std::string & | type = "" |
||
) |
Get a floating-point value from a child element.
Returns a doublereal value for the child named 'name' of element 'parent'. If 'type' is supplied and matches a known unit type, unit conversion to SI will be done if the child element has an attribute 'units'.
Note, it's an error for the child element not to exist.
Example:
Code snippet:
reads the corresponding XML file:
<state> <pressure units="Pa"> 101325.0 </pressure> <\state>
parent | reference to the XML_Node object of the parent XML element |
name | Name of the XML child element |
type | String type. Currently known types are "toSI" and "actEnergy", and "" , for no conversion. The default value is "", which implies that no conversion is allowed. |
Definition at line 267 of file ctml.cpp.
References XML_Node::child(), getFloatCurrent(), XML_Node::hasChild(), and XML_Node::name().
Referenced by PDSS_ConstVol::constructPDSSXML(), PDSS_HKFT::constructPDSSXML(), PDSS_SSVol::constructPDSSXML(), VPSSMgr_Water_ConstVol::createInstallPDSS(), VPSSMgr_ConstVol::createInstallPDSS(), Cantera::getArrhenius(), getFloatDefaultUnits(), getOptionalFloat(), Cantera::getRateCoefficient(), Cantera::getStick(), TransportFactory::getTransportData(), LiquidTranInteraction::init(), VPSSMgr_Water_ConstVol::initThermoXML(), VPSSMgr_ConstVol::initThermoXML(), MineralEQ3::initThermoXML(), IdealMolalSoln::initThermoXML(), IdealSolidSolnPhase::initThermoXML(), LatticePhase::initThermoXML(), DebyeHuckel::initThermoXML(), HMWSoln::initThermoXML(), Cantera::installAdsorbateThermoFromXML(), Cantera::installMu0ThermoFromXML(), Cantera::installSimpleThermoFromXML(), Cantera::installSpecies(), LTPspecies::LTPspecies(), StFlow::restore(), Inlet1D::restore(), OutletRes1D::restore(), Surf1D::restore(), ReactingSurf1D::restore(), SemiconductorPhase::setParametersFromXML(), EdgePhase::setParametersFromXML(), MetalPhase::setParametersFromXML(), ConstDensityThermo::setParametersFromXML(), StoichSubstance::setParametersFromXML(), SurfPhase::setParametersFromXML(), StoichSubstanceSSTP::setParametersFromXML(), MetalSHEelectrons::setParametersFromXML(), LatticePhase::setParametersFromXML(), MixtureFugacityTP::setStateFromXML(), MolalityVPSSTP::setStateFromXML(), and ThermoPhase::setStateFromXML().
doublereal getFloatCurrent | ( | const Cantera::XML_Node & | currXML, |
const std::string & | type = "" |
||
) |
Get a floating-point value from the current XML element.
Returns a doublereal value from the current element. If 'type' is supplied and matches a known unit type, unit conversion to SI will be done if the child element has an attribute 'units'.
Note, it's an error for the child element not to exist.
Example:
Code snippet:
Reads the corresponding XML file:
<state> <pressure units="Pa"> 101325.0 </pressure> <\state>
currXML | reference to the current XML_Node object |
type | String type. Currently known types are "toSI" and "actEnergy", and "" , for no conversion. The default value is "", which implies that no conversion is allowed. |
Definition at line 279 of file ctml.cpp.
References Cantera::actEnergyToSI(), Cantera::fpValue(), XML_Node::name(), Cantera::Tiny, Cantera::toSI(), Cantera::Undef, and Cantera::writelog().
Referenced by getFloat(), and LTPspecies_Const::LTPspecies_Const().
bool getOptionalFloat | ( | const Cantera::XML_Node & | parent, |
const std::string & | name, | ||
doublereal & | fltRtn, | ||
const std::string & | type = "" |
||
) |
Get an optional floating-point value from a child element.
Returns a doublereal value for the child named 'name' of element 'parent'. If 'type' is supplied and matches a known unit type, unit conversion to SI will be done if the child element has an attribute 'units'.
Example:
Code snippet:
reads the corresponding XML file:
<state> <pressure units="Pa"> 101325.0 </pressure> <\state>
parent | reference to the XML_Node object of the parent XML element |
name | Name of the XML child element |
fltRtn | Float Return. It will be overridden if the XML element exists. |
type | String type. Currently known types are "toSI" and "actEnergy", and "" , for no conversion. The default value is "", which implies that no conversion is allowed. |
Definition at line 335 of file ctml.cpp.
References getFloat(), and XML_Node::hasChild().
Referenced by HMWSoln::initThermoXML(), HMWSoln::readXMLCroppingCoefficients(), StFlow::restore(), and SurfPhase::setStateFromXML().
doublereal getFloatDefaultUnits | ( | const Cantera::XML_Node & | parent, |
const std::string & | name, | ||
const std::string & | defaultUnits, | ||
const std::string & | type = "toSI" |
||
) |
Get a floating-point value from a child element with a defined units field.
Returns a doublereal value for the child named 'name' of element 'parent'. 'type' must be supplied and match a known unit type. Note, it's an error for the child element not to exist.
Example:
Code snippet:
reads the corresponding XML file:
<state> <pressure units="Pa"> 101325.0 </pressure> <\state>
parent | reference to the XML_Node object of the parent XML element |
name | Name of the XML child element |
defaultUnits | Default units string to be found in the units attribute. If the units string in the XML field is equal to defaultUnits, no units conversion will be carried out. |
type | String type. Currently known types are "toSI" and "actEnergy", and "" , for no conversion. The default value is "", which implies that no conversion is allowed. |
Definition at line 347 of file ctml.cpp.
References Cantera::actEnergyToSI(), getFloat(), and Cantera::toSI().
Referenced by MineralEQ3::initThermoXML(), StoichSubstanceSSTP::initThermoXML(), MetalSHEelectrons::initThermoXML(), FixedChemPotSSTP::initThermoXML(), Cantera::installMinEQ3asShomateThermoFromXML(), and FixedChemPotSSTP::setParametersFromXML().
bool getOptionalModel | ( | const Cantera::XML_Node & | parent, |
const std::string & | nodeName, | ||
std::string & | modelName | ||
) |
Get an optional model name from a named child node.
Returns the model name attribute for the child named 'nodeName' of element 'parent'. Note, it's optional for the child node to exist
Example:
Code snippet:
reads the corresponding XML file:
<transport model="Simple"> <compositionDependence model="Solvent_Only"/> </transport>
On return modelName is set to "Solvent_Only".
parent | reference to the XML_Node object of the parent XML element |
nodeName | Name of the XML child element |
modelName | On return this contains the contents of the model attribute |
Definition at line 376 of file ctml.cpp.
References XML_Node::child(), and XML_Node::hasChild().
Referenced by SimpleTransport::initLiquid().
int getInteger | ( | const Cantera::XML_Node & | parent, |
const std::string & | name | ||
) |
Get an integer value from a child element.
Returns an integer value for the child named 'name' of element 'parent'. Note, it's an error for the child element not to exist.
Example:
Code snippet:
reads the corresponding XML file:
<state> <numProcs> 10 <numProcs/> <\state>
parent | reference to the XML_Node object of the parent XML element |
name | Name of the XML child element |
Definition at line 387 of file ctml.cpp.
References XML_Node::child(), XML_Node::hasChild(), XML_Node::name(), and Cantera::writelog().
Referenced by Cantera::installMu0ThermoFromXML().
size_t getFloatArray | ( | const Cantera::XML_Node & | node, |
std::vector< doublereal > & | v, | ||
const bool | convert = true , |
||
const std::string & | unitsString = "" , |
||
const std::string & | nodeName = "floatArray" |
||
) |
This function reads the current node or a child node of the current node with the default name, "floatArray", with a value field consisting of a comma separated list of floats.
This function will read either the current XML node or a child node to the current XML node, with the name "floatArray". It will have a title attribute, and the body of the XML node will be filled out with a comma separated list of doublereals. Get an array of floats from the XML Node. The argument field is assumed to consist of an arbitrary number of comma separated floats, with an arbitrary amount of white space separating each field. If the node array has an units attribute field, then the units are used to convert the floats, iff convert is true.
Example:
Code snippet:
reads the corresponding XML file:
<state> <floatArray units="m3"> 32.4, 1, 100. <\floatArray> <\state>
and will produce the vector:
v[0] = 32.4 v[1] = 1.0 v[2] = 100.
node | XML parent node of the floatArray |
v | Output vector of floats containing the floatArray information. |
convert | Conversion to SI is carried out if this boolean is True. The default is true. |
unitsString | String name of the type attribute. This is an optional parameter. The default is to have an empty string. The only string that is recognized is actEnergy. Anything else has no effect. This affects what units converter is used. |
nodeName | XML Name of the XML node to read. The default value for the node name is floatArray |
Definition at line 419 of file ctml.cpp.
References Cantera::actEnergyToSI(), Cantera::fp2str(), Cantera::fpValueCheck(), XML_Node::getChildren(), XML_Node::name(), Cantera::npos, Cantera::Tiny, Cantera::toSI(), Cantera::Undef, XML_Node::value(), and Cantera::writelog().
Referenced by PDSS_SSVol::constructPDSSXML(), Cantera::getRateCoefficient(), LiquidTranInteraction::init(), Cantera::installAdsorbateThermoFromXML(), Cantera::installMu0ThermoFromXML(), Cantera::installNasa9ThermoFromXML(), Cantera::installNasaThermoFromXML(), Cantera::installShomateThermoFromXML(), Cantera::installStatMechThermoFromXML(), LTPspecies_ExpT::LTPspecies_ExpT(), LTPspecies_Poly::LTPspecies_Poly(), HMWSoln::readXMLBinarySalt(), RedlichKisterVPSSTP::readXMLBinarySpecies(), MixedSolventElectrolyte::readXMLBinarySpecies(), MargulesVPSSTP::readXMLBinarySpecies(), PhaseCombo_Interaction::readXMLBinarySpecies(), RedlichKwongMFTP::readXMLCrossFluid(), HMWSoln::readXMLLambdaNeutral(), HMWSoln::readXMLMunnnNeutral(), HMWSoln::readXMLPsiCommonAnion(), HMWSoln::readXMLPsiCommonCation(), RedlichKwongMFTP::readXMLPureFluid(), HMWSoln::readXMLThetaAnion(), HMWSoln::readXMLThetaCation(), HMWSoln::readXMLZetaCation(), StFlow::restore(), and Domain1D::restore().
void getMap | ( | const Cantera::XML_Node & | node, |
std::map< std::string, std::string > & | m | ||
) |
This routine is used to interpret the value portions of XML elements that contain colon separated pairs.
These are used, for example, in describing the element composition of species.
<atomArray> H:4 C:1 <atomArray\>
The string is first separated into a string vector according to the location of white space. Then each string is again separated into two parts according to the location of a colon in the string. The first part of the string is used as the key, while the second part of the string is used as the value, in the return map. It is an error to not find a colon in each string pair.
node | Current node |
m | Output Map containing the pairs of values found in the XML Node |
Definition at line 508 of file ctml.cpp.
References getStringArray(), and Cantera::npos.
Referenced by DebyeHuckel::initThermoXML(), HMWSoln::initThermoXML(), and Cantera::installSpecies().
int getPairs | ( | const Cantera::XML_Node & | node, |
std::vector< std::string > & | key, | ||
std::vector< std::string > & | val | ||
) |
This function interprets the value portion of an XML element as a series of "Pairs" separated by white space.
Each pair consists of non-whitespace characters. The first ":" found in the pair string is used to separate the string into two parts. The first part is called the "key" The second part is called the "val". String vectors of key[i] and val[i] are returned in the argument list. Warning: No spaces are allowed in each pair. Quotes get included as part of the string. Example:
<xmlNode> red:112 blue:34 green:banana </xmlNode>
Returns:
index | key | val |
---|---|---|
0 | "red" | "112" |
1 | "blue" | "34" |
2 | "green" | "banana" |
node | XML Node |
key | Vector of keys for each entry |
val | Vector of values for each entry |
Definition at line 527 of file ctml.cpp.
References getStringArray(), and Cantera::npos.
Referenced by PDSS_IonsFromNeutral::constructPDSSXML(), Cantera::getEfficiencies(), Cantera::getReagents(), and LatticeSolidPhase::setParametersFromXML().
void getMatrixValues | ( | const Cantera::XML_Node & | node, |
const std::vector< std::string > & | keyStringRow, | ||
const std::vector< std::string > & | keyStringCol, | ||
Cantera::Array2D & | returnValues, | ||
const bool | convert = true , |
||
const bool | matrixSymmetric = false |
||
) |
This function interprets the value portion of an XML element as a series of "Matrix ids and entries" separated by white space.
Each pair consists of non-whitespace characters. The first two ":" found in the pair string is used to separate the string into three parts. The first part is called the first key. The second part is the second key. Both parts must match an entry in the keyString1 and keyString2, respectively, in order to provide a location to place the object in the matrix. The third part is called the value. It is expected to be a double. It is translated into a double and placed into the correct location in the matrix.
Warning: No spaces are allowed in each triplet. Quotes are part of the string.
Example: keyString = red, blue, black, green
<xmlNode> red:green:112 blue:black:3.3E-23 </xmlNode>
Returns:
retnValues(0, 3) = 112 retnValues(1, 2) = 3.3E-23
node | XML Node containing the information for the matrix |
keyStringRow | Key string for the row |
keyStringCol | Key string for the column entries |
returnValues | Return Matrix. |
convert | If this is true, and if the node has a units attribute, then conversion to SI units is carried out. Default is true. |
matrixSymmetric | If true entries are made so that the matrix is always symmetric. Default is false. |
Definition at line 547 of file ctml.cpp.
References Cantera::fpValueCheck(), getStringArray(), Array2D::nColumns(), Cantera::npos, Array2D::nRows(), and Cantera::toSI().
Referenced by DebyeHuckel::initThermoXML().
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.
It then separates the string up into tokens according to the location of white space.
The separate tokens are returned in the string vector
node | Node to get the value from |
v | Output vector containing the string tokens |
Definition at line 639 of file ctml.cpp.
References Cantera::tokenizeString(), and XML_Node::value().
Referenced by Elements::addElementsFromXML(), Phase::addElementsFromXML(), HMWSoln::constructPhaseXML(), Cantera::formSpeciesXMLNodeList(), Cantera::getFalloff(), getMap(), getMatrixValues(), getPairs(), Cantera::importKinetics(), IdealMolalSoln::initThermoXML(), DebyeHuckel::initThermoXML(), and HMWSoln::initThermoXML().