Cantera  3.0.0
Loading...
Searching...
No Matches
VPStandardStateTP.h
Go to the documentation of this file.
1/**
2 * @file VPStandardStateTP.h
3 * Header file for a derived class of ThermoPhase that handles
4 * variable pressure standard state methods for calculating
5 * thermodynamic properties (see @ref thermoprops and
6 * class @link Cantera::VPStandardStateTP VPStandardStateTP@endlink).
7 */
8
9// This file is part of Cantera. See License.txt in the top-level directory or
10// at https://cantera.org/license.txt for license and copyright information.
11
12#ifndef CT_VPSTANDARDSTATETP_H
13#define CT_VPSTANDARDSTATETP_H
14
15#include "ThermoPhase.h"
16
17namespace Cantera
18{
19
20class PDSS;
21
22/**
23 * @ingroup thermoprops
24 *
25 * This is a filter class for ThermoPhase that implements some preparatory steps
26 * for efficiently handling a variable pressure standard state for species.
27 *
28 * Several concepts are introduced. The first concept is there are temporary
29 * variables for holding the species standard state values of Cp, H, S, G, and V
30 * at the last temperature and pressure called. These functions are not
31 * recalculated if a new call is made using the previous temperature and
32 * pressure.
33 *
34 * To support the above functionality, pressure and temperature variables,
35 * m_Plast_ss and m_Tlast_ss, are kept which store the last pressure and
36 * temperature used in the evaluation of standard state properties.
37 *
38 * This class is usually used for nearly incompressible phases. For those
39 * phases, it makes sense to change the equation of state independent variable
40 * from density to pressure. The variable m_Pcurrent contains the current value
41 * of the pressure within the phase.
42 */
44{
45public:
46 //! @name Constructors and Duplicators for VPStandardStateTP
47
48 //! Constructor.
50
51 ~VPStandardStateTP() override;
52
53 bool isCompressible() const override {
54 return false;
55 }
56
57 //! @name Utilities (VPStandardStateTP)
58 //! @{
59
60 int standardStateConvention() const override;
61
62 //! @}
63 //! @name Partial Molar Properties of the Solution (VPStandardStateTP)
64 //! @{
65
66 //! Get the array of non-dimensional species chemical potentials.
67 /*!
68 * These are partial molar Gibbs free energies, @f$ \mu_k / \hat R T @f$.
69 *
70 * We close the loop on this function, here, calling getChemPotentials() and
71 * then dividing by RT. No need for child classes to handle.
72 *
73 * @param mu Output vector of non-dimensional species chemical potentials
74 * Length: m_kk.
75 * @deprecated To be removed after %Cantera 3.0. Use getChemPotentials() instead.
76 */
77 void getChemPotentials_RT(double* mu) const override;
78
79 //! @}
80 //! @name Properties of the Standard State of the Species in the Solution
81 //!
82 //! Within VPStandardStateTP, these properties are calculated via a common
83 //! routine, _updateStandardStateThermo(), which must be overloaded in
84 //! inherited objects. The values are cached within this object, and are not
85 //! recalculated unless the temperature or pressure changes.
86 //! @{
87
88 void getStandardChemPotentials(double* mu) const override;
89 void getEnthalpy_RT(double* hrt) const override;
90 void getEntropy_R(double* sr) const override;
91 void getGibbs_RT(double* grt) const override;
92 void getPureGibbs(double* gpure) const override;
93 void getIntEnergy_RT(double* urt) const override;
94 void getCp_R(double* cpr) const override;
95 void getStandardVolumes(double* vol) const override;
96 virtual const vector<double>& getStandardVolumes() const;
97 //! @}
98
99 //! Set the temperature of the phase
100 /*!
101 * Currently this passes down to setState_TP(). It does not make sense to
102 * calculate the standard state without first setting T and P.
103 *
104 * @param temp Temperature (kelvin)
105 */
106 void setTemperature(const double temp) override;
107
108 //! Set the internally stored pressure (Pa) at constant temperature and
109 //! composition
110 /*!
111 * Currently this passes down to setState_TP(). It does not make sense to
112 * calculate the standard state without first setting T and P.
113 *
114 * @param p input Pressure (Pa)
115 */
116 void setPressure(double p) override;
117
118 //! Set the temperature and pressure at the same time
119 /*!
120 * Note this function triggers a reevaluation of the standard state
121 * quantities.
122 *
123 * @param T temperature (kelvin)
124 * @param pres pressure (pascal)
125 */
126 void setState_TP(double T, double pres) override;
127
128 //! Returns the current pressure of the phase
129 /*!
130 * The pressure is an independent variable in this phase. Its current value
131 * is stored in the object VPStandardStateTP.
132 *
133 * @returns the pressure in pascals.
134 */
135 double pressure() const override {
136 return m_Pcurrent;
137 }
138
139 //! Updates the standard state thermodynamic functions at the current T and P of the solution.
140 /*!
141 * This function must be called for every call to functions in this class. It checks
142 * to see whether the temperature or pressure has changed and thus the ss
143 * thermodynamics functions for all of the species must be recalculated.
144 *
145 * This function is responsible for updating the following internal members:
146 *
147 * - #m_hss_RT;
148 * - #m_cpss_R;
149 * - #m_gss_RT;
150 * - #m_sss_R;
151 * - #m_Vss
152 */
153 virtual void updateStandardStateThermo() const;
154
155 double minTemp(size_t k=npos) const override;
156 double maxTemp(size_t k=npos) const override;
157
158
159protected:
160 /**
161 * Calculate the density of the mixture using the partial molar volumes and
162 * mole fractions as input.
163 *
164 * The formula for this is
165 *
166 * @f[
167 * \rho = \frac{\sum_k{X_k W_k}}{\sum_k{X_k V_k}}
168 * @f]
169 *
170 * where @f$ X_k @f$ are the mole fractions, @f$ W_k @f$ are the molecular
171 * weights, and @f$ V_k @f$ are the pure species molar volumes.
172 *
173 * Note, the basis behind this formula is that in an ideal solution the
174 * partial molar volumes are equal to the pure species molar volumes. We
175 * have additionally specified in this class that the pure species molar
176 * volumes are independent of temperature and pressure.
177 *
178 * NOTE: This function is not a member of the ThermoPhase base class.
179 */
180 virtual void calcDensity();
181
182 //! Updates the standard state thermodynamic functions at the current T and
183 //! P of the solution.
184 /*!
185 * This function must be called for every call to functions in this class. This
186 * function is responsible for updating the following internal members:
187 *
188 * - #m_hss_RT;
189 * - #m_cpss_R;
190 * - #m_gss_RT;
191 * - #m_sss_R;
192 * - #m_Vss
193 *
194 * This function doesn't check to see if the temperature or pressure has changed. It
195 * automatically assumes that it has changed.
196 */
197 virtual void _updateStandardStateThermo() const;
198
199public:
200 //! @name Thermodynamic Values for the Species Reference States
201 //!
202 //! There are also temporary variables for holding the species reference-
203 //! state values of Cp, H, S, and V at the last temperature and reference
204 //! pressure called. These functions are not recalculated if a new call is
205 //! made using the previous temperature. All calculations are done within the
206 //! routine _updateRefStateThermo().
207 //! @{
208
209 void getEnthalpy_RT_ref(double* hrt) const override;
210 void getGibbs_RT_ref(double* grt) const override;
211
212protected:
213 const vector<double>& Gibbs_RT_ref() const;
214
215public:
216 void getGibbs_ref(double* g) const override;
217 void getEntropy_R_ref(double* er) const override;
218 void getCp_R_ref(double* cprt) const override;
219 void getStandardVolumes_ref(double* vol) const override;
220
221 //! @}
222 //! @name Initialization Methods - For Internal use
223 //!
224 //! The following methods are used in the process of constructing
225 //! the phase and setting its parameters from a specification in an
226 //! input file. They are not normally used in application programs.
227 //! To see how they are used, see importPhase().
228 //! @{
229
230 void initThermo() override;
231 void getSpeciesParameters(const string& name, AnyMap& speciesNode) const override;
232
233 using Phase::addSpecies;
234 bool addSpecies(shared_ptr<Species> spec) override;
235
236 //! Install a PDSS object for species *k*
237 void installPDSS(size_t k, unique_ptr<PDSS>&& pdss);
238 //! @}
239
240 PDSS* providePDSS(size_t k);
241 const PDSS* providePDSS(size_t k) const;
242
243protected:
244 void invalidateCache() override;
245
246 //! Current value of the pressure - state variable
247 /*!
248 * Because we are now using the pressure as a state variable, we need to
249 * carry it along within this object
250 *
251 * units = Pascals
252 */
254
255 //! The minimum temperature at which data for all species is valid
256 double m_minTemp = 0.0;
257
258 //! The maximum temperature at which data for all species is valid
260
261 //! The last temperature at which the standard state thermodynamic
262 //! properties were calculated at.
263 mutable double m_Tlast_ss = -1.0;
264
265 //! The last pressure at which the Standard State thermodynamic properties
266 //! were calculated at.
267 mutable double m_Plast_ss = -1.0;
268
269 //! Storage for the PDSS objects for the species
270 /*!
271 * Storage is in species index order. VPStandardStateTp owns each of the
272 * objects. Copy operations are deep.
273 */
274 vector<unique_ptr<PDSS>> m_PDSS_storage;
275
276 //! Vector containing the species reference enthalpies at T = m_tlast
277 //! and P = p_ref.
278 mutable vector<double> m_h0_RT;
279
280 //! Vector containing the species reference constant pressure heat
281 //! capacities at T = m_tlast and P = p_ref.
282 mutable vector<double> m_cp0_R;
283
284 //! Vector containing the species reference Gibbs functions at T = m_tlast
285 //! and P = p_ref.
286 mutable vector<double> m_g0_RT;
287
288 //! Vector containing the species reference entropies at T = m_tlast
289 //! and P = p_ref.
290 mutable vector<double> m_s0_R;
291
292 //! Vector containing the species reference molar volumes
293 mutable vector<double> m_V0;
294
295 //! Vector containing the species Standard State enthalpies at T = m_tlast
296 //! and P = m_plast.
297 mutable vector<double> m_hss_RT;
298
299 //! Vector containing the species Standard State constant pressure heat
300 //! capacities at T = m_tlast and P = m_plast.
301 mutable vector<double> m_cpss_R;
302
303 //! Vector containing the species Standard State Gibbs functions at T =
304 //! m_tlast and P = m_plast.
305 mutable vector<double> m_gss_RT;
306
307 //! Vector containing the species Standard State entropies at T = m_tlast
308 //! and P = m_plast.
309 mutable vector<double> m_sss_R;
310
311 //! Vector containing the species standard state volumes at T = m_tlast and
312 //! P = m_plast
313 mutable vector<double> m_Vss;
314};
315}
316
317#endif
Header file for class ThermoPhase, the base class for phases with thermodynamic properties,...
A map of string keys to values whose type can vary at runtime.
Definition AnyMap.h:427
Virtual base class for a species with a pressure dependent standard state.
Definition PDSS.h:147
virtual bool addSpecies(shared_ptr< Species > spec)
Add a Species to this Phase.
Definition Phase.cpp:822
string name() const
Return the name of the phase.
Definition Phase.cpp:20
Base class for a phase with thermodynamic properties.
This is a filter class for ThermoPhase that implements some preparatory steps for efficiently handlin...
double m_Plast_ss
The last pressure at which the Standard State thermodynamic properties were calculated at.
int standardStateConvention() const override
This method returns the convention used in specification of the standard state, of which there are cu...
double pressure() const override
Returns the current pressure of the phase.
vector< double > m_g0_RT
Vector containing the species reference Gibbs functions at T = m_tlast and P = p_ref.
bool isCompressible() const override
Return whether phase represents a compressible substance.
vector< double > m_sss_R
Vector containing the species Standard State entropies at T = m_tlast and P = m_plast.
void installPDSS(size_t k, unique_ptr< PDSS > &&pdss)
Install a PDSS object for species k
void getSpeciesParameters(const string &name, AnyMap &speciesNode) const override
Get phase-specific parameters of a Species object such that an identical one could be reconstructed a...
void getEntropy_R(double *sr) const override
Get the array of nondimensional Entropy functions for the standard state species at the current T and...
vector< double > m_h0_RT
Vector containing the species reference enthalpies at T = m_tlast and P = p_ref.
virtual void _updateStandardStateThermo() const
Updates the standard state thermodynamic functions at the current T and P of the solution.
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 getStandardChemPotentials(double *mu) const override
Get the array of chemical potentials at unit activity for the species at their standard states at the...
void getCp_R(double *cpr) const override
Get the nondimensional Heat Capacities at constant pressure for the species standard states at the cu...
void initThermo() override
Initialize the ThermoPhase object after all species have been set up.
void setPressure(double p) override
Set the internally stored pressure (Pa) at constant temperature and composition.
vector< unique_ptr< PDSS > > m_PDSS_storage
Storage for the PDSS objects for the species.
void getStandardVolumes_ref(double *vol) const override
Get the molar volumes of the species reference states at the current T and P_ref of the solution.
vector< double > m_gss_RT
Vector containing the species Standard State Gibbs functions at T = m_tlast and P = m_plast.
double m_Tlast_ss
The last temperature at which the standard state thermodynamic properties were calculated at.
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.
void getEnthalpy_RT(double *hrt) const override
Get the nondimensional Enthalpy functions for the species at their standard states at the current T a...
vector< double > m_cpss_R
Vector containing the species Standard State constant pressure heat capacities at T = m_tlast and P =...
double m_maxTemp
The maximum temperature at which data for all species is valid.
void getEntropy_R_ref(double *er) const override
Returns the vector of nondimensional entropies of the reference state at the current temperature of t...
void setTemperature(const double temp) override
Set the temperature of the phase.
double minTemp(size_t k=npos) const override
Minimum temperature for which the thermodynamic data for the species or phase are valid.
vector< double > m_s0_R
Vector containing the species reference entropies at T = m_tlast and P = p_ref.
vector< double > m_Vss
Vector containing the species standard state volumes at T = m_tlast and P = m_plast.
double m_minTemp
The minimum temperature at which data for all species is valid.
void getGibbs_RT(double *grt) const override
Get the nondimensional Gibbs functions for the species in their standard states at the current T and ...
vector< double > m_V0
Vector containing the species reference molar volumes.
void invalidateCache() override
Invalidate any cached values which are normally updated only when a change in state is detected.
void getCp_R_ref(double *cprt) const override
Returns the vector of nondimensional constant pressure heat capacities of the reference state at the ...
void setState_TP(double T, double pres) override
Set the temperature and pressure at the same time.
void getIntEnergy_RT(double *urt) const override
Returns the vector of nondimensional Internal Energies of the standard state species at the current T...
vector< double > m_cp0_R
Vector containing the species reference constant pressure heat capacities at T = m_tlast and P = p_re...
virtual void updateStandardStateThermo() const
Updates the standard state thermodynamic functions at the current T and P of the solution.
vector< double > m_hss_RT
Vector containing the species Standard State enthalpies at T = m_tlast and P = m_plast.
bool addSpecies(shared_ptr< Species > spec) override
Add a Species to this Phase.
void getChemPotentials_RT(double *mu) const override
Get the array of non-dimensional species chemical potentials.
void getGibbs_RT_ref(double *grt) const override
Returns the vector of nondimensional Gibbs Free Energies of the reference state at the current temper...
double maxTemp(size_t k=npos) const override
Maximum temperature for which the thermodynamic data for the species are valid.
double m_Pcurrent
Current value of the pressure - state variable.
void getEnthalpy_RT_ref(double *hrt) const override
Returns the vector of nondimensional enthalpies of the reference state at the current temperature of ...
virtual void calcDensity()
Calculate the density of the mixture using the partial molar volumes and mole fractions as input.
const double OneAtm
One atmosphere [Pa].
Definition ct_defs.h:96
Namespace for the Cantera kernel.
Definition AnyMap.cpp:564
const size_t npos
index returned by functions to indicate "no position"
Definition ct_defs.h:195
const double BigNumber
largest number to compare to inf.
Definition ct_defs.h:160