Mallard 0.8.0
Unstructured, GPU accelerated, high-order finite volume CFD solver
Mallard website
Loading...
Searching...
No Matches
mechanism.h
Go to the documentation of this file.
1
12#ifndef CHEMISTRY_MECHANISM_H
13#define CHEMISTRY_MECHANISM_H
14
15#include <array>
16#include <cstdint>
17#include <string>
18#include <utility>
19#include <vector>
20
21namespace chemistry {
22
23// Physical constants (CODATA 2018 exact values, as in Cantera); quantities in kmol
24constexpr double AVOGADRO = 6.02214076e26; // 1/kmol
25constexpr double BOLTZMANN = 1.380649e-23; // J/K
26constexpr double GAS_CONSTANT = AVOGADRO * BOLTZMANN; // J/(kmol K)
27constexpr double ELEMENTARY_CHARGE = 1.602176634e-19; // C
28constexpr double ONE_ATM = 101325.0; // Pa
29constexpr double LIGHT_SPEED = 299792458.0; // m/s
30constexpr double EPSILON_0 = 8.854187812773345e-12; // F/m, as in Cantera
31
36double atomic_weight(const std::string & symbol);
37
38enum class ThermoModel {
39 NASA7,
40 NASA9,
42};
43
57 std::vector<double> T_bounds; // n_ranges + 1, increasing
58 std::vector<std::array<double, 9>> coeffs; // per range
59 std::array<double, 4> constant_cp = {}; // CONSTANT_CP: T0 [K], h0 [J/kmol], s0, cp0 [J/(kmol K)]
60
65 size_t range(double T) const;
66};
67
68enum class MoleculeGeometry {
69 ATOM,
70 LINEAR,
72};
73
80 double diameter = 0.0; // Lennard-Jones collision diameter [m]
81 double well_depth = 0.0; // Lennard-Jones well depth [J]
82 double dipole = 0.0; // [C m]
83 double polarizability = 0.0; // [m^3]
84 double rotational_relaxation = 0.0; // collision number at 298 K
85};
86
87struct Species {
88 std::string name;
89 std::vector<std::pair<std::string, double>> composition; // element, atoms
90 double molecular_weight = 0.0; // kg/kmol
92 bool has_transport = false;
94};
95
97struct Arrhenius {
98 double A = 0.0;
99 double b = 0.0;
100 double Ea_R = 0.0; // activation energy over the gas constant [K]
101};
102
103enum class ReactionType {
106 FALLOFF,
107 PLOG, // pressure-dependent Arrhenius: ln k interpolated linearly in ln p
108 CHEBYSHEV, // log10 k as a Chebyshev series in 1/T and log10 p
109};
110
111enum class FalloffType {
112 LINDEMANN,
113 TROE,
114 SRI,
115};
116
122struct Reaction {
123 std::string equation;
125 std::vector<std::pair<uint32_t, double>> reactants; // species, stoichiometric coefficient
126 std::vector<std::pair<uint32_t, double>> products;
127 std::vector<std::pair<uint32_t, double>> orders; // forward reaction orders of the reactants
128 bool reversible = true;
129 bool duplicate = false;
130 Arrhenius rate; // falloff: the high-pressure limit
131 Arrhenius low; // falloff: the low-pressure limit
133 std::array<double, 5> falloff_params = {}; // Troe A, T3, T1, T2; SRI a, b, c, d, e
134 std::vector<std::pair<uint32_t, double>> efficiencies; // third-body efficiencies other than the default
135 double default_efficiency = 1.0;
136 std::vector<std::pair<double, Arrhenius>> plog; // PLOG: (pressure [Pa], rate), by increasing pressure
137 std::array<double, 4> chebyshev_range = {}; // Chebyshev: T_min, T_max [K], p_min, p_max [Pa]
139 std::vector<double> chebyshev; // (n_T x n_p) coefficients of log10 k, k in SI with kmol
140};
141
145struct Mechanism {
146 std::string file;
147 std::string phase;
148 std::vector<std::string> elements;
149 std::vector<Species> species;
150 std::vector<Reaction> reactions;
151
152 uint32_t n_species() const { return static_cast<uint32_t>(species.size()); }
153
155 int32_t species_index(const std::string & name) const;
156
157 std::vector<std::string> species_names() const;
158};
159
167Mechanism read_mechanism(const std::string & file, const std::string & phase = "");
168
169} // namespace chemistry
170
171#endif // CHEMISTRY_MECHANISM_H
KOKKOS_INLINE_FUNCTION rtype dot(const rtype *a, const rtype *b)
Compute the dot product of two arrays.
Definition common_math.h:32
const char * symbol
Definition mechanism.cpp:33
Definition kinetics.h:25
constexpr double ONE_ATM
Definition mechanism.h:28
MoleculeGeometry
Definition mechanism.h:68
constexpr double GAS_CONSTANT
Definition mechanism.h:26
ThermoModel
Definition mechanism.h:38
constexpr double BOLTZMANN
Definition mechanism.h:25
double atomic_weight(const std::string &symbol)
Atomic weight in kg/kmol of an element symbol (Cantera's table; case-insensitive),...
Definition mechanism.cpp:600
constexpr double LIGHT_SPEED
Definition mechanism.h:29
constexpr double ELEMENTARY_CHARGE
Definition mechanism.h:27
ReactionType
Definition mechanism.h:103
FalloffType
Definition mechanism.h:111
constexpr double EPSILON_0
Definition mechanism.h:30
constexpr double AVOGADRO
Definition mechanism.h:24
Mechanism read_mechanism(const std::string &file, const std::string &phase)
Read a phase of a Cantera YAML file.
Definition mechanism.cpp:628
Modified Arrhenius rate k = A T^b exp(-Ea / (R T)), SI units with kmol.
Definition mechanism.h:97
double b
Definition mechanism.h:99
double A
Definition mechanism.h:98
double Ea_R
Definition mechanism.h:100
One ideal-gas phase of a Cantera YAML file: its elements, species and reactions.
Definition mechanism.h:145
std::vector< Species > species
Definition mechanism.h:149
uint32_t n_species() const
Definition mechanism.h:152
std::vector< std::string > species_names() const
Definition mechanism.cpp:622
std::vector< std::string > elements
Definition mechanism.h:148
int32_t species_index(const std::string &name) const
Index of a species by name, or -1 if the mechanism has none.
Definition mechanism.cpp:615
std::string phase
Definition mechanism.h:147
std::vector< Reaction > reactions
Definition mechanism.h:150
std::string file
Definition mechanism.h:146
A gas-phase reaction: elementary, three-body or falloff (Lindemann, Troe, SRI), reversible (reverse r...
Definition mechanism.h:122
std::array< double, 5 > falloff_params
Definition mechanism.h:133
FalloffType falloff
Definition mechanism.h:132
bool reversible
Definition mechanism.h:128
ReactionType type
Definition mechanism.h:124
uint32_t chebyshev_n_p
Definition mechanism.h:138
std::vector< std::pair< double, Arrhenius > > plog
Definition mechanism.h:136
std::vector< double > chebyshev
Definition mechanism.h:139
std::vector< std::pair< uint32_t, double > > products
Definition mechanism.h:126
std::vector< std::pair< uint32_t, double > > reactants
Definition mechanism.h:125
uint32_t chebyshev_n_T
Definition mechanism.h:138
std::string equation
Definition mechanism.h:123
double default_efficiency
Definition mechanism.h:135
std::vector< std::pair< uint32_t, double > > efficiencies
Definition mechanism.h:134
Arrhenius low
Definition mechanism.h:131
Arrhenius rate
Definition mechanism.h:130
std::vector< std::pair< uint32_t, double > > orders
Definition mechanism.h:127
std::array< double, 4 > chebyshev_range
Definition mechanism.h:137
bool duplicate
Definition mechanism.h:129
Species thermodynamics as piecewise polynomials in NASA-9 form, one per temperature range: cp/R = a0/...
Definition mechanism.h:55
std::array< double, 4 > constant_cp
Definition mechanism.h:59
ThermoModel model
Definition mechanism.h:56
std::vector< std::array< double, 9 > > coeffs
Definition mechanism.h:58
size_t range(double T) const
Index of the range used at T. As in Cantera, a NASA-7 bound belongs to the range below it,...
Definition mechanism.cpp:608
std::vector< double > T_bounds
Definition mechanism.h:57
Gas transport data of a species (Cantera's "gas" transport model), in SI units.
Definition mechanism.h:78
double rotational_relaxation
Definition mechanism.h:84
double well_depth
Definition mechanism.h:81
double dipole
Definition mechanism.h:82
double diameter
Definition mechanism.h:80
MoleculeGeometry geometry
Definition mechanism.h:79
double polarizability
Definition mechanism.h:83
Definition mechanism.h:87
std::vector< std::pair< std::string, double > > composition
Definition mechanism.h:89
double molecular_weight
Definition mechanism.h:90
SpeciesTransport transport
Definition mechanism.h:93
std::string name
Definition mechanism.h:88
SpeciesThermo thermo
Definition mechanism.h:91
bool has_transport
Definition mechanism.h:92