1 /**
2  * @file ReactionData.h
3  */
4 
5 // This file is part of Cantera. See License.txt in the top-level directory or
6 // at https://cantera.org/license.txt for license and copyright information.
7 
8 #ifndef CT_REACTIONDATA_H
9 #define CT_REACTIONDATA_H
10 
11 #include "cantera/base/ct_defs.h"
12 
13 namespace Cantera
14 {
15 
16 class ThermoPhase;
17 
18 
19 //! Data container holding shared data specific to ArrheniusRate
20 /**
21  * The data container `ArrheniusData` holds precalculated data common to
22  * all `ArrheniusRate` objects.
23  */
24 struct ArrheniusData
25 {
ArrheniusDataArrheniusData26     ArrheniusData() : m_temperature(1.), m_logT(0.), m_recipT(1.) {}
27 
28     //! Update data container based on temperature *T*
updateArrheniusData29     void update(double T)
30     {
31         m_temperature = T;
32         m_logT = std::log(T);
33         m_recipT = 1./T;
34     }
35 
36     //! Update data container based on temperature *T* and pressure *P*
updateArrheniusData37     void update(double T, double P) { update(T); }
38 
39     //! Update data container based on *bulk* phase state
40     void update(const ThermoPhase& bulk);
41 
42     //! Update number of species; unused
resizeSpeciesArrheniusData43     void resizeSpecies(size_t n_species) {}
44 
45     double m_temperature; //!< temperature
46     double m_logT; //!< logarithm of temperature
47     double m_recipT;  //!< inverse of temperature
48 };
49 
50 
51 //! Data container holding shared data specific to PlogRate
52 /**
53  * The data container `PlogData` holds precalculated data common to
54  * all `PlogRate` objects.
55  */
56 struct PlogData
57 {
PlogDataPlogData58     PlogData() : m_temperature(1.), m_logT(0.), m_recipT(1.), m_logP(0.) {}
59 
60     //! Update data container based on temperature *T* (raises exception)
61     void update(double T);
62 
63     //! Update data container based on temperature *T* and *P*
updatePlogData64     void update(double T, double P)
65     {
66         m_temperature = T;
67         m_logT = std::log(T);
68         m_recipT = 1./T;
69         m_logP = std::log(P);
70    }
71 
72     //! Update data container based on *bulk* phase state
73     void update(const ThermoPhase& bulk);
74 
75     //! Update number of species; unused
resizeSpeciesPlogData76     void resizeSpecies(size_t n_species) {}
77 
78     double m_temperature; //!< temperature
79     double m_logT; //!< logarithm of temperature
80     double m_recipT; //!< inverse of temperature
81     double m_logP; //!< logarithm of pressure
82 };
83 
84 
85 //! Data container holding shared data specific to ChebyshevRate
86 /**
87  * The data container `ChebyshevData` holds precalculated data common to
88  * all `ChebyshevRate3` objects.
89  */
90 struct ChebyshevData
91 {
ChebyshevDataChebyshevData92     ChebyshevData() : m_temperature(1.), m_recipT(1.), m_log10P(0.) {}
93 
94     //! Update data container based on temperature *T* (raises exception)
95     void update(double T);
96 
97     //! Update data container based on temperature *T* and *P*
updateChebyshevData98     void update(double T, double P)
99     {
100         m_temperature = T;
101         m_recipT = 1./T;
102         m_log10P = std::log10(P);
103     }
104 
105     //! Update data container based on *bulk* phase state
106     void update(const ThermoPhase& bulk);
107 
108     //! Update number of species; unused
resizeSpeciesChebyshevData109     void resizeSpecies(size_t n_species) {}
110 
111     double m_temperature; //!< temperature
112     double m_recipT; //!< inverse of temperature
113     double m_log10P; //!< base 10 logarithm of pressure
114 };
115 
116 
117 //! Data container holding shared data specific to CustomFunc1Rate
118 struct CustomFunc1Data
119 {
CustomFunc1DataCustomFunc1Data120     CustomFunc1Data() : m_temperature(1.) {}
121 
122     //! Update data container based on temperature *T*
updateCustomFunc1Data123     void update(double T) { m_temperature = T; }
124 
125     //! Update data container based on temperature *T* and pressure *P*
updateCustomFunc1Data126     void update(double T, double P) { update(T); }
127 
128     //! Update data container based on *bulk* phase state
129     void update(const ThermoPhase& bulk);
130 
131     //! Update number of species; unused
resizeSpeciesCustomFunc1Data132     void resizeSpecies(size_t n_species) {}
133 
134     double m_temperature; //!< temperature
135 };
136 
137 }
138 
139 #endif
140