Cantera  2.0
VPSSMgr.h
Go to the documentation of this file.
1 /**
2  * @file VPSSMgr.h
3  * Declaration file for a virtual base class that manages
4  * the calculation of standard state properties for all of the
5  * species in a single phase, assuming a variable P and T standard state
6  * (see \ref mgrpdssthermocalc and
7  * class \link Cantera::VPSSMgr VPSSMgr\endlink).
8  */
9 /*
10  * Copyright (2005) Sandia Corporation. Under the terms of
11  * Contract DE-AC04-94AL85000 with Sandia Corporation, the
12  * U.S. Government retains certain rights in this software.
13  */
14 
15 #ifndef CT_VPSSMGR_H
16 #define CT_VPSSMGR_H
17 
18 #include "cantera/base/ct_defs.h"
19 #include "mix_defs.h"
20 
21 namespace Cantera
22 {
23 
24 class SpeciesThermoInterpType;
25 class VPStandardStateTP;
26 class XML_Node;
27 class SpeciesThermo;
28 class PDSS;
29 /**
30  * @defgroup mgrpdssthermocalc Managers for Calculating Standard-State Thermodynamics
31  *
32  * To compute the thermodynamic properties of multicomponent
33  * solutions, it is necessary to know something about the
34  * thermodynamic properties of the individual species present in
35  * the solution. Exactly what sort of species properties are
36  * required depends on the thermodynamic model for the
37  * solution. For a gaseous solution (i.e., a gas mixture), the
38  * species properties required are usually ideal gas properties at
39  * the mixture temperature and at a reference pressure (almost always at
40  * 1 bar). For other types of solutions, however, it may
41  * not be possible to isolate the species in a "pure" state. For
42  * example, the thermodynamic properties of, say, Na+ and Cl- in
43  * saltwater are not easily determined from data on the properties
44  * of solid NaCl, or solid Na metal, or chlorine gas. In this
45  * case, the solvation in water is fundamental to the identity of
46  * the species, and some other reference state must be used. One
47  * common convention for liquid solutions is to use thermodynamic
48  * data for the solutes in the limit of infinite dilution within the
49  * pure solvent; another convention is to reference all properties
50  * to unit molality.
51  *
52  * In defining these standard states for species in a phase, we make
53  * the following definition. A reference state is a standard state
54  * of a species in a phase limited to one particular pressure, the reference
55  * pressure. The reference state specifies the dependence of all
56  * thermodynamic functions as a function of the temperature, in
57  * between a minimum temperature and a maximum temperature. The
58  * reference state also specifies the molar volume of the species
59  * as a function of temperature. The molar volume is a thermodynamic
60  * function.
61  * A full standard state does the same thing as a reference state,
62  * but specifies the thermodynamics functions at all pressures.
63  *
64  * Class VPSSMgr is the base class
65  * for a family of classes that compute properties of all
66  * species in a phase in their standard states, for a range of temperatures
67  * and pressures.
68  *
69  * Phases which use the VPSSMGr class must have their respective
70  * ThermoPhase objects actually be derivatives of the VPStandardState
71  * class. These classes assume that there exists a standard state
72  * for each species in the phase, where the Thermodynamic functions are specified
73  * as a function of temperature and pressure. Standard state thermo objects for each
74  * species in the phase are all derived from the PDSS virtual base class.
75  * Calculators for these
76  * standard state thermo , which coordinate the calculation for all of the species
77  * in a phase, are all derived from VPSSMgr.
78  * In turn, these standard states may employ reference state calculation to
79  * aid in their calculations. And the VPSSMgr calculators may also employ
80  * SimpleThermo calculators to help in calculating the properties for all of the
81  * species in a phase. However, there are some PDSS objects which do not employ
82  * reference state calculations. An example of this is a real equation of state for
83  * liquid water used within the calculation of brine thermodynamics.
84  *
85  * Typically calls to calculate standard state thermo properties are virtual calls
86  * at the ThermoPhase level. It is left to the child classes of ThermoPhase to
87  * specify how these are carried out. Usually, this will involve calling the
88  * m_spthermo pointer to a SpeciesThermo object to calculate the reference state
89  * thermodynamic properties. Then, the pressure dependence is added in within the
90  * child ThermoPhase object to complete the specification of the standard state.
91  * The VPStandardStateTP class, however, redefines the calls to the calculation of
92  * standard state properties to use VPSSMgr class calls. A listing of
93  * these classes and important pointers are supplied below.
94  *
95  *
96  * - ThermoPhase
97  * - \link Cantera::ThermoPhase::m_spthermo m_spthermo\endlink
98  * This is a pointer to a %SpeciesThermo manager class that
99  * handles the reference %state Thermodynamic calculations.
100  * .
101  * - VPStandardStateTP (inherits from %ThermoPhase)
102  * - \link Cantera::ThermoPhase::m_spthermo m_spthermo\endlink
103  * %SpeciesThermo manager handling reference %state Thermodynamic calculations.
104  * may or may not be used by the VPSSMgr class. For species
105  * which don't have a reference state class defined, a default
106  * class, called STITbyPDSS which is installed into the SpeciesThermo
107  * class, actually calculates reference state
108  * thermo by calling a PDSS object.
109  * - \link Cantera::VPStandardStateTP::m_VPSS_ptr m_VPSS_ptr\endlink
110  * This is a pointer to a %VPSSMgr class which handles the
111  * standard %state thermo calculations. It may
112  * or may not use the pointer, m_spthermo, in its calculations.
113  * .
114  * .
115  *
116  * The following classes inherit from VPSSMgr. Each of these classes
117  * handle multiple species and by definition all of the species in a phase.
118  * It is a requirement that a VPSSMgr object handles all of the
119  * species in a phase.
120  *
121  *
122  * - VPSSMgr_IdealGas
123  * - standardState model = "IdealGas"
124  * - This model assumes that all species in the phase obey the
125  * ideal gas law for their pressure dependence. The manager
126  * uses a SpeciesThermo object to handle the calculation of the
127  * reference state.
128  * .
129  *
130  * - VPSSMgr_ConstVol
131  * - standardState model = "ConstVol"
132  * - This model assumes that all species in the phase obey the
133  * constant partial molar volume pressure dependence.
134  * The manager uses a SpeciesThermo object to handle the
135  * calculation of the reference state.
136  * .
137  *
138  * - VPSSMgr_Water_ConstVol
139  * - standardState model = "Water_ConstVol"
140  * - This model assumes that all species but one in the phase obey the
141  * constant partial molar volume pressure dependence.
142  * The manager uses a SpeciesThermo object to handle the
143  * calculation of the reference state for those species.
144  * Species 0 is assumed to be water, and a real equation
145  * of state is used to model the T, P behavior.
146  * .
147  *
148  * - VPSSMgr_Water_HKFT
149  * - standardState model = "Water_HKFT"
150  * - This model assumes that all species but one in the phase obey the
151  * HKFT equation of state.
152  * Species 0 is assumed to be water, and a real equation
153  * of state is used to model the T, P behavior.
154  * .
155  *
156  * - VPSSMgr_General
157  * - standardState model = "General"
158  * - This model is completely general. Nothing is assumed at this
159  * level. Calls consist of loops to PDSS property evaluations.
160  * .
161  * .
162  *
163  * The choice of which VPSSMgr object to be used is implicitly made by
164  * %Cantera by querying the XML data file for compatibility.
165  * However, each of these VPSSMgr objects may be explicitly requested in the XML file
166  * by adding in the following XML node into the thermo section of the
167  * phase XML Node. For example, the code example listed below
168  * explicitly requests that the VPSSMgr_IdealGas
169  * object be used to handle the standard state thermodynamics calculations.
170  *
171  * @verbatim
172  <phase id="Silane_Pyrolysis" dim="3">
173  . . .
174  <thermo model="VPIdealGas">
175  <standardState model="IdealGas">
176  <\thermo>
177  . . .
178  <\phase>
179  @endverbatim
180  *
181  * If it turns out that the VPSSMgr_IdealGas class can not handle the standard
182  * state calculation, then %Cantera will fail during the instantiation phase
183  * printing out an informative error message.
184  *
185  * In the source code listing above, the thermo model, VPIdealGas ,was requested. The
186  * thermo model specifies the type of ThermoPhase object to use. In this case
187  * the object IdealSolnGasVPSS (with the ideal gas suboption) is used. %IdealSolnGasVPSS
188  * inherits from VPStandardStateTP, so that it actually has a VPSSMgr pointer
189  * to be specified. Note, in addition to the IdealGas entry to the model
190  * parameter in standardState node, we could have also specified the "General"
191  * option. The general option will always work. An example of this
192  * usage is listed below.
193  *
194  * @verbatim
195  <phase id="Silane_Pyrolysis" dim="3">
196  . . .
197  <thermo model="VPIdealGas">
198  <standardState model="General">
199  <\thermo>
200  . . .
201  <\phase>
202  @endverbatim
203  *
204  * The "General" option will cause the VPSSMgr_General %VPSSMgr class to be used.
205  * In this manager, the calculations are all handled at the PDSS object
206  * level. This is completely general, but, may be significantly
207  * slower.
208  *
209  *
210  * @ingroup thermoprops
211  */
212 
213 //! Virtual base class for the classes that manage the calculation
214 //! of standard state properties for all the species in a phase.
215 /*!
216  * This class defines the interface which all subclasses must implement.
217  *
218  * Class %VPSSMgr is the base class
219  * for a family of classes that compute properties of a set of
220  * species in their standard state at a range of temperatures
221  * and pressures.
222  *
223  * and pressure are unchanged.
224  *
225  * If #m_useTmpRefStateStorage is set to true, then the following internal
226  * arrays, containing information about the reference arrays,
227  * are calculated and kept up to date at every call.
228  *
229  * - #m_h0_RT
230  * - #m_g0_RT
231  * - #m_s0_R
232  * - #m_cp0_R
233  *
234  * The virtual function #_updateRefStateThermo() is supplied to do this
235  * and may be reimplemented in child routines. A default implementation
236  * based on the speciesThermo class is supplied in this base class.
237  * #_updateStandardStateThermo() is called whenever a reference state
238  * property is needed.
239  *
240  * When #m_useTmpStandardStateStorage is true, then the following
241  * internal arrays, containing information on the standard state properties
242  * are calculated and kept up to date.
243  *
244  * - #m_hss_RT;
245  * - #m_cpss_R;
246  * - #m_gss_RT;
247  * - #m_sss_R;
248  * - #m_Vss
249  *
250  * The virtual function #_updateStandardStateThermo() is supplied to do this
251  * and must be reimplemented in child routines,
252  * when #m_useTmpStandardStateStorage is true.
253  * It may be optionally reimplemented in child routines if
254  * #m_useTmpStandardStateStorage is false.
255  * #_updateStandardStateThermo() is called whenever a standard state property is needed.
256  *
257  * This class is usually used for nearly incompressible phases. For those phases, it
258  * makes sense to change the equation of state independent variable from
259  * density to pressure.
260  *
261  */
262 class VPSSMgr
263 {
264 
265 public:
266 
267  //! Constructor
268  /*!
269  * @param vptp_ptr Pointer to the Variable pressure %ThermoPhase object
270  * This object must have already been malloced.
271  *
272  * @param spth Pointer to the optional SpeciesThermo object
273  * that will handle the calculation of the reference
274  * state thermodynamic coefficients.
275  */
276  VPSSMgr(VPStandardStateTP* vptp_ptr, SpeciesThermo* spth = 0);
277 
278  //! Destructor
279  virtual ~VPSSMgr();
280 
281  //! Copy Constructor for the %SpeciesThermo object.
282  /*!
283  * @param right Reference to %SpeciesThermo object to be copied into the
284  * current one.
285  */
286  VPSSMgr(const VPSSMgr& right);
287 
288  //! Assignment operator for the %SpeciesThermo object
289  /*!
290  * This is NOT a virtual function.
291  *
292  * @param right Reference to %SpeciesThermo object to be copied into the
293  * current one.
294  */
295  VPSSMgr& operator=(const VPSSMgr& right);
296 
297  //! Duplication routine for objects which inherit from
298  //! %VPSSMgr
299  /*!
300  * This virtual routine can be used to duplicate %VPSSMgr objects
301  * inherited from %VPSSMgr even if the application only has
302  * a pointer to %VPSSMgr to work with.
303  */
304  virtual VPSSMgr* duplMyselfAsVPSSMgr() const;
305 
306 
307  /*!
308  * @name Properties of the Standard State of the Species in the Solution
309  *
310  */
311  //@{
312 
313  //!Get the array of chemical potentials at unit activity.
314  /*!
315  * These are the standard state chemical potentials \f$ \mu^0_k(T,P)
316  * \f$. The values are evaluated at the current temperature and pressure.
317  *
318  * @param mu Output vector of standard state chemical potentials.
319  * length = m_kk. units are J / kmol.
320  */
321  virtual void getStandardChemPotentials(doublereal* mu) const;
322 
323  /**
324  * Get the nondimensional Gibbs functions for the species
325  * at their standard states of solution at the current T and P
326  * of the solution.
327  *
328  * @param grt Output vector of nondimensional standard state
329  * Gibbs free energies. length = m_kk.
330  */
331  virtual void getGibbs_RT(doublereal* grt) const;
332 
333  /**
334  * Get the nondimensional Enthalpy functions for the species
335  * at their standard states at the current
336  * <I>T</I> and <I>P</I> of the solution.
337  *
338  * @param hrt Output vector of standard state enthalpies.
339  * length = m_kk. units are unitless.
340  */
341  virtual void getEnthalpy_RT(doublereal* hrt) const;
342 
343  //! Return a reference to a vector of the molar enthalpies of the
344  //! species in their standard states
345  const vector_fp& enthalpy_RT() const {
346  return m_hss_RT;
347  }
348 
349  /**
350  * Get the array of nondimensional Enthalpy functions for the
351  * standard state species
352  * at the current <I>T</I> and <I>P</I> of the solution.
353  *
354  * @param sr Output vector of nondimensional standard state
355  * entropies. length = m_kk.
356  */
357  virtual void getEntropy_R(doublereal* sr) const;
358 
359  //! Return a reference to a vector of the entropies of the
360  //! species
361  const vector_fp& entropy_R() const {
362  return m_sss_R;
363  }
364 
365  //! Returns the vector of nondimensional
366  //! internal Energies of the standard state at the current temperature
367  //! and pressure of the solution for each species.
368  /*!
369  * The internal energy is calculated from the enthalpy from the
370  * following formula:
371  *
372  * \f[
373  * u^{ss}_k(T,P) = h^{ss}_k(T) - P * V^{ss}_k
374  * \f]
375  *
376  * @param urt Output vector of nondimensional standard state
377  * internal energies. length = m_kk.
378  */
379  virtual void getIntEnergy_RT(doublereal* urt) const;
380 
381  //! Get the nondimensional Heat Capacities at constant
382  //! pressure for the standard state of the species
383  //! at the current T and P.
384  /*!
385  *
386  * This is redefined here to call the internal function, _updateStandardStateThermo(),
387  * which calculates all standard state properties at the same time.
388  *
389  * @param cpr Output vector containing the
390  * the nondimensional Heat Capacities at constant
391  * pressure for the standard state of the species.
392  * Length: m_kk.
393  */
394  virtual void getCp_R(doublereal* cpr) const;
395 
396  //! Return a reference to a vector of the constant pressure
397  //! heat capacities of the species
398  const vector_fp& cp_R() const {
399  return m_cpss_R;
400  }
401 
402  //! Get the molar volumes of each species in their standard
403  //! states at the current
404  //! <I>T</I> and <I>P</I> of the solution.
405  /*!
406  * units = m^3 / kmol
407  *
408  * This is redefined here to call the internal function,
409  * _updateStandardStateThermo(),
410  * which calculates all standard state properties at the same time.
411  *
412  * @param vol Output vector of species volumes. length = m_kk.
413  * units = m^3 / kmol
414  */
415  virtual void getStandardVolumes(doublereal* vol) const;
416 
417  //! Return a reference to a vector of the species standard molar volumes
418  const vector_fp& standardVolumes() const {
419  return m_Vss;
420  }
421 
422 public:
423 
424  //@}
425  /// @name Thermodynamic Values for the Species Reference States (VPStandardStateTP)
426  /*!
427  * There are also temporary
428  * variables for holding the species reference-state values of Cp, H, S, and V at the
429  * last temperature and reference pressure called. These functions
430  * are not recalculated
431  * if a new call is made using the previous temperature.
432  * All calculations are done within the routine _updateRefStateThermo().
433  */
434  //@{
435 
436  /*!
437  * Returns the vector of nondimensional
438  * enthalpies of the reference state at the current temperature
439  * of the solution and the reference pressure for the species.
440  *
441  * @param hrt Output vector contains the nondimensional enthalpies
442  * of the reference state of the species
443  * length = m_kk, units = dimensionless.
444  */
445  virtual void getEnthalpy_RT_ref(doublereal* hrt) const;
446 
447  /*!
448  * Returns the vector of nondimensional
449  * Gibbs free energies of the reference state at the current temperature
450  * of the solution and the reference pressure for the species.
451  *
452  * @param grt Output vector contains the nondimensional Gibbs free energies
453  * of the reference state of the species
454  * length = m_kk, units = dimensionless.
455  */
456  virtual void getGibbs_RT_ref(doublereal* grt) const ;
457 
458 
459  //! Return a reference to the vector of Gibbs free energies of the species
460  const vector_fp& Gibbs_RT_ref() const {
461  return m_g0_RT;
462  }
463 
464  /*!
465  * Returns the vector of the
466  * gibbs function of the reference state at the current temperature
467  * of the solution and the reference pressure for the species.
468  * units = J/kmol
469  *
470  * @param g Output vector contain the Gibbs free energies
471  * of the reference state of the species
472  * length = m_kk, units = J/kmol.
473  */
474  virtual void getGibbs_ref(doublereal* g) const ;
475 
476  /*!
477  * Returns the vector of nondimensional
478  * entropies of the reference state at the current temperature
479  * of the solution and the reference pressure for the species.
480  *
481  * @param er Output vector contain the nondimensional entropies
482  * of the species in their reference states
483  * length: m_kk, units: dimensionless.
484  */
485  virtual void getEntropy_R_ref(doublereal* er) const ;
486 
487  /*!
488  * Returns the vector of nondimensional
489  * constant pressure heat capacities of the reference state
490  * at the current temperature of the solution
491  * and reference pressure for the species.
492  *
493  * @param cpr Output vector contains the nondimensional heat capacities
494  * of the species in their reference states
495  * length: m_kk, units: dimensionless.
496  */
497  virtual void getCp_R_ref(doublereal* cpr) const ;
498 
499  //! Get the molar volumes of the species reference states at the current
500  //! <I>T</I> and <I>P_ref</I> of the solution.
501  /*!
502  * units = m^3 / kmol
503  *
504  * @param vol Output vector containing the standard state volumes.
505  * Length: m_kk.
506  */
507  virtual void getStandardVolumes_ref(doublereal* vol) const ;
508 
509  //@}
510  /// @name Setting the Internal State of the System
511  /*!
512  * All calls to change the internal state of the system's T and P
513  * are done through these routines
514  * - setState_TP()
515  * - setState_T()
516  * - setState_P()
517  *
518  * These routine in turn call the following underlying virtual functions
519  *
520  * - _updateRefStateThermo()
521  * - _updateStandardStateThermo()
522  *
523  * An important point to note is that between calls the assumption
524  * that the underlying PDSS objects will retain their set Temperatures
525  * and Pressure CAN NOT BE MADE. For efficiency reasons, we may twiddle
526  * these to get derivatives.
527  */
528  //@{
529 
530  //! Set the temperature (K) and pressure (Pa)
531  /*!
532  * This sets the temperature and pressure and triggers
533  * calculation of underlying quantities
534  *
535  * @param T Temperature (K)
536  * @param P Pressure (Pa)
537  */
538  virtual void setState_TP(doublereal T, doublereal P);
539 
540  //! Set the temperature (K)
541  /*!
542  * @param T Temperature (K)
543  */
544  virtual void setState_T(doublereal T);
545 
546  //! Set the pressure (Pa)
547  /*!
548  * @param P Pressure (Pa)
549  */
550  virtual void setState_P(doublereal P);
551 
552  //! Return the temperature stored in the object
553  doublereal temperature() const {
554  return m_tlast;
555  }
556 
557  //! Return the pressure stored in the object
558  doublereal pressure() const {
559  return m_plast;
560  }
561 
562  //! Return the pointer to the reference-state Thermo calculator
563  //! SpeciesThermo object.
565  return m_spthermo;
566  }
567 
568  //! Updates the internal standard state thermodynamic vectors at the
569  //! current T and P of the solution.
570  /*!
571  * If you are to peak internally inside the object, you need to
572  * call these functions after setState functions in order to be sure
573  * that the vectors are current.
574  */
575  virtual void updateStandardStateThermo();
576 
577  //! Updates the internal reference state thermodynamic vectors at the
578  //! current T of the solution and the reference pressure.
579  /*!
580  * If you are to peak internally inside the object, you need to
581  * call these functions after setState functions in order to be sure
582  * that the vectors are current.
583  */
584  virtual void updateRefStateThermo() const;
585 
586 protected:
587 
588  //! Updates the standard state thermodynamic functions at the
589  //! current T and P of the solution.
590  /*!
591  * @internal
592  *
593  * If m_useTmpStandardStateStorage is true,
594  * this function must be called for every call to functions in this
595  * class. It checks to see whether the temperature or pressure has changed and
596  * thus the ss thermodynamics functions for all of the species
597  * must be recalculated.
598  *
599  * This function is responsible for updating the following internal members,
600  * when m_useTmpStandardStateStorage is true.
601  *
602  * - m_hss_RT;
603  * - m_cpss_R;
604  * - m_gss_RT;
605  * - m_sss_R;
606  * - m_Vss
607  *
608  * If m_useTmpStandardStateStorage is not true, this function may be
609  * required to be called by child classes to update internal member data.
610  *
611  * Note, this will throw an error. It must be reimplemented in derived classes.
612  *
613  * Underscore updates never check for the state of the system
614  * They just do the calculation.
615  */
616  virtual void _updateStandardStateThermo();
617 
618  //! Updates the reference state thermodynamic functions at the
619  //! current T of the solution and the reference pressure
620  /*!
621  * Underscore updates never check for the state of the system
622  * They just do the calculation.
623  */
624  virtual void _updateRefStateThermo() const;
625 
626 public:
627  //@}
628  //! @name Utility Methods - Reports on various quantities
629  /*!
630  * The following methods are used in the process of reporting
631  * various states and attributes
632  */
633  //@{
634 
635  //! This utility function reports the type of parameterization
636  //! used for the species with index number index.
637  /*!
638  *
639  * @param index Species index
640  */
641  virtual PDSS_enumType reportPDSSType(int index = -1) const ;
642 
643 
644  //! This utility function reports the type of manager
645  //! for the calculation of ss properties
646  /*!
647  * @return Returns an enum type called VPSSMgr_enumType, which is a list
648  * of the known VPSSMgr objects
649  */
650  virtual VPSSMgr_enumType reportVPSSMgrType() const ;
651 
652  //! Minimum temperature.
653  /*!
654  * If no argument is supplied, this
655  * method returns the minimum temperature for which \e all
656  * parameterizations are valid. If an integer index k is
657  * supplied, then the value returned is the minimum
658  * temperature for species k in the phase.
659  *
660  * @param k Species index
661  */
662  virtual doublereal minTemp(size_t k=npos) const ;
663 
664  //! Maximum temperature.
665  /*!
666  * If no argument is supplied, this
667  * method returns the maximum temperature for which \e all
668  * parameterizations are valid. If an integer index k is
669  * supplied, then the value returned is the maximum
670  * temperature for parameterization k.
671  *
672  * @param k Species Index
673  */
674  virtual doublereal maxTemp(size_t k=npos) const;
675 
676  //! The reference-state pressure for the standard state
677  /*!
678  *
679  * returns the reference state pressure in Pascals for
680  * species k. If k is left out of the argument list,
681  * it returns the reference state pressure for the first
682  * species.
683  * Note that some SpeciesThermo implementations, such
684  * as those for ideal gases, require that all species
685  * in the same phase have the same reference state pressures.
686  *
687  * @param k Species index. Default is -1, which returns
688  * the generic answer.
689  */
690  virtual doublereal refPressure(size_t k=npos) const ;
691 
692 
693  //@}
694  //! @name Initialization Methods - For Internal use (VPStandardState)
695  /*!
696  * The following methods are used in the process of constructing
697  * the phase and setting its parameters from a specification in an
698  * input file. They are not normally used in application programs.
699  * To see how they are used, see files importCTML.cpp and
700  * ThermoFactory.cpp.
701  */
702  //@{
703 
704  //! @internal Initialize the object
705  /*!
706  * This method is provided to allow
707  * subclasses to perform any initialization required after all
708  * species have been added. For example, it might be used to
709  * resize internal work arrays that must have an entry for
710  * each species. The base class implementation does nothing,
711  * and subclasses that do not require initialization do not
712  * need to overload this method. When importing a CTML phase
713  * description, this method is called just prior to returning
714  * from function importPhase().
715  *
716  * @see importCTML.cpp
717  */
718  virtual void initThermo();
719 
720  //! Initialize the lengths within the object
721  /*!
722  * Note this function is not virtual
723  */
724  void initLengths();
725 
726  //! Finalize the thermo after all species have been entered
727  /*!
728  * This function is the LAST initialization routine to be
729  * called. It's called after createInstallPDSS() has been
730  * called for each species in the phase, and after initThermo()
731  * has been called.
732  * It's called via an inner-to-outer onion shell like manner.
733  *
734  * In this routine, we currently calculate the reference pressure,
735  * the minimum and maximum temperature for the applicability
736  * of the thermo formulation.
737  *
738  * @param phaseNode Reference to the phaseNode XML node.
739  * @param id ID of the phase.
740  */
741  virtual void initThermoXML(XML_Node& phaseNode, std::string id);
742 
743  //! Install specific content for species k in the reference-state
744  //! thermodynamic SpeciesManager object
745  /*!
746  * This occurs before matrices are sized appropriately.
747  *
748  * @param k Species index in the phase
749  * @param speciesNode XML Node corresponding to the species
750  * @param phaseNode_ptr Pointer to the XML Node corresponding
751  * to the phase which owns the species
752  */
753  void installSTSpecies(size_t k, const XML_Node& speciesNode,
754  const XML_Node* phaseNode_ptr);
755 
756  //! Install specific content for species k in the standard-state
757  //! thermodynamic calculator and also create/return a PDSS object
758  //! for that species.
759  /*!
760  * This occurs before matrices are sized appropriately.
761  *
762  * @param k Species index in the phase
763  * @param speciesNode XML Node corresponding to the species
764  * @param phaseNode_ptr Pointer to the XML Node corresponding
765  * to the phase which owns the species
766  */
767  virtual PDSS* createInstallPDSS(size_t k, const XML_Node& speciesNode,
768  const XML_Node* const phaseNode_ptr);
769 
770 
771  //! Initialize the internal shallow pointers in this object
772  /*!
773  * There are a bunch of internal shallow pointers that point to the owning
774  * VPStandardStateTP and SpeciesThermo objects. This function reinitializes
775  * them. This function is called like an onion.
776  *
777  * @param vp_ptr Pointer to the VPStandardStateTP standard state
778  * @param sp_ptr Pointer to the SpeciesThermo standard state
779  */
780  virtual void initAllPtrs(VPStandardStateTP* vp_ptr, SpeciesThermo* sp_ptr);
781 
782 protected:
783 
784  //! Number of species in the phase
785  size_t m_kk;
786 
787  //! Variable pressure ThermoPhase object
789 
790  //! Pointer to reference state thermo calculator
791  /*!
792  * Note, this can have a value of 0
793  */
795 
796  //! The last temperature at which the standard state thermodynamic
797  //! properties were calculated at.
798  mutable doublereal m_tlast;
799 
800  //! The last pressure at which the Standard State thermodynamic
801  //! properties were calculated at.
802  mutable doublereal m_plast;
803 
804  /*!
805  * Reference pressure (Pa) must be the same for all species
806  * - defaults to 1 atm.
807  */
808  mutable doublereal m_p0;
809 
810  //! minimum temperature for the standard state calculations
811  doublereal m_minTemp;
812 
813  //! maximum temperature for the standard state calculations
814  doublereal m_maxTemp;
815 
816  /*!
817  * boolean indicating whether temporary reference state storage is used
818  * -> default is false
819  */
821 
822  /*!
823  * Vector containing the species reference enthalpies at T = m_tlast
824  * and P = p_ref.
825  */
827 
828  /**
829  * Vector containing the species reference constant pressure
830  * heat capacities at T = m_tlast and P = p_ref.
831  */
833 
834  /**
835  * Vector containing the species reference Gibbs functions
836  * at T = m_tlast and P = p_ref.
837  */
839 
840  /**
841  * Vector containing the species reference entropies
842  * at T = m_tlast and P = p_ref.
843  */
844  mutable vector_fp m_s0_R;
845 
846  //! Vector containing the species reference molar volumes
847  mutable vector_fp m_V0;
848 
849  /*!
850  * boolean indicating whether temporary standard state storage is used
851  * -> default is false
852  */
854 
855  /**
856  * Vector containing the species Standard State enthalpies at T = m_tlast
857  * and P = m_plast.
858  */
860 
861  /**
862  * Vector containing the species Standard State constant pressure
863  * heat capacities at T = m_tlast and P = m_plast.
864  */
866 
867  /**
868  * Vector containing the species Standard State Gibbs functions
869  * at T = m_tlast and P = m_plast.
870  */
872 
873  /**
874  * Vector containing the species Standard State entropies
875  * at T = m_tlast and P = m_plast.
876  */
878 
879  /**
880  * Vector containing the species standard state volumes
881  * at T = m_tlast and P = m_plast
882  */
883  mutable vector_fp m_Vss;
884 
885 
886  //! species reference enthalpies - used by individual PDSS objects
887  /*!
888  * Vector containing the species reference enthalpies at T = m_tlast
889  * and P = p_ref.
890  */
892 
893  //! species reference heat capacities - used by individual PDSS objects
894  /**
895  * Vector containing the species reference constant pressure
896  * heat capacities at T = m_tlast and P = p_ref.
897  */
899 
900  //! species reference gibbs free energies - used by individual PDSS objects
901  /**
902  * Vector containing the species reference Gibbs functions
903  * at T = m_tlast and P = p_ref.
904  */
906 
907  //! species reference entropies - used by individual PDSS objects
908  /**
909  * Vector containing the species reference entropies
910  * at T = m_tlast and P = p_ref.
911  */
913 
914 
915  //! species reference state molar Volumes - used by individual PDSS objects
916  /**
917  * Vector containing the rf molar volumes
918  * at T = m_tlast and P = p_ref.
919  */
921 
922  //! species standard state enthalpies - used by individual PDSS objects
923  /*!
924  * Vector containing the species standard state enthalpies at T = m_tlast
925  * and P = p_ref.
926  */
928 
929  //! species standard state heat capacities - used by individual PDSS objects
930  /**
931  * Vector containing the species standard state constant pressure
932  * heat capacities at T = m_tlast and P = p_ref.
933  */
935 
936  //! species standard state gibbs free energies - used by individual PDSS objects
937  /**
938  * Vector containing the species standard state Gibbs functions
939  * at T = m_tlast and P = p_ref.
940  */
942 
943  //! species standard state entropies - used by individual PDSS objects
944  /**
945  * Vector containing the species standard state entropies
946  * at T = m_tlast and P = p_ref.
947  */
949 
950  //! species standard state molar Volumes - used by individual PDSS objects
951  /**
952  * Vector containing the ss molar volumes
953  * at T = m_tlast and P = p_ref.
954  */
956 
957 
958  friend class PDSS;
959 private:
960 
961  //! Error message to indicate an unimplemented feature
962  /*!
963  * @param msg Error message string
964  */
965  void err(std::string msg) const;
966 
967 };
968 //@}
969 }
970 
971 #endif