26 double charge_,
double size_)
38AnyMap Species::parameters(
const ThermoPhase* phase,
bool withInput)
const
41 speciesNode[
"name"] =
name;
43 speciesNode[
"composition"].setFlowStyle();
46 speciesNode[
"charge"] =
charge;
49 speciesNode[
"size"] =
size;
52 AnyMap thermoNode =
thermo->parameters(withInput);
53 if (thermoNode.size()) {
54 speciesNode[
"thermo"] = std::move(thermoNode);
58 speciesNode[
"transport"] = transport->parameters(withInput);
61 phase->getSpeciesParameters(
name, speciesNode);
63 if (withInput &&
input.
hasKey(
"equation-of-state")) {
64 auto& eosIn =
input[
"equation-of-state"].asVector<AnyMap>();
65 for (
const auto& eos : eosIn) {
66 auto& out = speciesNode[
"equation-of-state"].getMapWhere(
67 "model", eos[
"model"].asString(),
true);
72 speciesNode.update(
input);
79 std::string name = species_node[
"name"];
81 auto s = make_shared<Species>(name, comp);
82 if (species_node.
hasChild(
"charge")) {
83 s->charge =
getFloat(species_node,
"charge");
86 s->size =
getFloat(species_node,
"size");
88 if (species_node.
hasChild(
"thermo")) {
95 if (species_node.
hasChild(
"transport")) {
97 s->transport->validate(*s);
101 if (species_node.
hasChild(
"stoichIsMods")) {
102 s->input[
"Debye-Huckel"][
"weak-acid-charge"] =
103 getFloat(species_node,
"stoichIsMods");
106 if (species_node.
hasChild(
"electrolyteSpeciesType")) {
107 s->input[
"Debye-Huckel"][
"electrolyte-species-type"] =
108 species_node.
child(
"electrolyteSpeciesType").
value();
113 if (stdstate && stdstate->
findByName(
"molarVolume")) {
114 s->input[
"molar_volume"] =
getFloat(*stdstate,
"molarVolume",
"toSI");
119 if (thermo && thermo->
attrib(
"model") ==
"IonFromNeutral") {
120 if (thermo->
hasChild(
"specialSpecies")) {
121 auto& eos = s->input[
"equation-of-state"].getMapWhere(
122 "model",
"ions-from-neutral-molecule",
true);
123 eos[
"special-species"] =
true;
132 unique_ptr<Species> s(
new Species(node[
"name"].asString(),
133 node[
"composition"].asMap<double>()));
135 if (node.
hasKey(
"thermo")) {
142 if (s->composition.find(
"E") != s->composition.end()) {
143 s->charge = -s->composition[
"E"];
146 if (node.
hasKey(
"transport")) {
148 s->transport->validate(*s);
153 const static std::set<std::string> known_keys{
154 "thermo",
"transport"
156 s->input.setUnits(node.
units());
157 for (
const auto& item : node) {
158 if (known_keys.count(item.first) == 0) {
159 s->input[item.first] = item.second;
162 s->input.applyUnits();
163 s->input.copyMetadata(node);
170 std::vector<shared_ptr<Species> > all_species;
171 for (
const auto& spnode : node.
child(
"speciesData").
getChildren(
"species")) {
179 std::vector<shared_ptr<Species> > all_species;
Header for factory functions to build instances of classes that manage the standard-state thermodynam...
Pure Virtual Base class for individual species reference state thermodynamic managers and text for th...
Declaration for class Cantera::Species.
Header file for class ThermoPhase, the base class for phases with thermodynamic properties,...
A map of string keys to values whose type can vary at runtime.
const UnitSystem & units() const
Return the default units that should be used to convert stored values.
double getDouble(const std::string &key, double default_) const
If key exists, return it as a double, otherwise return default_.
bool hasKey(const std::string &key) const
Returns true if the map contains an item named key.
void update(const AnyMap &other, bool keepExisting=true)
Add items from other to this AnyMap.
A wrapper for a variable whose type is determined at runtime.
const std::vector< T > & asVector(size_t nMin=npos, size_t nMax=npos) const
Return the held value, if it is a vector of type T.
Abstract Base class for the thermodynamic manager for an individual species' reference state.
Contains data about a single chemical species.
compositionMap composition
The elemental composition of the species.
std::string name
The name of the species.
double charge
The electrical charge on the species, in units of the elementary charge.
double size
The effective size of the species.
shared_ptr< SpeciesThermoInterpType > thermo
Thermodynamic data for the species.
AnyMap input
Input parameters used to define a species, for example from a YAML input file.
Class XML_Node is a tree-based representation of the contents of an XML file.
std::string attrib(const std::string &attr) const
Function returns the value of an attribute.
bool hasChild(const std::string &ch) const
Tests whether the current node has a child node with a particular name.
const XML_Node * findByName(const std::string &nm, int depth=100000) const
This routine carries out a recursive search for an XML node based on the name of the node.
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...
std::string value() const
Return the value of an XML node as a string.
XML_Node & child(const size_t n) const
Return a changeable reference to the n'th child of the current node.
Definitions for the classes that are thrown when Cantera experiences an error condition (also contain...
CTML ("Cantera Markup Language") is the variant of XML that Cantera uses to store data.
This file contains definitions for utility functions and text for modules, inputfiles,...
Namespace for the Cantera kernel.
doublereal getFloat(const XML_Node &parent, const std::string &name, const std::string &type="")
Get a floating-point value from a child element.
unique_ptr< SpeciesThermoInterpType > newSpeciesThermo(const AnyMap &thermo_node)
Create a new SpeciesThermoInterpType object using the specified parameters.
shared_ptr< Species > newSpecies(const XML_Node &species_node)
Create a new Species object from a 'species' XML_Node.
std::vector< shared_ptr< Species > > getSpecies(const XML_Node &node)
Generate Species objects for all <species> nodes in an XML document.
std::map< std::string, double > compositionMap
Map connecting a string name with a double.
shared_ptr< TransportData > newTransportData(const XML_Node &transport_node)
Create a new TransportData object from a 'transport' XML_Node.
compositionMap parseCompString(const std::string &ss, const std::vector< std::string > &names=std::vector< std::string >())
Parse a composition string into a map consisting of individual key:composition pairs.
SpeciesThermoInterpType * newSpeciesThermoInterpType(int type, double tlow, double thigh, double pref, const double *coeffs)
Create a new SpeciesThermoInterpType object given a corresponding constant.
Contains declarations for string manipulation functions within Cantera.