Cantera  2.0
IdealSolnGasVPSS.h
Go to the documentation of this file.
1 /**
2  * @file IdealSolnGasVPSS.h
3  * Definition file for a derived class of ThermoPhase that assumes either
4  * an ideal gas or ideal solution approximation and handles
5  * variable pressure standard state methods for calculating
6  * thermodynamic properties (see \ref thermoprops and
7  * class \link Cantera::IdealSolnGasVPSS IdealSolnGasVPSS\endlink).
8  */
9 /*
10  * Copyright (2005) Sandia Corporation. Under the terms of
11  * Contract DE-AC04-94AL85000 with Sandia Corporation, the
12  * U.S. Government retains certain rights in this software.
13  */
14 #ifndef CT_IDEALSOLNGASVPSS_H
15 #define CT_IDEALSOLNGASVPSS_H
16 
17 #include "VPStandardStateTP.h"
18 #include "VPSSMgr.h"
19 
20 namespace Cantera
21 {
22 
23 class XML_Node;
24 class PDSS;
25 
26 /*!
27  * @name CONSTANTS - Models for the Standard State of IdealSolnPhase's
28  */
29 //@{
30 const int cIdealSolnGasPhaseG = 6009;
31 const int cIdealSolnGasPhase0 = 6010;
32 const int cIdealSolnGasPhase1 = 6011;
33 const int cIdealSolnGasPhase2 = 6012;
34 
35 
36 /**
37  * @ingroup thermoprops
38  *
39  * This class can handle either an ideal solution or an ideal gas approximation
40  * of a phase.
41  *
42  *
43  * @nosubgrouping
44  */
46 {
47 
48 public:
49 
50  /*!
51  *
52  * @name Constructors and Duplicators for %IdealSolnGasVPSS
53  *
54  */
55  /// Constructor.
57 
58  IdealSolnGasVPSS(std::string infile, std::string id="");
59 
60  /// Copy Constructor.
62 
63  /// Assignment operator
65 
66  /// Destructor.
67  virtual ~IdealSolnGasVPSS();
68 
69  /*
70  * Duplication routine
71  */
72  virtual ThermoPhase* duplMyselfAsThermoPhase() const;
73 
74  //@}
75 
76  /**
77  * @name Utilities (IdealSolnGasVPSS)
78  */
79  //@{
80  /**
81  * Equation of state type flag. The base class returns
82  * zero. Subclasses should define this to return a unique
83  * non-zero value. Constants defined for this purpose are
84  * listed in mix_defs.h.
85  */
86  virtual int eosType() const;
87 
88  //@}
89 
90  /// Molar enthalpy. Units: J/kmol.
91  doublereal enthalpy_mole() const;
92 
93  /// Molar internal energy. Units: J/kmol.
94  doublereal intEnergy_mole() const;
95 
96  /// Molar entropy. Units: J/kmol/K.
97  doublereal entropy_mole() const;
98 
99  /// Molar Gibbs function. Units: J/kmol.
100  doublereal gibbs_mole() const;
101 
102  /// Molar heat capacity at constant pressure. Units: J/kmol/K.
103  doublereal cp_mole() const;
104 
105  /// Molar heat capacity at constant volume. Units: J/kmol/K.
106  doublereal cv_mole() const;
107 
108  /**
109  * @}
110  * @name Mechanical Properties
111  * @{
112  */
113 
114  //! Set the pressure in the fluid
115  /*!
116  * @param p pressure in pascals.
117  */
118  void setPressure(doublereal p);
119 
120  //! Returns the isothermal compressibility. Units: 1/Pa.
121  /*!
122  * The isothermal compressibility is defined as
123  * \f[
124  * \kappa_T = -\frac{1}{v}\left(\frac{\partial v}{\partial P}\right)_T
125  * \f]
126  */
127  virtual doublereal isothermalCompressibility() const;
128 
129 protected:
130  /**
131  * Calculate the density of the mixture using the partial
132  * molar volumes and mole fractions as input
133  *
134  * The formula for this is
135  *
136  * \f[
137  * \rho = \frac{\sum_k{X_k W_k}}{\sum_k{X_k V_k}}
138  * \f]
139  *
140  * where \f$X_k\f$ are the mole fractions, \f$W_k\f$ are
141  * the molecular weights, and \f$V_k\f$ are the pure species
142  * molar volumes.
143  *
144  * Note, the basis behind this formula is that in an ideal
145  * solution the partial molar volumes are equal to the
146  * species standard state molar volumes.
147  * The species molar volumes may be functions
148  * of temperature and pressure.
149  *
150  * NOTE: This is a non-virtual function, which is not a
151  * member of the ThermoPhase base class.
152  */
153  virtual void calcDensity();
154 
155 public:
156 
157  //! This method returns an array of generalized concentrations
158  /*!
159  * \f$ C^a_k\f$ are defined such that \f$ a_k = C^a_k /
160  * C^0_k, \f$ where \f$ C^0_k \f$ is a standard concentration
161  * defined below and \f$ a_k \f$ are activities used in the
162  * thermodynamic functions. These activity (or generalized)
163  * concentrations are used
164  * by kinetics manager classes to compute the forward and
165  * reverse rates of elementary reactions. Note that they may
166  * or may not have units of concentration --- they might be
167  * partial pressures, mole fractions, or surface coverages,
168  * for example.
169  *
170  * @param c Output array of generalized concentrations. The
171  * units depend upon the implementation of the
172  * reaction rate expressions within the phase.
173  */
174  virtual void getActivityConcentrations(doublereal* c) const;
175 
176  //! Returns the standard concentration \f$ C^0_k \f$, which is used to normalize
177  //! the generalized concentration.
178  /*!
179  * This is defined as the concentration by which the generalized
180  * concentration is normalized to produce the activity.
181  * In many cases, this quantity will be the same for all species in a phase.
182  * Since the activity for an ideal gas mixture is
183  * simply the mole fraction, for an ideal gas \f$ C^0_k = P/\hat R T \f$.
184  *
185  * @param k Optional parameter indicating the species. The default
186  * is to assume this refers to species 0.
187  * @return
188  * Returns the standard Concentration in units of m3 kmol-1.
189  */
190  virtual doublereal standardConcentration(size_t k=0) const;
191 
192  //! Returns the natural logarithm of the standard
193  //! concentration of the kth species
194  /*!
195  * @param k index of the species. (defaults to zero)
196  */
197  virtual doublereal logStandardConc(size_t k=0) const;
198 
199  //! Returns the units of the standard and generalized concentrations.
200  /*!
201  * Note they have the same units, as their
202  * ratio is defined to be equal to the activity of the kth
203  * species in the solution, which is unitless.
204  *
205  * This routine is used in print out applications where the
206  * units are needed. Usually, MKS units are assumed throughout
207  * the program and in the XML input files.
208  *
209  * The base %ThermoPhase class assigns the default quantities
210  * of (kmol/m3) for all species.
211  * Inherited classes are responsible for overriding the default
212  * values if necessary.
213  *
214  * @param uA Output vector containing the units
215  * uA[0] = kmol units - default = 1
216  * uA[1] = m units - default = -nDim(), the number of spatial
217  * dimensions in the Phase class.
218  * uA[2] = kg units - default = 0;
219  * uA[3] = Pa(pressure) units - default = 0;
220  * uA[4] = Temperature units - default = 0;
221  * uA[5] = time units - default = 0
222  * @param k species index. Defaults to 0.
223  * @param sizeUA output int containing the size of the vector.
224  * Currently, this is equal to 6.
225  */
226  virtual void getUnitsStandardConc(double* uA, int k = 0,
227  int sizeUA = 6) const;
228 
229  //! Get the array of non-dimensional activity coefficients at
230  //! the current solution temperature, pressure, and solution concentration.
231  /*!
232  * For ideal gases, the activity coefficients are all equal to one.
233  *
234  * @param ac Output vector of activity coefficients. Length: m_kk.
235  */
236  virtual void getActivityCoefficients(doublereal* ac) const;
237 
238 
239  /// @name Partial Molar Properties of the Solution (IdealSolnGasVPSS)
240  //@{
241 
242  //! Get the array of non-dimensional species chemical potentials
243  //! These are partial molar Gibbs free energies.
244  /*!
245  * \f$ \mu_k / \hat R T \f$.
246  * Units: unitless
247  *
248  * We close the loop on this function, here, calling
249  * getChemPotentials() and then dividing by RT. No need for child
250  * classes to handle.
251  *
252  * @param mu Output vector of non-dimensional species chemical potentials
253  * Length: m_kk.
254  */
255  void getChemPotentials_RT(doublereal* mu) const;
256 
257  //! Get the species chemical potentials. Units: J/kmol.
258  /*!
259  * This function returns a vector of chemical potentials of the
260  * species in solution at the current temperature, pressure
261  * and mole fraction of the solution.
262  *
263  * @param mu Output vector of species chemical
264  * potentials. Length: m_kk. Units: J/kmol
265  */
266  virtual void getChemPotentials(doublereal* mu) const;
267 
268  //! Get the species partial molar enthalpies. Units: J/kmol.
269  /*!
270  * @param hbar Output vector of species partial molar enthalpies.
271  * Length: m_kk. units are J/kmol.
272  */
273  virtual void getPartialMolarEnthalpies(doublereal* hbar) const;
274 
275  //! Get the species partial molar entropies. Units: J/kmol/K.
276  /*!
277  * @param sbar Output vector of species partial molar entropies.
278  * Length = m_kk. units are J/kmol/K.
279  */
280  virtual void getPartialMolarEntropies(doublereal* sbar) const;
281 
282  //! Get the species partial molar enthalpies. Units: J/kmol.
283  /*!
284  * @param ubar Output vector of species partial molar internal energies.
285  * Length = m_kk. units are J/kmol.
286  */
287  virtual void getPartialMolarIntEnergies(doublereal* ubar) const;
288 
289  //! Get the partial molar heat capacities Units: J/kmol/K
290  /*!
291  * @param cpbar Output vector of species partial molar heat capacities
292  * at constant pressure.
293  * Length = m_kk. units are J/kmol/K.
294  */
295  virtual void getPartialMolarCp(doublereal* cpbar) const;
296 
297  //! Get the species partial molar volumes. Units: m^3/kmol.
298  /*!
299  * @param vbar Output vector of species partial molar volumes.
300  * Length = m_kk. units are m^3/kmol.
301  */
302  virtual void getPartialMolarVolumes(doublereal* vbar) const;
303 
304  //@}
305 
306  /*!
307  * @name Properties of the Standard State of the Species in the Solution
308  *
309  * Properties of the standard states are delegated to the VPSSMgr object.
310  * The values are cached within this object, and are not recalculated unless
311  * the temperature or pressure changes.
312  */
313  //@{
314 
315  //@}
316 
317  /// @name Thermodynamic Values for the Species Reference States (IdealSolnGasVPSS)
318  /*!
319  * Properties of the reference states are delegated to the VPSSMgr object.
320  * The values are cached within this object, and are not recalculated unless
321  * the temperature or pressure changes.
322  */
323  //@{
324 
325  //@}
326 
327 
328 public:
329 
330  //! @name Initialization Methods - For Internal use (VPStandardState)
331  /*!
332  * The following methods are used in the process of constructing
333  * the phase and setting its parameters from a specification in an
334  * input file. They are not normally used in application programs.
335  * To see how they are used, see files importCTML.cpp and
336  * ThermoFactory.cpp.
337  */
338  //@{
339 
340 
341  //! Set equation of state parameter values from XML
342  //! entries.
343  /*!
344  * This method is called by function importPhase in
345  * file importCTML.cpp when processing a phase definition in
346  * an input file. It should be overloaded in subclasses to set
347  * any parameters that are specific to that particular phase
348  * model.
349  *
350  * @param thermoNode An XML_Node object corresponding to
351  * the "thermo" entry for this phase in the input file.
352  */
353  virtual void setParametersFromXML(const XML_Node& thermoNode);
354 
355  //! @internal Initialize the object
356  /*!
357  * This method is provided to allow
358  * subclasses to perform any initialization required after all
359  * species have been added. For example, it might be used to
360  * resize internal work arrays that must have an entry for
361  * each species. The base class implementation does nothing,
362  * and subclasses that do not require initialization do not
363  * need to overload this method. When importing a CTML phase
364  * description, this method is called just prior to returning
365  * from function importPhase().
366  *
367  * @see importCTML.cpp
368  */
369  virtual void initThermo();
370 
371 
372  //!This method is used by the ChemEquil equilibrium solver.
373  /*!
374  * It sets the state such that the chemical potentials satisfy
375  * \f[ \frac{\mu_k}{\hat R T} = \sum_m A_{k,m}
376  * \left(\frac{\lambda_m} {\hat R T}\right) \f] where
377  * \f$ \lambda_m \f$ is the element potential of element m. The
378  * temperature is unchanged. Any phase (ideal or not) that
379  * implements this method can be equilibrated by ChemEquil.
380  *
381  * @param lambda_RT Input vector of dimensionless element potentials
382  * The length is equal to nElements().
383  */
384  void setToEquilState(const doublereal* lambda_RT);
385 
386  //! Initialize a ThermoPhase object, potentially reading activity
387  //! coefficient information from an XML database.
388  /*!
389  *
390  * This routine initializes the lengths in the current object and
391  * then calls the parent routine.
392  * This method is provided to allow
393  * subclasses to perform any initialization required after all
394  * species have been added. For example, it might be used to
395  * resize internal work arrays that must have an entry for
396  * each species. The base class implementation does nothing,
397  * and subclasses that do not require initialization do not
398  * need to overload this method. When importing a CTML phase
399  * description, this method is called just prior to returning
400  * from function importPhase().
401  *
402  * @param phaseNode This object must be the phase node of a
403  * complete XML tree
404  * description of the phase, including all of the
405  * species data. In other words while "phase" must
406  * point to an XML phase object, it must have
407  * sibling nodes "speciesData" that describe
408  * the species in the phase.
409  * @param id ID of the phase. If nonnull, a check is done
410  * to see if phaseNode is pointing to the phase
411  * with the correct id.
412  */
413  virtual void initThermoXML(XML_Node& phaseNode, std::string id);
414 
415 private:
416  //! @internal Initialize the internal lengths in this object.
417  /*!
418  * Note this is not a virtual function and only handles
419  * this object
420  */
421  void initLengths();
422 
423  //@}
424 
425 protected:
426 
427  //! boolean indicating what ideal solution this is
428  /*!
429  * - 1 = ideal gas
430  * - 0 = ideal soln
431  */
433 
434  //! form of the generalized concentrations
435  /*!
436  * - 0 unity
437  * - 1 1/V_k
438  * - 2 1/V_0
439  */
440  int m_formGC;
441 
442  //! Temporary storage - length = m_kk.
444 
445 };
446 }
447 
448 #endif