Cantera  3.1.0a1
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 https://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 (such as 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.
60  SingleSpeciesTP() = default;
61 
62  string type() const override {
63  return "SingleSpecies";
64  }
65 
66  bool isPure() const override {
67  return true;
68  }
69 
70  //! @name Molar Thermodynamic Properties of the Solution
71  //!
72  //! These functions are resolved at this level, by reference to the partial
73  //! molar functions and standard state functions for species 0. Derived
74  //! classes don't need to supply entries for these functions.
75  //! @{
76 
77  double enthalpy_mole() const override;
78  double intEnergy_mole() const override;
79  double entropy_mole() const override;
80  double gibbs_mole() const override;
81  double cp_mole() const override;
82  double cv_mole() const override;
83 
84  //! @}
85  //! @name Activities, Standard State, and Activity Concentrations
86  //!
87  //! The activity @f$ a_k @f$ of a species in solution is related to the
88  //! chemical potential by @f[ \mu_k = \mu_k^0(T) + \hat R T \ln a_k. @f]
89  //! The quantity @f$ \mu_k^0(T) @f$ is the chemical potential at unit activity,
90  //! which depends only on temperature.
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  void getActivities(double* a) const override {
102  a[0] = 1.0;
103  }
104 
105  void getActivityCoefficients(double* ac) const override {
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 chemical potentials
118  /*!
119  * These are the phase, partial molar, and the standard state chemical
120  * potentials.
121  * @f$ \mu(T,P) = \mu^0_k(T,P) @f$.
122  *
123  * @param mu On return, Contains the chemical potential of the single
124  * species and the phase. Units are J / kmol . Length = 1
125  */
126  void getChemPotentials(double* mu) const override;
127 
128  //! Get the species partial molar enthalpies. Units: J/kmol.
129  /*!
130  * These are the phase enthalpies. @f$ h_k @f$.
131  *
132  * @param hbar Output vector of species partial molar enthalpies.
133  * Length: 1. units are J/kmol.
134  */
135  void getPartialMolarEnthalpies(double* hbar) const override;
136 
137  //! Get the species partial molar internal energies. Units: J/kmol.
138  /*!
139  * These are the phase internal energies. @f$ u_k @f$.
140  *
141  * @param ubar On return, Contains the internal energy of the single species
142  * and the phase. Units are J / kmol . Length = 1
143  */
144  void getPartialMolarIntEnergies(double* ubar) const override;
145 
146  //! Get the species partial molar entropy. Units: J/kmol K.
147  /*!
148  * This is the phase entropy. @f$ s(T,P) = s_o(T,P) @f$.
149  *
150  * @param sbar On return, Contains the entropy of the single species and the
151  * phase. Units are J / kmol / K . Length = 1
152  */
153  void getPartialMolarEntropies(double* sbar) const override;
154 
155  //! Get the species partial molar Heat Capacities. Units: J/ kmol /K.
156  /*!
157  * This is the phase heat capacity. @f$ Cp(T,P) = Cp_o(T,P) @f$.
158  *
159  * @param cpbar On return, Contains the heat capacity of the single species
160  * and the phase. Units are J / kmol / K . Length = 1
161  */
162  void getPartialMolarCp(double* cpbar) const override;
163 
164  //! Get the species partial molar volumes. Units: m^3/kmol.
165  /*!
166  * This is the phase molar volume. @f$ V(T,P) = V_o(T,P) @f$.
167  *
168  * @param vbar On return, Contains the molar volume of the single species
169  * and the phase. Units are m^3 / kmol. Length = 1
170  */
171  void getPartialMolarVolumes(double* vbar) const override;
172 
173  //! @}
174  //! @name Properties of the Standard State of the Species in the Solution
175  //!
176  //! These functions are the primary way real properties are
177  //! supplied to derived thermodynamics classes of SingleSpeciesTP.
178  //! These functions must be supplied in derived classes. They
179  //! are not resolved at the SingleSpeciesTP level.
180  //! @{
181 
182  void getPureGibbs(double* gpure) const override;
183 
184  //! Get the molar volumes of each species in their standard states at the
185  //! current *T* and *P* of the solution.
186  /*!
187  * units = m^3 / kmol
188  *
189  * We resolve this function at this level, by assigning the molecular weight
190  * divided by the phase density
191  *
192  * @param vbar On output this contains the standard volume of the species
193  * and phase (m^3/kmol). Vector of length 1
194  */
195  void getStandardVolumes(double* vbar) const override;
196 
197  //! @}
198  //! @name Thermodynamic Values for the Species Reference State
199  //!
200  //! Almost all functions in this group are resolved by this class. The
201  //! internal energy function is not given by this class, since it would
202  //! involve a specification of the equation of state.
203  //! @{
204 
205  void getEnthalpy_RT_ref(double* hrt) const override;
206  void getGibbs_RT_ref(double* grt) const override;
207  void getGibbs_ref(double* g) const override;
208  void getEntropy_R_ref(double* er) const override;
209  void getCp_R_ref(double* cprt) const override;
210 
211  //! @}
212  //! @name Setting the State
213  //!
214  //! These methods set all or part of the thermodynamic state.
215  //! @{
216 
217  //! Mass fractions are fixed, with Y[0] = 1.0.
218  void setMassFractions(const double* const y) override {};
219 
220  //! Mole fractions are fixed, with x[0] = 1.0.
221  void setMoleFractions(const double* const x) override {};
222 
223  void setState_HP(double h, double p, double tol=1e-9) override;
224  void setState_UV(double u, double v, double tol=1e-9) override;
225  void setState_SP(double s, double p, double tol=1e-9) override;
226  void setState_SV(double s, double v, double tol=1e-9) override;
227  //! @}
228 
229  bool addSpecies(shared_ptr<Species> spec) override;
230 
231 protected:
232  //! The current pressure of the solution (Pa). It gets initialized to 1 atm.
233  double m_press = OneAtm;
234 
235  // Reference pressure (Pa). Must be the same for all species. Defaults to
236  // 1 atm.
237  double m_p0 = OneAtm;
238 
239  //! Dimensionless enthalpy at the (mtlast, m_p0)
240  mutable double m_h0_RT;
241  //! Dimensionless heat capacity at the (mtlast, m_p0)
242  mutable double m_cp0_R;
243  //! Dimensionless entropy at the (mtlast, m_p0)
244  mutable double m_s0_R;
245 
246  //! This internal routine calculates new species Cp0, H0, and S0 whenever the
247  //! temperature has changed.
248  void _updateThermo() const;
249 };
250 
251 }
252 
253 #endif
Header file for class ThermoPhase, the base class for phases with thermodynamic properties,...
The SingleSpeciesTP class is a filter class for ThermoPhase.
double enthalpy_mole() const override
Molar enthalpy. Units: J/kmol.
void getPartialMolarEnthalpies(double *hbar) const override
Get the species partial molar enthalpies. Units: J/kmol.
void getChemPotentials(double *mu) const override
Get the array of chemical potentials.
SingleSpeciesTP()=default
Base empty constructor.
void getGibbs_ref(double *g) const override
Returns the vector of the Gibbs function of the reference state at the current temperature of the sol...
void setMassFractions(const double *const y) override
Mass fractions are fixed, with Y[0] = 1.0.
void getActivities(double *a) const override
Get the array of non-dimensional activities at the current solution temperature, pressure,...
string type() const override
String indicating the thermodynamic model implemented.
void setMoleFractions(const double *const x) override
Mole fractions are fixed, with x[0] = 1.0.
void setState_HP(double h, double p, double tol=1e-9) override
Set the internally stored specific enthalpy (J/kg) and pressure (Pa) of the phase.
void getPartialMolarVolumes(double *vbar) const override
Get the species partial molar volumes. Units: m^3/kmol.
double cv_mole() const override
Molar heat capacity at constant volume. Units: J/kmol/K.
double m_h0_RT
Dimensionless enthalpy at the (mtlast, m_p0)
double m_press
The current pressure of the solution (Pa). It gets initialized to 1 atm.
void getPureGibbs(double *gpure) const override
Get the Gibbs functions for the standard state of the species at the current T and P of the solution.
double m_s0_R
Dimensionless entropy at the (mtlast, m_p0)
void getEntropy_R_ref(double *er) const override
Returns the vector of nondimensional entropies of the reference state at the current temperature of t...
bool isPure() const override
Return whether phase represents a pure (single species) substance.
double intEnergy_mole() const override
Molar internal energy. Units: J/kmol.
double entropy_mole() const override
Molar entropy. Units: J/kmol/K.
void getCp_R_ref(double *cprt) const override
Returns the vector of nondimensional constant pressure heat capacities of the reference state at the ...
void getPartialMolarIntEnergies(double *ubar) const override
Get the species partial molar internal energies. Units: J/kmol.
double m_cp0_R
Dimensionless heat capacity at the (mtlast, m_p0)
double cp_mole() const override
Molar heat capacity at constant pressure. Units: J/kmol/K.
void setState_SV(double s, double v, double tol=1e-9) override
Set the specific entropy (J/kg/K) and specific volume (m^3/kg).
void getPartialMolarCp(double *cpbar) const override
Get the species partial molar Heat Capacities. Units: J/ kmol /K.
double gibbs_mole() const override
Molar Gibbs function. Units: J/kmol.
bool addSpecies(shared_ptr< Species > spec) override
Add a Species to this Phase.
void getStandardVolumes(double *vbar) const override
Get the molar volumes of each species in their standard states at the current T and P of the solution...
void _updateThermo() const
This internal routine calculates new species Cp0, H0, and S0 whenever the temperature has changed.
void setState_UV(double u, double v, double tol=1e-9) override
Set the specific internal energy (J/kg) and specific volume (m^3/kg).
void getGibbs_RT_ref(double *grt) const override
Returns the vector of nondimensional Gibbs Free Energies of the reference state at the current temper...
void getActivityCoefficients(double *ac) const override
Get the array of non-dimensional molar-based activity coefficients at the current solution temperatur...
void setState_SP(double s, double p, double tol=1e-9) override
Set the specific entropy (J/kg/K) and pressure (Pa).
void getPartialMolarEntropies(double *sbar) const override
Get the species partial molar entropy. Units: J/kmol K.
void getEnthalpy_RT_ref(double *hrt) const override
Returns the vector of nondimensional enthalpies of the reference state at the current temperature of ...
Base class for a phase with thermodynamic properties.
Definition: ThermoPhase.h:390
const double OneAtm
One atmosphere [Pa].
Definition: ct_defs.h:96
Namespace for the Cantera kernel.
Definition: AnyMap.cpp:564