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