Cantera  2.0
StoichSubstance.h
Go to the documentation of this file.
1 /**
2  * @file StoichSubstance.h
3  * This file contains the class declarations for the StoichSubstance
4  * ThermoPhase class.
5  */
6 
7 // Copyright 2001 California Institute of Technology
8 
9 #ifndef CT_STOICHSUBSTANCE_H
10 #define CT_STOICHSUBSTANCE_H
11 
12 #include "mix_defs.h"
13 #include "ThermoPhase.h"
14 #include "SpeciesThermo.h"
15 
16 namespace Cantera
17 {
18 
19 /**
20  * @ingroup thermoprops
21  *
22  * Class StoichSubstance represents a stoichiometric (fixed composition)
23  * incompressible substance.
24  * \nosubgrouping
25  *
26  */
28 {
29 
30 public:
31 
32  //! Default empty constructor
34 
35  //! Copy Constructor
36  /*!
37  * Copy constructor for the object. Constructed
38  * object will be a clone of this object, but will
39  * also own all of its data.
40  * This is a wrapper around the assignment operator
41  *
42  * @param right Object to be copied.
43  */
44  StoichSubstance(const StoichSubstance& right);
45 
46  //! Assignment operator
47  /*!
48  * Assignment operator for the object. Constructed
49  * object will be a clone of this object, but will
50  * also own all of its data.
51  *
52  * @param right Object to be copied.
53  */
55 
56  //! Destructor
57  virtual ~StoichSubstance();
58 
59  //! Duplicator from the %ThermoPhase parent class
60  /*
61  * Given a pointer to a %ThermoPhase object, this function will
62  * duplicate the %ThermoPhase object and all underlying structures.
63  * This is basically a wrapper around the copy constructor.
64  *
65  * @return returns a pointer to a %ThermoPhase
66  */
68 
69  /**
70  *
71  * @name Utilities
72  * @{
73  */
74 
75  /**
76  * Equation of state flag. Returns the value cStoichSubstance,
77  * defined in mix_defs.h.
78  */
79  virtual int eosType() const {
80  return cStoichSubstance;
81  }
82 
83 
84  /**
85  * @}
86  * @name Molar Thermodynamic Properties of the Solution ---------
87  * @{
88  */
89 
90  /**
91  * Molar enthalpy. Units: J/kmol. For an incompressible,
92  * stoichiometric substance, the internal energy is
93  * independent of pressure, and therefore the molar enthalpy
94  * is \f[ \hat h(T, P) = \hat u(T) + P \hat v \f], where the
95  * molar specific volume is constant.
96  */
97  virtual doublereal enthalpy_mole() const;
98 
99  /**
100  * Molar internal energy. J/kmol. For an incompressible,
101  * stoichiometric substance, the molar internal energy is
102  * independent of pressure. Since the thermodynamic properties
103  * are specified by giving the standard-state enthalpy, the
104  * term \f$ P_0 \hat v\f$ is subtracted from the specified molar
105  * enthalpy to compute the molar internal energy.
106  */
107  virtual doublereal intEnergy_mole() const;
108 
109  /**
110  * Molar entropy. Units: J/kmol/K. For an incompressible,
111  * stoichiometric substance, the molar entropy depends only on
112  * the temperature.
113  */
114  virtual doublereal entropy_mole() const;
115 
116 
117  /**
118  * Molar gibbs Function. Units: J/kmol. This is determined
119  * from the molar enthalpy and entropy functions.
120  */
121  virtual doublereal gibbs_mole() const;
122 
123  /**
124  * Molar heat capacity at constant pressure. Units: J/kmol/K.
125  * For an incompressible substance, \f$ \hat c_p = \hat c_v\f$.
126  */
127  virtual doublereal cp_mole() const;
128 
129  /**
130  * Molar heat capacity at constant volume. Units: J/kmol/K.
131  * For an incompressible substance, \f$ \hat c_p = \hat c_v\f$.
132  */
133  virtual doublereal cv_mole() const;
134 
135  //@}
136 
137 
138  /**
139  * @name Mechanical Equation of State
140  * @{
141  */
142 
143 
144  //! Report the Pressure. Units: Pa.
145  /*!
146  * For an incompressible substance, the density is independent
147  * of pressure. This method simply returns the stored
148  * pressure value.
149  */
150  virtual doublereal pressure() const;
151 
152 
153  //! Set the pressure at constant temperature. Units: Pa.
154  /*!
155  * For an incompressible substance, the density is
156  * independent of pressure. Therefore, this method only
157  * stores the specified pressure value. It does not
158  * modify the density.
159  *
160  * @param p Pressure (units - Pa)
161  */
162  virtual void setPressure(doublereal p);
163 
164  //@}
165 
166  /**
167  * @name Chemical Potentials and Activities
168  *@{
169  */
170 
171  /**
172  * This method returns the array of generalized
173  * concentrations. For a stoichiometric substance, there is
174  * only one species, and the generalized concentration is 1.0.
175  */
176  virtual void getActivityConcentrations(doublereal* c) const;
177 
178  /**
179  * The standard concentration. This is defined as the concentration
180  * by which the generalized concentration is normalized to produce
181  * the activity.
182  */
183  virtual doublereal standardConcentration(size_t k=0) const;
184 
185  /**
186  * Returns the natural logarithm of the standard
187  * concentration of the kth species
188  */
189  virtual doublereal logStandardConc(size_t k=0) const;
190 
191  /**
192  * Get the array of chemical potentials at unit activity
193  * \f$ \mu^0_k \f$.
194  *
195  * For a stoichiometric substance, there is no activity term in
196  * the chemical potential expression, and therefore the
197  * standard chemical potential and the chemical potential
198  * are both equal to the molar Gibbs function.
199  */
200  virtual void getStandardChemPotentials(doublereal* mu0) const;
201 
202  /**
203  * Returns the units of the standard and generalized
204  * concentrations Note they have the same units, as their
205  * ratio is defined to be equal to the activity of the kth
206  * species in the solution, which is unitless.
207  *
208  * This routine is used in print out applications where the
209  * units are needed. Usually, MKS units are assumed throughout
210  * the program and in the XML input files.
211  *
212  * uA[0] = kmol units - default = 0
213  * uA[1] = m units - default = 0
214  * uA[2] = kg units - default = 0;
215  * uA[3] = Pa(pressure) units - default = 0;
216  * uA[4] = Temperature units - default = 0;
217  * uA[5] = time units - default = 0
218  */
219  virtual void getUnitsStandardConc(double* uA, int k = 0,
220  int sizeUA = 6) const;
221 
222 
223  //@}
224  /// @name Partial Molar Properties of the Solution ----------------------------
225  //@{
226 
227 
228  /**
229  * Get the array of non-dimensional chemical potentials
230  * \f$ \mu_k / \hat R T \f$.
231  */
232  virtual void getChemPotentials_RT(doublereal* mu) const;
233 
234  /**
235  * For a stoichiometric substance, there is only one species.
236  * This method returns the molar gibbs function in the
237  * first element of array \c mu.
238  */
239  virtual void getChemPotentials(doublereal* mu) const;
240 
241  /**
242  * Get the species electrochemical potentials. Units: J/kmol.
243  * This method adds a term \f$ Fz_k \phi_k \f$ to the
244  * to each chemical potential.
245  */
246  void getElectrochemPotentials(doublereal* mu) const;
247 
248  /**
249  * Returns an array of partial molar enthalpies for the species
250  * in the mixture.
251  * Units (J/kmol)
252  */
253  virtual void getPartialMolarEnthalpies(doublereal* hbar) const;
254 
255  /**
256  * Returns an array of partial molar entropies of the species in the
257  * solution. Units: J/kmol/K.
258  */
259  virtual void getPartialMolarEntropies(doublereal* sbar) const;
260 
261  /**
262  * returns an array of partial molar volumes of the species
263  * in the solution. Units: m^3 kmol-1.
264  */
265  virtual void getPartialMolarVolumes(doublereal* vbar) const;
266 
267 
268  //@}
269  /// @name Properties of the Standard State of the Species in the Solution -----
270  //@{
271  /**
272  * Get the nondimensional Enthalpy functions for the species
273  * at their standard states at the current
274  * <I>T</I> and <I>P</I> of the solution.
275  */
276  virtual void getEnthalpy_RT(doublereal* hrt) const;
277 
278  /**
279  * Get the array of nondimensional Enthalpy functions for the
280  * standard state species
281  * at the current <I>T</I> and <I>P</I> of the solution.
282  */
283  virtual void getEntropy_R(doublereal* sr) const;
284 
285  /**
286  * Get the nondimensional Gibbs functions for the species
287  * at their standard states of solution at the current T and P
288  * of the solution.
289  */
290  virtual void getGibbs_RT(doublereal* grt) const;
291 
292  //! Get the Gibbs functions for the standard
293  //! state of the species at the current <I>T</I> and <I>P</I> of the solution
294  /*!
295  * Units are Joules/kmol
296  * @param gpure Output vector of standard state gibbs free energies
297  * Length: m_kk.
298  */
299  virtual void getPureGibbs(doublereal* gpure) const;
300 
301  /**
302  * Get the nondimensional Heat Capacities at constant
303  * pressure for the standard state of the species
304  * at the current T and P.
305  */
306  virtual void getCp_R(doublereal* cpr) const;
307 
308  /**
309  * Get the standard volumes for the standard state of the species
310  * at the current T and P
311  */
312  virtual void getStandardVolumes(doublereal* vol) const;
313 
314  //@}
315  /// @name Thermodynamic Values for the Species Reference States --------------------
316  //@{
317 
318  /**
319  * Returns the vector of nondimensional
320  * enthalpies of the reference state at the current temperature
321  * of the solution and the reference pressure for the species.
322  *
323  * This function fills in its one entry in hrt[] by calling
324  * the underlying species thermo function for the
325  * dimensionless enthalpy.
326  */
327  virtual void getEnthalpy_RT_ref(doublereal* hrt) const;
328 
329 #ifdef H298MODIFY_CAPABILITY
330 
331  virtual void modifyOneHf298SS(const int k, const doublereal Hf298New) {
332  m_spthermo->modifyOneHf298(k, Hf298New);
333  m_tlast += 0.0001234;
334  }
335 #endif
336  /**
337  * Returns the vector of nondimensional
338  * enthalpies of the reference state at the current temperature
339  * of the solution and the reference pressure for the species.
340  *
341  * This function fills in its one entry in hrt[] by calling
342  * the underlying species thermo function for the
343  * dimensionless gibbs free energy, calculated from the
344  * dimensionless enthalpy and entropy.
345  */
346  virtual void getGibbs_RT_ref(doublereal* grt) const;
347 
348  /**
349  * Returns the vector of the
350  * gibbs function of the reference state at the current temperature
351  * of the solution and the reference pressure for the species.
352  * units = J/kmol
353  *
354  * This function fills in its one entry in g[] by calling
355  * the underlying species thermo functions for the
356  * gibbs free energy, calculated from enthalpy and the
357  * entropy, and the multiplying by RT.
358  */
359  virtual void getGibbs_ref(doublereal* g) const;
360 
361  /**
362  * Returns the vector of nondimensional
363  * entropies of the reference state at the current temperature
364  * of the solution and the reference pressure for the species.
365  *
366  * This function fills in its one entry in hrt[] by calling
367  * the underlying species thermo function for the
368  * dimensionless entropy.
369  */
370  virtual void getEntropy_R_ref(doublereal* er) const;
371 
372  //! Returns the vector of nondimensional
373  //! constant pressure heat capacities of the reference state
374  //! at the current temperature of the solution
375  //! and reference pressure for each species.
376  /*!
377  * @param cprt Output vector of nondimensional reference state
378  * heat capacities at constant pressure for the species.
379  * Length: m_kk
380  */
381  virtual void getCp_R_ref(doublereal* cprt) const;
382 
383  virtual void initThermo();
384 
385  virtual void setParameters(int n, double* const c);
386 
387  virtual void getParameters(int& n, double* const c) const;
388 
389  virtual void setParametersFromXML(const XML_Node& eosdata);
390 
391 protected:
392 
393  size_t m_kk;
394  doublereal m_tmin;
395  doublereal m_tmax;
396  doublereal m_press;
397  doublereal m_p0;
398 
399  mutable doublereal m_tlast;
400  mutable vector_fp m_h0_RT;
401  mutable vector_fp m_cp0_R;
402  mutable vector_fp m_s0_R;
403 
404 private:
405 
406  void _updateThermo() const;
407 };
408 
409 }
410 
411 #endif
412 
413 
414 
415 
416