Cantera  2.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ConstDensityThermo.h
Go to the documentation of this file.
1 /**
2  * @file ConstDensityThermo.h
3  * Header for a Thermo manager for incompressible ThermoPhases
4  * (see \ref thermoprops and \link Cantera::ConstDensityThermo ConstDensityThermo\endlink).
5  */
6 /*
7  * Copyright 2002 California Institute of Technology
8  */
9 
10 #ifndef CT_CONSTRHOTHERMO_H
11 #define CT_CONSTRHOTHERMO_H
12 
13 #include "ThermoPhase.h"
14 #include "cantera/base/utilities.h"
15 
16 namespace Cantera
17 {
18 
19 //! Overloads the virtual methods of class ThermoPhase to implement the
20 //! incompressible equation of state.
21 /**
22  * <b> Specification of Solution Thermodynamic Properties </b>
23  *
24  * The density is assumed to be constant, no matter what the concentration of the solution.
25  *
26  * @ingroup thermoprops
27  */
29 {
30 public:
31  //! Constructor.
33 
34  //! Copy Constructor
35  /*!
36  * @param right Object to be copied
37  */
39 
40  //! Assignment Operator
41  /*!
42  * @param right Object to be copied
43  */
45 
46  //! Duplication routine for objects which inherit from ThermoPhase
47  /*!
48  * This virtual routine can be used to duplicate objects
49  * derived from ThermoPhase even if the application only has
50  * a pointer to ThermoPhase to work with.
51  */
52  virtual ThermoPhase* duplMyselfAsThermoPhase() const;
53 
54  //! Returns a constant corresponding to this class's equation of state
55  virtual int eosType() const;
56 
57  /// Molar enthalpy. Units: J/kmol.
58  virtual doublereal enthalpy_mole() const;
59 
60  /// Molar entropy. Units: J/kmol/K.
61  virtual doublereal entropy_mole() const;
62 
63  /// Molar heat capacity at constant pressure. Units: J/kmol/K.
64  virtual doublereal cp_mole() const;
65 
66  /// Molar heat capacity at constant volume. Units: J/kmol/K.
67  virtual doublereal cv_mole() const;
68 
69  //! Return the thermodynamic pressure (Pa).
70  virtual doublereal pressure() const;
71 
72  //! Set the internally stored pressure (Pa) at constant
73  //! temperature and composition
74  /*!
75  * @param p input Pressure (Pa)
76  */
77  virtual void setPressure(doublereal p);
78 
79  //! This method returns an array of generalized concentrations
80  /*!
81  * \f$ C^a_k\f$ are defined such that \f$ a_k = C^a_k /
82  * C^0_k, \f$ where \f$ C^0_k \f$ is a standard concentration
83  * defined below and \f$ a_k \f$ are activities used in the
84  * thermodynamic functions. These activity (or generalized)
85  * concentrations are used
86  * by kinetics manager classes to compute the forward and
87  * reverse rates of elementary reactions. Note that they may
88  * or may not have units of concentration --- they might be
89  * partial pressures, mole fractions, or surface coverages,
90  * for example.
91  *
92  * @param c Output array of generalized concentrations. The
93  * units depend upon the implementation of the
94  * reaction rate expressions within the phase.
95  */
96  virtual void getActivityConcentrations(doublereal* c) const;
97 
98  //! Get the array of non-dimensional molar-based activity coefficients at
99  //! the current solution temperature, pressure, and solution concentration.
100  /*!
101  * @param ac Output vector of activity coefficients. Length: m_kk.
102  */
103  virtual void getActivityCoefficients(doublereal* ac) const;
104 
105  //! Get the species chemical potentials. Units: J/kmol.
106  /*!
107  * This function returns a vector of chemical potentials of the
108  * species in solution at the current temperature, pressure
109  * and mole fraction of the solution.
110  *
111  * @param mu Output vector of species chemical
112  * potentials. Length: m_kk. Units: J/kmol
113  */
114  virtual void getChemPotentials(doublereal* mu) const;
115 
116  //! Get the array of chemical potentials at unit activity for the species
117  //! at their standard states at the current <I>T</I> and <I>P</I> of the solution.
118  /*!
119  * These are the standard state chemical potentials \f$ \mu^0_k(T,P)
120  * \f$. The values are evaluated at the current
121  * temperature and pressure of the solution
122  *
123  * @param mu0 Output vector of chemical potentials.
124  * Length: m_kk.
125  */
126  virtual void getStandardChemPotentials(doublereal* mu0) const;
127 
128  //! Return the standard concentration for the kth species
129  /*!
130  * The standard concentration \f$ C^0_k \f$ used to normalize
131  * the activity (i.e., generalized) concentration. In many cases, this quantity
132  * will be the same for all species in a phase - for example,
133  * for an ideal gas \f$ C^0_k = P/\hat R T \f$. For this
134  * reason, this method returns a single value, instead of an
135  * array. However, for phases in which the standard
136  * concentration is species-specific (e.g. surface species of
137  * different sizes), this method may be called with an
138  * optional parameter indicating the species.
139  *
140  * @param k Optional parameter indicating the species. The default
141  * is to assume this refers to species 0.
142  * @return
143  * Returns the standard Concentration in units of m3 kmol-1.
144  */
145  virtual doublereal standardConcentration(size_t k=0) const;
146 
147  //! Get the Gibbs functions for the standard
148  //! state of the species at the current <I>T</I> and <I>P</I> of the solution
149  /*!
150  * Units are Joules/kmol
151  * @param gpure Output vector of standard state Gibbs free energies
152  * Length: m_kk.
153  */
154  virtual void getPureGibbs(doublereal* gpure) const {
155  const vector_fp& gibbsrt = gibbs_RT();
156  scale(gibbsrt.begin(), gibbsrt.end(), gpure, _RT());
157  }
158 
159  //! Get the nondimensional Enthalpy functions for the species
160  //! at their standard states at the current <I>T</I> and <I>P</I> of the solution.
161  /*!
162  * @param hrt Output vector of nondimensional standard state enthalpies.
163  * Length: m_kk.
164  */
165  void getEnthalpy_RT(doublereal* hrt) const {
166  const vector_fp& _h = enthalpy_RT();
167  std::copy(_h.begin(), _h.end(), hrt);
168  }
169 
170  //! Get the array of nondimensional Entropy functions for the
171  //! standard state species at the current <I>T</I> and <I>P</I> of the solution.
172  /*!
173  * @param sr Output vector of nondimensional standard state entropies.
174  * Length: m_kk.
175  */
176  void getEntropy_R(doublereal* sr) const {
177  const vector_fp& _s = entropy_R();
178  std::copy(_s.begin(), _s.end(), sr);
179  }
180 
181  //! Get the nondimensional Gibbs functions for the species
182  //! in their standard states at the current <I>T</I> and <I>P</I> of the solution.
183  /*!
184  * @param grt Output vector of nondimensional standard state Gibbs free energies
185  * Length: m_kk.
186  */
187  virtual void getGibbs_RT(doublereal* grt) const {
188  const vector_fp& gibbsrt = gibbs_RT();
189  std::copy(gibbsrt.begin(), gibbsrt.end(), grt);
190  }
191 
192  //! Get the nondimensional Heat Capacities at constant
193  //! pressure for the species standard states
194  //! at the current <I>T</I> and <I>P</I> of the solution
195  /*!
196  * @param cpr Output vector of nondimensional standard state heat capacities
197  * Length: m_kk.
198  */
199  void getCp_R(doublereal* cpr) const {
200  const vector_fp& _cpr = cp_R();
201  std::copy(_cpr.begin(), _cpr.end(), cpr);
202  }
203 
204  //! Returns a reference to the vector of nondimensional
205  //! enthalpies of the reference state at the current temperature
206  //! of the solution and the reference pressure for the species.
207  const vector_fp& enthalpy_RT() const {
208  _updateThermo();
209  return m_h0_RT;
210  }
211 
212  //! Returns a reference to the vector of nondimensional
213  //! Gibbs Free Energies of the reference state at the current temperature
214  //! of the solution and the reference pressure for the species.
215  const vector_fp& gibbs_RT() const {
216  _updateThermo();
217  return m_g0_RT;
218  }
219 
220  //! Returns a reference to the vector of nondimensional
221  //! entropies of the reference state at the current temperature
222  //! of the solution and the reference pressure for each species.
223  const vector_fp& entropy_R() const {
224  _updateThermo();
225  return m_s0_R;
226  }
227 
228  //! Returns a reference to the vector of nondimensional
229  //! constant pressure heat capacities of the reference state
230  //! at the current temperature of the solution
231  //! and reference pressure for each species.
232  const vector_fp& cp_R() const {
233  _updateThermo();
234  return m_cp0_R;
235  }
236 
237  //! Initialize the ThermoPhase object after all species have been set up
238  /*!
239  * @internal Initialize.
240  *
241  * This method is provided to allow
242  * subclasses to perform any initialization required after all
243  * species have been added. For example, it might be used to
244  * resize internal work arrays that must have an entry for
245  * each species. The base class implementation does nothing,
246  * and subclasses that do not require initialization do not
247  * need to overload this method. When importing a CTML phase
248  * description, this method is called from ThermoPhase::initThermoXML(),
249  * which is called from importPhase(),
250  * just prior to returning from function importPhase().
251  */
252  virtual void initThermo();
253 
254  //!This method is used by the ChemEquil equilibrium solver.
255  /*!
256  * It sets the state such that the chemical potentials satisfy
257  * \f[ \frac{\mu_k}{\hat R T} = \sum_m A_{k,m}
258  * \left(\frac{\lambda_m} {\hat R T}\right) \f] where
259  * \f$ \lambda_m \f$ is the element potential of element m. The
260  * temperature is unchanged. Any phase (ideal or not) that
261  * implements this method can be equilibrated by ChemEquil.
262  *
263  * @param lambda_RT Input vector of dimensionless element potentials
264  * The length is equal to nElements().
265  */
266  virtual void setToEquilState(const doublereal* lambda_RT);
267 
268  //! Set the equation of state parameters
269  /*!
270  * @internal
271  * The number and meaning of these depends on the subclass.
272  *
273  * @param n number of parameters
274  * @param c array of \a n coefficients
275  */
276  virtual void setParameters(int n, doublereal* const c) {
277  setDensity(c[0]);
278  }
279 
280  //! Get the equation of state parameters in a vector
281  /*!
282  * @internal
283  * The number and meaning of these depends on the subclass.
284  *
285  * @param n number of parameters
286  * @param c array of \a n coefficients
287  */
288  virtual void getParameters(int& n, doublereal* const c) const {
289  double d = density();
290  c[0] = d;
291  n = 1;
292  }
293 
294  //! Set equation of state parameter values from XML entries.
295  /*!
296  *
297  * This method is called by function importPhase() when processing a phase
298  * definition in an input file. It should be overloaded in subclasses to set
299  * any parameters that are specific to that particular phase
300  * model. Note, this method is called before the phase is
301  * initialized with elements and/or species.
302  *
303  * @param eosdata An XML_Node object corresponding to
304  * the "thermo" entry for this phase in the input file.
305  */
306  virtual void setParametersFromXML(const XML_Node& eosdata);
307 
308 protected:
309  //! Temporary storage for dimensionless reference state enthalpies
311 
312  //! Temporary storage for dimensionless reference state heat capacities
314 
315  //! Temporary storage for dimensionless reference state Gibbs energies
317 
318  //! Temporary storage for dimensionless reference state entropies
319  mutable vector_fp m_s0_R;
320 
321  //! Temporary array containing internally calculated partial pressures
322  mutable vector_fp m_pp;
323 
324  //! Current pressure (Pa)
325  doublereal m_press;
326 
327 private:
328  //! Function to update the reference state thermo functions
329  void _updateThermo() const;
330 };
331 }
332 
333 #endif
virtual doublereal density() const
Density (kg/m^3).
Definition: Phase.h:608
void getEntropy_R(doublereal *sr) const
Get the array of nondimensional Entropy functions for the standard state species at the current T and...
vector_fp m_s0_R
Temporary storage for dimensionless reference state entropies.
Various templated functions that carry out common vector operations (see Templated Utility Functions)...
virtual doublereal standardConcentration(size_t k=0) const
Return the standard concentration for the kth species.
virtual void setToEquilState(const doublereal *lambda_RT)
This method is used by the ChemEquil equilibrium solver.
doublereal _RT() const
Return the Gas Constant multiplied by the current temperature.
Definition: ThermoPhase.h:936
virtual void getGibbs_RT(doublereal *grt) const
Get the nondimensional Gibbs functions for the species in their standard states at the current T and ...
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...
const vector_fp & cp_R() const
Returns a reference to the vector of nondimensional constant pressure heat capacities of the referenc...
virtual ThermoPhase * duplMyselfAsThermoPhase() const
Duplication routine for objects which inherit from ThermoPhase.
void getEnthalpy_RT(doublereal *hrt) const
Get the nondimensional Enthalpy functions for the species at their standard states at the current T a...
virtual void getActivityCoefficients(doublereal *ac) const
Get the array of non-dimensional molar-based activity coefficients at the current solution temperatur...
Class XML_Node is a tree-based representation of the contents of an XML file.
Definition: xml.h:100
vector_fp m_h0_RT
Temporary storage for dimensionless reference state enthalpies.
virtual doublereal cp_mole() const
Molar heat capacity at constant pressure. Units: J/kmol/K.
doublereal m_press
Current pressure (Pa)
vector_fp m_pp
Temporary array containing internally calculated partial pressures.
Base class for a phase with thermodynamic properties.
Definition: ThermoPhase.h:97
virtual void getChemPotentials(doublereal *mu) const
Get the species chemical potentials. Units: J/kmol.
virtual void setPressure(doublereal p)
Set the internally stored pressure (Pa) at constant temperature and composition.
virtual void getStandardChemPotentials(doublereal *mu0) const
Get the array of chemical potentials at unit activity for the species at their standard states at the...
void _updateThermo() const
Function to update the reference state thermo functions.
virtual void getParameters(int &n, doublereal *const c) const
Get the equation of state parameters in a vector.
Overloads the virtual methods of class ThermoPhase to implement the incompressible equation of state...
virtual void setParameters(int n, doublereal *const c)
Set the equation of state parameters.
virtual doublereal cv_mole() const
Molar heat capacity at constant volume. Units: J/kmol/K.
const vector_fp & enthalpy_RT() const
Returns a reference to the vector of nondimensional enthalpies of the reference state at the current ...
virtual void setParametersFromXML(const XML_Node &eosdata)
Set equation of state parameter values from XML entries.
const vector_fp & gibbs_RT() const
Returns a reference to the vector of nondimensional Gibbs Free Energies of the reference state at the...
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
void scale(InputIter begin, InputIter end, OutputIter out, S scale_factor)
Multiply elements of an array by a scale factor.
Definition: utilities.h:158
virtual int eosType() const
Returns a constant corresponding to this class's equation of state.
virtual doublereal enthalpy_mole() const
Molar enthalpy. Units: J/kmol.
virtual void getActivityConcentrations(doublereal *c) const
This method returns an array of generalized concentrations.
void getCp_R(doublereal *cpr) const
Get the nondimensional Heat Capacities at constant pressure for the species standard states at the cu...
ConstDensityThermo & operator=(const ConstDensityThermo &right)
Assignment Operator.
const vector_fp & entropy_R() const
Returns a reference to the vector of nondimensional entropies of the reference state at the current t...
virtual doublereal entropy_mole() const
Molar entropy. Units: J/kmol/K.
virtual doublereal pressure() const
Return the thermodynamic pressure (Pa).
vector_fp m_g0_RT
Temporary storage for dimensionless reference state Gibbs energies.
vector_fp m_cp0_R
Temporary storage for dimensionless reference state heat capacities.
Header file for class ThermoPhase, the base class for phases with thermodynamic properties, and the text for the Module thermoprops (see Thermodynamic Properties and class ThermoPhase).
virtual void setDensity(const doublereal density_)
Set the internally stored density (kg/m^3) of the phase Note the density of a phase is an independent...
Definition: Phase.h:623
virtual void initThermo()
Initialize the ThermoPhase object after all species have been set up.