Cantera  3.3.0a1
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 Properties of the Standard State of the Species in the Solution
64 //!
65 //! Within VPStandardStateTP, these properties are calculated via a common
66 //! routine, _updateStandardStateThermo(), which must be overloaded in
67 //! inherited objects. The values are cached within this object, and are not
68 //! recalculated unless the temperature or pressure changes.
69 //! @{
70
71 void getStandardChemPotentials(double* mu) const override;
72 void getEnthalpy_RT(double* hrt) const override;
73 void getEntropy_R(double* sr) const override;
74 void getGibbs_RT(double* grt) const override;
75 void getIntEnergy_RT(double* urt) const override;
76 void getCp_R(double* cpr) const override;
77 void getStandardVolumes(double* vol) const override;
78 virtual const vector<double>& getStandardVolumes() const;
79 //! @}
80
81 //! Set the temperature of the phase
82 /*!
83 * Currently this passes down to setState_TP(). It does not make sense to
84 * calculate the standard state without first setting T and P.
85 *
86 * @param temp Temperature (kelvin)
87 */
88 void setTemperature(const double temp) override;
89
90 //! Set the internally stored pressure (Pa) at constant temperature and
91 //! composition
92 /*!
93 * Currently this passes down to setState_TP(). It does not make sense to
94 * calculate the standard state without first setting T and P.
95 *
96 * @param p input Pressure (Pa)
97 */
98 void setPressure(double p) override;
99
100 //! Set the temperature and pressure at the same time
101 /*!
102 * Note this function triggers a reevaluation of the standard state
103 * quantities.
104 *
105 * @param T temperature (kelvin)
106 * @param pres pressure (pascal)
107 */
108 void setState_TP(double T, double pres) override;
109
110 //! Returns the current pressure of the phase
111 /*!
112 * The pressure is an independent variable in this phase. Its current value
113 * is stored in the object VPStandardStateTP.
114 *
115 * @returns the pressure in pascals.
116 */
117 double pressure() const override {
118 return m_Pcurrent;
119 }
120
121 //! Updates the standard state thermodynamic functions at the current T and P of the solution.
122 /*!
123 * This function must be called for every call to functions in this class. It checks
124 * to see whether the temperature or pressure has changed and thus the ss
125 * thermodynamics functions for all of the species must be recalculated.
126 *
127 * This function is responsible for updating the following internal members:
128 *
129 * - #m_hss_RT;
130 * - #m_cpss_R;
131 * - #m_gss_RT;
132 * - #m_sss_R;
133 * - #m_Vss
134 */
135 virtual void updateStandardStateThermo() const;
136
137 double minTemp(size_t k=npos) const override;
138 double maxTemp(size_t k=npos) const override;
139
140
141protected:
142 /**
143 * Calculate the density of the mixture using the partial molar volumes and
144 * mole fractions as input.
145 *
146 * The formula for this is
147 *
148 * @f[
149 * \rho = \frac{\sum_k{X_k W_k}}{\sum_k{X_k V_k}}
150 * @f]
151 *
152 * where @f$ X_k @f$ are the mole fractions, @f$ W_k @f$ are the molecular
153 * weights, and @f$ V_k @f$ are the pure species molar volumes.
154 *
155 * Note, the basis behind this formula is that in an ideal solution the
156 * partial molar volumes are equal to the pure species molar volumes. We
157 * have additionally specified in this class that the pure species molar
158 * volumes are independent of temperature and pressure.
159 *
160 * NOTE: This function is not a member of the ThermoPhase base class.
161 */
162 virtual void calcDensity();
163
164 //! Updates the standard state thermodynamic functions at the current T and
165 //! P of the solution.
166 /*!
167 * This function must be called for every call to functions in this class. This
168 * function is responsible for updating the following internal members:
169 *
170 * - #m_hss_RT;
171 * - #m_cpss_R;
172 * - #m_gss_RT;
173 * - #m_sss_R;
174 * - #m_Vss
175 *
176 * This function doesn't check to see if the temperature or pressure has changed. It
177 * automatically assumes that it has changed.
178 */
179 virtual void _updateStandardStateThermo() const;
180
181public:
182 //! @name Thermodynamic Values for the Species Reference States
183 //!
184 //! There are also temporary variables for holding the species reference-
185 //! state values of Cp, H, S, and V at the last temperature and reference
186 //! pressure called. These functions are not recalculated if a new call is
187 //! made using the previous temperature. All calculations are done within the
188 //! routine _updateRefStateThermo().
189 //! @{
190
191 void getEnthalpy_RT_ref(double* hrt) const override;
192 void getGibbs_RT_ref(double* grt) const override;
193 void getGibbs_ref(double* g) const override;
194 void getEntropy_R_ref(double* er) const override;
195 void getCp_R_ref(double* cprt) const override;
196 void getStandardVolumes_ref(double* vol) const override;
197
198 //! @}
199 //! @name Initialization Methods - For Internal use
200 //!
201 //! The following methods are used in the process of constructing
202 //! the phase and setting its parameters from a specification in an
203 //! input file. They are not normally used in application programs.
204 //! To see how they are used, see importPhase().
205 //! @{
206
207 void initThermo() override;
208 void getSpeciesParameters(const string& name, AnyMap& speciesNode) const override;
209
210 using Phase::addSpecies;
211 bool addSpecies(shared_ptr<Species> spec) override;
212
213 //! Install a PDSS object for species *k*
214 void installPDSS(size_t k, unique_ptr<PDSS>&& pdss);
215 //! @}
216
217 PDSS* providePDSS(size_t k);
218 const PDSS* providePDSS(size_t k) const;
219
220protected:
221 void invalidateCache() override;
222
223 //! Current value of the pressure - state variable
224 /*!
225 * Because we are now using the pressure as a state variable, we need to
226 * carry it along within this object
227 *
228 * units = Pascals
229 */
231
232 //! The minimum temperature at which data for all species is valid
233 double m_minTemp = 0.0;
234
235 //! The maximum temperature at which data for all species is valid
237
238 //! The last temperature at which the standard state thermodynamic
239 //! properties were calculated at.
240 mutable double m_Tlast_ss = -1.0;
241
242 //! The last pressure at which the Standard State thermodynamic properties
243 //! were calculated at.
244 mutable double m_Plast_ss = -1.0;
245
246 //! Storage for the PDSS objects for the species
247 /*!
248 * Storage is in species index order. VPStandardStateTp owns each of the
249 * objects. Copy operations are deep.
250 */
251 vector<unique_ptr<PDSS>> m_PDSS_storage;
252
253 //! Vector containing the species reference enthalpies at T = m_tlast
254 //! and P = p_ref.
255 mutable vector<double> m_h0_RT;
256
257 //! Vector containing the species reference constant pressure heat
258 //! capacities at T = m_tlast and P = p_ref.
259 mutable vector<double> m_cp0_R;
260
261 //! Vector containing the species reference Gibbs functions at T = m_tlast
262 //! and P = p_ref.
263 mutable vector<double> m_g0_RT;
264
265 //! Vector containing the species reference entropies at T = m_tlast
266 //! and P = p_ref.
267 mutable vector<double> m_s0_R;
268
269 //! Vector containing the species reference molar volumes
270 mutable vector<double> m_V0;
271
272 //! Vector containing the species Standard State enthalpies at T = m_tlast
273 //! and P = m_plast.
274 mutable vector<double> m_hss_RT;
275
276 //! Vector containing the species Standard State constant pressure heat
277 //! capacities at T = m_tlast and P = m_plast.
278 mutable vector<double> m_cpss_R;
279
280 //! Vector containing the species Standard State Gibbs functions at T =
281 //! m_tlast and P = m_plast.
282 mutable vector<double> m_gss_RT;
283
284 //! Vector containing the species Standard State entropies at T = m_tlast
285 //! and P = m_plast.
286 mutable vector<double> m_sss_R;
287
288 //! Vector containing the species standard state volumes at T = m_tlast and
289 //! P = m_plast
290 mutable vector<double> m_Vss;
291};
292}
293
294#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:431
Virtual base class for a species with a pressure dependent standard state.
Definition PDSS.h:140
virtual bool addSpecies(shared_ptr< Species > spec)
Add a Species to this Phase.
Definition Phase.cpp:724
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 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 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:595
const size_t npos
index returned by functions to indicate "no position"
Definition ct_defs.h:180
const double BigNumber
largest number to compare to inf.
Definition ct_defs.h:160