Cantera  2.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 // Copyright 2007 California Institute of Technology
10 
11 #ifndef CT_ADSORBATE_H
12 #define CT_ADSORBATE_H
13 
15 
16 namespace Cantera
17 {
18 
19 /**
20  * An adsorbed surface species.
21  *
22  * This class is designed specifically for use by the class
23  * GeneralSpeciesThermo. It implements a model for the
24  * thermodynamic properties of a molecule that can be modeled as a
25  * set of independent quantum harmonic oscillators.
26  *
27  * @ingroup spthermo
28  */
30 {
31 public:
32 
33  //! Empty constructor
35  m_nFreqs(0) {
36  }
37 
38  //! Full Constructor
39  /*!
40  * @param n Species index
41  * @param tlow output - Minimum temperature
42  * @param thigh output - Maximum temperature
43  * @param pref output - reference pressure (Pa).
44  * @deprecated Use the constructor which does not require the species index.
45  * To be removed after Cantera 2.2.
46  */
47  Adsorbate(size_t n, doublereal tlow, doublereal thigh, doublereal pref,
48  const doublereal* coeffs)
49  : SpeciesThermoInterpType(n, tlow, thigh, pref)
50  {
51  m_nFreqs = int(coeffs[0]);
52  m_be = coeffs[1];
53  m_freq.resize(m_nFreqs);
54  std::copy(coeffs+2, coeffs + 2 + m_nFreqs, m_freq.begin());
55  }
56 
57  //! Full Constructor
58  /*!
59  * @param tlow output - Minimum temperature
60  * @param thigh output - Maximum temperature
61  * @param pref output - reference pressure (Pa).
62  */
63  Adsorbate(double tlow, double thigh, double pref, const double* coeffs)
64  : SpeciesThermoInterpType(tlow, thigh, pref)
65  {
66  m_nFreqs = int(coeffs[0]);
67  m_be = coeffs[1];
68  m_freq.resize(m_nFreqs);
69  std::copy(coeffs+2, coeffs + 2 + m_nFreqs, m_freq.begin());
70  }
71 
72  /// Copy Constructor
73  Adsorbate(const Adsorbate& b) :
74  m_be(b.m_be) {
75  m_nFreqs = b.m_nFreqs;
76  std::copy(b.m_freq.begin(), b.m_freq.begin() + m_nFreqs,
77  m_freq.begin());
78  }
79 
81  duplMyselfAsSpeciesThermoInterpType() const {
82  Adsorbate* np = new Adsorbate(*this);
83  return (SpeciesThermoInterpType*) np;
84  }
85 
86  virtual int reportType() const {
87  return ADSORBATE;
88  }
89 
90  void updatePropertiesTemp(const doublereal temp,
91  doublereal* cp_R,
92  doublereal* h_RT,
93  doublereal* s_R) const {
94  h_RT[m_index] = _energy_RT(temp);
95  cp_R[m_index] = (temp*h_RT[m_index]
96  - (temp-0.01)*_energy_RT(temp-0.01))/0.01;
97  s_R[m_index] = h_RT[m_index] - _free_energy_RT(temp);
98  }
99 
100  void reportParameters(size_t& n, int& type,
101  doublereal& tlow, doublereal& thigh,
102  doublereal& pref,
103  doublereal* const coeffs) const {
104  n = m_index;
105  type = ADSORBATE;
106  tlow = m_lowT;
107  thigh = m_highT;
108  pref = m_Pref;
109  coeffs[0] = static_cast<double>(m_nFreqs);
110  coeffs[1] = m_be;
111  for (size_t i = 2; i < m_nFreqs+2; i++) {
112  coeffs[i] = m_freq[i-2];
113  }
114  }
115 
116 protected:
117  size_t m_nFreqs;
118  //! array of vib frequencies
120  doublereal m_be;
121 
122  doublereal _energy_RT(double T) const {
123  doublereal x, hnu_kt, hnu, sum = 0.0;
124  doublereal kt = T*Boltzmann;
125  for (size_t i = 0; i < m_nFreqs; i++) {
126  hnu = Planck * m_freq[i];
127  hnu_kt = hnu/kt;
128  x = exp(-hnu_kt);
129  sum += hnu_kt * x/(1.0 - x);
130  }
131  return sum + m_be/(GasConstant*T);
132  }
133 
134  doublereal _free_energy_RT(double T) const {
135  doublereal x, hnu_kt, sum = 0.0;
136  doublereal kt = T*Boltzmann;
137  for (size_t i = 0; i < m_nFreqs; i++) {
138  hnu_kt = Planck * m_freq[i] / kt;
139  x = exp(-hnu_kt);
140  sum += log(1.0 - x);
141  }
142  return sum + m_be/(GasConstant*T);
143  }
144 
145  doublereal _entropy_R(double T) const {
146  return _energy_RT(T) - _free_energy_RT(T);
147  }
148 
149 };
150 
151 }
152 #endif
void reportParameters(size_t &n, int &type, doublereal &tlow, doublereal &thigh, doublereal &pref, doublereal *const coeffs) const
This utility function reports back the type of parameterization and all of the parameters for the spe...
void updatePropertiesTemp(const doublereal temp, doublereal *cp_R, doublereal *h_RT, doublereal *s_R) const
Compute the reference-state property of one species.
Pure Virtual Base class for the thermodynamic manager for an individual species' reference state...
Adsorbate()
Empty constructor.
Adsorbate(const Adsorbate &b)
Copy Constructor.
virtual int reportType() const
Returns an integer representing the type of parameterization.
vector_fp m_freq
array of vib frequencies
Pure Virtual Base class for individual species reference state thermodynamic managers and text for th...
doublereal m_highT
Highest valid temperature.
const doublereal Planck
Planck's constant. [J-s].
Definition: ct_defs.h:79
doublereal m_lowT
lowest valid temperature
An adsorbed surface species.
Adsorbate(size_t n, doublereal tlow, doublereal thigh, doublereal pref, const doublereal *coeffs)
Full Constructor.
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
const doublereal GasConstant
Universal Gas Constant. [J/kmol/K].
Definition: ct_defs.h:64
Adsorbate(double tlow, double thigh, double pref, const double *coeffs)
Full Constructor.
doublereal m_Pref
Reference state pressure.
const doublereal Boltzmann
Boltzmann's constant [J/K].
Definition: ct_defs.h:76
#define ADSORBATE
Surface Adsorbate Model for a species on a surface.