| Cantera 3.0.0

Loading...
Searching...
No Matches
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.
45 Composition composition;
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.
83 AnyMap input;
84
85 protected:
86
87 //! The molecular weight of the species, in atomic mass units. Includes
88 //! electron mass for charged species.
89 double m_molecularWeight = Undef;
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
AnyMap.h
Cantera::AnyMap
A map of string keys to values whose type can vary at runtime.
Definition AnyMap.h:427
Cantera::AnyValue
A wrapper for a variable whose type is determined at runtime.
Definition AnyMap.h:86
Cantera::Species
Contains data about a single chemical species.
Definition Species.h:25
Cantera::Species::m_molecularWeight
double m_molecularWeight
The molecular weight of the species, in atomic mass units.
Definition Species.h:89
Cantera::Species::composition
Composition composition
The elemental composition of the species.
Definition Species.h:45
Cantera::Species::name
string name
The name of the species.
Definition Species.h:41
Cantera::Species::setMolecularWeight
void setMolecularWeight(double weight)
Set the molecular weight of the species.
Definition Species.cpp:48
Cantera::Species::molecularWeight
double molecularWeight()
The molecular weight [amu] of the species.
Definition Species.cpp:29
Cantera::Species::charge
double charge
The electrical charge on the species, in units of the elementary charge.
Definition Species.h:48
Cantera::Species::size
double size
The effective size of the species.
Definition Species.h:52
Cantera::Species::thermo
shared_ptr< SpeciesThermoInterpType > thermo
Thermodynamic data for the species.
Definition Species.h:80
Cantera::Species::Species
Species(const Species &)=delete
Species objects are not copyable or assignable.
Cantera::Species::input
AnyMap input
Input parameters used to define a species, for example from a YAML input file.
Definition Species.h:83
Cantera::ThermoPhase
Base class for a phase with thermodynamic properties.
Definition ThermoPhase.h:390
ct_defs.h
This file contains definitions of constants, types and terms that are used in internal routines and a...
Cantera
Namespace for the Cantera kernel.
Definition AnyMap.cpp:564
Cantera::Undef
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
Cantera::getSpecies
vector< shared_ptr< Species > > getSpecies(const AnyValue &items)
Generate Species objects for each item (an AnyMap) in items.
Definition Species.cpp:143
Cantera::newSpecies
unique_ptr< Species > newSpecies(const AnyMap &node)
Create a new Species object from an AnyMap specification.
Definition Species.cpp:105
Cantera::Composition
map< string, double > Composition
Map from string names to doubles.
Definition ct_defs.h:184