Cantera  3.1.0a1
Species.h
Go to the documentation of this file.
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 ThermoPhase;
18 
19 //! Contains data about a single chemical species
20 /*!
21  * This class stores the data about a species which may be needed to add it to
22  * a ThermoPhase or Transport object.
23  */
24 class Species
25 {
26 public:
27  Species() = default;
28 
29  //! Constructor
30  Species(const string& name, const Composition& comp,
31  double charge=0.0, double size=1.0);
32 
33  //! Species objects are not copyable or assignable
34  Species(const Species&) = delete;
35  Species& operator=(const Species& other) = delete;
36  ~Species() = default;
37 
38  AnyMap parameters(const ThermoPhase* phase=0, bool withInput=true) const;
39 
40  //! The name of the species
41  string name;
42 
43  //! The elemental composition of the species. Keys are element names; values
44  //! are the corresponding atomicities.
46 
47  //! The electrical charge on the species, in units of the elementary charge.
48  double charge = 0.0;
49 
50  //! The effective size of the species. Currently used only for surface
51  //! species, where it represents the number of sites occupied.
52  double size = 1.0;
53 
54  //! The molecular weight [amu] of the species.
55  /*!
56  * Calculates and sets the molecular weight from the elemental composition of the
57  * species and element definitions in Elements.cpp, if the molecular weight is
58  * Undef.
59  *
60  * @since New in version 3.0
61  */
62  double molecularWeight();
63 
64  //! Set the molecular weight of the species.
65  /*!
66  * Since phases can have custom element weights, the phase will always call this
67  * method when a species is added to that phase. The species may also call this
68  * method the first time the molecularWeight() method is called if the species has
69  * not been added to a phase.
70  *
71  * @param weight: The weight of this species to assign
72  *
73  * @since New in version 3.0
74  */
75  void setMolecularWeight(double weight);
76 
77  shared_ptr<TransportData> transport;
78 
79  //! Thermodynamic data for the species
80  shared_ptr<SpeciesThermoInterpType> thermo;
81 
82  //! Input parameters used to define a species, for example from a YAML input file.
84 
85 protected:
86 
87  //! The molecular weight of the species, in atomic mass units. Includes
88  //! electron mass for charged species.
90 };
91 
92 //! Create a new Species object from an AnyMap specification
93 unique_ptr<Species> newSpecies(const AnyMap& node);
94 
95 //! Generate Species objects for each item (an AnyMap) in `items`.
96 vector<shared_ptr<Species>> getSpecies(const AnyValue& items);
97 
98 }
99 
100 #endif
A map of string keys to values whose type can vary at runtime.
Definition: AnyMap.h:427
A wrapper for a variable whose type is determined at runtime.
Definition: AnyMap.h:86
Contains data about a single chemical species.
Definition: Species.h:25
double m_molecularWeight
The molecular weight of the species, in atomic mass units.
Definition: Species.h:89
Composition composition
The elemental composition of the species.
Definition: Species.h:45
string name
The name of the species.
Definition: Species.h:41
void setMolecularWeight(double weight)
Set the molecular weight of the species.
Definition: Species.cpp:48
double molecularWeight()
The molecular weight [amu] of the species.
Definition: Species.cpp:29
double charge
The electrical charge on the species, in units of the elementary charge.
Definition: Species.h:48
double size
The effective size of the species.
Definition: Species.h:52
shared_ptr< SpeciesThermoInterpType > thermo
Thermodynamic data for the species.
Definition: Species.h:80
Species(const Species &)=delete
Species objects are not copyable or assignable.
AnyMap input
Input parameters used to define a species, for example from a YAML input file.
Definition: Species.h:83
Base class for a phase with thermodynamic properties.
Definition: ThermoPhase.h:390
This file contains definitions of constants, types and terms that are used in internal routines and a...
Namespace for the Cantera kernel.
Definition: AnyMap.cpp:564
const double Undef
Fairly random number to be used to initialize variables against to see if they are subsequently defin...
Definition: ct_defs.h:164
vector< shared_ptr< Species > > getSpecies(const AnyValue &items)
Generate Species objects for each item (an AnyMap) in items.
Definition: Species.cpp:143
unique_ptr< Species > newSpecies(const AnyMap &node)
Create a new Species object from an AnyMap specification.
Definition: Species.cpp:105
map< string, double > Composition
Map from string names to doubles.
Definition: ct_defs.h:177