Cantera  2.0
VPSSMgr_General.h
Go to the documentation of this file.
1 /**
2  * @file VPSSMgr_General.h
3  * Declaration file for a derived class that handles the calculation
4  * of standard state thermo properties for
5  * a set of species belonging to a single phase in a completely general
6  * but slow way (see \ref mgrpdssthermocalc and
7  * class \link Cantera::VPSSMgr_General VPSSMgr_General\endlink).
8  */
9 /*
10  * Copyright (2007) 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_GENERAL_H
16 #define CT_VPSSMGR_GENERAL_H
17 
18 #include "cantera/base/ct_defs.h"
19 #include "VPSSMgr.h"
20 
21 namespace Cantera
22 {
23 
24 class SpeciesThermoInterpType;
25 class VPStandardStateTP;
26 class SpeciesThermo;
27 class PDSS;
28 
29 
30 //! Class that handles the calculation of standard state thermo properties for
31 //! a set of species belonging to a single phase in a completely general
32 //! but slow way.
33 /*!
34  * This class manages the calculation of standard state thermo properties for
35  * a set of species belonging to a single phase in a completely general
36  * but slow way.
37  * The way this does this is to call the underlying PDSS routines one at a
38  * time for every species.
39  *
40  * @ingroup mgrpdssthermocalc
41  */
42 class VPSSMgr_General : public VPSSMgr
43 {
44 
45 public:
46 
47  //! Constructor
48  /*!
49  * @param vp_ptr Pointer to the owning VPStandardStateTP object
50  * for the phase. It's a requirement that this be
51  * already malloced.
52  * @param spth Pointer to the SpeciesThermo object for the
53  * phase. It's a requirement that this be already
54  * malloced.
55  */
57  SpeciesThermo* spth);
58 
59  //! Destructor
60  virtual ~VPSSMgr_General();
61 
62  //! Copy Constructor for the %SpeciesThermo object.
63  /*!
64  * @param right Reference to %SpeciesThermo object to be copied into the
65  * current one.
66  */
67  VPSSMgr_General(const VPSSMgr_General& right);
68 
69  //! Assignment operator for the %SpeciesThermo object
70  /*!
71  * This is NOT a virtual function.
72  *
73  * @param right Reference to %SpeciesThermo object to be copied into the
74  * current one.
75  */
77 
78  //! Duplication routine for objects which inherit from
79  //! %VPSSSpeciesThermo
80  /*!
81  * This virtual routine can be used to duplicate %VPSSSpeciesThermo objects
82  * inherited from %VPSSSpeciesThermo even if the application only has
83  * a pointer to %VPSSSpeciesThermo to work with.
84  */
85  virtual VPSSMgr* duplMyselfAsVPSSMgr() const;
86 
87  /*!
88  * @name Properties of the Standard State of the Species in the Solution
89  *
90  * Within VPStandardStateTP, these properties are calculated via a common routine,
91  * _updateStandardStateThermo(),
92  * which must be overloaded in inherited objects.
93  * The values are cached within this object, and are not recalculated unless
94  * the temperature or pressure changes.
95  */
96  //@{
97 
98 
99 protected:
100 
101  //! Internally updates the standard state thermodynamic functions at the current
102  //! T and P of the solution.
103  /*!
104  * @internal
105  *
106  * If m_useTmpStandardStateStorage is true,
107  * this function must be called whenever the temperature or pressure
108  * has changed.
109  *
110  * This function is responsible for updating the following internal members,
111  * when m_useTmpStandardStateStorage is true.
112  *
113  * - m_hss_RT;
114  * - m_cpss_R;
115  * - m_gss_RT;
116  * - m_sss_R;
117  * - m_Vss
118  *
119  * If m_useTmpStandardStateStorage is not true, this function may be
120  * required to be called every time information is requested from
121  * this object.
122  *
123  * Underscore updates never check for the state of the system
124  * They just do the calculation.
125  */
126  virtual void _updateStandardStateThermo();
127 
128  //! Updates the reference state thermodynamic functions at the
129  //! current T of the solution and the reference pressure
130  /*!
131  * Underscore updates never check for the state of the system
132  * They just do the calculation.
133  */
134  virtual void _updateRefStateThermo() const;
135 
136  //@}
137  /// @name Thermodynamic Values for the Species Reference States (VPStandardStateTP)
138  /*!
139  * There are also temporary
140  * variables for holding the species reference-state values of Cp, H, S, and V at the
141  * last temperature and reference pressure called. These functions are not recalculated
142  * if a new call is made using the previous temperature.
143  * All calculations are done within the routine _updateRefStateThermo().
144  */
145  //@{
146 
147  /*!
148  * Returns the vector of the
149  * gibbs function of the reference state at the current temperature
150  * of the solution and the reference pressure for the species.
151  * units = J/kmol
152  *
153  * @param g Output vector contain the Gibbs free energies
154  * of the reference state of the species
155  * length = m_kk, units = J/kmol.
156  */
157  virtual void getGibbs_ref(doublereal* g) const ;
158 
159  //! @name Initialization Methods - For Internal use (VPStandardState)
160  /*!
161  * The following methods are used in the process of constructing
162  * the phase and setting its parameters from a specification in an
163  * input file. They are not normally used in application programs.
164  * To see how they are used, see files importCTML.cpp and
165  * ThermoFactory.cpp.
166  */
167  //@{
168 
169 
170  //! @internal Initialize the object
171  /*!
172  * This method is provided to allow
173  * subclasses to perform any initialization required after all
174  * species have been added. For example, it might be used to
175  * resize internal work arrays that must have an entry for
176  * each species. The base class implementation does nothing,
177  * and subclasses that do not require initialization do not
178  * need to overload this method. When importing a CTML phase
179  * description, this method is called just prior to returning
180  * from function importPhase().
181  *
182  * @see importCTML.cpp
183  */
184  virtual void initThermo();
185 
186  //! Finalize the thermo objects after all species have been entered
187  /*!
188  * This function is the LAST initialization routine to be
189  * called. It's called after createInstallPDSS() has been
190  * called for each species in the phase, and after initThermo()
191  * has been called.
192  * It's called via an inner-to-outer onion-shell like manner.
193  *
194  * Currently, this routine passed control to the parent class
195  * without doing anything.
196  *
197  * @param phaseNode Reference to the phaseNode XML node.
198  * @param id ID of the phase.
199  */
200  virtual void initThermoXML(XML_Node& phaseNode, std::string id);
201 
202 private:
203  //! Local factory routine for the creation of PDSS objects
204  /*!
205  * This routine is specific to the VPSSMgr_General object.
206  * It will create a PDSS object for species k, by searching
207  * and querying for the "standardState" XML node in the standard
208  * state description of the species. If this XML node doesn't
209  * exist, it will assume that the standard state is an ideal
210  * gas.
211  * It decides on the attribute, "model", what PDSS object
212  * to create.
213  *
214  * @param k Species number
215  * @param speciesNode XML node for the standard state of the species
216  * @param phaseNode_ptr pointer to the phase XML node
217  * @param doST output variable indicating whether the
218  * instantiation has resulted in a SpeciesThermo object
219  * being created and registered with the SpeciesThermo
220  * manager class.
221  *
222  * @return Returns the pointer to a malloced PDSS object
223  */
224  PDSS* returnPDSS_ptr(size_t k, const XML_Node& speciesNode,
225  const XML_Node* const phaseNode_ptr, bool& doST);
226 
227 public:
228 
229  //! Factory routine for the creation of PDSS objects that are
230  //! then internally registered with this VPSSMgr object
231  /*!
232  * This function sets up the internal data within this object for
233  * handling the calculation of the standard state for the species.
234  *
235  * This routine
236  * will create a PDSS object for species k, by searching
237  * and querying for the "standardState" XML node in the standard
238  * state description of the species.
239  * It will then store the object's pointer in a vector of pointers,
240  * and it will own the object.
241  *
242  * @param k Species number
243  * @param speciesNode XML node for the standard state of the species
244  * @param phaseNode_ptr pointer to the phase XML node
245  *
246  * @return Returns the pointer to the malloced PDSS object
247  */
248  virtual PDSS* createInstallPDSS(size_t k, const XML_Node& speciesNode,
249  const XML_Node* const phaseNode_ptr);
250 
251  //! This utility function reports the type of parameterization
252  //! used for the species with index number index.
253  /*!
254  *
255  * @param index Species index
256  */
257  virtual PDSS_enumType reportPDSSType(int index = -1) const ;
258 
259 
260  //! This utility function reports the type of manager
261  //! for the calculation of the standard state properties
262  /*!
263  *
264  */
265  virtual VPSSMgr_enumType reportVPSSMgrType() const ;
266 
267  //! Initialize the internal shallow pointers in this object
268  /*!
269  * There are a bunch of internal shallow pointers that point to the owning
270  * VPStandardStateTP and SpeciesThermo objects. This function reinitializes
271  * them. This function is called like an onion.
272  *
273  * @param vp_ptr Pointer to the VPStandardStateTP standard state
274  * @param sp_ptr Pointer to the SpeciesThermo standard state
275  */
276  virtual void initAllPtrs(VPStandardStateTP* vp_ptr, SpeciesThermo* sp_ptr);
277 
278 private:
279 
280  //! Shallow pointers containing the PDSS objects for the species
281  //! in this phase.
282  /*!
283  * This object doesn't own these pointers.
284  */
285  std::vector<PDSS*> m_PDSS_ptrs;
286 
287 
288  //! VPStandardStateTP has its own err routine
289  /*!
290  * @param msg Error message string
291  */
292  doublereal err(std::string msg) const;
293 
294 
295 };
296 //@}
297 }
298 
299 #endif
300