Cantera  2.1.2
LatticePhase.h
Go to the documentation of this file.
1 /**
2  * @file LatticePhase.h
3  * Header for a simple thermodynamics model of a bulk phase derived from ThermoPhase,
4  * assuming a lattice of solid atoms
5  * (see \ref thermoprops and class \link Cantera::LatticePhase LatticePhase\endlink).
6  */
7 
8 // Copyright 2005 California Institute of Technology
9 
10 #ifndef CT_LATTICE_H
11 #define CT_LATTICE_H
12 
13 #include "cantera/base/config.h"
14 
15 #include "cantera/base/ct_defs.h"
16 #include "mix_defs.h"
17 #include "ThermoPhase.h"
18 #include "SpeciesThermo.h"
19 #include "cantera/base/utilities.h"
20 
21 namespace Cantera
22 {
23 
24 //! A simple thermodynamic model for a bulk phase,
25 //! assuming a lattice of solid atoms
26 /*!
27  * The bulk consists of a matrix of equivalent sites whose molar density
28  * does not vary with temperature or pressure. The thermodynamics
29  * obeys the ideal solution laws. The phase and the pure species phases which
30  * comprise the standard states of the species are assumed to have
31  * zero volume expansivity and zero isothermal compressibility.
32  *
33  * The density of matrix sites is given by the variable \f$ C_o \f$,
34  * which has SI units of kmol m-3.
35  *
36  * <b> Specification of Species Standard State Properties </b>
37  *
38  * It is assumed that the reference state thermodynamics may be
39  * obtained by a pointer to a populated species thermodynamic property
40  * manager class (see ThermoPhase::m_spthermo). However, how to relate pressure
41  * changes to the reference state thermodynamics is within this class.
42  *
43  * Pressure is defined as an independent variable in this phase. However, it has
44  * no effect on any quantities, as the molar concentration is a constant.
45  *
46  * The standard state enthalpy function is given by the following relation,
47  * which has a weak dependence on the system pressure, \f$P\f$.
48  *
49  * \f[
50  * h^o_k(T,P) =
51  * h^{ref}_k(T) + \left( \frac{P - P_{ref}}{C_o} \right)
52  * \f]
53  *
54  * For an incompressible substance, the molar internal energy is
55  * independent of pressure. Since the thermodynamic properties
56  * are specified by giving the standard-state enthalpy, the
57  * term \f$ \frac{P_{ref}}{C_o} \f$ is subtracted from the specified reference molar
58  * enthalpy to compute the standard state molar internal energy:
59  *
60  * \f[
61  * u^o_k(T,P) = h^{ref}_k(T) - \frac{P_{ref}}{C_o}
62  * \f]
63  *
64  * The standard state heat capacity, internal energy, and entropy are independent
65  * of pressure. The standard state gibbs free energy is obtained
66  * from the enthalpy and entropy functions.
67  *
68  * The standard state molar volume is independent of temperature, pressure,
69  * and species identity:
70  *
71  * \f[
72  * V^o_k(T,P) = \frac{1.0}{C_o}
73  * \f]
74  *
75  * <HR>
76  * <H2> Specification of Solution Thermodynamic Properties </H2>
77  * <HR>
78  *
79  * The activity of species \f$ k \f$ defined in the phase, \f$ a_k \f$, is
80  * given by the ideal solution law:
81  *
82  * \f[
83  * a_k = X_k ,
84  * \f]
85  *
86  * where \f$ X_k \f$ is the mole fraction of species <I>k</I>.
87  * The chemical potential for species <I>k</I> is equal to
88  *
89  * \f[
90  * \mu_k(T,P) = \mu^o_k(T, P) + R T \log(X_k)
91  * \f]
92  *
93  * The partial molar entropy for species <I>k</I> is given by the following relation,
94  *
95  * \f[
96  * \tilde{s}_k(T,P) = s^o_k(T,P) - R \log(X_k) = s^{ref}_k(T) - R \log(X_k)
97  * \f]
98  *
99  * The partial molar enthalpy for species <I>k</I> is
100  *
101  * \f[
102  * \tilde{h}_k(T,P) = h^o_k(T,P) = h^{ref}_k(T) + \left( \frac{P - P_{ref}}{C_o} \right)
103  * \f]
104  *
105  * The partial molar Internal Energy for species <I>k</I> is
106  *
107  * \f[
108  * \tilde{u}_k(T,P) = u^o_k(T,P) = u^{ref}_k(T)
109  * \f]
110  *
111  * The partial molar Heat Capacity for species <I>k</I> is
112  *
113  * \f[
114  * \tilde{Cp}_k(T,P) = Cp^o_k(T,P) = Cp^{ref}_k(T)
115  * \f]
116  *
117  * The partial molar volume is independent of temperature, pressure,
118  * and species identity:
119  *
120  * \f[
121  * \tilde{V}_k(T,P) = V^o_k(T,P) = \frac{1.0}{C_o}
122  * \f]
123  *
124  * It is assumed that the reference state thermodynamics may be
125  * obtained by a pointer to a populated species thermodynamic property
126  * manager class (see ThermoPhase::m_spthermo). How to relate pressure
127  * changes to the reference state thermodynamics is resolved at this level.
128  *
129  * Pressure is defined as an independent variable in this phase. However, it only
130  * has a weak dependence on the enthalpy, and doesn't effect the molar
131  * concentration.
132  *
133  * <HR>
134  * <H2> %Application within %Kinetics Managers </H2>
135  * <HR>
136  *
137  * \f$ C^a_k\f$ are defined such that \f$ C^a_k = a_k = X_k \f$
138  * \f$ C^s_k \f$, the standard concentration, is
139  * defined to be equal to one. \f$ a_k \f$ are activities used in the
140  * thermodynamic functions. These activity (or generalized)
141  * concentrations are used
142  * by kinetics manager classes to compute the forward and
143  * reverse rates of elementary reactions.
144  * The activity concentration,\f$ C^a_k \f$, is given by the following expression.
145  *
146  * \f[
147  * C^a_k = C^s_k X_k = X_k
148  * \f]
149  *
150  * The standard concentration for species <I>k</I> is identically one
151  *
152  * \f[
153  * C^s_k = C^s = 1.0
154  * \f]
155  *
156  * For example, a bulk-phase binary gas reaction between species j and k, producing
157  * a new species l would have the
158  * following equation for its rate of progress variable, \f$ R^1 \f$, which has
159  * units of kmol m-3 s-1.
160  *
161  * \f[
162  * R^1 = k^1 C_j^a C_k^a = k^1 X_j X_k
163  * \f]
164  *
165  * The reverse rate constant can then be obtained from the law of microscopic reversibility
166  * and the equilibrium expression for the system.
167  *
168  * \f[
169  * \frac{X_j X_k}{ X_l} = K_a^{o,1} = \exp(\frac{\mu^o_l - \mu^o_j - \mu^o_k}{R T} )
170  * \f]
171  *
172  * \f$ K_a^{o,1} \f$ is the dimensionless form of the equilibrium constant, associated with
173  * the pressure dependent standard states \f$ \mu^o_l(T,P) \f$ and their associated activities,
174  * \f$ a_l \f$, repeated here:
175  *
176  * \f[
177  * \mu_l(T,P) = \mu^o_l(T, P) + R T \log(a_l)
178  * \f]
179  *
180  * The concentration equilibrium constant, \f$ K_c \f$, may be obtained by changing over
181  * to activity concentrations. When this is done:
182  *
183  * \f[
184  * \frac{C^a_j C^a_k}{ C^a_l} = C^o K_a^{o,1} = K_c^1 =
185  * \exp(\frac{\mu^{o}_l - \mu^{o}_j - \mu^{o}_k}{R T} )
186  * \f]
187  *
188  *
189  * %Kinetics managers will calculate the concentration equilibrium constant, \f$ K_c \f$,
190  * using the second and third part of the above expression as a definition for the concentration
191  * equilibrium constant.
192  *
193  * <HR>
194  * <H2> Instantiation of the Class </H2>
195  * <HR>
196  *
197  * The constructor for this phase is located in the default ThermoFactory
198  * for %Cantera. A new %LatticePhase object may be created by the following code snippet:
199  *
200  * @code
201  * XML_Node *xc = get_XML_File("O_lattice_SiO2.xml");
202  * XML_Node * const xs = xc->findNameID("phase", "O_lattice_SiO2");
203  * ThermoPhase *tp = newPhase(*xs);
204  * LatticePhase *o_lattice = dynamic_cast <LatticPhase *>(tp);
205  * @endcode
206  *
207  * or by the following constructor:
208  *
209  * @code
210  * XML_Node *xc = get_XML_File("O_lattice_SiO2.xml");
211  * XML_Node * const xs = xc->findNameID("phase", "O_lattice_SiO2");
212  * LatticePhase *o_lattice = new LatticePhase(*xs);
213  * @endcode
214  *
215  * The XML file used in this example is listed in the next section
216  *
217  * <HR>
218  * <H2> XML Example </H2>
219  * <HR>
220  *
221  * An example of an XML Element named phase setting up a LatticePhase object named "O_lattice_SiO2"
222  * is given below.
223  *
224  * @code
225  * <!-- phase O_lattice_SiO2 -->
226  * <phase dim="3" id="O_lattice_SiO2">
227  * <elementArray datasrc="elements.xml"> Si H He </elementArray>
228  * <speciesArray datasrc="#species_data">
229  * O_O Vac_O
230  * </speciesArray>
231  * <reactionArray datasrc="#reaction_data"/>
232  * <thermo model="Lattice">
233  * <site_density> 73.159 </site_density>
234  * <vacancy_species> Vac_O </vacancy_species>
235  * </thermo>
236  * <kinetics model="BulkKinetics"/>
237  * <transport model="None"/>
238  * </phase>
239  * @endcode
240  *
241  * The model attribute "Lattice" of the thermo XML element identifies the phase as
242  * being of the type handled by the LatticePhase object.
243  *
244  * @ingroup thermoprops
245  */
246 class LatticePhase : public ThermoPhase
247 {
248 public:
249  //! Base Empty constructor
250  LatticePhase();
251 
252  //! Copy Constructor
253  /*!
254  * @param right Object to be copied
255  */
256  LatticePhase(const LatticePhase& right);
257 
258  //! Assignment operator
259  /*!
260  * @param right Object to be copied
261  */
262  LatticePhase& operator=(const LatticePhase& right);
263 
264  //! Full constructor for a lattice phase
265  /*!
266  * @param inputFile String name of the input file
267  * @param id string id of the phase name
268  */
269  LatticePhase(const std::string& inputFile, const std::string& id = "");
270 
271  //! Full constructor for a water phase
272  /*!
273  * @param phaseRef XML node referencing the lattice phase.
274  * @param id string id of the phase name
275  */
276  LatticePhase(XML_Node& phaseRef, const std::string& id = "");
277 
278  //! Duplication function
279  /*!
280  * This virtual function is used to create a duplicate of the
281  * current phase. It's used to duplicate the phase when given
282  * a ThermoPhase pointer to the phase.
283  */
285 
286  //! Equation of state flag. Returns the value cLattice
287  virtual int eosType() const {
288  return cLattice;
289  }
290 
291  //! @name Molar Thermodynamic Properties of the Solution
292  //! @{
293 
294  //! Return the Molar Enthalpy. Units: J/kmol.
295  /*!
296  * For an ideal solution,
297  *
298  * \f[
299  * \hat h(T,P) = \sum_k X_k \hat h^0_k(T,P),
300  * \f]
301  *
302  * The standard-state pure-species Enthalpies
303  * \f$ \hat h^0_k(T,P) \f$ are computed first by the species reference
304  * state thermodynamic property manager and then a small pressure dependent term is
305  * added in.
306  *
307  * \see SpeciesThermo
308  */
309  virtual doublereal enthalpy_mole() const;
310 
311  //! Molar internal energy of the solution. Units: J/kmol.
312  /*!
313  * For an ideal, constant partial molar volume solution mixture with
314  * pure species phases which exhibit zero volume expansivity and
315  * zero isothermal compressibility:
316  *
317  * \f[
318  * \hat u(T,X) = \hat h(T,P,X) - p \hat V
319  * = \sum_k X_k \hat h^0_k(T) - P_{ref} (\sum_k{X_k \hat V^0_k})
320  * \f]
321  *
322  * and is a function only of temperature.
323  * The reference-state pure-species enthalpies
324  * \f$ \hat h^0_k(T) \f$ are computed by the species thermodynamic
325  * property manager.
326  * @see SpeciesThermo
327  */
328  virtual doublereal intEnergy_mole() const;
329 
330  //! Molar entropy of the solution. Units: J/kmol/K
331  /*!
332  * For an ideal, constant partial molar volume solution mixture with
333  * pure species phases which exhibit zero volume expansivity:
334  * \f[
335  * \hat s(T, P, X_k) = \sum_k X_k \hat s^0_k(T) - \hat R \sum_k X_k log(X_k)
336  * \f]
337  * The reference-state pure-species entropies
338  * \f$ \hat s^0_k(T,p_{ref}) \f$ are computed by the species thermodynamic
339  * property manager. The pure species entropies are independent of
340  * pressure since the volume expansivities are equal to zero.
341  *
342  * Units: J/kmol/K.
343  *
344  * @see SpeciesThermo
345  */
346  virtual doublereal entropy_mole() const;
347 
348  //! Molar gibbs free energy of the solution. Units: J/kmol.
349  /*!
350  * For an ideal, constant partial molar volume solution mixture with
351  * pure species phases which exhibit zero volume expansivity:
352  * \f[
353  * \hat g(T, P) = \sum_k X_k \hat g^0_k(T,P) + \hat R T \sum_k X_k log(X_k)
354  * \f]
355  * The reference-state pure-species gibbs free energies
356  * \f$ \hat g^0_k(T) \f$ are computed by the species thermodynamic
357  * property manager, while the standard state gibbs free energies
358  * \f$ \hat g^0_k(T,P) \f$ are computed by the member function, gibbs_RT().
359  *
360  * @see SpeciesThermo
361  */
362  virtual doublereal gibbs_mole() const;
363 
364  //! Molar heat capacity at constant pressure of the solution.
365  //! Units: J/kmol/K.
366  /*!
367  * For an ideal, constant partial molar volume solution mixture with
368  * pure species phases which exhibit zero volume expansivity:
369  * \f[
370  * \hat c_p(T,P) = \sum_k X_k \hat c^0_{p,k}(T) .
371  * \f]
372  * The heat capacity is independent of pressure.
373  * The reference-state pure-species heat capacities
374  * \f$ \hat c^0_{p,k}(T) \f$ are computed by the species thermodynamic
375  * property manager.
376  *
377  * @see SpeciesThermo
378  */
379  virtual doublereal cp_mole() const;
380 
381  //! Molar heat capacity at constant volume of the solution.
382  //! Units: J/kmol/K.
383  /*!
384  * For an ideal, constant partial molar volume solution mixture with
385  * pure species phases which exhibit zero volume expansivity:
386  * \f[
387  * \hat c_v(T,P) = \hat c_p(T,P)
388  * \f]
389  *
390  * The two heat capacities are equal.
391  */
392  virtual doublereal cv_mole() const;
393 
394  //@}
395  /// @name Mechanical Equation of State Properties
396  /**
397  * In this equation of state implementation, the density is a
398  * function only of the mole fractions. Therefore, it can't be
399  * an independent variable. Instead, the pressure is used as the
400  * independent variable. Functions which try to set the thermodynamic
401  * state by calling setDensity() may cause an exception to be
402  * thrown.
403  */
404  //@{
405 
406  //! Pressure. Units: Pa.
407  /*!
408  * For this incompressible system, we return the internally stored
409  * independent value of the pressure.
410  */
411  virtual doublereal pressure() const {
412  return m_Pcurrent;
413  }
414 
415  //! Set the internally stored pressure (Pa) at constant
416  //! temperature and composition
417  /*!
418  * This method sets the pressure within the object.
419  * The mass density is not a function of pressure.
420  *
421  * @param p Input Pressure (Pa)
422  */
423  virtual void setPressure(doublereal p);
424 
425  //! Calculate the density of the mixture using the partial
426  //! molar volumes and mole fractions as input
427  /*!
428  * The formula for this is
429  *
430  * \f[
431  * \rho = \frac{\sum_k{X_k W_k}}{\sum_k{X_k V_k}}
432  * \f]
433  *
434  * where \f$X_k\f$ are the mole fractions, \f$W_k\f$ are
435  * the molecular weights, and \f$V_k\f$ are the pure species
436  * molar volumes.
437  *
438  * Note, the basis behind this formula is that in an ideal
439  * solution the partial molar volumes are equal to the pure
440  * species molar volumes. We have additionally specified
441  * in this class that the pure species molar volumes are
442  * independent of temperature and pressure.
443  */
444  doublereal calcDensity();
445 
446  //! Set the mole fractions
447  /*!
448  * @param x Input vector of mole fractions.
449  * Length: m_kk.
450  */
451  virtual void setMoleFractions(const doublereal* const x);
452 
453  //! Set the mole fractions, but don't normalize them to one.
454  /*!
455  * @param x Input vector of mole fractions.
456  * Length: m_kk.
457  */
458  virtual void setMoleFractions_NoNorm(const doublereal* const x);
459 
460  //! Set the mass fractions, and normalize them to one.
461  /*!
462  * @param y Input vector of mass fractions.
463  * Length: m_kk.
464  */
465  virtual void setMassFractions(const doublereal* const y);
466 
467  //! Set the mass fractions, but don't normalize them to one
468  /*!
469  * @param y Input vector of mass fractions.
470  * Length: m_kk.
471  */
472  virtual void setMassFractions_NoNorm(const doublereal* const y);
473 
474  //! Set the concentration,
475  /*!
476  * @param c Input vector of concentrations.
477  * Length: m_kk.
478  */
479  virtual void setConcentrations(const doublereal* const c);
480 
481  //@}
482  /// @name Activities, Standard States, and Activity Concentrations
483  /**
484  * The activity \f$a_k\f$ of a species in solution is
485  * related to the chemical potential by \f[ \mu_k = \mu_k^0(T)
486  * + \hat R T \log a_k. \f] The quantity \f$\mu_k^0(T,P)\f$ is
487  * the chemical potential at unit activity, which depends only
488  * on temperature and the pressure.
489  * Activity is assumed to be molality-based here.
490  */
491  //@{
492 
493  /**
494  * This method returns an array of generalized concentrations
495  * \f$ C_k\f$ that are defined such that
496  * \f$ a_k = C_k / C^0_k, \f$ where \f$ C^0_k \f$
497  * is a standard concentration
498  * defined below. These generalized concentrations are used
499  * by kinetics manager classes to compute the forward and
500  * reverse rates of elementary reactions.
501  *
502  * @param c Array of generalized concentrations. The
503  * units depend upon the implementation of the
504  * reaction rate expressions within the phase.
505  */
506  virtual void getActivityConcentrations(doublereal* c) const;
507 
508  //! Return the standard concentration for the kth species
509  /*!
510  * The standard concentration \f$ C^0_k \f$ used to normalize
511  * the activity (i.e., generalized) concentration for use
512  *
513  * For the time being, we will use the concentration of pure
514  * solvent for the the standard concentration of all species.
515  * This has the effect of making mass-action reaction rates
516  * based on the molality of species proportional to the
517  * molality of the species.
518  *
519  * @param k Optional parameter indicating the species. The default
520  * is to assume this refers to species 0.
521  * @return
522  * Returns the standard Concentration in units of
523  * m<SUP>3</SUP> kmol<SUP>-1</SUP>.
524  *
525  * @param k Species index
526  */
527  virtual doublereal standardConcentration(size_t k=0) const;
528 
529  //! Returns the natural logarithm of the standard
530  //! concentration of the kth species
531  /*!
532  * @param k Species index
533  */
534  virtual doublereal logStandardConc(size_t k=0) const;
535 
536  //! Get the array of non-dimensional activity coefficients at
537  //! the current solution temperature, pressure, and solution concentration.
538  /*!
539  * For this phase, the activity coefficients are all equal to one.
540  *
541  * @param ac Output vector of activity coefficients. Length: m_kk.
542  */
543  virtual void getActivityCoefficients(doublereal* ac) const;
544 
545  //@}
546  /// @name Partial Molar Properties of the Solution
547  //@{
548 
549  //! Get the species chemical potentials. Units: J/kmol.
550  /*!
551  * This function returns a vector of chemical potentials of the
552  * species in solid solution at the current temperature, pressure
553  * and mole fraction of the solid solution.
554  *
555  * @param mu Output vector of species chemical
556  * potentials. Length: m_kk. Units: J/kmol
557  */
558  virtual void getChemPotentials(doublereal* mu) const;
559 
560  //@}
561  /// @name Partial Molar Properties of the Solution
562  //@{
563 
564  /**
565  * Returns an array of partial molar enthalpies for the species
566  * in the mixture.
567  * Units (J/kmol)
568  * For this phase, the partial molar enthalpies are equal to the
569  * pure species enthalpies
570  * \f[
571  * \bar h_k(T,P) = \hat h^{ref}_k(T) + (P - P_{ref}) \hat V^0_k
572  * \f]
573  * The reference-state pure-species enthalpies, \f$ \hat h^{ref}_k(T) \f$,
574  * at the reference pressure,\f$ P_{ref} \f$,
575  * are computed by the species thermodynamic
576  * property manager. They are polynomial functions of temperature.
577  * @see SpeciesThermo
578  *
579  * @param hbar Output vector containing partial molar enthalpies.
580  * Length: m_kk.
581  */
582  virtual void getPartialMolarEnthalpies(doublereal* hbar) const;
583 
584  /**
585  * Returns an array of partial molar entropies of the species in the
586  * solution. Units: J/kmol/K.
587  * For this phase, the partial molar entropies are equal to the
588  * pure species entropies plus the ideal solution contribution.
589  * \f[
590  * \bar s_k(T,P) = \hat s^0_k(T) - R log(X_k)
591  * \f]
592  * The reference-state pure-species entropies,\f$ \hat s^{ref}_k(T) \f$,
593  * at the reference pressure, \f$ P_{ref} \f$, are computed by the
594  * species thermodynamic
595  * property manager. They are polynomial functions of temperature.
596  * @see SpeciesThermo
597  *
598  * @param sbar Output vector containing partial molar entropies.
599  * Length: m_kk.
600  */
601  virtual void getPartialMolarEntropies(doublereal* sbar) const;
602 
603  /**
604  * Returns an array of partial molar Heat Capacities at constant
605  * pressure of the species in the
606  * solution. Units: J/kmol/K.
607  * For this phase, the partial molar heat capacities are equal
608  * to the standard state heat capacities.
609  *
610  * @param cpbar Output vector of partial heat capacities. Length: m_kk.
611  */
612  virtual void getPartialMolarCp(doublereal* cpbar) const;
613 
614  //! Return an array of partial molar volumes for the
615  //! species in the mixture. Units: m^3/kmol.
616  /*!
617  * @param vbar Output vector of species partial molar volumes.
618  * Length = m_kk. units are m^3/kmol.
619  */
620  virtual void getPartialMolarVolumes(doublereal* vbar) const;
621 
622  //! Get the array of chemical potentials at unit activity for the
623  //! species standard states at the current <I>T</I> and <I>P</I> of the solution.
624  /*!
625  * These are the standard state chemical potentials \f$ \mu^0_k(T,P)
626  * \f$. The values are evaluated at the current
627  * temperature and pressure of the solution
628  *
629  * @param mu Output vector of chemical potentials.
630  * Length: m_kk.
631  */
632  virtual void getStandardChemPotentials(doublereal* mu) const;
633 
634  //! Get the Gibbs functions for the standard
635  //! state of the species at the current <I>T</I> and <I>P</I> of the solution
636  /*!
637  * Units are Joules/kmol
638  * @param gpure Output vector of standard state gibbs free energies
639  * Length: m_kk.
640  */
641  virtual void getPureGibbs(doublereal* gpure) const;
642 
643  //@}
644  /// @name Properties of the Standard State of the Species in the Solution
645  //@{
646 
647  //! Get the nondimensional Enthalpy functions for the species standard states
648  //! at their standard states at the current <I>T</I> and <I>P</I> of the solution.
649  /*!
650  * A small pressure dependent term is added onto the reference state enthalpy
651  * to get the pressure dependence of this term.
652  *
653  * \f[
654  * h^o_k(T,P) = h^{ref}_k(T) + \left( \frac{P - P_{ref}}{C_o} \right)
655  * \f]
656  *
657  * The reference state thermodynamics is
658  * obtained by a pointer to a populated species thermodynamic property
659  * manager class (see ThermoPhase::m_spthermo). How to relate pressure
660  * changes to the reference state thermodynamics is resolved at this level.
661  *
662  * @param hrt Output vector of nondimensional standard state enthalpies.
663  * Length: m_kk.
664  */
665  virtual void getEnthalpy_RT(doublereal* hrt) const;
666 
667  //! Get the array of nondimensional Entropy functions for the
668  //! species standard states at the current <I>T</I> and <I>P</I> of the solution.
669  /*!
670  * The entropy of the standard state is defined as independent of
671  * pressure here.
672  *
673  * \f[
674  * s^o_k(T,P) = s^{ref}_k(T)
675  * \f]
676  *
677  * The reference state thermodynamics is
678  * obtained by a pointer to a populated species thermodynamic property
679  * manager class (see ThermoPhase::m_spthermo). How to relate pressure
680  * changes to the reference state thermodynamics is resolved at this level.
681  *
682  * @param sr Output vector of nondimensional standard state entropies.
683  * Length: m_kk.
684  */
685  virtual void getEntropy_R(doublereal* sr) const;
686 
687  //! Get the nondimensional Gibbs functions for the species
688  //! standard states at the current <I>T</I> and <I>P</I> of the solution.
689  /*!
690  * The standard gibbs free energies are obtained from the enthalpy
691  * and entropy formulation.
692  *
693  * \f[
694  * g^o_k(T,P) = h^{o}_k(T,P) - T s^{o}_k(T,P)
695  * \f]
696  *
697  * @param grt Output vector of nondimensional standard state gibbs free energies
698  * Length: m_kk.
699  */
700  virtual void getGibbs_RT(doublereal* grt) const;
701 
702  //! Get the nondimensional Heat Capacities at constant
703  //! pressure for the species standard states
704  //! at the current <I>T</I> and <I>P</I> of the solution
705  /*!
706  * The heat capacity of the standard state is independent of pressure
707  *
708  * \f[
709  * Cp^o_k(T,P) = Cp^{ref}_k(T)
710  * \f]
711  *
712  * The reference state thermodynamics is
713  * obtained by a pointer to a populated species thermodynamic property
714  * manager class (see ThermoPhase::m_spthermo). How to relate pressure
715  * changes to the reference state thermodynamics is resolved at this level.
716  *
717  * @param cpr Output vector of nondimensional standard state heat capacities
718  * Length: m_kk.
719  */
720  virtual void getCp_R(doublereal* cpr) const;
721 
722  //! Get the molar volumes of the species standard states at the current
723  //! <I>T</I> and <I>P</I> of the solution.
724  /*!
725  * units = m^3 / kmol
726  *
727  * @param vol Output vector containing the standard state volumes.
728  * Length: m_kk.
729  */
730  virtual void getStandardVolumes(doublereal* vol) const;
731 
732  //@}
733  /// @name Thermodynamic Values for the Species Reference States
734  //@{
735 
736 #ifdef H298MODIFY_CAPABILITY
737 
738  //! Modify the value of the 298 K Heat of Formation of one species in the phase (J kmol-1)
739  /*!
740  * The 298K heat of formation is defined as the enthalpy change to create the standard state
741  * of the species from its constituent elements in their standard states at 298 K and 1 bar.
742  *
743  * @param k Species k
744  * @param Hf298New Specify the new value of the Heat of Formation at 298K and 1 bar
745  */
746  virtual void modifyOneHf298SS(const size_t& k, const doublereal Hf298New) {
747  m_spthermo->modifyOneHf298(k, Hf298New);
748  m_tlast += 0.0001234;
749  }
750 #endif
751 
752  //! Returns the vector of nondimensional
753  //! Enthalpies of the reference state at the current temperature
754  //! of the solution and the reference pressure for the phase.
755  /*!
756  * @return Output vector of nondimensional reference state
757  * Enthalpies of the species.
758  * Length: m_kk
759  */
760  const vector_fp& enthalpy_RT_ref() const;
761 
762  //! Returns a reference to the dimensionless reference state Gibbs free energy vector.
763  /*!
764  * This function is part of the layer that checks/recalculates the reference
765  * state thermo functions.
766  */
767  const vector_fp& gibbs_RT_ref() const;
768 
769  //! Returns the vector of nondimensional
770  //! Gibbs Free Energies of the reference state at the current temperature
771  //! of the solution and the reference pressure for the species.
772  /*!
773  * @param grt Output vector containing the nondimensional reference state
774  * Gibbs Free energies. Length: m_kk.
775  */
776  virtual void getGibbs_RT_ref(doublereal* grt) const;
777 
778  //! Returns the vector of the gibbs function of the reference state at the current temperature
779  //! of the solution and the reference pressure for the species.
780  /*!
781  * units = J/kmol
782  *
783  * @param g Output vector containing the reference state
784  * Gibbs Free energies. Length: m_kk. Units: J/kmol.
785  */
786  virtual void getGibbs_ref(doublereal* g) const;
787 
788  //! Returns a reference to the dimensionless reference state Entropy vector.
789  /*!
790  * This function is part of the layer that checks/recalculates the reference
791  * state thermo functions.
792  */
793  const vector_fp& entropy_R_ref() const;
794 
795  //! Returns a reference to the dimensionless reference state Heat Capacity vector.
796  /*!
797  * This function is part of the layer that checks/recalculates the reference
798  * state thermo functions.
799  */
800  const vector_fp& cp_R_ref() const;
801 
802  //@}
803  /// @name Utilities for Initialization of the Object
804  //@{
805 
806  //! Initialize the ThermoPhase object after all species have been set up
807  /*!
808  * @internal Initialize.
809  *
810  * This method performs any initialization required after all
811  * species have been added. For example, it is used to
812  * resize internal work arrays that must have an entry for
813  * each species.
814  * This method is called from ThermoPhase::initThermoXML(),
815  * which is called from importPhase(),
816  * just prior to returning from the function, importPhase().
817  *
818  * @see importCTML.cpp
819  */
820  virtual void initThermo();
821 
822  //! Import and initialize a ThermoPhase object using an XML tree.
823  /*!
824  * Here we read extra information about the XML description
825  * of a phase. Regular information about elements and species
826  * and their reference state thermodynamic information
827  * have already been read at this point.
828  * For example, we do not need to call this function for
829  * ideal gas equations of state.
830  * This function is called from importPhase()
831  * after the elements and the
832  * species are initialized with default ideal solution
833  * level data.
834  *
835  * @param phaseNode This object must be the phase node of a
836  * complete XML tree
837  * description of the phase, including all of the
838  * species data. In other words while "phase" must
839  * point to an XML phase object, it must have
840  * sibling nodes "speciesData" that describe
841  * the species in the phase.
842  * @param id ID of the phase. If nonnull, a check is done
843  * to see if phaseNode is pointing to the phase
844  * with the correct id.
845  */
846  virtual void initThermoXML(XML_Node& phaseNode, const std::string& id);
847 
848  //! Set the equation of state parameters from the argument list
849  /*!
850  * @internal
851  * Set equation of state parameters.
852  *
853  * @param n number of parameters. Must be one
854  * @param c array of \a n coefficients
855  * c[0] = The bulk lattice density (kmol m-3)
856  * @deprecated Use setMolarDensity()
857  */
858  virtual void setParameters(int n, doublereal* const c);
859 
860  //! Get the equation of state parameters in a vector
861  /*!
862  * @internal
863  *
864  * @param n number of parameters
865  * @param c array of \a n coefficients
866  *
867  * For this phase:
868  * - n = 1
869  * - c[0] = molar density of phase [ kmol/m^3 ]
870  * @deprecated Use molarDensity()
871  */
872  virtual void getParameters(int& n, doublereal* const c) const;
873 
874  //! Set equation of state parameter values from XML entries.
875  /*!
876  * This method is called by function importPhase() in
877  * file importCTML.cpp when processing a phase definition in
878  * an input file. It should be overloaded in subclasses to set
879  * any parameters that are specific to that particular phase
880  * model. Note, this method is called before the phase is
881  * initialized with elements and/or species.
882  *
883  * For this phase, the molar density of the phase is specified in this block,
884  * and is a required parameter.
885  *
886  * @param eosdata An XML_Node object corresponding to
887  * the "thermo" entry for this phase in the input file.
888  *
889  * eosdata points to the thermo block, and looks like this:
890  *
891  * @code
892  * <phase id="O_lattice_SiO2" >
893  * <thermo model="Lattice">
894  * <site_density units="kmol/m^3"> 73.159 </site_density>
895  * <vacancy_species> "O_vacancy" </vacancy_species>
896  * </thermo>
897  * </phase>
898  * @endcode
899  */
900  virtual void setParametersFromXML(const XML_Node& eosdata);
901  //@}
902 
903 protected:
904  //! Reference state pressure
905  doublereal m_Pref;
906 
907  //! The current pressure
908  /*!
909  * Since the density isn't a function of pressure, but only of the
910  * mole fractions, we need to independently specify the pressure.
911  * The density variable which is inherited as part of the State class,
912  * m_dens, is always kept current whenever T, P, or X[] change.
913  */
914  doublereal m_Pcurrent;
915 
916  //! Current value of the temperature (Kelvin)
917  mutable doublereal m_tlast;
918 
919  //! Reference state enthalpies / RT
921 
922  //! Temporary storage for the reference state heat capacities
924 
925  //! Temporary storage for the reference state gibbs energies
927 
928  //! Temporary storage for the reference state entropies at the current temperature
929  mutable vector_fp m_s0_R;
930 
931  //! String name for the species which represents a vacancy
932  //! in the lattice
933  /*!
934  * This string is currently unused
935  */
936  std::string m_vacancy;
937 
938  //! Vector of molar volumes for each species in the solution
939  /**
940  * Species molar volumes \f$ m^3 kmol^-1 \f$
941  */
943 
944  //! Site Density of the lattice solid
945  /*!
946  * Currently, this is imposed as a function of T, P or composition
947  *
948  * units are kmol m-3
949  */
950  doublereal m_site_density;
951 
952 private:
953  //! Update the species reference state thermodynamic functions
954  /*!
955  * The polynomials for the standard state functions are only
956  * reevaluated if the temperature has changed.
957  */
958  void _updateThermo() const;
959 };
960 }
961 
962 #endif
virtual void getStandardVolumes(doublereal *vol) const
Get the molar volumes of the species standard states at the current T and P of the solution...
doublereal m_site_density
Site Density of the lattice solid.
Definition: LatticePhase.h:950
doublereal m_tlast
Current value of the temperature (Kelvin)
Definition: LatticePhase.h:917
doublereal m_Pref
Reference state pressure.
Definition: LatticePhase.h:905
Various templated functions that carry out common vector operations (see Templated Utility Functions)...
virtual void getActivityConcentrations(doublereal *c) const
The activity of a species in solution is related to the chemical potential by The quantity is the ...
doublereal calcDensity()
Calculate the density of the mixture using the partial molar volumes and mole fractions as input...
vector_fp m_g0_RT
Temporary storage for the reference state gibbs energies.
Definition: LatticePhase.h:926
vector_fp m_s0_R
Temporary storage for the reference state entropies at the current temperature.
Definition: LatticePhase.h:929
virtual void getGibbs_RT(doublereal *grt) const
Get the nondimensional Gibbs functions for the species standard states at the current T and P of the ...
vector_fp m_h0_RT
Reference state enthalpies / RT.
Definition: LatticePhase.h:920
virtual void modifyOneHf298SS(const int k, const doublereal Hf298New)
Modify the value of the 298 K Heat of Formation of one species in the phase (J kmol-1) ...
Definition: ThermoPhase.h:227
virtual void getParameters(int &n, doublereal *const c) const
Get the equation of state parameters in a vector.
virtual int eosType() const
Equation of state flag. Returns the value cLattice.
Definition: LatticePhase.h:287
virtual void getGibbs_RT_ref(doublereal *grt) const
Returns the vector of nondimensional Gibbs Free Energies of the reference state at the current temper...
Class XML_Node is a tree-based representation of the contents of an XML file.
Definition: xml.h:100
This file contains definitions of terms that are used in internal routines and are unlikely to need m...
virtual void setParameters(int n, doublereal *const c)
Set the equation of state parameters from the argument list.
Virtual base class for the calculation of multiple-species thermodynamic reference-state property man...
virtual void setPressure(doublereal p)
Set the internally stored pressure (Pa) at constant temperature and composition.
A simple thermodynamic model for a bulk phase, assuming a lattice of solid atoms. ...
Definition: LatticePhase.h:246
virtual doublereal entropy_mole() const
Molar entropy of the solution. Units: J/kmol/K.
virtual void setParametersFromXML(const XML_Node &eosdata)
Set equation of state parameter values from XML entries.
virtual void getPartialMolarEnthalpies(doublereal *hbar) const
Returns an array of partial molar enthalpies for the species in the mixture.
std::string m_vacancy
String name for the species which represents a vacancy in the lattice.
Definition: LatticePhase.h:936
ThermoPhase * duplMyselfAsThermoPhase() const
Duplication function.
virtual void setMoleFractions_NoNorm(const doublereal *const x)
Set the mole fractions, but don't normalize them to one.
LatticePhase & operator=(const LatticePhase &right)
Assignment operator.
virtual doublereal gibbs_mole() const
Molar gibbs free energy of the solution. Units: J/kmol.
Base class for a phase with thermodynamic properties.
Definition: ThermoPhase.h:101
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...
virtual doublereal standardConcentration(size_t k=0) const
Return the standard concentration for the kth species.
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...
doublereal m_Pcurrent
The current pressure.
Definition: LatticePhase.h:914
virtual void setMoleFractions(const doublereal *const x)
Set the mole fractions.
vector_fp m_cp0_R
Temporary storage for the reference state heat capacities.
Definition: LatticePhase.h:923
virtual doublereal cv_mole() const
Molar heat capacity at constant volume of the solution.
virtual doublereal pressure() const
In this equation of state implementation, the density is a function only of the mole fractions...
Definition: LatticePhase.h:411
virtual void getPartialMolarVolumes(doublereal *vbar) const
Return an array of partial molar volumes for the species in the mixture.
void _updateThermo() const
Update the species reference state thermodynamic functions.
const vector_fp & gibbs_RT_ref() const
Returns a reference to the dimensionless reference state Gibbs free energy vector.
virtual void getCp_R(doublereal *cpr) const
Get the nondimensional Heat Capacities at constant pressure for the species standard states at the cu...
virtual void initThermo()
Initialize the ThermoPhase object after all species have been set up.
virtual void getEntropy_R(doublereal *sr) const
Get the array of nondimensional Entropy functions for the species standard states at the current T an...
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:165
virtual void getStandardChemPotentials(doublereal *mu) const
Get the array of chemical potentials at unit activity for the species standard states at the current ...
const vector_fp & enthalpy_RT_ref() const
Returns the vector of nondimensional Enthalpies of the reference state at the current temperature of ...
virtual doublereal enthalpy_mole() const
Return the Molar Enthalpy. Units: J/kmol.
vector_fp m_speciesMolarVolume
Vector of molar volumes for each species in the solution.
Definition: LatticePhase.h:942
virtual void getEnthalpy_RT(doublereal *hrt) const
Get the nondimensional Enthalpy functions for the species standard states at their standard states at...
virtual void getPartialMolarCp(doublereal *cpbar) const
Returns an array of partial molar Heat Capacities at constant pressure of the species in the solution...
const vector_fp & entropy_R_ref() const
Returns a reference to the dimensionless reference state Entropy vector.
virtual doublereal intEnergy_mole() const
Molar internal energy of the solution. Units: J/kmol.
virtual void setConcentrations(const doublereal *const c)
Set the concentration,.
const vector_fp & cp_R_ref() const
Returns a reference to the dimensionless reference state Heat Capacity vector.
virtual void getActivityCoefficients(doublereal *ac) const
Get the array of non-dimensional activity coefficients at the current solution temperature, pressure, and solution concentration.
virtual doublereal logStandardConc(size_t k=0) const
Returns the natural logarithm of the standard concentration of the kth species.
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 initThermoXML(XML_Node &phaseNode, const std::string &id)
Import and initialize a ThermoPhase object using an XML tree.
virtual doublereal cp_mole() const
Molar heat capacity at constant pressure of the solution.
virtual void setMassFractions_NoNorm(const doublereal *const y)
Set the mass fractions, but don't normalize them to one.
SpeciesThermo * m_spthermo
Pointer to the calculation manager for species reference-state thermodynamic properties.
Definition: ThermoPhase.h:1625
LatticePhase()
Base Empty constructor.
virtual void getPartialMolarEntropies(doublereal *sbar) const
Returns an array of partial molar entropies of the species in the solution.
virtual void setMassFractions(const doublereal *const y)
Set the mass fractions, and normalize them to one.
virtual void getChemPotentials(doublereal *mu) const
Get the species chemical potentials. Units: J/kmol.