20 Species::Species(
const string& name_,
const Composition& comp_,
21 double charge_,
double size_)
34 auto search = elements.find(eName);
35 if (search != elements.end()) {
36 if (search->second < 0) {
38 "element '{}' has no stable isotopes", eName);
40 weight += search->second * stoich;
52 if (weight_cmp > 1.0e-9) {
54 "Species::setMolecularWeight",
55 "Molecular weight of species '{}' is changing from {} to {}.",
69 speciesNode[
"name"] =
name;
74 speciesNode[
"charge"] =
charge;
77 speciesNode[
"size"] =
size;
80 AnyMap thermoNode =
thermo->parameters(withInput);
81 if (thermoNode.size()) {
82 speciesNode[
"thermo"] = std::move(thermoNode);
86 speciesNode[
"transport"] = transport->parameters(withInput);
91 if (withInput &&
input.
hasKey(
"equation-of-state")) {
92 auto& eosIn =
input[
"equation-of-state"].asVector<AnyMap>();
93 for (
const auto& eos : eosIn) {
94 auto& out = speciesNode[
"equation-of-state"].getMapWhere(
95 "model", eos[
"model"].asString(),
true);
107 auto s = make_unique<Species>(node[
"name"].asString(),
108 node[
"composition"].asMap<double>());
110 if (node.
hasKey(
"thermo")) {
113 s->thermo = make_shared<SpeciesThermoInterpType>();
117 if (s->composition.find(
"E") != s->composition.end()) {
118 s->charge = -s->composition[
"E"];
121 if (node.
hasKey(
"transport")) {
123 s->transport->validate(*s);
128 const static set<string> known_keys{
129 "thermo",
"transport"
131 s->input.setUnits(node.
units());
132 for (
const auto& [key, child] : node) {
133 if (known_keys.count(key) == 0) {
134 s->input[key] = child;
137 s->input.applyUnits();
138 s->input.copyMetadata(node);
145 vector<shared_ptr<Species>> all_species;
Contains the getElementWeight function and the definitions of element constraint types.
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.
double getDouble(const string &key, double default_) const
If key exists, return it as a double, otherwise return default_.
bool hasKey(const string &key) const
Returns true if the map contains an item named key.
void setFlowStyle(bool flow=true)
Use "flow" style when outputting this AnyMap to YAML.
const UnitSystem & units() const
Return the default units that should be used to convert stored values.
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 vector< T > & asVector(size_t nMin=npos, size_t nMax=npos) const
Return the held value, if it is a vector of type T.
Base class for exceptions thrown by Cantera classes.
double m_molecularWeight
The molecular weight of the species, in atomic mass units.
Composition composition
The elemental composition of the species.
string name
The name of the species.
void setMolecularWeight(double weight)
Set the molecular weight of the species.
double molecularWeight()
The molecular weight [amu] 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.
Base class for a phase with thermodynamic properties.
virtual void getSpeciesParameters(const string &name, AnyMap &speciesNode) const
Get phase-specific parameters of a Species object such that an identical one could be reconstructed a...
Definitions for the classes that are thrown when Cantera experiences an error condition (also contain...
This file contains definitions for utility functions and text for modules, inputfiles and logging,...
void warn_user(const string &method, const string &msg, const Args &... args)
Print a user warning raised from method as CanteraWarning.
Namespace for the Cantera kernel.
const double Undef
Fairly random number to be used to initialize variables against to see if they are subsequently defin...
vector< shared_ptr< Species > > getSpecies(const AnyValue &items)
Generate Species objects for each item (an AnyMap) in items.
unique_ptr< SpeciesThermoInterpType > newSpeciesThermo(const AnyMap &node)
Create a new SpeciesThermoInterpType object using the specified parameters.
unique_ptr< Species > newSpecies(const AnyMap &node)
Create a new Species object from an AnyMap specification.
const map< string, double > & elementWeights()
Get a map with the element and isotope symbols and names as keys and weights as values.
unique_ptr< TransportData > newTransportData(const AnyMap &node)
Create a new TransportData object from an AnyMap specification.
map< string, double > Composition
Map from string names to doubles.
Contains declarations for string manipulation functions within Cantera.