Cantera  2.0
AdsorbateThermo.h
Go to the documentation of this file.
1 /**
2  * @file AdsorbateThermo.h
3  *
4  * Header for a single-species standard
5  * state object derived from \link Cantera::SpeciesThermoInterpType
6  * SpeciesThermoInterpType\endlink based on the expressions for the
7  * thermo properties of a species with several vibrational models.
8  *
9  */
10 // Copyright 2007 California Institute of Technology
11 
12 
13 #ifndef CT_ADSORBATE_H
14 #define CT_ADSORBATE_H
15 
17 
18 namespace Cantera
19 {
20 
21 /**
22  * An adsorbed surface species.
23  *
24  * This class is designed specifically for use by the class
25  * GeneralSpeciesThermo. It implements a model for the
26  * thermodynamic properties of a molecule that can be modeled as a
27  * set of independent quantum harmonic oscillators.
28  *
29  * @ingroup spthermo
30  */
32 {
33 
34 public:
35 
36  //! Empty constructor
38  : m_lowT(0.0),
39  m_highT(0.0),
40  m_index(0),
41  m_nFreqs(0) {
42  }
43 
44 
45  //! Full Constructor
46  /*!
47  * @param n Species index
48  * @param tlow output - Minimum temperature
49  * @param thigh output - Maximum temperature
50  * @param pref output - reference pressure (Pa).
51  */
52  Adsorbate(size_t n, doublereal tlow, doublereal thigh, doublereal pref,
53  const doublereal* coeffs) : m_lowT(tlow),
54  m_highT(thigh),
55  m_index(n) {
56  m_nFreqs = int(coeffs[0]);
57  m_be = coeffs[1];
58  m_freq.resize(m_nFreqs);
59  std::copy(coeffs+2, coeffs + 2 + m_nFreqs, m_freq.begin());
60  }
61 
62  /// Copy Constructor
63  Adsorbate(const Adsorbate& b) :
64  m_lowT(b.m_lowT),
65  m_highT(b.m_highT),
66  m_Pref(b.m_Pref),
67  m_index(b.m_index),
68  m_be(b.m_be) {
69  m_nFreqs = b.m_nFreqs;
70  std::copy(b.m_freq.begin(), b.m_freq.begin() + m_nFreqs,
71  m_freq.begin());
72  }
73 
74  //! destructor
75  virtual ~Adsorbate() {}
76 
77  //! duplicator
80  Adsorbate* np = new Adsorbate(*this);
81  return (SpeciesThermoInterpType*) np;
82  }
83 
84  virtual void install(std::string name, size_t index, int type,
85  const doublereal* c, doublereal minTemp, doublereal maxTemp,
86  doublereal refPressure) {
87  m_be = c[1];
88  m_nFreqs = int(c[0]);
89  for (size_t n = 0; n < m_nFreqs; n++) {
90  m_freq[n] = c[n+2];
91  }
92  m_index = index;
93 
94  m_lowT = minTemp;
95  m_highT = maxTemp;
97  }
98 
99 
100  //! Returns the minimum temperature that the thermo
101  //! parameterization is valid
102  virtual doublereal minTemp() const {
103  return m_lowT;
104  }
105 
106  //! Returns the maximum temperature that the thermo
107  //! parameterization is valid
108  virtual doublereal maxTemp() const {
109  return m_highT;
110  }
111 
112  //! Returns the reference pressure (Pa)
113  virtual doublereal refPressure() const {
114  return OneAtm;
115  }
116 
117  //! Returns an integer representing the type of parameterization
118  virtual int reportType() const {
119  return ADSORBATE;
120  }
121 
122  //! Returns an integer representing the species index
123  virtual size_t speciesIndex() const {
124  return m_index;
125  }
126 
127 
128  //! Compute the reference-state property of one species
129  /*!
130  * Given temperature T in K, this method updates the values of
131  * the non-dimensional heat capacity at constant pressure,
132  * enthalpy, and entropy, at the reference pressure, Pref
133  * of one of the species. The species index is used
134  * to reference into the cp_R, h_RT, and s_R arrays.
135  *
136  * @param temp Temperature (Kelvin)
137  * @param cp_R Vector of Dimensionless heat capacities.
138  * (length m_kk).
139  * @param h_RT Vector of Dimensionless enthalpies.
140  * (length m_kk).
141  * @param s_R Vector of Dimensionless entropies.
142  * (length m_kk).
143  */
144  void updatePropertiesTemp(const doublereal temp,
145  doublereal* cp_R,
146  doublereal* h_RT,
147  doublereal* s_R) const {
148  h_RT[m_index] = _energy_RT(temp);
149  cp_R[m_index] = (temp*h_RT[m_index]
150  - (temp-0.01)*_energy_RT(temp-0.01))/0.01;
151  s_R[m_index] = h_RT[m_index] - _free_energy_RT(temp);
152  }
153 
154  //! This utility function reports back the type of
155  /*! parameterization and all of the parameters for the
156  * species, index.
157  *
158  * All parameters are output variables
159  *
160  * @param n Species index
161  * @param type Integer type of the standard type
162  * @param tlow output - Minimum temperature
163  * @param thigh output - Maximum temperature
164  * @param pref output - reference pressure (Pa).
165  * @param coeffs Vector of coefficients used to set the
166  * parameters for the standard state.
167  */
168  void reportParameters(size_t& n, int& type,
169  doublereal& tlow, doublereal& thigh,
170  doublereal& pref,
171  doublereal* const coeffs) const {
172  n = m_index;
173  type = ADSORBATE;
174  tlow = m_lowT;
175  thigh = m_highT;
176  pref = m_Pref;
177  coeffs[0] = static_cast<double>(m_nFreqs);
178  coeffs[1] = m_be;
179  for (size_t i = 2; i < m_nFreqs+2; i++) {
180  coeffs[i] = m_freq[i-2];
181  }
182  }
183 
184 protected:
185  //! lowest valid temperature
186  doublereal m_lowT;
187  //! Highest valid temperature
188  doublereal m_highT;
189  //! Reference state pressure
190  doublereal m_Pref;
191  //! species index
192  size_t m_index;
193  size_t m_nFreqs;
194  //! array of vib frequencies
196  doublereal m_be;
197 
198 
199  doublereal _energy_RT(double T) const {
200  doublereal x, hnu_kt, hnu, sum = 0.0;
201  doublereal kt = T*Boltzmann;
202  for (size_t i = 0; i < m_nFreqs; i++) {
203  hnu = Planck * m_freq[i];
204  hnu_kt = hnu/kt;
205  x = exp(-hnu_kt);
206  sum += hnu_kt * x/(1.0 - x);
207  }
208  return sum + m_be/(GasConstant*T);
209  }
210 
211  doublereal _free_energy_RT(double T) const {
212  doublereal x, hnu_kt, sum = 0.0;
213  doublereal kt = T*Boltzmann;
214  for (size_t i = 0; i < m_nFreqs; i++) {
215  hnu_kt = Planck * m_freq[i] / kt;
216  x = exp(-hnu_kt);
217  sum += log(1.0 - x);
218  }
219  return sum + m_be/(GasConstant*T);
220  }
221 
222  doublereal _entropy_R(double T) const {
223  return _energy_RT(T) - _free_energy_RT(T);
224  }
225 
226 };
227 
228 }
229 #endif
230 
231 
232 
233