Cantera  2.0
StatMech.h
Go to the documentation of this file.
1 /**
2  * @file StatMech.h
3  * Header for a single-species standard state object derived
4  * from
5  */
6 /*
7  * Copyright(2006) Sandia Corporation. Under the terms of
8  * Contract DE-AC04-94AL85000 with Sandia Corporation, the
9  * U.S. Government retains certain rights in this software.
10  */
11 
12 #ifndef CT_STATMECH_H
13 #define CT_STATMECH_H
14 
15 #include "cantera/base/global.h"
17 #include "SpeciesThermoMgr.h"
18 #include <string>
19 #include <map>
20 
21 namespace Cantera
22 {
23 
24 // Statistical mechanics
25 /*!
26  * @ingroup spthermo
27  */
28 class StatMech : public SpeciesThermoInterpType
29 {
30 
31 public:
32 
33  //! Empty constructor
34  StatMech();
35 
36 
37  //! constructor used in templated instantiations
38  /*!
39  * @param n Species index
40  * @param tlow Minimum temperature
41  * @param thigh Maximum temperature
42  * @param pref reference pressure (Pa).
43  * @param coeffs Vector of coefficients used to set the
44  * parameters for the standard state.
45  */
46  StatMech(int n, doublereal tlow, doublereal thigh, doublereal pref,
47  const doublereal* coeffs, const std::string& my_name);
48 
49  //! copy constructor
50  /*!
51  * @param b object to be copied
52  */
53  StatMech(const StatMech& b);
54 
55  //! assignment operator
56  /*!
57  * @param b object to be copied
58  */
59  StatMech& operator=(const StatMech& b);
60 
61  //! Destructor
62  virtual ~StatMech();
63 
64  //! duplicator
66  duplMyselfAsSpeciesThermoInterpType() const;
67 
68  //! Returns the minimum temperature that the thermo
69  //! parameterization is valid
70  virtual doublereal minTemp() const;
71 
72  //! Returns the maximum temperature that the thermo
73  //! parameterization is valid
74  virtual doublereal maxTemp() const;
75 
76  //! Returns the reference pressure (Pa)
77  virtual doublereal refPressure() const;
78 
79  //! Returns an integer representing the type of parameterization
80  virtual int reportType() const;
81 
82  //! Returns an integer representing the species index
83  virtual size_t speciesIndex() const;
84 
85  //! Build a series of maps for the properties needed for species
86  int buildmap();
87 
88  //! Update the properties for this species, given a temperature polynomial
89  /*!
90  * This method is called with a pointer to an array containing the
91  * functions of temperature needed by this parameterization, and three
92  * pointers to arrays where the computed property values should be
93  * written. This method updates only one value in each array.
94  *
95  * \f[
96  * \frac{C_p^0(T)}{R} = \frac{C_v^0(T)}{R} + 1
97  * \f]
98  *
99  * Where,
100  * \f[
101  * \frac{C_v^0(T)}{R} = \frac{C_v^{tr}(T)}{R} + \frac{C_v^{vib}(T)}{R}
102  * \f]
103  *
104  * Temperature Polynomial:
105  * tt[0] = t;
106  *
107  * @param tt vector of temperature polynomials
108  * @param cp_R Vector of Dimensionless heat capacities. (length m_kk).
109  * @param h_RT Vector of Dimensionless enthalpies. (length m_kk).
110  * @param s_R Vector of Dimensionless entropies. (length m_kk).
111  */
112  virtual void updateProperties(const doublereal* tt,
113  doublereal* cp_R, doublereal* h_RT, doublereal* s_R) const;
114 
115 
116  //! Compute the reference-state property of one species
117  /*!
118  * Given temperature T in K, this method updates the values of the non-
119  * dimensional heat capacity at constant pressure, enthalpy, and entropy,
120  * at the reference pressure, Pref of one of the species. The species
121  * index is used to reference into the cp_R, h_RT, and s_R arrays.
122  *
123  * @param temp Temperature (Kelvin)
124  * @param cp_R Vector of Dimensionless heat capacities. (length m_kk).
125  * @param h_RT Vector of Dimensionless enthalpies. (length m_kk).
126  * @param s_R Vector of Dimensionless entropies. (length m_kk).
127  */
128  virtual void updatePropertiesTemp(const doublereal temp,
129  doublereal* cp_R, doublereal* h_RT,
130  doublereal* s_R) const;
131 
132  //! This utility function reports back the type of parameterization and
133  //! all of the parameters for the species, index.
134  /*!
135  * All parameters are output variables
136  *
137  * @param n Species index
138  * @param type Integer type of the standard type
139  * @param tlow output - Minimum temperature
140  * @param thigh output - Maximum temperature
141  * @param pref output - reference pressure (Pa).
142  * @param coeffs Vector of coefficients used to set the
143  * parameters for the standard state. There are
144  * 12 of them, designed to be compatible
145  * with the multiple temperature formulation.
146  * coeffs[0] is equal to one.
147  * coeffs[1] is min temperature
148  * coeffs[2] is max temperature
149  * coeffs[3+i] from i =0,9 are the coefficients themselves
150  */
151  virtual void reportParameters(size_t& n, int& type,
152  doublereal& tlow, doublereal& thigh,
153  doublereal& pref,
154  doublereal* const coeffs) const;
155 
156  //! Modify parameters for the standard state
157  /*!
158  * @param coeffs Vector of coefficients used to set the
159  * parameters for the standard state.
160  */
161  virtual void modifyParameters(doublereal* coeffs);
162 
163 protected:
164  //! lowest valid temperature
165  doublereal m_lowT;
166  //! highest valid temperature
167  doublereal m_highT;
168  //! standard-state pressure
169  doublereal m_Pref;
170  //! species index
171  int m_index;
172  //! array of polynomial coefficients
173  vector_fp m_coeff;
174 
175  std::string sp_name;
176 
177  //*generic species struct that contains everything we need here
178  // achtung: add doxygen markup here
179  // achtung: convert doubles to realdoubles
180  struct species {
181  //Nominal T-R Degrees of freedom (cv = cfs*k*T)
182  doublereal cfs;
183 
184  // Mol. Wt. Molecular weight (kg/kmol)
185  doublereal mol_weight;
186 
187  // number of vibrational temperatures necessary
188  int nvib;
189 
190  // Theta_v Characteristic vibrational temperature(s) (K)
191  doublereal theta[5];
192  };
193 
194  std::map<std::string,species*> name_map;
195 
196 };
197 
198 }
199 #endif