Cantera 2.6.0
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 virtual ~VPStandardStateTP();
52
53 virtual bool isCompressible() const {
54 return false;
55 }
56
57 //! @name Utilities (VPStandardStateTP)
58 //! @{
59
60 virtual int standardStateConvention() const;
61
62 virtual void getdlnActCoeffdlnN_diag(doublereal* dlnActCoeffdlnN_diag) const {
63 throw NotImplementedError("VPStandardStateTP::getdlnActCoeffdlnN_diag");
64 }
65
66 //! @}
67 //! @name Partial Molar Properties of the Solution (VPStandardStateTP)
68 //! @{
69
70 //! Get the array of non-dimensional species chemical potentials.
71 /*!
72 * These are partial molar Gibbs free energies, \f$ \mu_k / \hat R T \f$.
73 *
74 * We close the loop on this function, here, calling getChemPotentials() and
75 * then dividing by RT. No need for child classes to handle.
76 *
77 * @param mu Output vector of non-dimensional species chemical potentials
78 * Length: m_kk.
79 */
80 virtual void getChemPotentials_RT(doublereal* mu) const;
81
82 //! @}
83 /*!
84 * @name Properties of the Standard State of the Species in the Solution
85 *
86 * Within VPStandardStateTP, these properties are calculated via a common
87 * routine, _updateStandardStateThermo(), which must be overloaded in
88 * inherited objects. The values are cached within this object, and are not
89 * recalculated unless the temperature or pressure changes.
90 */
91 //! @{
92
93 virtual void getStandardChemPotentials(doublereal* mu) const;
94 virtual void getEnthalpy_RT(doublereal* hrt) const;
95 virtual void getEntropy_R(doublereal* sr) const;
96 virtual void getGibbs_RT(doublereal* grt) const;
97 virtual void getPureGibbs(doublereal* gpure) const;
98 virtual void getIntEnergy_RT(doublereal* urt) const;
99 virtual void getCp_R(doublereal* cpr) const;
100 virtual void getStandardVolumes(doublereal* vol) const;
101 virtual const vector_fp& getStandardVolumes() const;
102 //! @}
103
104 //! Set the temperature of the phase
105 /*!
106 * Currently this passes down to setState_TP(). It does not make sense to
107 * calculate the standard state without first setting T and P.
108 *
109 * @param temp Temperature (kelvin)
110 */
111 virtual void setTemperature(const doublereal temp);
112
113 //! Set the internally stored pressure (Pa) at constant temperature and
114 //! composition
115 /*!
116 * Currently this passes down to setState_TP(). It does not make sense to
117 * calculate the standard state without first setting T and P.
118 *
119 * @param p input Pressure (Pa)
120 */
121 virtual void setPressure(doublereal p);
122
123 //! Set the temperature and pressure at the same time
124 /*!
125 * Note this function triggers a reevaluation of the standard state
126 * quantities.
127 *
128 * @param T temperature (kelvin)
129 * @param pres pressure (pascal)
130 */
131 virtual void setState_TP(doublereal T, doublereal pres);
132
133 //! Returns the current pressure of the phase
134 /*!
135 * The pressure is an independent variable in this phase. Its current value
136 * is stored in the object VPStandardStateTP.
137 *
138 * @returns the pressure in pascals.
139 */
140 virtual doublereal pressure() const {
141 return m_Pcurrent;
142 }
143
144 //! Updates the standard state thermodynamic functions at the current T and P of the solution.
145 /*!
146 * If m_useTmpStandardStateStorage is true, this function must be called for
147 * every call to functions in this class. It checks to see whether the
148 * temperature or pressure has changed and thus the ss thermodynamics
149 * functions for all of the species must be recalculated.
150 *
151 * This function is responsible for updating the following internal members,
152 * when m_useTmpStandardStateStorage is true.
153 *
154 * - m_hss_RT;
155 * - m_cpss_R;
156 * - m_gss_RT;
157 * - m_sss_R;
158 * - m_Vss
159 *
160 * If m_useTmpStandardStateStorage is not true, this function may be
161 * required to be called by child classes to update internal member data.
162 */
163 virtual void updateStandardStateThermo() const;
164
165 virtual double minTemp(size_t k=npos) const;
166 virtual double maxTemp(size_t k=npos) const;
167
168
169protected:
170 /**
171 * Calculate the density of the mixture using the partial molar volumes and
172 * mole fractions as input.
173 *
174 * The formula for this is
175 *
176 * \f[
177 * \rho = \frac{\sum_k{X_k W_k}}{\sum_k{X_k V_k}}
178 * \f]
179 *
180 * where \f$X_k\f$ are the mole fractions, \f$W_k\f$ are the molecular
181 * weights, and \f$V_k\f$ are the pure species molar volumes.
182 *
183 * Note, the basis behind this formula is that in an ideal solution the
184 * partial molar volumes are equal to the pure species molar volumes. We
185 * have additionally specified in this class that the pure species molar
186 * volumes are independent of temperature and pressure.
187 *
188 * NOTE: This function is not a member of the ThermoPhase base class.
189 */
190 virtual void calcDensity();
191
192 //! Updates the standard state thermodynamic functions at the current T and
193 //! P of the solution.
194 /*!
195 * @internal
196 *
197 * If m_useTmpStandardStateStorage is true,
198 * this function must be called for every call to functions in this class.
199 *
200 * This function is responsible for updating the following internal members,
201 * when m_useTmpStandardStateStorage is true.
202 *
203 * - m_hss_RT;
204 * - m_cpss_R;
205 * - m_gss_RT;
206 * - m_sss_R;
207 * - m_Vss
208 *
209 * This function doesn't check to see if the temperature or pressure
210 * has changed. It automatically assumes that it has changed.
211 * If m_useTmpStandardStateStorage is not true, this function may be
212 * required to be called by child classes to update internal member data..
213 */
214 virtual void _updateStandardStateThermo() const;
215
216public:
217 /// @name Thermodynamic Values for the Species Reference States
218 /*!
219 * There are also temporary variables for holding the species reference-
220 * state values of Cp, H, S, and V at the last temperature and reference
221 * pressure called. These functions are not recalculated if a new call is
222 * made using the previous temperature. All calculations are done within the
223 * routine _updateRefStateThermo().
224 */
225 //! @{
226
227 virtual void getEnthalpy_RT_ref(doublereal* hrt) const;
228 virtual void getGibbs_RT_ref(doublereal* grt) const;
229
230protected:
231 const vector_fp& Gibbs_RT_ref() const;
232
233public:
234 virtual void getGibbs_ref(doublereal* g) const;
235 virtual void getEntropy_R_ref(doublereal* er) const;
236 virtual void getCp_R_ref(doublereal* cprt) const;
237 virtual void getStandardVolumes_ref(doublereal* vol) const;
238 //! @}
239
240 //! @name Initialization Methods - For Internal use
241 /*!
242 * The following methods are used in the process of constructing
243 * the phase and setting its parameters from a specification in an
244 * input file. They are not normally used in application programs.
245 * To see how they are used, see importPhase().
246 */
247 //! @{
248
249 virtual void initThermo();
250 virtual void getSpeciesParameters(const std::string& name,
251 AnyMap& speciesNode) const;
252
253 using Phase::addSpecies;
254 virtual bool addSpecies(shared_ptr<Species> spec);
255
256 //! Install a PDSS object for species *k*
257 void installPDSS(size_t k, std::unique_ptr<PDSS>&& pdss);
258 //! @}
259
260 PDSS* providePDSS(size_t k);
261 const PDSS* providePDSS(size_t k) const;
262
263protected:
264 virtual void invalidateCache();
265
266 //! Current value of the pressure - state variable
267 /*!
268 * Because we are now using the pressure as a state variable, we need to
269 * carry it along within this object
270 *
271 * units = Pascals
272 */
273 doublereal m_Pcurrent;
274
275 //! The minimum temperature at which data for all species is valid
276 double m_minTemp;
277
278 //! The maximum temperature at which data for all species is valid
279 double m_maxTemp;
280
281 //! The last temperature at which the standard state thermodynamic
282 //! properties were calculated at.
283 mutable doublereal m_Tlast_ss;
284
285 //! The last pressure at which the Standard State thermodynamic properties
286 //! were calculated at.
287 mutable doublereal m_Plast_ss;
288
289 //! Storage for the PDSS objects for the species
290 /*!
291 * Storage is in species index order. VPStandardStateTp owns each of the
292 * objects. Copy operations are deep.
293 */
294 std::vector<std::unique_ptr<PDSS>> m_PDSS_storage;
295
296 //! Vector containing the species reference enthalpies at T = m_tlast
297 //! and P = p_ref.
299
300 //! Vector containing the species reference constant pressure heat
301 //! capacities at T = m_tlast and P = p_ref.
303
304 //! Vector containing the species reference Gibbs functions at T = m_tlast
305 //! and P = p_ref.
307
308 //! Vector containing the species reference entropies at T = m_tlast
309 //! and P = p_ref.
311
312 //! Vector containing the species reference molar volumes
314
315 //! Vector containing the species Standard State enthalpies at T = m_tlast
316 //! and P = m_plast.
318
319 //! Vector containing the species Standard State constant pressure heat
320 //! capacities at T = m_tlast and P = m_plast.
322
323 //! Vector containing the species Standard State Gibbs functions at T =
324 //! m_tlast and P = m_plast.
326
327 //! Vector containing the species Standard State entropies at T = m_tlast
328 //! and P = m_plast.
330
331 //! Vector containing the species standard state volumes at T = m_tlast and
332 //! P = m_plast
334};
335}
336
337#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:399
An error indicating that an unimplemented function has been called.
Definition: ctexceptions.h:187
Virtual base class for a species with a pressure dependent standard state.
Definition: PDSS.h:148
virtual bool addSpecies(shared_ptr< Species > spec)
Add a Species to this Phase.
Definition: Phase.cpp:803
std::string name() const
Return the name of the phase.
Definition: Phase.cpp:70
Base class for a phase with thermodynamic properties.
Definition: ThermoPhase.h:102
This is a filter class for ThermoPhase that implements some preparatory steps for efficiently handlin...
vector_fp m_g0_RT
Vector containing the species reference Gibbs functions at T = m_tlast and P = p_ref.
vector_fp m_cp0_R
Vector containing the species reference constant pressure heat capacities at T = m_tlast and P = p_re...
virtual bool addSpecies(shared_ptr< Species > spec)
virtual void getGibbs_RT_ref(doublereal *grt) const
Returns the vector of nondimensional Gibbs Free Energies of the reference state at the current temper...
virtual void getGibbs_RT(doublereal *grt) const
Get the nondimensional Gibbs functions for the species in their standard states at the current T and ...
doublereal m_Tlast_ss
The last temperature at which the standard state thermodynamic properties were calculated at.
virtual void _updateStandardStateThermo() const
Updates the standard state thermodynamic functions at the current T and P of the solution.
vector_fp m_h0_RT
Vector containing the species reference enthalpies at T = m_tlast and P = p_ref.
doublereal m_Plast_ss
The last pressure at which the Standard State thermodynamic properties were calculated at.
virtual void setState_TP(doublereal T, doublereal pres)
Set the temperature and pressure at the same time.
virtual void getdlnActCoeffdlnN_diag(doublereal *dlnActCoeffdlnN_diag) const
Get the array of log species mole number derivatives of the log activity coefficients.
vector_fp m_s0_R
Vector containing the species reference entropies at T = m_tlast and P = p_ref.
virtual void getCp_R(doublereal *cpr) const
Get the nondimensional Heat Capacities at constant pressure for the species standard states at the cu...
virtual bool isCompressible() const
Return whether phase represents a compressible substance.
vector_fp m_Vss
Vector containing the species standard state volumes at T = m_tlast and P = m_plast.
virtual void getEntropy_R(doublereal *sr) const
Get the array of nondimensional Entropy functions for the standard state species at the current T and...
virtual void setPressure(doublereal p)
Set the internally stored pressure (Pa) at constant temperature and composition.
void installPDSS(size_t k, std::unique_ptr< PDSS > &&pdss)
Install a PDSS object for species k
double m_maxTemp
The maximum temperature at which data for all species is valid.
virtual double minTemp(size_t k=npos) const
Minimum temperature for which the thermodynamic data for the species or phase are valid.
double m_minTemp
The minimum temperature at which data for all species is valid.
virtual int standardStateConvention() const
This method returns the convention used in specification of the standard state, of which there are cu...
virtual void getEntropy_R_ref(doublereal *er) const
Returns the vector of nondimensional entropies of the reference state at the current temperature of t...
vector_fp m_sss_R
Vector containing the species Standard State entropies at T = m_tlast and P = m_plast.
vector_fp m_cpss_R
Vector containing the species Standard State constant pressure heat capacities at T = m_tlast and P =...
virtual void getIntEnergy_RT(doublereal *urt) const
Returns the vector of nondimensional Internal Energies of the standard state species at the current T...
virtual void setTemperature(const doublereal temp)
Set the temperature of the phase.
doublereal m_Pcurrent
Current value of the pressure - state variable.
virtual doublereal pressure() const
Returns the current pressure of the phase.
virtual void getCp_R_ref(doublereal *cprt) const
Returns the vector of nondimensional constant pressure heat capacities of the reference state at the ...
virtual void getSpeciesParameters(const std::string &name, AnyMap &speciesNode) const
Get phase-specific parameters of a Species object such that an identical one could be reconstructed a...
virtual void getStandardChemPotentials(doublereal *mu) const
Get the array of chemical potentials at unit activity for the species at their standard states at the...
virtual void getStandardVolumes_ref(doublereal *vol) const
Get the molar volumes of the species reference states at the current T and P_ref of the solution.
virtual double maxTemp(size_t k=npos) const
Maximum temperature for which the thermodynamic data for the species are valid.
virtual void getChemPotentials_RT(doublereal *mu) const
Get the array of non-dimensional species chemical potentials.
vector_fp m_gss_RT
Vector containing the species Standard State Gibbs functions at T = m_tlast and P = m_plast.
vector_fp m_V0
Vector containing the species reference molar volumes.
virtual void updateStandardStateThermo() const
Updates the standard state thermodynamic functions at the current T and P of the solution.
virtual void getGibbs_ref(doublereal *g) const
Returns the vector of the Gibbs function of the reference state at the current temperature of the sol...
virtual void invalidateCache()
Invalidate any cached values which are normally updated only when a change in state is detected.
vector_fp m_hss_RT
Vector containing the species Standard State enthalpies at T = m_tlast and P = m_plast.
virtual void getEnthalpy_RT(doublereal *hrt) const
Get the nondimensional Enthalpy functions for the species at their standard states at the current T a...
std::vector< std::unique_ptr< PDSS > > m_PDSS_storage
Storage for the PDSS objects for the species.
virtual void getPureGibbs(doublereal *gpure) const
Get the Gibbs functions for the standard state of the species at the current T and P of the solution.
virtual void getEnthalpy_RT_ref(doublereal *hrt) const
virtual void calcDensity()
Calculate the density of the mixture using the partial molar volumes and mole fractions as input.
Namespace for the Cantera kernel.
Definition: AnyMap.h:29
const size_t npos
index returned by functions to indicate "no position"
Definition: ct_defs.h:192
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
Definition: ct_defs.h:184