Cantera  2.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SingleSpeciesTP.h
Go to the documentation of this file.
1 /**
2  * @file SingleSpeciesTP.h
3  * Header for the SingleSpeciesTP class, which is a filter class for ThermoPhase,
4  * that eases the construction of single species phases
5  * ( see \ref thermoprops and class \link Cantera::SingleSpeciesTP SingleSpeciesTP\endlink).
6  *
7  */
8 /*
9  * Copyright (2005) Sandia Corporation. Under the terms of
10  * Contract DE-AC04-94AL85000 with Sandia Corporation, the
11  * U.S. Government retains certain rights in this software.
12  */
13 #ifndef CT_SINGLESPECIESTP_H
14 #define CT_SINGLESPECIESTP_H
15 
16 #include "ThermoPhase.h"
17 
18 
19 namespace Cantera
20 {
21 
22 /**
23  * @ingroup thermoprops
24  *
25  * The SingleSpeciesTP class is a filter class for ThermoPhase.
26  * What it does is to simplify the construction of ThermoPhase
27  * objects by assuming that the phase consists of one and
28  * only one type of species. In other words, it's a stoichiometric
29  * phase. However, no assumptions are made concerning the
30  * thermodynamic functions or the equation of state of the
31  * phase. Therefore it's an incomplete description of
32  * the thermodynamics. The complete description must be
33  * made in a derived class of SingleSpeciesTP.
34  *
35  * Several different groups of thermodynamic functions are resolved
36  * at this level by this class. For example, All partial molar property
37  * routines call their single species standard state equivalents.
38  * All molar solution thermodynamic routines call the single species
39  * standard state equivalents.
40  * Activities routines are resolved at this level, as there is only
41  * one species.
42  *
43  * It is assumed that the reference state thermodynamics may be
44  * obtained by a pointer to a populated species thermodynamic property
45  * manager class (see ThermoPhase::m_spthermo). How to relate pressure
46  * changes to the reference state thermodynamics is again left open
47  * to implementation.
48  *
49  * Mole fraction and Mass fraction vectors are assumed to be equal
50  * to x[0] = 1 y[0] = 1, respectively. Simplifications to the interface
51  * of setState_TPY() and setState_TPX() functions result and are made
52  * within the class.
53  *
54  * Note, this class can handle the thermodynamic description of one
55  * phase of one species. It can not handle the description of phase
56  * equilibrium between two phases of a stoichiometric compound
57  * (e.g. water liquid and water vapor, below the critical point).
58  * However, it may be used to describe the thermodynamics of one phase
59  * of such a compound even past the phase equilibrium point, up to the
60  * point where the phase itself ceases to be a stable phase.
61  *
62  * This class doesn't do much at the initialization level.
63  * Its SingleSpeciesTP::initThermo()
64  * member does check that one and only one species has been defined
65  * to occupy the phase.
66  */
68 {
69 public:
70  //! Base empty constructor.
72 
73  //! Copy constructor
74  /*!
75  * @param right Object to be copied
76  */
77  SingleSpeciesTP(const SingleSpeciesTP& right);
78 
79  //! Assignment operator
80  /*!
81  * @param right Object to be copied
82  */
84 
85  //! Duplication function
86  /*!
87  * This virtual function is used to create a duplicate of the
88  * current phase. It's used to duplicate the phase when given
89  * a ThermoPhase pointer to the phase.
90  *
91  * @return It returns a ThermoPhase pointer.
92  */
94 
95  /**
96  * Returns the equation of state type flag.
97  * This is a modified base class.
98  * Therefore, if not overridden in derived classes,
99  * this call will throw an exception.
100  */
101  virtual int eosType() const;
102 
103  /**
104  * @name Molar Thermodynamic Properties of the Solution
105  *
106  * These functions are resolved at this level, by reference
107  * to the partial molar functions and standard state
108  * functions for species 0. Derived classes don't need
109  * to supply entries for these functions.
110  * @{
111  */
112 
113  /// Molar enthalpy. Units: J/kmol.
114  /*!
115  * This function is resolved here by calling the standard state
116  * thermo function.
117  */
118  doublereal enthalpy_mole() const;
119 
120  /// Molar internal energy. Units: J/kmol.
121  /*!
122  * This function is resolved here by calling the standard state
123  * thermo function.
124  */
125  doublereal intEnergy_mole() const;
126 
127  /// Molar entropy. Units: J/kmol/K.
128  /*!
129  * This function is resolved here by calling the standard state
130  * thermo function.
131  */
132  doublereal entropy_mole() const;
133 
134  /// Molar Gibbs function. Units: J/kmol.
135  /*!
136  * This function is resolved here by calling the standard state
137  * thermo function.
138  */
139  doublereal gibbs_mole() const;
140 
141  /// Molar heat capacity at constant pressure. Units: J/kmol/K.
142  /*!
143  * This function is resolved here by calling the standard state
144  * thermo function.
145  */
146  doublereal cp_mole() const;
147 
148  /// Molar heat capacity at constant volume. Units: J/kmol/K.
149  /*!
150  * This function is resolved here by calling the standard state
151  * thermo function.
152  */
153  doublereal cv_mole() const;
154 
155  /**
156  * @}
157  * @name Activities, Standard State, and Activity Concentrations
158  *
159  * The activity \f$a_k\f$ of a species in solution is
160  * related to the chemical potential by \f[ \mu_k = \mu_k^0(T)
161  * + \hat R T \log a_k. \f] The quantity \f$\mu_k^0(T)\f$ is
162  * the chemical potential at unit activity, which depends only
163  * on temperature.
164  * @{
165  */
166 
167  /**
168  * Get the array of non-dimensional activities at
169  * the current solution temperature, pressure, and
170  * solution concentration.
171  *
172  * We redefine this function to just return 1.0 here.
173  *
174  * @param a Output vector of activities. Length: 1.
175  */
176  virtual void getActivities(doublereal* a) const {
177  a[0] = 1.0;
178  }
179 
180  /**
181  * Get the array of non-dimensional activity coefficients at
182  * the current solution temperature, pressure, and
183  * solution concentration.
184  *
185  * @param ac Output vector of activity coefficients. Length: 1.
186  */
187  virtual void getActivityCoefficients(doublereal* ac) const {
188  ac[0] = 1.0;
189  }
190 
191  //@}
192  /// @name Partial Molar Properties of the Solution
193  ///
194  /// These functions are resolved at this level, by reference
195  /// to the partial molar functions and standard state
196  /// functions for species 0. Derived classes don't need
197  /// to supply entries for these functions.
198  //@{
199 
200  //! Get the array of non-dimensional species chemical potentials
201  //! These are partial molar Gibbs free energies.
202  /*!
203  * These are the phase, partial molar, and the standard state
204  * dimensionless chemical potentials.
205  * \f$ \mu_k / \hat R T \f$.
206  *
207  * Units: unitless
208  *
209  * @param murt On return, Contains the chemical potential / RT of the single species
210  * and the phase. Units are unitless. Length = 1
211  */
212  void getChemPotentials_RT(doublereal* murt) const;
213 
214  //! Get the array of chemical potentials
215  /*!
216  * These are the phase, partial molar, and the standard state chemical potentials.
217  * \f$ \mu(T,P) = \mu^0_k(T,P) \f$.
218  *
219  * @param mu On return, Contains the chemical potential of the single species
220  * and the phase. Units are J / kmol . Length = 1
221  */
222  void getChemPotentials(doublereal* mu) const;
223 
224  //! Get the species electrochemical potentials. Units: J/kmol.
225  /*!
226  * This method adds a term \f$ Fz_k \phi_k \f$ to
227  * each chemical potential.
228  *
229  * This is resolved here. A single species phase
230  * is not allowed to have anything other than a zero charge.
231  *
232  * @param mu On return, Contains the electrochemical potential of the single species
233  * and the phase. Units J/kmol . Length = 1
234  */
235  void getElectrochemPotentials(doublereal* mu) const;
236 
237  //! Get the species partial molar enthalpies. Units: J/kmol.
238  /*!
239  * These are the phase enthalpies. \f$ h_k \f$.
240  *
241  * @param hbar Output vector of species partial molar enthalpies.
242  * Length: 1. units are J/kmol.
243  */
244  void getPartialMolarEnthalpies(doublereal* hbar) const;
245 
246  //! Get the species partial molar internal energies. Units: J/kmol.
247  /*!
248  * These are the phase internal energies. \f$ u_k \f$.
249  *
250  * @param ubar On return, Contains the internal energy of the single species
251  * and the phase. Units are J / kmol . Length = 1
252  */
253  virtual void getPartialMolarIntEnergies(doublereal* ubar) const;
254 
255  //! Get the species partial molar entropy. Units: J/kmol K.
256  /*!
257  * This is the phase entropy. \f$ s(T,P) = s_o(T,P) \f$.
258  *
259  * @param sbar On return, Contains the entropy of the single species
260  * and the phase. Units are J / kmol / K . Length = 1
261  */
262  void getPartialMolarEntropies(doublereal* sbar) const;
263 
264  //! Get the species partial molar Heat Capacities. Units: J/ kmol /K.
265  /*!
266  * This is the phase heat capacity. \f$ Cp(T,P) = Cp_o(T,P) \f$.
267  *
268  * @param cpbar On return, Contains the heat capacity of the single species
269  * and the phase. Units are J / kmol / K . Length = 1
270  */
271  void getPartialMolarCp(doublereal* cpbar) const;
272 
273  //! Get the species partial molar volumes. Units: m^3/kmol.
274  /*!
275  * This is the phase molar volume. \f$ V(T,P) = V_o(T,P) \f$.
276  *
277  * @param vbar On return, Contains the molar volume of the single species
278  * and the phase. Units are m^3 / kmol. Length = 1
279  */
280  void getPartialMolarVolumes(doublereal* vbar) const;
281 
282  //@}
283  /// @name Properties of the Standard State of the Species in the Solution
284  /// These functions are the primary way real properties are
285  /// supplied to derived thermodynamics classes of SingleSpeciesTP.
286  /// These functions must be supplied in derived classes. They
287  /// are not resolved at the SingleSpeciesTP level.
288  //@{
289 
290  /**
291  * Get the dimensional Gibbs functions for the standard
292  * state of the species at the current T and P.
293  *
294  * @param gpure returns a vector of size 1, containing the Gibbs function
295  * Units: J/kmol.
296  */
297  void getPureGibbs(doublereal* gpure) const;
298 
299  //! Get the molar volumes of each species in their standard
300  //! states at the current <I>T</I> and <I>P</I> of the solution.
301  /*!
302  * units = m^3 / kmol
303  *
304  * We resolve this function at this level, by assigning
305  * the molecular weight divided by the phase density
306  *
307  * @param vbar On output this contains the standard volume of the species
308  * and phase (m^3/kmol). Vector of length 1
309  */
310  void getStandardVolumes(doublereal* vbar) const;
311 
312  //@}
313  /// @name Thermodynamic Values for the Species Reference State
314  ///
315  /// Almost all functions in this group are resolved by this
316  /// class. It is assumed that the m_spthermo species thermo
317  /// pointer is populated and yields the reference state thermodynamics
318  /// The internal energy function is not given by this
319  /// class, since it would involve a specification of the
320  /// equation of state.
321  //@{
322 
323  /*!
324  * Returns the vector of nondimensional
325  * enthalpies of the reference state at the current temperature
326  * of the solution and the reference pressure for the species.
327  *
328  * This function is resolved in this class. It is assumed that the m_spthermo species thermo
329  * pointer is populated and yields the reference state.
330  *
331  * @param hrt Output vector containing the nondimensional reference state enthalpies
332  * Length: m_kk.
333  */
334  virtual void getEnthalpy_RT_ref(doublereal* hrt) const;
335 
336  /*!
337  * Returns the vector of nondimensional
338  * enthalpies of the reference state at the current temperature
339  * of the solution and the reference pressure for the species.
340  *
341  * This function is resolved in this class. It is assumed that the m_spthermo species thermo
342  * pointer is populated and yields the reference state.
343  *
344  * @param grt Output vector containing the nondimensional reference state
345  * Gibbs Free energies. Length: m_kk.
346  */
347  virtual void getGibbs_RT_ref(doublereal* grt) const;
348 
349  /*!
350  * Returns the vector of the
351  * Gibbs function of the reference state at the current temperature
352  * of the solution and the reference pressure for the species.
353  * units = J/kmol
354  *
355  * This function is resolved in this class. It is assumed that the m_spthermo species thermo
356  * pointer is populated and yields the reference state.
357  *
358  * @param g Output vector containing the reference state
359  * Gibbs Free energies. Length: m_kk. Units: J/kmol.
360  */
361  virtual void getGibbs_ref(doublereal* g) const;
362 
363  /*!
364  * Returns the vector of nondimensional
365  * entropies of the reference state at the current temperature
366  * of the solution and the reference pressure for each species.
367  *
368  * This function is resolved in this class. It is assumed that the m_spthermo species thermo
369  * pointer is populated and yields the reference state.
370  *
371  * @param er Output vector containing the nondimensional reference state
372  * entropies. Length: m_kk.
373  */
374  virtual void getEntropy_R_ref(doublereal* er) const;
375 
376  /*!
377  * Returns the vector of nondimensional
378  * constant pressure heat capacities of the reference state
379  * at the current temperature of the solution
380  * and reference pressure for each species.
381  *
382  * This function is resolved in this class. It is assumed that the m_spthermo species thermo
383  * pointer is populated and yields the reference state.
384  *
385  * @param cprt Output vector of nondimensional reference state
386  * heat capacities at constant pressure for the species.
387  * Length: m_kk
388  */
389  virtual void getCp_R_ref(doublereal* cprt) const;
390 
391  /**
392  * @name Setting the State
393  *
394  * These methods set all or part of the thermodynamic state.
395  * @{
396  */
397 
398  //! Mass fractions are fixed, with Y[0] = 1.0.
399  void setMassFractions(const doublereal* const y) {};
400 
401  //! Mole fractions are fixed, with x[0] = 1.0.
402  void setMoleFractions(const doublereal* const x) {};
403 
404  //! Set the internally stored specific enthalpy (J/kg) and pressure (Pa) of the phase.
405  /*!
406  * @param h Specific enthalpy (J/kg)
407  * @param p Pressure (Pa)
408  * @param tol Optional parameter setting the tolerance of the
409  * calculation.
410  */
411  virtual void setState_HP(doublereal h, doublereal p,
412  doublereal tol = 1.e-8);
413 
414  //! Set the specific internal energy (J/kg) and specific volume (m^3/kg).
415  /*!
416  * This function fixes the internal state of the phase so that
417  * the specific internal energy and specific volume have the value of the input parameters.
418  *
419  * @param u specific internal energy (J/kg)
420  * @param v specific volume (m^3/kg).
421  * @param tol Optional parameter setting the tolerance of the
422  * calculation.
423  */
424  virtual void setState_UV(doublereal u, doublereal v,
425  doublereal tol = 1.e-8);
426 
427  //! Set the specific entropy (J/kg/K) and pressure (Pa).
428  /*!
429  * This function fixes the internal state of the phase so that
430  * the specific entropy and the pressure have the value of the input parameters.
431  *
432  * @param s specific entropy (J/kg/K)
433  * @param p specific pressure (Pa).
434  * @param tol Optional parameter setting the tolerance of the
435  * calculation.
436  */
437  virtual void setState_SP(doublereal s, doublereal p,
438  doublereal tol = 1.e-8);
439 
440  //! Set the specific entropy (J/kg/K) and specific volume (m^3/kg).
441  /*!
442  * This function fixes the internal state of the phase so that
443  * the specific entropy and specific volume have the value of the input parameters.
444  *
445  * @param s specific entropy (J/kg/K)
446  * @param v specific volume (m^3/kg).
447  * @param tol Optional parameter setting the tolerance of the
448  * calculation.
449  */
450  virtual void setState_SV(doublereal s, doublereal v,
451  doublereal tol = 1.e-8);
452  //@}
453 
454  /**
455  * @internal Initialize.
456  *
457  * This method is provided to allow
458  * subclasses to perform any initialization required after all
459  * species have been added. For example, it might be used to
460  * resize internal work arrays that must have an entry for
461  * each species. When importing a CTML phase
462  * description, this method is called just prior to returning
463  * from function importPhase().
464  *
465  * Inheriting objects should call this function
466  *
467  * This version sets the mole fraction vector to x[0] = 1.0, and then
468  * calls the ThermoPhase::initThermo() function.
469  */
470  virtual void initThermo();
471 
472 protected:
473  //! The current pressure of the solution (Pa)
474  /*!
475  * It gets initialized to 1 atm.
476  */
477  doublereal m_press;
478 
479  /*!
480  * Reference pressure (Pa) must be the same for all species
481  * - defaults to 1 atm.
482  */
483  doublereal m_p0;
484 
485  //! Dimensionless enthalpy at the (mtlast, m_p0)
487  //! Dimensionless heat capacity at the (mtlast, m_p0)
489  //! Dimensionless entropy at the (mtlast, m_p0)
490  mutable vector_fp m_s0_R;
491 
492 protected:
493  /**
494  * @internal
495  * This crucial internal routine calls the species thermo
496  * update program to calculate new species Cp0, H0, and
497  * S0 whenever the temperature has changed.
498  */
499  void _updateThermo() const;
500 };
501 
502 }
503 
504 #endif
doublereal cv_mole() const
Molar heat capacity at constant volume. Units: J/kmol/K.
ThermoPhase * duplMyselfAsThermoPhase() const
Duplication function.
virtual void setState_HP(doublereal h, doublereal p, doublereal tol=1.e-8)
Set the internally stored specific enthalpy (J/kg) and pressure (Pa) of the phase.
virtual void getEnthalpy_RT_ref(doublereal *hrt) const
virtual void setState_UV(doublereal u, doublereal v, doublereal tol=1.e-8)
Set the specific internal energy (J/kg) and specific volume (m^3/kg).
virtual void getEntropy_R_ref(doublereal *er) const
void getPartialMolarCp(doublereal *cpbar) const
Get the species partial molar Heat Capacities. Units: J/ kmol /K.
void setMassFractions(const doublereal *const y)
Mass fractions are fixed, with Y[0] = 1.0.
vector_fp m_s0_R
Dimensionless entropy at the (mtlast, m_p0)
Base class for a phase with thermodynamic properties.
Definition: ThermoPhase.h:97
void getChemPotentials_RT(doublereal *murt) const
Get the array of non-dimensional species chemical potentials These are partial molar Gibbs free energ...
void getPartialMolarEnthalpies(doublereal *hbar) const
Get the species partial molar enthalpies. Units: J/kmol.
virtual void getActivities(doublereal *a) const
Get the array of non-dimensional activities at the current solution temperature, pressure, and solution concentration.
virtual void getGibbs_RT_ref(doublereal *grt) const
virtual void getCp_R_ref(doublereal *cprt) const
void getPartialMolarEntropies(doublereal *sbar) const
Get the species partial molar entropy. Units: J/kmol K.
virtual int eosType() const
Returns the equation of state type flag.
doublereal enthalpy_mole() const
Molar enthalpy. Units: J/kmol.
void getChemPotentials(doublereal *mu) const
Get the array of chemical potentials.
SingleSpeciesTP & operator=(const SingleSpeciesTP &right)
Assignment operator.
void getElectrochemPotentials(doublereal *mu) const
Get the species electrochemical potentials. Units: J/kmol.
doublereal entropy_mole() const
Molar entropy. Units: J/kmol/K.
vector_fp m_h0_RT
Dimensionless enthalpy at the (mtlast, m_p0)
vector_fp m_cp0_R
Dimensionless heat capacity at the (mtlast, m_p0)
virtual void getGibbs_ref(doublereal *g) const
void getStandardVolumes(doublereal *vbar) const
Get the molar volumes of each species in their standard states at the current T and P of the solution...
virtual void setState_SP(doublereal s, doublereal p, doublereal tol=1.e-8)
Set the specific entropy (J/kg/K) and pressure (Pa).
doublereal gibbs_mole() const
Molar Gibbs function. Units: J/kmol.
doublereal intEnergy_mole() const
Molar internal energy. Units: J/kmol.
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
virtual void setState_SV(doublereal s, doublereal v, doublereal tol=1.e-8)
Set the specific entropy (J/kg/K) and specific volume (m^3/kg).
virtual void getPartialMolarIntEnergies(doublereal *ubar) const
Get the species partial molar internal energies. Units: J/kmol.
doublereal m_press
The current pressure of the solution (Pa)
void setMoleFractions(const doublereal *const x)
Mole fractions are fixed, with x[0] = 1.0.
doublereal cp_mole() const
Molar heat capacity at constant pressure. Units: J/kmol/K.
void getPartialMolarVolumes(doublereal *vbar) const
Get the species partial molar volumes. Units: m^3/kmol.
void getPureGibbs(doublereal *gpure) const
Get the dimensional Gibbs functions for the standard state of the species at the current T and P...
SingleSpeciesTP()
Base empty constructor.
Header file for class ThermoPhase, the base class for phases with thermodynamic properties, and the text for the Module thermoprops (see Thermodynamic Properties and class ThermoPhase).
virtual void getActivityCoefficients(doublereal *ac) const
Get the array of non-dimensional activity coefficients at the current solution temperature, pressure, and solution concentration.
The SingleSpeciesTP class is a filter class for ThermoPhase.