Cantera  2.4.0
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 // This file is part of Cantera. See License.txt in the top-level directory or
9 // at http://www.cantera.org/license.txt for license and copyright information.
10 
11 #ifndef CT_SINGLESPECIESTP_H
12 #define CT_SINGLESPECIESTP_H
13 
14 #include "ThermoPhase.h"
15 
16 namespace Cantera
17 {
18 
19 /**
20  * @ingroup thermoprops
21  *
22  * The SingleSpeciesTP class is a filter class for ThermoPhase. What it does is
23  * to simplify the construction of ThermoPhase objects by assuming that the
24  * phase consists of one and only one type of species. In other words, it's a
25  * stoichiometric phase. However, no assumptions are made concerning the
26  * thermodynamic functions or the equation of state of the phase. Therefore it's
27  * an incomplete description of the thermodynamics. The complete description
28  * must be made in a derived class of SingleSpeciesTP.
29  *
30  * Several different groups of thermodynamic functions are resolved at this
31  * level by this class. For example, All partial molar property routines call
32  * their single species standard state equivalents. All molar solution
33  * thermodynamic routines call the single species standard state equivalents.
34  * Activities routines are resolved at this level, as there is only one species.
35  *
36  * It is assumed that the reference state thermodynamics may be obtained by a
37  * pointer to a populated species thermodynamic property manager class (see
38  * ThermoPhase::m_spthermo). How to relate pressure changes to the reference
39  * state thermodynamics is again left open to implementation.
40  *
41  * Mole fraction and Mass fraction vectors are assumed to be equal to x[0] = 1
42  * y[0] = 1, respectively. Simplifications to the interface of setState_TPY()
43  * and setState_TPX() functions result and are made within the class.
44  *
45  * Note, this class can handle the thermodynamic description of one phase of one
46  * species. It can not handle the description of phase equilibrium between two
47  * phases of a stoichiometric compound (e.g. water liquid and water vapor, below
48  * the critical point). However, it may be used to describe the thermodynamics
49  * of one phase of such a compound even past the phase equilibrium point, up to
50  * the point where the phase itself ceases to be a stable phase.
51  *
52  * This class doesn't do much at the initialization level. Its
53  * SingleSpeciesTP::initThermo() member does check that one and only one species
54  * has been defined to occupy the phase.
55  */
57 {
58 public:
59  //! Base empty constructor.
61 
62  virtual std::string type() const {
63  return "SingleSpecies";
64  }
65 
66  /**
67  * @name Molar Thermodynamic Properties of the Solution
68  *
69  * These functions are resolved at this level, by reference to the partial
70  * molar functions and standard state functions for species 0. Derived
71  * classes don't need to supply entries for these functions.
72  * @{
73  */
74 
75  virtual doublereal enthalpy_mole() const;
76  virtual doublereal intEnergy_mole() const;
77  virtual doublereal entropy_mole() const;
78  virtual doublereal gibbs_mole() const;
79  virtual doublereal cp_mole() const;
80  virtual doublereal cv_mole() const;
81 
82  /**
83  * @}
84  * @name Activities, Standard State, and Activity Concentrations
85  *
86  * The activity \f$a_k\f$ of a species in solution is related to the
87  * chemical potential by \f[ \mu_k = \mu_k^0(T) + \hat R T \log a_k. \f]
88  * The quantity \f$\mu_k^0(T)\f$ is the chemical potential at unit activity,
89  * which depends only on temperature.
90  * @{
91  */
92 
93  /**
94  * Get the array of non-dimensional activities at the current solution
95  * temperature, pressure, and solution concentration.
96  *
97  * We redefine this function to just return 1.0 here.
98  *
99  * @param a Output vector of activities. Length: 1.
100  */
101  virtual void getActivities(doublereal* a) const {
102  a[0] = 1.0;
103  }
104 
105  virtual void getActivityCoefficients(doublereal* ac) const {
106  ac[0] = 1.0;
107  }
108 
109  //@}
110  /// @name Partial Molar Properties of the Solution
111  ///
112  /// These functions are resolved at this level, by reference to the partial
113  /// molar functions and standard state functions for species 0. Derived
114  /// classes don't need to supply entries for these functions.
115  //@{
116 
117  //! Get the array of non-dimensional species chemical potentials. These are
118  //! partial molar Gibbs free energies.
119  /*!
120  * These are the phase, partial molar, and the standard state dimensionless
121  * chemical potentials.
122  * \f$ \mu_k / \hat R T \f$.
123  *
124  * Units: unitless
125  *
126  * @param murt On return, Contains the chemical potential / RT of the
127  * single species and the phase. Units are unitless. Length = 1
128  */
129  virtual void getChemPotentials_RT(doublereal* murt) const;
130 
131  //! Get the array of chemical potentials
132  /*!
133  * These are the phase, partial molar, and the standard state chemical
134  * potentials.
135  * \f$ \mu(T,P) = \mu^0_k(T,P) \f$.
136  *
137  * @param mu On return, Contains the chemical potential of the single
138  * species and the phase. Units are J / kmol . Length = 1
139  */
140  virtual void getChemPotentials(doublereal* mu) const;
141 
142  //! Get the species partial molar enthalpies. Units: J/kmol.
143  /*!
144  * These are the phase enthalpies. \f$ h_k \f$.
145  *
146  * @param hbar Output vector of species partial molar enthalpies.
147  * Length: 1. units are J/kmol.
148  */
149  virtual void getPartialMolarEnthalpies(doublereal* hbar) const;
150 
151  //! Get the species partial molar internal energies. Units: J/kmol.
152  /*!
153  * These are the phase internal energies. \f$ u_k \f$.
154  *
155  * @param ubar On return, Contains the internal energy of the single species
156  * and the phase. Units are J / kmol . Length = 1
157  */
158  virtual void getPartialMolarIntEnergies(doublereal* ubar) const;
159 
160  //! Get the species partial molar entropy. Units: J/kmol K.
161  /*!
162  * This is the phase entropy. \f$ s(T,P) = s_o(T,P) \f$.
163  *
164  * @param sbar On return, Contains the entropy of the single species and the
165  * phase. Units are J / kmol / K . Length = 1
166  */
167  virtual void getPartialMolarEntropies(doublereal* sbar) const;
168 
169  //! Get the species partial molar Heat Capacities. Units: J/ kmol /K.
170  /*!
171  * This is the phase heat capacity. \f$ Cp(T,P) = Cp_o(T,P) \f$.
172  *
173  * @param cpbar On return, Contains the heat capacity of the single species
174  * and the phase. Units are J / kmol / K . Length = 1
175  */
176  virtual void getPartialMolarCp(doublereal* cpbar) const;
177 
178  //! Get the species partial molar volumes. Units: m^3/kmol.
179  /*!
180  * This is the phase molar volume. \f$ V(T,P) = V_o(T,P) \f$.
181  *
182  * @param vbar On return, Contains the molar volume of the single species
183  * and the phase. Units are m^3 / kmol. Length = 1
184  */
185  virtual void getPartialMolarVolumes(doublereal* vbar) const;
186 
187  //@}
188  /// @name Properties of the Standard State of the Species in the Solution
189  /// These functions are the primary way real properties are
190  /// supplied to derived thermodynamics classes of SingleSpeciesTP.
191  /// These functions must be supplied in derived classes. They
192  /// are not resolved at the SingleSpeciesTP level.
193  //@{
194 
195  virtual void getPureGibbs(doublereal* gpure) const;
196 
197  //! Get the molar volumes of each species in their standard states at the
198  //! current *T* and *P* of the solution.
199  /*!
200  * units = m^3 / kmol
201  *
202  * We resolve this function at this level, by assigning the molecular weight
203  * divided by the phase density
204  *
205  * @param vbar On output this contains the standard volume of the species
206  * and phase (m^3/kmol). Vector of length 1
207  */
208  virtual void getStandardVolumes(doublereal* vbar) const;
209 
210  //@}
211  /// @name Thermodynamic Values for the Species Reference State
212  ///
213  /// Almost all functions in this group are resolved by this class. The
214  /// internal energy function is not given by this class, since it would
215  /// involve a specification of the equation of state.
216  //@{
217 
218  virtual void getEnthalpy_RT_ref(doublereal* hrt) const;
219  virtual void getGibbs_RT_ref(doublereal* grt) const;
220  virtual void getGibbs_ref(doublereal* g) const;
221  virtual void getEntropy_R_ref(doublereal* er) const;
222  virtual void getCp_R_ref(doublereal* cprt) const;
223 
224  /**
225  * @name Setting the State
226  *
227  * These methods set all or part of the thermodynamic state.
228  * @{
229  */
230 
231  //! Mass fractions are fixed, with Y[0] = 1.0.
232  virtual void setMassFractions(const doublereal* const y) {};
233 
234  //! Mole fractions are fixed, with x[0] = 1.0.
235  virtual void setMoleFractions(const doublereal* const x) {};
236 
237  virtual void setState_HP(double h, double p, double tol=1e-9);
238  virtual void setState_UV(double u, double v, double tol=1e-9);
239  virtual void setState_SP(double s, double p, double tol=1e-9);
240  virtual void setState_SV(double s, double v, double tol=1e-9);
241  //@}
242 
243  virtual bool addSpecies(shared_ptr<Species> spec);
244 
245 protected:
246  //! The current pressure of the solution (Pa). It gets initialized to 1 atm.
247  doublereal m_press;
248 
249  // Reference pressure (Pa). Must be the same for all species. Defaults to
250  // 1 atm.
251  doublereal m_p0;
252 
253  //! Dimensionless enthalpy at the (mtlast, m_p0)
254  mutable double m_h0_RT;
255  //! Dimensionless heat capacity at the (mtlast, m_p0)
256  mutable double m_cp0_R;
257  //! Dimensionless entropy at the (mtlast, m_p0)
258  mutable double m_s0_R;
259 
260  /**
261  * @internal This crucial internal routine calls the species thermo update
262  * program to calculate new species Cp0, H0, and S0 whenever the
263  * temperature has changed.
264  */
265  void _updateThermo() const;
266 };
267 
268 }
269 
270 #endif
virtual void getGibbs_ref(doublereal *g) const
Returns the vector of the Gibbs function of the reference state at the current temperature of the sol...
virtual doublereal cp_mole() const
Molar heat capacity at constant pressure. Units: J/kmol/K.
virtual void setState_UV(double u, double v, double tol=1e-9)
Set the specific internal energy (J/kg) and specific volume (m^3/kg).
double m_h0_RT
Dimensionless enthalpy at the (mtlast, m_p0)
virtual bool addSpecies(shared_ptr< Species > spec)
virtual void getPartialMolarEntropies(doublereal *sbar) const
Get the species partial molar entropy. Units: J/kmol K.
virtual void getPartialMolarCp(doublereal *cpbar) const
Get the species partial molar Heat Capacities. Units: J/ kmol /K.
virtual std::string type() const
String indicating the thermodynamic model implemented.
double m_cp0_R
Dimensionless heat capacity at the (mtlast, m_p0)
Base class for a phase with thermodynamic properties.
Definition: ThermoPhase.h:93
virtual 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(double s, double p, double tol=1e-9)
Set the specific entropy (J/kg/K) and pressure (Pa).
virtual void getPartialMolarEnthalpies(doublereal *hbar) const
Get the species partial molar enthalpies. Units: J/kmol.
virtual doublereal cv_mole() const
Molar heat capacity at constant volume. Units: J/kmol/K.
double m_s0_R
Dimensionless entropy at the (mtlast, m_p0)
virtual void getChemPotentials(doublereal *mu) const
Get the array of chemical potentials.
virtual void getChemPotentials_RT(doublereal *murt) const
Get the array of non-dimensional species chemical potentials.
virtual void getCp_R_ref(doublereal *cprt) const
Returns the vector of nondimensional constant pressure heat capacities of the reference state at the ...
virtual doublereal enthalpy_mole() const
Molar enthalpy. Units: J/kmol.
virtual void getPureGibbs(doublereal *gpure) const
Get the Gibbs functions for the standard state of the species at the current T and P of the solution...
virtual void getPartialMolarVolumes(doublereal *vbar) const
Get the species partial molar volumes. Units: m^3/kmol.
virtual void getPartialMolarIntEnergies(doublereal *ubar) const
Get the species partial molar internal energies. Units: J/kmol.
virtual doublereal gibbs_mole() const
Molar Gibbs function. Units: J/kmol.
virtual void setMassFractions(const doublereal *const y)
Mass fractions are fixed, with Y[0] = 1.0.
virtual void getActivities(doublereal *a) const
Get the array of non-dimensional activities at the current solution temperature, pressure, and solution concentration.
doublereal m_press
The current pressure of the solution (Pa). It gets initialized to 1 atm.
virtual doublereal intEnergy_mole() const
Molar internal energy. Units: J/kmol.
virtual void getGibbs_RT_ref(doublereal *grt) const
Returns the vector of nondimensional Gibbs Free Energies of the reference state at the current temper...
virtual void setState_HP(double h, double p, double tol=1e-9)
Set the internally stored specific enthalpy (J/kg) and pressure (Pa) of the phase.
SingleSpeciesTP()
Base empty constructor.
virtual void getEnthalpy_RT_ref(doublereal *hrt) const
Returns the vector of nondimensional enthalpies of the reference state at the current temperature of ...
Namespace for the Cantera kernel.
Definition: AnyMap.cpp:8
virtual void setState_SV(double s, double v, double tol=1e-9)
Set the specific entropy (J/kg/K) and specific volume (m^3/kg).
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 getEntropy_R_ref(doublereal *er) const
Returns the vector of nondimensional entropies of the reference state at the current temperature of t...
The SingleSpeciesTP class is a filter class for ThermoPhase.
virtual void getActivityCoefficients(doublereal *ac) const
Get the array of non-dimensional molar-based activity coefficients at the current solution temperatur...
virtual void setMoleFractions(const doublereal *const x)
Mole fractions are fixed, with x[0] = 1.0.
virtual doublereal entropy_mole() const
Molar entropy. Units: J/kmol/K.