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