30 std::string default_phase,
bool check_for_duplicates)
39 vector<XML_Node*> rarrays = p.
getChildren(
"reactionArray");
40 if (rarrays.empty()) {
43 for (
size_t n = 0; n < rarrays.size(); n++) {
66 if (sk[
"species"] ==
"undeclared") {
69 if (sk[
"third_bodies"] ==
"undeclared") {
77 vector<XML_Node*> incl = rxns.
getChildren(
"include");
78 vector<XML_Node*> allrxns = rdata->
getChildren(
"reaction");
81 for (
size_t i = 0; i < allrxns.size(); i++) {
87 for (
size_t nii = 0; nii < incl.size(); nii++) {
89 string imin = ii[
"min"];
90 string imax = ii[
"max"];
94 iwild = imin.find(
"*");
96 imin = imin.substr(0,iwild);
101 for (
size_t i = 0; i < allrxns.size(); i++) {
107 rxid = rxid.substr(0,iwild);
113 if ((rxid >= imin) && (rxid <= imax)) {
124 if (check_for_duplicates) {
141 string owning_phase = phase[
"id"];
143 bool check_for_duplicates =
false;
146 if (d[
"reactions"] ==
"yes") {
147 check_for_duplicates =
true;
154 vector<string> phase_ids;
159 phase_ids.push_back(owning_phase);
164 for (
size_t n = 0; n < phase_ids.size(); n++) {
165 string phase_id = phase_ids[n];
166 bool phase_ok =
false;
169 for (
size_t m = 0; m < th.size(); m++) {
170 if (th[m]->
id() == phase_id) {
178 msg +=
" "+th[m]->id();
182 "phase "+phase_id+
" not found. Supplied phases are:"+msg);
208 std::vector<ThermoPhase*> phases{th};
222 vector<string> phase_ids;
227 phase_ids.push_back(p[
"id"]);
235 for (
const auto& sp : reactants) {
241 for (
const auto& sp : products) {
248 std::vector<double> e_counter(phase_ids.size(), 0.0);
251 for (
const auto& sp : products) {
254 double stoich = sp.second;
255 for (
size_t m = 0; m < phase_ids.size(); m++) {
256 if (phase_ids[m] == ph.
id()) {
257 e_counter[m] += stoich * ph.
charge(k);
264 for (
const auto& sp : reactants) {
267 double stoich = sp.second;
268 for (
size_t m = 0; m < phase_ids.size(); m++) {
269 if (phase_ids[m] == ph.
id()) {
270 e_counter[m] -= stoich * ph.
charge(k);
277 bool echemical =
false;
278 for(
size_t m = 0; m < phase_ids.size(); m++) {
279 if (fabs(e_counter[m]) > 1e-4) {
289 if ((type !=
"butlervolmer_noactivitycoeffs" &&
290 type !=
"butlervolmer" &&
291 type !=
"surfaceaffinity") &&
293 XML_Node& f = r.
child(
"rateCoeff").addChild(
"electrochem",
"");
XML_Node * get_XML_Node(const std::string &file_ID, XML_Node *root)
This routine will locate an XML node in either the input XML tree or in another input file specified ...
std::vector< XML_Node * > getChildren(const std::string &name) const
Get a vector of pointers to XML_Node containing all of the children of the current node which match t...
CTML ("Cantera Markup Language") is the variant of XML that Cantera uses to store data...
size_t speciesIndex(const std::string &name) const
Returns the index of a species named 'name' within the Phase object.
const size_t npos
index returned by functions to indicate "no position"
Headers for the factory class that can create known ThermoPhase objects (see Thermodynamic Properties...
Class XML_Node is a tree-based representation of the contents of an XML file.
virtual bool addReaction(shared_ptr< Reaction > r)
Add a single reaction to the mechanism.
bool installReactionArrays(const XML_Node &p, Kinetics &kin, std::string default_phase, bool check_for_duplicates)
Install information about reactions into the kinetics object, kin.
Base class for a phase with thermodynamic properties.
virtual void init()
Prepare the class for the addition of reactions, after all phases have been added.
bool importKinetics(const XML_Node &phase, std::vector< ThermoPhase *> th, Kinetics *k)
Import a reaction mechanism for a phase or an interface.
std::map< std::string, doublereal > Composition
Map from string names to doubles.
thermo_t & speciesPhase(const std::string &nm)
This function looks up the name of a species and returns a reference to the ThermoPhase object of the...
bool checkElectrochemReaction(const XML_Node &p, Kinetics &kin, const XML_Node &r)
Check to ensure that all electrochemical reactions are specified correctly.
Public interface for kinetics managers.
size_t kineticsSpeciesIndex(size_t k, size_t n) const
The location of species k of phase n in species arrays.
XML_Node * parent() const
Returns a pointer to the parent node of the current node.
Base class for exceptions thrown by Cantera classes.
shared_ptr< Reaction > newReaction(const XML_Node &rxn_node)
Create a new Reaction object for the reaction defined in rxn_node
std::string value() const
Return the value of an XML node as a string.
virtual std::pair< size_t, size_t > checkDuplicates(bool throw_err=true) const
Check for unmarked duplicate reactions and unmatched marked duplicates.
void importPhase(XML_Node &phase, ThermoPhase *th)
Import a phase information into an empty ThermoPhase object.
void addAttribute(const std::string &attrib, const std::string &value)
Add or modify an attribute of the current node.
bool hasChild(const std::string &ch) const
Tests whether the current node has a child node with a particular name.
XML_Node & child(const size_t n) const
Return a changeable reference to the n'th child of the current node.
XML_Node & root() const
Return the root of the current XML_Node tree.
compositionMap parseCompString(const std::string &ss, const std::vector< std::string > &names)
Parse a composition string into a map consisting of individual key:composition pairs.
Definitions of global routines for the importing of data from XML files (see Input File Handling)...
std::string id() const
Return the string id for the phase.
std::string attrib(const std::string &attr) const
Function returns the value of an attribute.
void getStringArray(const XML_Node &node, std::vector< std::string > &v)
This function interprets the value portion of an XML element as a string.
Contains declarations for string manipulation functions within Cantera.
std::string toLowerCopy(const std::string &input)
Convert to lower case.
Namespace for the Cantera kernel.
virtual void addPhase(thermo_t &thermo)
Add a phase to the kinetics manager object.
void skipUndeclaredThirdBodies(bool skip)
Determine behavior when adding a new reaction that contains third-body efficiencies for species not d...
XML_Node * get_XML_NameID(const std::string &nameTarget, const std::string &file_ID, XML_Node *root)
This routine will locate an XML node in either the input XML tree or in another input file specified ...
doublereal charge(size_t k) const
Dimensionless electrical charge of a single molecule of species k The charge is normalized by the the...
size_t phaseIndex(const std::string &ph)
Return the phase index of a phase in the list of phases defined within the object.
void skipUndeclaredSpecies(bool skip)
Determine behavior when adding a new reaction that contains species not defined in any of the phases ...