Cantera  2.3.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  SingleSpeciesTP(const SingleSpeciesTP& right);
63  SingleSpeciesTP& operator=(const SingleSpeciesTP& right);
64  virtual ThermoPhase* duplMyselfAsThermoPhase() const;
65 
66  /**
67  * Returns the equation of state type flag. This is a modified base class.
68  * Therefore, if not overridden in derived classes, this call will throw an
69  * exception.
70  * @deprecated To be removed after Cantera 2.3.
71  */
72  virtual int eosType() const;
73  virtual std::string type() const {
74  return "SingleSpecies";
75  }
76 
77  /**
78  * @name Molar Thermodynamic Properties of the Solution
79  *
80  * These functions are resolved at this level, by reference to the partial
81  * molar functions and standard state functions for species 0. Derived
82  * classes don't need to supply entries for these functions.
83  * @{
84  */
85 
86  virtual doublereal enthalpy_mole() const;
87  virtual doublereal intEnergy_mole() const;
88  virtual doublereal entropy_mole() const;
89  virtual doublereal gibbs_mole() const;
90  virtual doublereal cp_mole() const;
91  virtual doublereal cv_mole() const;
92 
93  /**
94  * @}
95  * @name Activities, Standard State, and Activity Concentrations
96  *
97  * The activity \f$a_k\f$ of a species in solution is related to the
98  * chemical potential by \f[ \mu_k = \mu_k^0(T) + \hat R T \log a_k. \f]
99  * The quantity \f$\mu_k^0(T)\f$ is the chemical potential at unit activity,
100  * which depends only on temperature.
101  * @{
102  */
103 
104  /**
105  * Get the array of non-dimensional activities at the current solution
106  * temperature, pressure, and solution concentration.
107  *
108  * We redefine this function to just return 1.0 here.
109  *
110  * @param a Output vector of activities. Length: 1.
111  */
112  virtual void getActivities(doublereal* a) const {
113  a[0] = 1.0;
114  }
115 
116  virtual void getActivityCoefficients(doublereal* ac) const {
117  ac[0] = 1.0;
118  }
119 
120  //@}
121  /// @name Partial Molar Properties of the Solution
122  ///
123  /// These functions are resolved at this level, by reference to the partial
124  /// molar functions and standard state functions for species 0. Derived
125  /// classes don't need to supply entries for these functions.
126  //@{
127 
128  //! Get the array of non-dimensional species chemical potentials. These are
129  //! partial molar Gibbs free energies.
130  /*!
131  * These are the phase, partial molar, and the standard state dimensionless
132  * chemical potentials.
133  * \f$ \mu_k / \hat R T \f$.
134  *
135  * Units: unitless
136  *
137  * @param murt On return, Contains the chemical potential / RT of the
138  * single species and the phase. Units are unitless. Length = 1
139  */
140  virtual void getChemPotentials_RT(doublereal* murt) const;
141 
142  //! Get the array of chemical potentials
143  /*!
144  * These are the phase, partial molar, and the standard state chemical
145  * potentials.
146  * \f$ \mu(T,P) = \mu^0_k(T,P) \f$.
147  *
148  * @param mu On return, Contains the chemical potential of the single
149  * species and the phase. Units are J / kmol . Length = 1
150  */
151  virtual void getChemPotentials(doublereal* mu) const;
152 
153  //! Get the species partial molar enthalpies. Units: J/kmol.
154  /*!
155  * These are the phase enthalpies. \f$ h_k \f$.
156  *
157  * @param hbar Output vector of species partial molar enthalpies.
158  * Length: 1. units are J/kmol.
159  */
160  virtual void getPartialMolarEnthalpies(doublereal* hbar) const;
161 
162  //! Get the species partial molar internal energies. Units: J/kmol.
163  /*!
164  * These are the phase internal energies. \f$ u_k \f$.
165  *
166  * @param ubar On return, Contains the internal energy of the single species
167  * and the phase. Units are J / kmol . Length = 1
168  */
169  virtual void getPartialMolarIntEnergies(doublereal* ubar) const;
170 
171  //! Get the species partial molar entropy. Units: J/kmol K.
172  /*!
173  * This is the phase entropy. \f$ s(T,P) = s_o(T,P) \f$.
174  *
175  * @param sbar On return, Contains the entropy of the single species and the
176  * phase. Units are J / kmol / K . Length = 1
177  */
178  virtual void getPartialMolarEntropies(doublereal* sbar) const;
179 
180  //! Get the species partial molar Heat Capacities. Units: J/ kmol /K.
181  /*!
182  * This is the phase heat capacity. \f$ Cp(T,P) = Cp_o(T,P) \f$.
183  *
184  * @param cpbar On return, Contains the heat capacity of the single species
185  * and the phase. Units are J / kmol / K . Length = 1
186  */
187  virtual void getPartialMolarCp(doublereal* cpbar) const;
188 
189  //! Get the species partial molar volumes. Units: m^3/kmol.
190  /*!
191  * This is the phase molar volume. \f$ V(T,P) = V_o(T,P) \f$.
192  *
193  * @param vbar On return, Contains the molar volume of the single species
194  * and the phase. Units are m^3 / kmol. Length = 1
195  */
196  virtual void getPartialMolarVolumes(doublereal* vbar) const;
197 
198  //@}
199  /// @name Properties of the Standard State of the Species in the Solution
200  /// These functions are the primary way real properties are
201  /// supplied to derived thermodynamics classes of SingleSpeciesTP.
202  /// These functions must be supplied in derived classes. They
203  /// are not resolved at the SingleSpeciesTP level.
204  //@{
205 
206  virtual void getPureGibbs(doublereal* gpure) const;
207 
208  //! Get the molar volumes of each species in their standard states at the
209  //! current *T* and *P* of the solution.
210  /*!
211  * units = m^3 / kmol
212  *
213  * We resolve this function at this level, by assigning the molecular weight
214  * divided by the phase density
215  *
216  * @param vbar On output this contains the standard volume of the species
217  * and phase (m^3/kmol). Vector of length 1
218  */
219  virtual void getStandardVolumes(doublereal* vbar) const;
220 
221  //@}
222  /// @name Thermodynamic Values for the Species Reference State
223  ///
224  /// Almost all functions in this group are resolved by this class. The
225  /// internal energy function is not given by this class, since it would
226  /// involve a specification of the equation of state.
227  //@{
228 
229  virtual void getEnthalpy_RT_ref(doublereal* hrt) const;
230  virtual void getGibbs_RT_ref(doublereal* grt) const;
231  virtual void getGibbs_ref(doublereal* g) const;
232  virtual void getEntropy_R_ref(doublereal* er) const;
233  virtual void getCp_R_ref(doublereal* cprt) const;
234 
235  /**
236  * @name Setting the State
237  *
238  * These methods set all or part of the thermodynamic state.
239  * @{
240  */
241 
242  //! Mass fractions are fixed, with Y[0] = 1.0.
243  virtual void setMassFractions(const doublereal* const y) {};
244 
245  //! Mole fractions are fixed, with x[0] = 1.0.
246  virtual void setMoleFractions(const doublereal* const x) {};
247 
248  virtual void setState_HP(double h, double p, double tol=1e-9);
249  virtual void setState_UV(double u, double v, double tol=1e-9);
250  virtual void setState_SP(double s, double p, double tol=1e-9);
251  virtual void setState_SV(double s, double v, double tol=1e-9);
252  //@}
253 
254  virtual bool addSpecies(shared_ptr<Species> spec);
255 
256 protected:
257  //! The current pressure of the solution (Pa). It gets initialized to 1 atm.
258  doublereal m_press;
259 
260  // Reference pressure (Pa). Must be the same for all species. Defaults to
261  // 1 atm.
262  doublereal m_p0;
263 
264  //! Dimensionless enthalpy at the (mtlast, m_p0)
265  mutable double m_h0_RT;
266  //! Dimensionless heat capacity at the (mtlast, m_p0)
267  mutable double m_cp0_R;
268  //! Dimensionless entropy at the (mtlast, m_p0)
269  mutable double m_s0_R;
270 
271  /**
272  * @internal This crucial internal routine calls the species thermo update
273  * program to calculate new species Cp0, H0, and S0 whenever the
274  * temperature has changed.
275  */
276  void _updateThermo() const;
277 };
278 
279 }
280 
281 #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 int eosType() const
Returns the equation of state type flag.
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 ThermoPhase * duplMyselfAsThermoPhase() const
Duplication routine for objects which inherit from ThermoPhase.
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: application.cpp:29
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.