Cantera  2.0
Mu0Poly.h
Go to the documentation of this file.
1 /**
2  * @file Mu0Poly.h
3  * Header for a single-species standard state object derived
5  * on a piecewise constant mu0 interpolation
7  */
8 #ifndef CT_MU0POLY_H
9 #define CT_MU0POLY_H
10
12
13 namespace Cantera
14 {
15 class SpeciesThermo;
16 class XML_Node;
17
18 //! The %Mu0Poly class implements an interpolation of the Gibbs free energy based on a
19 //! piecewise constant heat capacity approximation.
20 /*!
21  * The %Mu0Poly class implements a piecewise constant heat capacity approximation.
22  * of the standard state chemical potential of one
23  * species at a single reference pressure.
24  * The chemical potential is input as a series of (\f$T\f$, \f$\mu^o(T)\f$)
25  * values. The first temperature is assumed to be equal
26  * to 298.15 K; however, this may be relaxed in the future.
27  * This information, and an assumption of a constant
28  * heat capacity within each interval is enough to
29  * calculate all thermodynamic functions.
30  *
31  * The piece-wise constant heat capacity is calculated from the change in the chemical potential over each interval.
32  * Once the heat capacity is known, the other thermodynamic functions may be determined.
33  * The basic equation for going from temperature point 1 to temperature point 2
34  * are as follows for \f$T \f$, \f$T_1 <= T <= T_2 \f$
35  *
36  * \f[
37  * \mu^o(T_1) = h^o(T_1) - T_1 * s^o(T_1)
38  * \f]
39  * \f[
40  * \mu^o(T_2) - \mu^o(T_1) = Cp^o(T_1)(T_2 - T_1) - Cp^o(T_1)(T_2)ln(\frac{T_2}{T_1}) - s^o(T_1)(T_2 - T_1)
41  * \f]
42  * \f[
43  * s^o(T_2) = s^o(T_1) + Cp^o(T_1)ln(\frac{T_2}{T_1})
44  * \f]
45  * \f[
46  * h^o(T_2) = h^o(T_1) + Cp^o(T_1)(T_2 - T_1)
47  * \f]
48  *
49  * Within each interval the following relations are used. For \f$T \f$, \f$T_1 <= T <= T_2 \f$
50  *
51  * \f[
52  * \mu^o(T) = \mu^o(T_1) + Cp^o(T_1)(T - T_1) - Cp^o(T_1)(T_2)ln(\frac{T}{T_1}) - s^o(T_1)(T - T_1)
53  * \f]
54  * \f[
55  * s^o(T) = s^o(T_1) + Cp^o(T_1)ln(\frac{T}{T_1})
56  * \f]
57  * \f[
58  * h^o(T) = h^o(T_1) + Cp^o(T_1)(T - T_1)
59  * \f]
60  *
61  * Notes about temperature interpolation for \f$T < T_1 \f$ and \f$T > T_{npoints} \f$.
62  * These are achieved by assuming a constant heat capacity
63  * equal to the value in the closest temperature interval.
64  * No error is thrown.
65  *
66  * @note In the future, a better assumption about the heat
67  * capacity may be employed, so that it can be continuous.
68  *
69  * @ingroup spthermo
70  */
72 {
73
74 public:
75
76  //! Constructor
77  Mu0Poly();
78
79  //! Constructor used in templated instantiations
80  /*!
81  *
82  * In the constructor, we calculate and store the
83  * piecewise linear approximation to the thermodynamic
84  * functions.
85  *
86  * @param n Species index
87  * @param tlow Minimum temperature
88  * @param thigh Maximum temperature
89  * @param pref reference pressure (Pa).
90  * @param coeffs Vector of coefficients used to set the
91  * parameters for the standard state for species n.
92  * There are \f$2+npoints*2 \f$ coefficients, where
93  * \f$npoints \f$ are the number of temperature points.
94  * Their identity is further broken down:
95  * - coeffs = number of points (integer)
96  * - coeffs = \f$h^o(298.15 K) \f$ (J/kmol)
97  * - coeffs = \f$T_1 \f$ (Kelvin)
98  * - coeffs = \f$\mu^o(T_1) \f$ (J/kmol)
99  * - coeffs = \f$T_2 \f$ (Kelvin)
100  * - coeffs = \f$\mu^o(T_2) \f$ (J/kmol)
101  * - coeffs = \f$T_3 \f$ (Kelvin)
102  * - coeffs = \f$\mu^o(T_3) \f$ (J/kmol)
103  * - ........
104  * .
105  */
106  Mu0Poly(size_t n, doublereal tlow, doublereal thigh,
107  doublereal pref, const doublereal* coeffs);
108
109  //! Copy constructor
110  Mu0Poly(const Mu0Poly&);
111
112  //! Assignment operator
113  Mu0Poly& operator=(const Mu0Poly&);
114
115  //! Destructor
116  virtual ~Mu0Poly();
117
118  //! Duplicator
119  virtual SpeciesThermoInterpType*
121
122  //! Returns the minimum temperature that the thermo
123  //! parameterization is valid
124  virtual doublereal minTemp() const;
125
126  //! Returns the maximum temperature that the thermo
127  //! parameterization is valid
128  virtual doublereal maxTemp() const;
129
130  //! Returns the reference pressure (Pa)
131  virtual doublereal refPressure() const;
132
133  //! Returns an integer representing the type of parameterization
134  virtual int reportType() const {
135  return MU0_INTERP;
136  }
137
138  //! Returns an integer representing the species index
139  virtual size_t speciesIndex() const {
140  return m_index;
141  }
142
143  //! Update the properties for this species, given a temperature polynomial
144  /*!
145  * This method is called with a pointer to an array containing the functions of
146  * temperature needed by this parameterization, and three pointers to arrays where the
147  * computed property values should be written. This method updates only one value in
148  * each array.
149  *
150  * Temperature Polynomial:
151  *
152  * tPoly = temp (Kelvin)
153  *
154  * @param tPoly vector of temperature polynomials. Length = 1
155  * @param cp_R Vector of Dimensionless heat capacities.
156  * (length m_kk).
157  * @param h_RT Vector of Dimensionless enthalpies.
158  * (length m_kk).
159  * @param s_R Vector of Dimensionless entropies.
160  * (length m_kk).
161  */
162  virtual void updateProperties(const doublereal* tPoly,
163  doublereal* cp_R, doublereal* h_RT,
164  doublereal* s_R) const ;
165
166  //! Compute the reference-state property of one species
167  /*!
168  * Given temperature T in K, this method updates the values of
169  * the non-dimensional heat capacity at constant pressure,
170  * enthalpy, and entropy, at the reference pressure, Pref
171  * of one of the species. The species index is used
172  * to reference into the cp_R, h_RT, and s_R arrays.
173  *
174  * @param temp Temperature (Kelvin)
175  * @param cp_R Vector of Dimensionless heat capacities.
176  * (length m_kk).
177  * @param h_RT Vector of Dimensionless enthalpies.
178  * (length m_kk).
179  * @param s_R Vector of Dimensionless entropies.
180  * (length m_kk).
181  */
182  virtual void updatePropertiesTemp(const doublereal temp,
183  doublereal* cp_R,
184  doublereal* h_RT,
185  doublereal* s_R) const ;
186
187  //!This utility function reports back the type of
188  //! parameterization and all of the parameters for the
189  //! species, index.
190  /*!
191  * All parameters are output variables
192  *
193  * @param n Species index
194  * @param type Integer type of the standard type
195  * @param tlow output - Minimum temperature
196  * @param thigh output - Maximum temperature
197  * @param pref output - reference pressure (Pa).
198  * @param coeffs Vector of coefficients used to set the
199  * parameters for the standard state.
200  */
201  virtual void reportParameters(size_t& n, int& type,
202  doublereal& tlow, doublereal& thigh,
203  doublereal& pref,
204  doublereal* const coeffs) const;
205
206  //! Modify parameters for the standard state
207  /*!
208  * @param coeffs Vector of coefficients used to set the
209  * parameters for the standard state.
210  */
211  virtual void modifyParameters(doublereal* coeffs);
212
213 protected:
214
215  /**
216  * Number of intervals in the interpolating linear
217  * approximation. Number of points is one more than the
218  * number of intervals.
219  */
221
222  /**
223  * Value of the enthalpy at T = 298.15.
224  * This value is tied to the Heat of formation of
225  * the species at 298.15.
226  */
227  doublereal m_H298;
228
229  /**
230  * Points at which the standard state chemical potential
231  * are given.
232  */
234
235  /**
236  * Mu0's are primary input data. They aren't strictly
237  * needed, but are kept here for convenience.
238  */
240
241  //! Dimensionless Enthalpies at the temperature points
243
244  //! Entropy at the points
246
247  //! Heat capacity at the points
249  //! Limiting low temperature
250  doublereal m_lowT;
251  //! Limiting high temperature
252  doublereal m_highT;
253
254  //! Reference pressure
255  doublereal m_Pref;
256
257  //! Species index
258  size_t m_index;
259
260 private:
261
262  //! process the coefficients
263  /*!
264  * Mu0Poly():
265  *
266  * In the constructor, we calculate and store the
267  * piecewise linear approximation to the thermodynamic
268  * functions.
269  *
270  * @param coeffs coefficients. These are defined as follows:
271  *
272  * coeffs = number of points (integer)
273  * 1 = H298(J/kmol)
274  * 2 = T1 (Kelvin)
275  * 3 = mu1 (J/kmol)
276  * 4 = T2 (Kelvin)
277  * 5 = mu2 (J/kmol)
278  * 6 = T3 (Kelvin)
279  * 7 = mu3 (J/kmol)
280  * ........
281  */
282  void processCoeffs(const doublereal* coeffs);
283
284 };
285
286 //! Install a Mu0 polynomial thermodynamic reference state
287 /*!
288  * Install a Mu0 polynomial thermodynamic reference state property
289  * parameterization for species k into a SpeciesThermo instance,
290  * getting the information from an XML database.
291  *
292  * @param speciesName Name of the species
293  * @param sp Owning SpeciesThermo object
294  * @param k Species index
295  * @param Mu0Node_ptr Pointer to the XML element containing the
296  * Mu0 information.
297  *
298  * @ingroup spthermo
299  */
300 void installMu0ThermoFromXML(std::string speciesName,
301  SpeciesThermo& sp, size_t k,
302  const XML_Node* Mu0Node_ptr);
303 }
304
305 #endif
306
307