Cantera  3.0.0
Loading...
Searching...
No Matches
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
16namespace 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{
58public:
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 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 * @deprecated To be removed after %Cantera 3.0. Use getChemPotentials() instead.
129 */
130 void getChemPotentials_RT(double* murt) const override;
131
132 //! Get the array of chemical potentials
133 /*!
134 * These are the phase, partial molar, and the standard state chemical
135 * potentials.
136 * @f$ \mu(T,P) = \mu^0_k(T,P) @f$.
137 *
138 * @param mu On return, Contains the chemical potential of the single
139 * species and the phase. Units are J / kmol . Length = 1
140 */
141 void getChemPotentials(double* mu) const override;
142
143 //! Get the species partial molar enthalpies. Units: J/kmol.
144 /*!
145 * These are the phase enthalpies. @f$ h_k @f$.
146 *
147 * @param hbar Output vector of species partial molar enthalpies.
148 * Length: 1. units are J/kmol.
149 */
150 void getPartialMolarEnthalpies(double* hbar) const override;
151
152 //! Get the species partial molar internal energies. Units: J/kmol.
153 /*!
154 * These are the phase internal energies. @f$ u_k @f$.
155 *
156 * @param ubar On return, Contains the internal energy of the single species
157 * and the phase. Units are J / kmol . Length = 1
158 */
159 void getPartialMolarIntEnergies(double* ubar) const override;
160
161 //! Get the species partial molar entropy. Units: J/kmol K.
162 /*!
163 * This is the phase entropy. @f$ s(T,P) = s_o(T,P) @f$.
164 *
165 * @param sbar On return, Contains the entropy of the single species and the
166 * phase. Units are J / kmol / K . Length = 1
167 */
168 void getPartialMolarEntropies(double* sbar) const override;
169
170 //! Get the species partial molar Heat Capacities. Units: J/ kmol /K.
171 /*!
172 * This is the phase heat capacity. @f$ Cp(T,P) = Cp_o(T,P) @f$.
173 *
174 * @param cpbar On return, Contains the heat capacity of the single species
175 * and the phase. Units are J / kmol / K . Length = 1
176 */
177 void getPartialMolarCp(double* cpbar) const override;
178
179 //! Get the species partial molar volumes. Units: m^3/kmol.
180 /*!
181 * This is the phase molar volume. @f$ V(T,P) = V_o(T,P) @f$.
182 *
183 * @param vbar On return, Contains the molar volume of the single species
184 * and the phase. Units are m^3 / kmol. Length = 1
185 */
186 void getPartialMolarVolumes(double* vbar) const override;
187
188 //! @}
189 //! @name Properties of the Standard State of the Species in the Solution
190 //!
191 //! These functions are the primary way real properties are
192 //! supplied to derived thermodynamics classes of SingleSpeciesTP.
193 //! These functions must be supplied in derived classes. They
194 //! are not resolved at the SingleSpeciesTP level.
195 //! @{
196
197 void getPureGibbs(double* gpure) const override;
198
199 //! Get the molar volumes of each species in their standard states at the
200 //! current *T* and *P* of the solution.
201 /*!
202 * units = m^3 / kmol
203 *
204 * We resolve this function at this level, by assigning the molecular weight
205 * divided by the phase density
206 *
207 * @param vbar On output this contains the standard volume of the species
208 * and phase (m^3/kmol). Vector of length 1
209 */
210 void getStandardVolumes(double* vbar) const override;
211
212 //! @}
213 //! @name Thermodynamic Values for the Species Reference State
214 //!
215 //! Almost all functions in this group are resolved by this class. The
216 //! internal energy function is not given by this class, since it would
217 //! involve a specification of the equation of state.
218 //! @{
219
220 void getEnthalpy_RT_ref(double* hrt) const override;
221 void getGibbs_RT_ref(double* grt) const override;
222 void getGibbs_ref(double* g) const override;
223 void getEntropy_R_ref(double* er) const override;
224 void getCp_R_ref(double* cprt) const override;
225
226 //! @}
227 //! @name Setting the State
228 //!
229 //! These methods set all or part of the thermodynamic state.
230 //! @{
231
232 //! Mass fractions are fixed, with Y[0] = 1.0.
233 void setMassFractions(const double* const y) override {};
234
235 //! Mole fractions are fixed, with x[0] = 1.0.
236 void setMoleFractions(const double* const x) override {};
237
238 void setState_HP(double h, double p, double tol=1e-9) override;
239 void setState_UV(double u, double v, double tol=1e-9) override;
240 void setState_SP(double s, double p, double tol=1e-9) override;
241 void setState_SV(double s, double v, double tol=1e-9) override;
242 //! @}
243
244 bool addSpecies(shared_ptr<Species> spec) override;
245
246protected:
247 //! The current pressure of the solution (Pa). It gets initialized to 1 atm.
248 double m_press = OneAtm;
249
250 // Reference pressure (Pa). Must be the same for all species. Defaults to
251 // 1 atm.
252 double m_p0 = OneAtm;
253
254 //! Dimensionless enthalpy at the (mtlast, m_p0)
255 mutable double m_h0_RT;
256 //! Dimensionless heat capacity at the (mtlast, m_p0)
257 mutable double m_cp0_R;
258 //! Dimensionless entropy at the (mtlast, m_p0)
259 mutable double m_s0_R;
260
261 //! This internal routine calculates new species Cp0, H0, and S0 whenever the
262 //! temperature has changed.
263 void _updateThermo() const;
264};
265
266}
267
268#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 getChemPotentials_RT(double *murt) const override
Get the array of non-dimensional species chemical potentials.
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.
const double OneAtm
One atmosphere [Pa].
Definition ct_defs.h:96
Namespace for the Cantera kernel.
Definition AnyMap.cpp:564