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