Cantera  2.1.2
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 #include "cantera/base/global.h"
16 
17 namespace Cantera
18 {
19 
20 /**
21  * An adsorbed surface species.
22  *
23  * This class is designed specifically for use by the class
24  * GeneralSpeciesThermo. It implements a model for the
25  * thermodynamic properties of a molecule that can be modeled as a
26  * set of independent quantum harmonic oscillators.
27  *
28  * @ingroup spthermo
29  */
31 {
32 public:
33 
34  //! Empty constructor
36  m_nFreqs(0) {
37  }
38 
39  //! Full Constructor
40  /*!
41  * @param n Species index
42  * @param tlow output - Minimum temperature
43  * @param thigh output - Maximum temperature
44  * @param pref output - reference pressure (Pa).
45  */
46  Adsorbate(size_t n, doublereal tlow, doublereal thigh, doublereal pref,
47  const doublereal* coeffs)
48  : SpeciesThermoInterpType(n, tlow, thigh, pref)
49  {
50  m_nFreqs = int(coeffs[0]);
51  m_be = coeffs[1];
52  m_freq.resize(m_nFreqs);
53  std::copy(coeffs+2, coeffs + 2 + m_nFreqs, m_freq.begin());
54  }
55 
56  /// Copy Constructor
57  Adsorbate(const Adsorbate& b) :
58  m_be(b.m_be) {
59  m_nFreqs = b.m_nFreqs;
60  std::copy(b.m_freq.begin(), b.m_freq.begin() + m_nFreqs,
61  m_freq.begin());
62  }
63 
66  Adsorbate* np = new Adsorbate(*this);
67  return (SpeciesThermoInterpType*) np;
68  }
69 
70  //! @deprecated Not a member of the base class
71  virtual void install(const std::string& name, size_t index, int type,
72  const doublereal* c, doublereal minTemp_, doublereal maxTemp_,
73  doublereal refPressure_) {
74  warn_deprecated("Adsorbate::install", "Not a member of the base class.");
75  m_be = c[1];
76  m_nFreqs = int(c[0]);
77  for (size_t n = 0; n < m_nFreqs; n++) {
78  m_freq[n] = c[n+2];
79  }
80  m_index = index;
81 
82  m_lowT = minTemp_;
83  m_highT = maxTemp_;
84  m_Pref = refPressure_;
85  }
86 
87  virtual int reportType() const {
88  return ADSORBATE;
89  }
90 
91  void updatePropertiesTemp(const doublereal temp,
92  doublereal* cp_R,
93  doublereal* h_RT,
94  doublereal* s_R) const {
95  h_RT[m_index] = _energy_RT(temp);
96  cp_R[m_index] = (temp*h_RT[m_index]
97  - (temp-0.01)*_energy_RT(temp-0.01))/0.01;
98  s_R[m_index] = h_RT[m_index] - _free_energy_RT(temp);
99  }
100 
101  //! @deprecated
102  void reportParameters(size_t& n, int& type,
103  doublereal& tlow, doublereal& thigh,
104  doublereal& pref,
105  doublereal* const coeffs) const {
106  warn_deprecated("AdsorbateThermo::reportParameters");
107  n = m_index;
108  type = ADSORBATE;
109  tlow = m_lowT;
110  thigh = m_highT;
111  pref = m_Pref;
112  coeffs[0] = static_cast<double>(m_nFreqs);
113  coeffs[1] = m_be;
114  for (size_t i = 2; i < m_nFreqs+2; i++) {
115  coeffs[i] = m_freq[i-2];
116  }
117  }
118 
119 protected:
120  size_t m_nFreqs;
121  //! array of vib frequencies
123  doublereal m_be;
124 
125  doublereal _energy_RT(double T) const {
126  doublereal x, hnu_kt, hnu, sum = 0.0;
127  doublereal kt = T*Boltzmann;
128  for (size_t i = 0; i < m_nFreqs; i++) {
129  hnu = Planck * m_freq[i];
130  hnu_kt = hnu/kt;
131  x = exp(-hnu_kt);
132  sum += hnu_kt * x/(1.0 - x);
133  }
134  return sum + m_be/(GasConstant*T);
135  }
136 
137  doublereal _free_energy_RT(double T) const {
138  doublereal x, hnu_kt, sum = 0.0;
139  doublereal kt = T*Boltzmann;
140  for (size_t i = 0; i < m_nFreqs; i++) {
141  hnu_kt = Planck * m_freq[i] / kt;
142  x = exp(-hnu_kt);
143  sum += log(1.0 - x);
144  }
145  return sum + m_be/(GasConstant*T);
146  }
147 
148  doublereal _entropy_R(double T) const {
149  return _energy_RT(T) - _free_energy_RT(T);
150  }
151 
152 };
153 
154 }
155 #endif
void reportParameters(size_t &n, int &type, doublereal &tlow, doublereal &thigh, doublereal &pref, doublereal *const coeffs) const
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...
void warn_deprecated(const std::string &method, const std::string &extra)
Print a warning indicating that method is deprecated.
Definition: global.cpp:76
Adsorbate()
Empty constructor.
Adsorbate(const Adsorbate &b)
Copy Constructor.
This file contains definitions for utility functions and text for modules, inputfiles, logs, textlogs, HTML_logs (see Input File Handling, Diagnostic Output, Writing messages to the screen and Writing HTML Logfiles).
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...
virtual void install(const std::string &name, size_t index, int type, const doublereal *c, doublereal minTemp_, doublereal maxTemp_, doublereal refPressure_)
doublereal m_highT
Highest valid temperature.
const doublereal Planck
Planck's constant. [J-s].
Definition: ct_defs.h:81
doublereal m_lowT
lowest valid temperature
An adsorbed surface species.
virtual SpeciesThermoInterpType * duplMyselfAsSpeciesThermoInterpType() const
duplicator
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:165
const doublereal GasConstant
Universal Gas Constant. [J/kmol/K].
Definition: ct_defs.h:66
doublereal m_Pref
Reference state pressure.
const doublereal Boltzmann
Boltzmann's constant [J/K].
Definition: ct_defs.h:78
#define ADSORBATE
Surface Adsorbate Model for a species on a surface.