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