Cantera  2.1.2
Enhanced3BConc.h
Go to the documentation of this file.
1 /**
2  * @file Enhanced3BConc.h
3  */
4 // Copyright 2001 California Institute of Technology
5 
6 
7 #ifndef CT_ENH_CONC_H
8 #define CT_ENH_CONC_H
9 
10 #include "cantera/base/ct_defs.h"
11 
12 namespace Cantera
13 {
14 
15 /**
16  * Computes enhanced third-body concentrations.
17  * @see GasKinetics
18  */
20 {
21 
22 public:
23 
24  Enhanced3BConc() : m_n(0), m_deflt(1.0) {}
25 
26  Enhanced3BConc(size_t n, const std::map<size_t, doublereal>& enhanced,
27  doublereal deflt = 1.0) {
28  std::map<size_t, doublereal>::const_iterator iter;
29  for (iter = enhanced.begin(); iter != enhanced.end(); ++iter) {
30  m_index.push_back(iter->first);
31  m_eff.push_back(iter->second - deflt);
32  }
33  m_deflt = deflt;
34  m_n = n;
35  }
36 
37  Enhanced3BConc(size_t n, const std::vector<size_t>& e_index,
38  const vector_fp& efficiencies, doublereal deflt = 1.0)
39  : m_index(e_index), m_eff(efficiencies) {
40  m_n = n;
41  m_deflt = deflt;
42  for (size_t i = 0; i < m_n; i++) {
43  m_eff[i] -= m_deflt;
44  }
45  }
46 
47  doublereal update(const vector_fp& c, doublereal ctot) const {
48  doublereal sum = 0.0;
49  for (size_t i = 0; i < m_n; i++) {
50  sum += m_eff[i] * c[m_index[i]];
51  }
52  return m_deflt * ctot + sum;
53  }
54 
55  void getEfficiencies(vector_fp& eff) const {
56  for (size_t i = 0; i < m_n; i++) {
57  eff[m_index[i]] = m_eff[i] + m_deflt;
58  }
59  }
60 
61 private:
62  size_t m_n;
63  std::vector<size_t> m_index;
64  vector_fp m_eff;
65  doublereal m_deflt;
66 };
67 
68 }
69 
70 #endif
71 
72 
73 
74 
This file contains definitions of terms that are used in internal routines and are unlikely to need m...
Computes enhanced third-body concentrations.
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:165