Cantera  2.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Mu0Poly.h
Go to the documentation of this file.
1 /**
2  * @file Mu0Poly.h
3  * Header for a single-species standard state object derived
4  * from \link Cantera::SpeciesThermoInterpType SpeciesThermoInterpType\endlink based
5  * on a piecewise constant mu0 interpolation
6  * (see \ref spthermo and class \link Cantera::Mu0Poly Mu0Poly\endlink).
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 public:
74  //! Constructor
75  Mu0Poly();
76 
77  //! Constructor used in templated instantiations
78  /*!
79  * In the constructor, we calculate and store the
80  * piecewise linear approximation to the thermodynamic
81  * functions.
82  *
83  * @param n Species index
84  * @param tlow Minimum temperature
85  * @param thigh Maximum temperature
86  * @param pref reference pressure (Pa).
87  * @param coeffs Vector of coefficients used to set the
88  * parameters for the standard state for species n.
89  * There are \f$ 2+npoints*2 \f$ coefficients, where
90  * \f$ npoints \f$ are the number of temperature points.
91  * Their identity is further broken down:
92  * - coeffs[0] = number of points (integer)
93  * - coeffs[1] = \f$ h^o(298.15 K) \f$ (J/kmol)
94  * - coeffs[2] = \f$ T_1 \f$ (Kelvin)
95  * - coeffs[3] = \f$ \mu^o(T_1) \f$ (J/kmol)
96  * - coeffs[4] = \f$ T_2 \f$ (Kelvin)
97  * - coeffs[5] = \f$ \mu^o(T_2) \f$ (J/kmol)
98  * - coeffs[6] = \f$ T_3 \f$ (Kelvin)
99  * - coeffs[7] = \f$ \mu^o(T_3) \f$ (J/kmol)
100  * - ........
101  * .
102  * @deprecated Use the constructor which does not require the species index.
103  * To be removed after Cantera 2.2.
104  */
105  Mu0Poly(size_t n, doublereal tlow, doublereal thigh,
106  doublereal pref, const doublereal* coeffs);
107 
108  //! Normal constructor
109  /*!
110  * In the constructor, we calculate and store the piecewise linear
111  * approximation to the thermodynamic functions.
112  *
113  * @param tlow Minimum temperature
114  * @param thigh Maximum temperature
115  * @param pref reference pressure (Pa).
116  * @param coeffs Vector of coefficients used to set the
117  * parameters for the standard state for species n.
118  * There are \f$ 2+npoints*2 \f$ coefficients, where
119  * \f$ npoints \f$ are the number of temperature points.
120  * Their identity is further broken down:
121  * - coeffs[0] = number of points (integer)
122  * - coeffs[1] = \f$ h^o(298.15 K) \f$ (J/kmol)
123  * - coeffs[2] = \f$ T_1 \f$ (Kelvin)
124  * - coeffs[3] = \f$ \mu^o(T_1) \f$ (J/kmol)
125  * - coeffs[4] = \f$ T_2 \f$ (Kelvin)
126  * - coeffs[5] = \f$ \mu^o(T_2) \f$ (J/kmol)
127  * - coeffs[6] = \f$ T_3 \f$ (Kelvin)
128  * - coeffs[7] = \f$ \mu^o(T_3) \f$ (J/kmol)
129  * - ........
130  * .
131  */
132  Mu0Poly(double tlow, double thigh, double pref, const double* coeffs);
133 
134  //! Copy constructor
135  Mu0Poly(const Mu0Poly&);
136 
137  //! Assignment operator
138  Mu0Poly& operator=(const Mu0Poly&);
139 
140  virtual SpeciesThermoInterpType*
141  duplMyselfAsSpeciesThermoInterpType() const;
142 
143  virtual int reportType() const {
144  return MU0_INTERP;
145  }
146 
147  //! Update the properties for this species, given a temperature polynomial
148  /*!
149  * This method is called with a pointer to an array containing the functions of
150  * temperature needed by this parameterization, and three pointers to arrays where the
151  * computed property values should be written. This method updates only one value in
152  * each array.
153  *
154  * Temperature Polynomial:
155  *
156  * tPoly[0] = temp (Kelvin)
157  *
158  * @param tPoly vector of temperature polynomials. Length = 1
159  * @param cp_R Vector of Dimensionless heat capacities. (length m_kk).
160  * @param h_RT Vector of Dimensionless enthalpies. (length m_kk).
161  * @param s_R Vector of Dimensionless entropies. (length m_kk).
162  */
163  virtual void updateProperties(const doublereal* tPoly,
164  doublereal* cp_R, doublereal* h_RT,
165  doublereal* s_R) const ;
166 
167  virtual void updatePropertiesTemp(const doublereal temp,
168  doublereal* cp_R,
169  doublereal* h_RT,
170  doublereal* s_R) const ;
171  virtual void reportParameters(size_t& n, int& type,
172  doublereal& tlow, doublereal& thigh,
173  doublereal& pref,
174  doublereal* const coeffs) const;
175 
176  //! Modify parameters for the standard state
177  /*!
178  * @param coeffs Vector of coefficients used to set the
179  * parameters for the standard state.
180  */
181  virtual void modifyParameters(doublereal* coeffs);
182 
183 protected:
184  /**
185  * Number of intervals in the interpolating linear approximation. Number
186  * of points is one more than the number of intervals.
187  */
189 
190  /**
191  * Value of the enthalpy at T = 298.15. This value is tied to the Heat of
192  * formation of the species at 298.15.
193  */
194  doublereal m_H298;
195 
196  //! Points at which the standard state chemical potential are given.
198 
199  /**
200  * Mu0's are primary input data. They aren't strictly
201  * needed, but are kept here for convenience.
202  */
204 
205  //! Dimensionless Enthalpies at the temperature points
207 
208  //! Entropy at the points
210 
211  //! Heat capacity at the points
213 
214 private:
215  //! process the coefficients
216  /*!
217  * Mu0Poly():
218  *
219  * In the constructor, we calculate and store the piecewise linear
220  * approximation to the thermodynamic functions.
221  *
222  * @param coeffs coefficients. These are defined as follows:
223  *
224  * coeffs[0] = number of points (integer)
225  * 1 = H298(J/kmol)
226  * 2 = T1 (Kelvin)
227  * 3 = mu1 (J/kmol)
228  * 4 = T2 (Kelvin)
229  * 5 = mu2 (J/kmol)
230  * 6 = T3 (Kelvin)
231  * 7 = mu3 (J/kmol)
232  * ........
233  */
234  void processCoeffs(const doublereal* coeffs);
235 };
236 
237 //! Install a Mu0 polynomial thermodynamic reference state
238 /*!
239  * Install a Mu0 polynomial thermodynamic reference state property
240  * parameterization for species k into a SpeciesThermo instance,
241  * getting the information from an XML database.
242  *
243  * @param Mu0Node Pointer to the XML element containing the
244  * Mu0 information.
245  *
246  * @ingroup spthermo
247  */
248 Mu0Poly* newMu0ThermoFromXML(const XML_Node& Mu0Node);
249 }
250 
251 #endif
Pure Virtual Base class for the thermodynamic manager for an individual species' reference state...
vector_fp m_s0_R_int
Entropy at the points.
Definition: Mu0Poly.h:209
virtual void updatePropertiesTemp(const doublereal temp, doublereal *cp_R, doublereal *h_RT, doublereal *s_R) const
Compute the reference-state property of one species.
Definition: Mu0Poly.cpp:92
Mu0Poly()
Constructor.
Definition: Mu0Poly.cpp:17
size_t m_numIntervals
Number of intervals in the interpolating linear approximation.
Definition: Mu0Poly.h:188
Class XML_Node is a tree-based representation of the contents of an XML file.
Definition: xml.h:100
vector_fp m_cp0_R_int
Heat capacity at the points.
Definition: Mu0Poly.h:212
The Mu0Poly class implements an interpolation of the Gibbs free energy based on a piecewise constant ...
Definition: Mu0Poly.h:71
virtual int reportType() const
Returns an integer representing the type of parameterization.
Definition: Mu0Poly.h:143
doublereal m_H298
Value of the enthalpy at T = 298.15.
Definition: Mu0Poly.h:194
#define MU0_INTERP
piecewise interpolation of mu0.
Pure Virtual Base class for individual species reference state thermodynamic managers and text for th...
virtual 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...
Definition: Mu0Poly.cpp:100
Mu0Poly & operator=(const Mu0Poly &)
Assignment operator.
Definition: Mu0Poly.cpp:52
vector_fp m_mu0_R_int
Mu0's are primary input data.
Definition: Mu0Poly.h:203
virtual void modifyParameters(doublereal *coeffs)
Modify parameters for the standard state.
Definition: Mu0Poly.cpp:120
virtual void updateProperties(const doublereal *tPoly, doublereal *cp_R, doublereal *h_RT, doublereal *s_R) const
Update the properties for this species, given a temperature polynomial.
Definition: Mu0Poly.cpp:73
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
vector_fp m_t0_int
Points at which the standard state chemical potential are given.
Definition: Mu0Poly.h:197
vector_fp m_h0_R_int
Dimensionless Enthalpies at the temperature points.
Definition: Mu0Poly.h:206
Mu0Poly * newMu0ThermoFromXML(const XML_Node &Mu0Node)
Install a Mu0 polynomial thermodynamic reference state.
Definition: Mu0Poly.cpp:125
void processCoeffs(const doublereal *coeffs)
process the coefficients
Definition: Mu0Poly.cpp:191