1 //! @file Species.h Declaration for class Cantera::Species.
2 
3 // This file is part of Cantera. See License.txt in the top-level directory or
4 // at https://cantera.org/license.txt for license and copyright information.
5 
6 #ifndef CT_SPECIES_H
7 #define CT_SPECIES_H
8 
9 #include "cantera/base/ct_defs.h"
10 #include "cantera/base/AnyMap.h"
11 
12 namespace Cantera
13 {
14 
15 class SpeciesThermoInterpType;
16 class TransportData;
17 class XML_Node;
18 class ThermoPhase;
19 
20 //! Contains data about a single chemical species
21 /*!
22  *  This class stores the data about a species which may be needed to add it to
23  *  a ThermoPhase or Transport object.
24  */
25 class Species
26 {
27 public:
28     Species();
29 
30     //! Constructor
31     Species(const std::string& name, const compositionMap& comp,
32             double charge=0.0, double size=1.0);
33 
34     //! Species objects are not copyable or assignable
35     Species(const Species&) = delete;
36     Species& operator=(const Species& other) = delete;
37     ~Species();
38 
39     AnyMap parameters(const ThermoPhase* phase=0, bool withInput=true) const;
40 
41     //! The name of the species
42     std::string name;
43 
44     //! The elemental composition of the species. Keys are element names; values
45     //! are the corresponding atomicities.
46     compositionMap composition;
47 
48     //! The electrical charge on the species, in units of the elementary charge.
49     double charge;
50 
51     //! The effective size of the species. Currently used only for surface
52     //! species, where it represents the number of sites occupied.
53     double size;
54 
55     shared_ptr<TransportData> transport;
56 
57     //! Thermodynamic data for the species
58     shared_ptr<SpeciesThermoInterpType> thermo;
59 
60     //! Input parameters used to define a species, e.g. from a YAML input file.
61     AnyMap input;
62 };
63 
64 //! Create a new Species object from a 'species' XML_Node.
65 //!
66 //! @deprecated The XML input format is deprecated and will be removed in
67 //!     Cantera 3.0.
68 shared_ptr<Species> newSpecies(const XML_Node& species_node);
69 
70 //! Create a new Species object from an AnyMap specification
71 unique_ptr<Species> newSpecies(const AnyMap& node);
72 
73 //! Generate Species objects for all `<species>` nodes in an XML document.
74 //!
75 //! The `<species>` nodes are assumed to be children of the `<speciesData>` node
76 //! in an XML document with a `<ctml>` root node, as in the case of XML files
77 //! produced by conversion from CTI files.
78 //!
79 //! This function can be used in combination with get_XML_File and
80 //! get_XML_from_string to get Species objects from either a file or a string,
81 //! respectively, where the string or file is formatted as either CTI or XML.
82 //!
83 //! @deprecated The XML input format is deprecated and will be removed in
84 //!     Cantera 3.0.
85 std::vector<shared_ptr<Species> > getSpecies(const XML_Node& node);
86 
87 //! Generate Species objects for each item (an AnyMap) in `items`.
88 std::vector<shared_ptr<Species>> getSpecies(const AnyValue& items);
89 
90 }
91 
92 #endif
93