[Kinetics] Combine ThirdBodyMgr and Enhanced3BConc as ThirdBodyCalc
The old classes are now deprecated. The name change was needed to avoid collisions with no-longer-necessary template parameter.
This commit is contained in:
parent
dab74d2d10
commit
60c221c845
4 changed files with 89 additions and 28 deletions
|
|
@ -8,12 +8,14 @@
|
|||
#define CT_ENH_CONC_H
|
||||
|
||||
#include "cantera/base/ct_defs.h"
|
||||
#include "cantera/base/global.h"
|
||||
|
||||
namespace Cantera
|
||||
{
|
||||
|
||||
/**
|
||||
* Computes enhanced third-body concentrations.
|
||||
* @deprecated Replaced by ThirdBodyCalc. To be removed after Cantera 2.2.
|
||||
* @see GasKinetics
|
||||
*/
|
||||
class Enhanced3BConc
|
||||
|
|
@ -21,45 +23,38 @@ class Enhanced3BConc
|
|||
|
||||
public:
|
||||
|
||||
Enhanced3BConc() : m_n(0), m_deflt(1.0) {}
|
||||
Enhanced3BConc() : m_deflt(1.0) {
|
||||
warn_deprecated("class Enhanced3BConc",
|
||||
"To be removed after Cantera 2.2.");
|
||||
}
|
||||
|
||||
Enhanced3BConc(size_t n, const std::map<size_t, doublereal>& enhanced,
|
||||
Enhanced3BConc(const std::map<size_t, doublereal>& enhanced,
|
||||
doublereal deflt = 1.0) {
|
||||
warn_deprecated("class Enhanced3BConc",
|
||||
"To be removed after Cantera 2.2.");
|
||||
std::map<size_t, doublereal>::const_iterator iter;
|
||||
for (iter = enhanced.begin(); iter != enhanced.end(); ++iter) {
|
||||
m_index.push_back(iter->first);
|
||||
m_eff.push_back(iter->second - deflt);
|
||||
}
|
||||
m_deflt = deflt;
|
||||
m_n = n;
|
||||
}
|
||||
|
||||
Enhanced3BConc(size_t n, const std::vector<size_t>& e_index,
|
||||
const vector_fp& efficiencies, doublereal deflt = 1.0)
|
||||
: m_index(e_index), m_eff(efficiencies) {
|
||||
m_n = n;
|
||||
m_deflt = deflt;
|
||||
for (size_t i = 0; i < m_n; i++) {
|
||||
m_eff[i] -= m_deflt;
|
||||
}
|
||||
}
|
||||
|
||||
doublereal update(const vector_fp& c, doublereal ctot) const {
|
||||
doublereal sum = 0.0;
|
||||
for (size_t i = 0; i < m_n; i++) {
|
||||
for (size_t i = 0; i < m_eff.size(); i++) {
|
||||
sum += m_eff[i] * c[m_index[i]];
|
||||
}
|
||||
return m_deflt * ctot + sum;
|
||||
}
|
||||
|
||||
void getEfficiencies(vector_fp& eff) const {
|
||||
for (size_t i = 0; i < m_n; i++) {
|
||||
for (size_t i = 0; i < m_eff.size(); i++) {
|
||||
eff[m_index[i]] = m_eff[i] + m_deflt;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
size_t m_n;
|
||||
std::vector<size_t> m_index;
|
||||
vector_fp m_eff;
|
||||
doublereal m_deflt;
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
#define CT_GASKINETICS_H
|
||||
|
||||
#include "BulkKinetics.h"
|
||||
#include "ThirdBodyMgr.h"
|
||||
#include "ThirdBodyCalc.h"
|
||||
#include "FalloffMgr.h"
|
||||
#include "Reaction.h"
|
||||
|
||||
|
|
@ -80,8 +80,8 @@ protected:
|
|||
|
||||
FalloffMgr m_falloffn;
|
||||
|
||||
ThirdBodyMgr<Enhanced3BConc> m_3b_concm;
|
||||
ThirdBodyMgr<Enhanced3BConc> m_falloff_concm;
|
||||
ThirdBodyCalc m_3b_concm;
|
||||
ThirdBodyCalc m_falloff_concm;
|
||||
|
||||
Rate1<Plog> m_plog_rates;
|
||||
Rate1<ChebyshevRate> m_cheb_rates;
|
||||
|
|
|
|||
69
include/cantera/kinetics/ThirdBodyCalc.h
Normal file
69
include/cantera/kinetics/ThirdBodyCalc.h
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
/**
|
||||
* @file ThirdBodyCalc.h
|
||||
*/
|
||||
|
||||
#ifndef CT_THIRDBODYCALC_H
|
||||
#define CT_THIRDBODYCALC_H
|
||||
|
||||
#include "cantera/base/utilities.h"
|
||||
|
||||
namespace Cantera
|
||||
{
|
||||
|
||||
//! Calculate and apply third-body effects on reaction rates, including non-
|
||||
//! unity third-body efficiencies.
|
||||
class ThirdBodyCalc
|
||||
{
|
||||
public:
|
||||
void install(size_t rxnNumber, const std::map<size_t, double>& enhanced,
|
||||
double dflt=1.0) {
|
||||
m_reaction_index.push_back(rxnNumber);
|
||||
m_default.push_back(dflt);
|
||||
|
||||
m_species.push_back(std::vector<size_t>());
|
||||
m_eff.push_back(vector_fp());
|
||||
for (std::map<size_t, double>::const_iterator iter = enhanced.begin();
|
||||
iter != enhanced.end();
|
||||
++iter)
|
||||
{
|
||||
m_species.back().push_back(iter->first);
|
||||
m_eff.back().push_back(iter->second - dflt);
|
||||
}
|
||||
}
|
||||
|
||||
void update(const vector_fp& conc, double ctot, double* work) {
|
||||
for (size_t i = 0; i < m_species.size(); i++) {
|
||||
double sum = 0.0;
|
||||
for (size_t j = 0; j < m_species[i].size(); j++) {
|
||||
sum += m_eff[i][j] * conc[m_species[i][j]];
|
||||
}
|
||||
work[i] = m_default[i] * ctot + sum;
|
||||
}
|
||||
}
|
||||
|
||||
void multiply(double* output, const double* work) {
|
||||
scatter_mult(work, work + m_reaction_index.size(),
|
||||
output, m_reaction_index.begin());
|
||||
}
|
||||
|
||||
size_t workSize() {
|
||||
return m_reaction_index.size();
|
||||
}
|
||||
|
||||
protected:
|
||||
//! Indices of third-body reactions within the full reaction array
|
||||
std::vector<size_t> m_reaction_index;
|
||||
|
||||
//! m_species[i][j] is the index of the j-th species in reaction i.
|
||||
std::vector<std::vector<size_t> > m_species;
|
||||
|
||||
//! m_eff[i][j] is the efficiency of the j-th species in reaction i.
|
||||
std::vector<vector_fp> m_eff;
|
||||
|
||||
//! The default efficiency for each reaction
|
||||
vector_fp m_default;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -15,32 +15,31 @@
|
|||
namespace Cantera
|
||||
{
|
||||
|
||||
//! @deprecated Replaced by ThirdBodyCalc. To be removed after Cantera 2.2.
|
||||
template<class _E>
|
||||
class ThirdBodyMgr
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
ThirdBodyMgr<_E>() : m_n(0) {}
|
||||
ThirdBodyMgr() {
|
||||
warn_deprecated("class ThirdBodyMgr", "To be removed after Cantera 2.2.");
|
||||
}
|
||||
|
||||
void install(size_t rxnNumber, const std::map<size_t, doublereal>& enhanced,
|
||||
doublereal dflt=1.0) {
|
||||
m_n++;
|
||||
m_reaction_index.push_back(rxnNumber);
|
||||
m_concm.push_back(_E(static_cast<int>(enhanced.size()),
|
||||
enhanced, dflt));
|
||||
m_concm.push_back(_E(enhanced, dflt));
|
||||
}
|
||||
|
||||
void update(const vector_fp& conc, doublereal ctot, doublereal* work) {
|
||||
typename std::vector<_E>::const_iterator b = m_concm.begin();
|
||||
//doublereal* v = m_values.begin();
|
||||
for (; b != m_concm.end(); ++b, ++work) {
|
||||
*work = b->update(conc, ctot);
|
||||
}
|
||||
}
|
||||
|
||||
void multiply(doublereal* output, const doublereal* work) {
|
||||
scatter_mult(work, work + m_n,
|
||||
scatter_mult(work, work + m_reaction_index.size(),
|
||||
output, m_reaction_index.begin());
|
||||
}
|
||||
|
||||
|
|
@ -54,8 +53,6 @@ public:
|
|||
}
|
||||
|
||||
protected:
|
||||
|
||||
int m_n;
|
||||
std::vector<size_t> m_reaction_index;
|
||||
std::vector<_E> m_concm;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue