Cantera  2.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ThirdBodyCalc.h
Go to the documentation of this file.
1 /**
2  * @file ThirdBodyCalc.h
3  */
4 
5 #ifndef CT_THIRDBODYCALC_H
6 #define CT_THIRDBODYCALC_H
7 
9 #include <cassert>
10 
11 namespace Cantera
12 {
13 
14 //! Calculate and apply third-body effects on reaction rates, including non-
15 //! unity third-body efficiencies.
17 {
18 public:
19  void install(size_t rxnNumber, const std::map<size_t, double>& enhanced,
20  double dflt=1.0) {
21  m_reaction_index.push_back(rxnNumber);
22  m_default.push_back(dflt);
23 
24  m_species.push_back(std::vector<size_t>());
25  m_eff.push_back(vector_fp());
26  for (std::map<size_t, double>::const_iterator iter = enhanced.begin();
27  iter != enhanced.end();
28  ++iter)
29  {
30  assert(iter->first != npos);
31  m_species.back().push_back(iter->first);
32  m_eff.back().push_back(iter->second - dflt);
33  }
34  }
35 
36  void update(const vector_fp& conc, double ctot, double* work) {
37  for (size_t i = 0; i < m_species.size(); i++) {
38  double sum = 0.0;
39  for (size_t j = 0; j < m_species[i].size(); j++) {
40  sum += m_eff[i][j] * conc[m_species[i][j]];
41  }
42  work[i] = m_default[i] * ctot + sum;
43  }
44  }
45 
46  void multiply(double* output, const double* work) {
47  scatter_mult(work, work + m_reaction_index.size(),
48  output, m_reaction_index.begin());
49  }
50 
51  size_t workSize() {
52  return m_reaction_index.size();
53  }
54 
55 protected:
56  //! Indices of third-body reactions within the full reaction array
57  std::vector<size_t> m_reaction_index;
58 
59  //! m_species[i][j] is the index of the j-th species in reaction i.
60  std::vector<std::vector<size_t> > m_species;
61 
62  //! m_eff[i][j] is the efficiency of the j-th species in reaction i.
63  std::vector<vector_fp> m_eff;
64 
65  //! The default efficiency for each reaction
67 };
68 
69 }
70 
71 #endif
vector_fp m_default
The default efficiency for each reaction.
Definition: ThirdBodyCalc.h:66
Various templated functions that carry out common vector operations (see Templated Utility Functions)...
const size_t npos
index returned by functions to indicate "no position"
Definition: ct_defs.h:165
Calculate and apply third-body effects on reaction rates, including non- unity third-body efficiencie...
Definition: ThirdBodyCalc.h:16
void scatter_mult(InputIter mult_begin, InputIter mult_end, RandAccessIter data, IndexIter index)
Multiply selected elements in an array by a contiguous sequence of multipliers.
Definition: utilities.h:475
std::vector< std::vector< size_t > > m_species
m_species[i][j] is the index of the j-th species in reaction i.
Definition: ThirdBodyCalc.h:60
std::vector< vector_fp > m_eff
m_eff[i][j] is the efficiency of the j-th species in reaction i.
Definition: ThirdBodyCalc.h:63
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
Definition: ct_defs.h:157
std::vector< size_t > m_reaction_index
Indices of third-body reactions within the full reaction array.
Definition: ThirdBodyCalc.h:57