Skip to content

Commit 5b58690

Browse files
ischoeglspeth
authored andcommitted
[Kinetics] Eliminate chained function calls
1 parent 6eb1e83 commit 5b58690

File tree

2 files changed

+25
-37
lines changed

2 files changed

+25
-37
lines changed

include/cantera/kinetics/Arrhenius.h

Lines changed: 21 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -166,25 +166,29 @@ class Arrhenius3 : public ArrheniusBase
166166
}
167167

168168
//! Evaluate reaction rate
169-
//! @internal Non-virtual method that should not be overloaded
170169
double evalRate(double logT, double recipT) const {
171170
return m_A * std::exp(m_b * logT - m_Ea_R * recipT);
172171
}
173172

174173
//! Evaluate natural logarithm of the rate constant.
175-
//! @internal Non-virtual method that should not be overloaded
176174
double evalLog(double logT, double recipT) const {
177175
return m_logA + m_b * logT - m_Ea_R * recipT;
178176
}
179177

180178
//! Evaluate reaction rate
181-
double evalRate(const ArrheniusData& shared_data) const {
179+
/*!
180+
* @param shared_data data shared by all reactions of a given type
181+
*/
182+
double evalFromStruct(const ArrheniusData& shared_data) const {
182183
return m_A * std::exp(m_b * shared_data.logT - m_Ea_R * shared_data.recipT);
183184
}
184185

185186
//! Evaluate derivative of reaction rate with respect to temperature
186187
//! divided by reaction rate
187-
double ddTScaled(const ArrheniusData& shared_data) const {
188+
/*!
189+
* @param shared_data data shared by all reactions of a given type
190+
*/
191+
double ddTScaledFromStruct(const ArrheniusData& shared_data) const {
188192
return (m_Ea_R * shared_data.recipT + m_b) * shared_data.recipT;
189193
}
190194
};
@@ -228,12 +232,13 @@ class TwoTempPlasma : public ArrheniusBase
228232
return "two-temperature-plasma";
229233
}
230234

231-
//! Context
232235
virtual void setContext(const Reaction& rxn, const Kinetics& kin) override;
233236

234237
//! Evaluate reaction rate
235-
//! @internal Non-virtual method that should not be overloaded
236-
double evalRate(const TwoTempPlasmaData& shared_data) const {
238+
/*!
239+
* @param shared_data data shared by all reactions of a given type
240+
*/
241+
double evalFromStruct(const TwoTempPlasmaData& shared_data) const {
237242
// m_E4_R is the electron activation (in temperature units)
238243
return m_A * std::exp(m_b * shared_data.logTe -
239244
m_Ea_R * shared_data.recipT +
@@ -246,9 +251,9 @@ class TwoTempPlasma : public ArrheniusBase
246251
/*!
247252
* This method does not consider changes of electron temperature.
248253
* A corresponding warning is raised.
249-
* @internal Non-virtual method that should not be overloaded
254+
* @param shared_data data shared by all reactions of a given type
250255
*/
251-
double ddTScaled(const TwoTempPlasmaData& shared_data) const;
256+
double ddTScaledFromStruct(const TwoTempPlasmaData& shared_data) const;
252257

253258
//! Return the electron activation energy *Ea* [J/kmol]
254259
double activationElectronEnergy() const {
@@ -313,7 +318,6 @@ class BlowersMasel : public ArrheniusBase
313318
return "Blowers-Masel";
314319
}
315320

316-
//! Set context
317321
virtual void setContext(const Reaction& rxn, const Kinetics& kin) override;
318322

319323
//! Update information specific to reaction
@@ -330,20 +334,21 @@ class BlowersMasel : public ArrheniusBase
330334
}
331335

332336
//! Evaluate reaction rate
333-
//! @internal Non-virtual method that should not be overloaded
334-
double evalRate(const BlowersMaselData& shared_data) const {
337+
/*!
338+
* @param shared_data data shared by all reactions of a given type
339+
*/
340+
double evalFromStruct(const BlowersMaselData& shared_data) const {
335341
double Ea_R = effectiveActivationEnergy_R(m_deltaH_R);
336342
return m_A * std::exp(m_b * shared_data.logT - Ea_R * shared_data.recipT);
337343
}
338344

339-
//! Evaluate derivative of reaction rate with respect to temperature
340345
//! divided by reaction rate
341346
/*!
342347
* This method does not consider potential changes due to a changed reaction
343348
* enthalpy. A corresponding warning is raised.
344-
* @internal Non-virtual method that should not be overloaded
349+
* @param shared_data data shared by all reactions of a given type
345350
*/
346-
double ddTScaled(const BlowersMaselData& shared_data) const;
351+
double ddTScaledFromStruct(const BlowersMaselData& shared_data) const;
347352

348353
//! Return the effective activation energy (a function of the delta H of reaction)
349354
//! divided by the gas constant (i.e. the activation temperature) [K]
@@ -384,7 +389,7 @@ class BlowersMasel : public ArrheniusBase
384389

385390
//! A class template for bulk phase reaction rate specifications
386391
template <class RateType, class DataType>
387-
class BulkRate final : public RateType
392+
class BulkRate : public RateType
388393
{
389394
public:
390395
BulkRate() = default;
@@ -425,23 +430,6 @@ class BulkRate final : public RateType
425430
node["type"] = RateType::type();
426431
}
427432
}
428-
429-
//! Evaluate reaction rate
430-
/*!
431-
* @param shared_data data shared by all reactions of a given type
432-
*/
433-
double evalFromStruct(const DataType& shared_data) const {
434-
return RateType::evalRate(shared_data);
435-
}
436-
437-
//! Evaluate derivative of reaction rate with respect to temperature
438-
//! divided by reaction rate
439-
/*!
440-
* @param shared_data data shared by all reactions of a given type
441-
*/
442-
double ddTScaledFromStruct(const DataType& shared_data) const {
443-
return RateType::ddTScaled(shared_data);
444-
}
445433
};
446434

447435
typedef BulkRate<Arrhenius3, ArrheniusData> ArrheniusRate;

src/kinetics/Arrhenius.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,16 +141,16 @@ TwoTempPlasma::TwoTempPlasma(double A, double b, double Ea, double EE)
141141
m_E4_R = EE / GasConstant;
142142
}
143143

144-
double TwoTempPlasma::ddTScaled(const TwoTempPlasmaData& shared_data) const
144+
double TwoTempPlasma::ddTScaledFromStruct(const TwoTempPlasmaData& shared_data) const
145145
{
146-
warn_user("TwoTempPlasma::ddTScaled",
146+
warn_user("TwoTempPlasma::ddTScaledFromStruct",
147147
"Temperature derivative does not consider changes of electron temperature.");
148148
return (m_Ea_R - m_E4_R) * shared_data.recipT * shared_data.recipT;
149149
}
150150

151151
void TwoTempPlasma::setContext(const Reaction& rxn, const Kinetics& kin)
152152
{
153-
// TwoTempPlasmaReaction is for a non-equilirium plasma, and the reverse rate
153+
// TwoTempPlasmaReaction is for a non-equilibrium plasma, and the reverse rate
154154
// cannot be calculated from the conventional thermochemistry.
155155
// @todo implement the reversible rate for non-equilibrium plasma
156156
if (rxn.reversible) {
@@ -175,7 +175,7 @@ BlowersMasel::BlowersMasel(double A, double b, double Ea0, double w)
175175
m_E4_R = w / GasConstant;
176176
}
177177

178-
double BlowersMasel::ddTScaled(const BlowersMaselData& shared_data) const
178+
double BlowersMasel::ddTScaledFromStruct(const BlowersMaselData& shared_data) const
179179
{
180180
warn_user("BlowersMasel::ddTScaledFromStruct",
181181
"Temperature derivative does not consider changes of reaction enthalpy.");

0 commit comments

Comments
 (0)