Cantera  2.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SpeciesThermoFactory.h
Go to the documentation of this file.
1 /**
2  * @file SpeciesThermoFactory.h
3  * Header for factory to build instances of classes that manage the
4  * standard-state thermodynamic properties of a set of species
5  * (see \ref spthermo and class
6  * \link Cantera::SpeciesThermoFactory SpeciesThermoFactory\endlink);
7  */
8 // Copyright 2001 California Institute of Technology
9 
10 #ifndef SPECIESTHERMO_FACTORY_H
11 #define SPECIESTHERMO_FACTORY_H
12 
13 #include "SpeciesThermo.h"
16 #include "cantera/base/ct_thread.h"
17 
18 namespace Cantera
19 {
20 
21 class XML_Node;
22 class VPStandardStateTP;
23 class VPSSMgr;
24 class ThermoPhase;
25 
26 /**
27  * Throw a named error for an unknown or missing species thermo model.
28  *
29  * @ingroup thermoprops
30  */
32 {
33 public:
34  //! constructor
35  /*!
36  * @param proc Function name error occurred.
37  * @param spName Species Name that caused the error
38  * @param speciesThermoModel Unrecognized species thermo model name
39  */
40  UnknownSpeciesThermoModel(const std::string& proc, const std::string& spName,
41  const std::string& speciesThermoModel) :
42  CanteraError(proc, "species " + spName +
43  ": Specified speciesThermoPhase model "
44  + speciesThermoModel +
45  " does not match any known type.") {}
46 };
47 
48 //! Factory to build instances of classes that manage the
49 //! standard-state thermodynamic properties of a set of species.
50 /*!
51  * This class is responsible for making the decision concerning
52  * which derivative of SpeciesThermo object to use.
53  * The SpeciesThermo object is used to calculate
54  * thermodynamic functions for the reference state.
55  * It queries the database of species to understand what
56  * the requirements are for the submodels for all of the
57  * species in the phase. Then, it picks the SpeciesThermo
58  * object to use, and passes it back to the calling routine.
59  * It doesn't load any of the data into the derived
60  * SpeciesThermo object.
61  *
62  * Making the choice of SpeciesThermo types is the only
63  * thing this class does.
64  *
65  * This class is implemented as a singleton -- one in which
66  * only one instance is needed. The recommended way to access
67  * the factory is to call this static method, which
68  * instantiates the class if it is the first call, but
69  * otherwise simply returns the pointer to the existing
70  * instance.
71  *
72  * @deprecated To be removed after Cantera 2.2. Use class GeneralSpeciesThermo directly
73  * @ingroup thermoprops
74  */
76 {
77 
78 public:
79 
80  //! Static method to return an instance of this class
81  /*!
82  * This class is implemented as a singleton -- one in which only one
83  * instance is needed. The recommended way to access the factory is to
84  * call this static method, which instantiates the class if it is the
85  * first call, but otherwise simply returns the pointer to the existing
86  * instance.
87  */
88  static SpeciesThermoFactory* factory();
89 
90  //! Delete static instance of this class
91  /**
92  * If it is necessary to explicitly delete the factory before
93  * the process terminates (for example, when checking for
94  * memory leaks) then this method can be called to delete it.
95  */
96  void deleteFactory();
97 
98  //! Create a new species property manager for the reference state.
99  /*!
100  * @param type the integer type to be created.
101  * @return Returns the pointer to the newly allocated species property
102  * manager for the reference state
103  * @deprecated To be removed after Cantera 2.2. Use GeneralSpeciesThermo
104  * directly.
105  */
106  SpeciesThermo* newSpeciesThermo(int type) const;
107 
108  //! Create a new species thermo property manager given a string
109  /*!
110  * @param stype String name for the species thermo type
111  * @return Returns the pointer to the newly malloced species
112  * property manager for the reference state
113  * @deprecated To be removed after Cantera 2.2. Use GeneralSpeciesThermo
114  * directly.
115  */
116  SpeciesThermo* newSpeciesThermoManager(const std::string& stype) const;
117 
118  //! Create a new species property manager for the reference
119  //! state for a group of species
120  /*!
121  * This routine will look through species nodes. It will discover what
122  * each species needs for its species property managers. Then,
123  * it will malloc and return the proper species property manager to use.
124  *
125  * @param spDataNodeList This vector contains a list of species XML
126  * nodes that will be in the phase
127  * @return Returns the pointer to the newly malloced species property
128  * manager for the reference state
129  * @deprecated To be removed after Cantera 2.2.
130  */
131  SpeciesThermo* newSpeciesThermo(std::vector<XML_Node*> & spDataNodeList) const;
132 
133  //! Install a species thermodynamic property parameterization
134  //! for the reference state for one species into a species thermo manager.
135  /*!
136  * @param k Species number
137  * @param speciesNode Reference to the XML node specifying the species
138  * standard state information
139  * @param th_ptr Pointer to the ThermoPhase object for the species
140  * @param spthermo Species reference state thermo manager
141  * @param phaseNode_ptr Optional pointer to the XML phase information for
142  * the phase in which the species resides
143  */
144  void installThermoForSpecies(size_t k, const XML_Node& speciesNode,
145  ThermoPhase* th_ptr, SpeciesThermo& spthermo,
146  const XML_Node* phaseNode_ptr = 0) const;
147 
148  //! Install a species thermodynamic property parameterization
149  //! for the standard state for one species into a species thermo manager, VPSSMgr
150  /*!
151  * This is a wrapper around the createInstallVPSS() function in the
152  * VPStandardStateTP object.
153  *
154  * This serves to install the species into vpss_ptr, create a PDSS file. We also
155  * read the XML database to extract the constants for these steps.
156  *
157  * @param k species number
158  * @param speciesNode Reference to the XML node specifying the species
159  * standard state information
160  * @param vp_ptr variable pressure ThermoPhase object
161  * @param vpss_ptr Pointer to the Manager for calculating variable
162  * pressure substances.
163  * @param spthermo_ptr Species reference state thermo manager
164  * @param phaseNode_ptr Optional Pointer to the XML phase information for
165  * the phase in which the species resides
166  * @deprecated To be removed after Cantera 2.2. Call
167  * VPStandardStateTP::createInstallVPSS directly instead.
168  */
169  void installVPThermoForSpecies(size_t k, const XML_Node& speciesNode,
170  VPStandardStateTP* vp_ptr,
171  VPSSMgr* vpss_ptr,
172  SpeciesThermo* spthermo_ptr,
173  const XML_Node* phaseNode_ptr) const;
174 
175 private:
176 
177  //! Pointer to the sole instance of this class, which is static
179 
180  //! Decl of the static mutex variable that locks the SpeciesThermo factory singleton
181  static mutex_t species_thermo_mutex;
182 
183  //! Constructor. This is made private, so that only the static
184  //! method factory() can instantiate the class.
186 };
187 
188 
189 ////////////////////// Convenience functions ////////////////////
190 //
191 // These functions allow using a different factory class that
192 // derives from SpeciesThermoFactory.
193 //
194 //////////////////////////////////////////////////////////////////
195 
196 
197 //! Create a new species thermo manager instance, by specifying the type and
198 //! (optionally) a pointer to the factory to use to create it.
199 /*!
200  * This utility program will look through species nodes. It will discover what
201  * each species needs for its species property managers. Then,
202  * it will malloc and return the proper species property manager to use.
203  *
204  * These functions allow using a different factory class that
205  * derives from SpeciesThermoFactory.
206  *
207  * @param type Species thermo type.
208  * @param f Pointer to a SpeciesThermoFactory. optional parameter.
209  * Defaults to NULL.
210  * @deprecated To be removed after Cantera 2.2. Use GeneralSpeciesThermo
211  * directly.
212  */
213 SpeciesThermo* newSpeciesThermoMgr(int type, SpeciesThermoFactory* f=0);
214 
215 //! Create a new species thermo manager instance, by specifying the type and
216 //! (optionally) a pointer to the factory to use to create it.
217 /*!
218  * This utility program is a basic factory operation for spawning a
219  * new species reference-state thermo manager
220  *
221  * These functions allows for using a different factory class that
222  * derives from SpeciesThermoFactory. However, no applications of this
223  * have been done yet.
224  *
225  * @param stype String specifying the species thermo type
226  * @param f Pointer to a SpeciesThermoFactory. optional parameter.
227  * Defaults to NULL.
228  * @deprecated To be removed after Cantera 2.2. Use GeneralSpeciesThermo
229  * directly.
230  */
231 SpeciesThermo* newSpeciesThermoMgr(const std::string& stype,
232  SpeciesThermoFactory* f=0);
233 
234 //! Function to return SpeciesThermo manager
235 /*!
236  * This utility program will look through species nodes. It will discover what
237  * each species needs for its species property managers. Then,
238  * it will malloc and return the proper species reference state manager to use.
239  *
240  * These functions allow using a different factory class that
241  * derives from SpeciesThermoFactory.
242  *
243  * @param spDataNodeList This vector contains a list of species XML nodes that
244  * will be in the phase
245  * @param f Pointer to a SpeciesThermoFactory. optional
246  * parameter. Defaults to NULL.
247  * @deprecated To be removed after Cantera 2.2.
248  */
249 SpeciesThermo* newSpeciesThermoMgr(std::vector<XML_Node*> spDataNodeList,
250  SpeciesThermoFactory* f=0);
251 
252 
253 //! Create a new SpeciesThermoInterpType object given a corresponding constant.
254 /*!
255  * @param type A constant specifying the type to be created
256  * @param tlow The lowest temperature at which the parameterization is valid
257  * @param thigh The highest temperature at which the parameterization is valid
258  * @param pref The reference pressure for the parameterization
259  * @param coeffs The array of coefficients for the parameterization
260  * @return Returns the pointer to the newly allocated
261  * SpeciesThermoInterpType object
262  */
263 SpeciesThermoInterpType* newSpeciesThermoInterpType(int type, double tlow,
264  double thigh, double pref, const double* coeffs);
265 
266 //! Create a new SpeciesThermoInterpType object given a string
267 /*!
268  * @param type String name for the species thermo type
269  * @param tlow The lowest temperature at which the parameterization is valid
270  * @param thigh The highest temperature at which the parameterization is valid
271  * @param pref The reference pressure for the parameterization
272  * @param coeffs The array of coefficients for the parameterization
273  * @return Returns the pointer to the newly allocated
274  * SpeciesThermoInterpType object
275  */
276 SpeciesThermoInterpType* newSpeciesThermoInterpType(const std::string& type,
277  double tlow, double thigh, double pref, const double* coeffs);
278 
279 //! Create a new SpeciesThermoInterpType object from XML_Node
280 /*!
281  * @param thermoNode 'thermo' XML_Node (child of the 'species' node) with child
282  * nodes representing parameterizations for one or more temperature ranges
283  * @return Returns the pointer to the newly allocated
284  * SpeciesThermoInterpType object
285  */
286 SpeciesThermoInterpType* newSpeciesThermoInterpType(const XML_Node& thermoNode);
287 
288 }
289 
290 #endif
Factory to build instances of classes that manage the standard-state thermodynamic properties of a se...
SpeciesThermoInterpType * newSpeciesThermoInterpType(int type, double tlow, double thigh, double pref, const double *coeffs)
Create a new SpeciesThermoInterpType object given a corresponding constant.
Virtual base class for the classes that manage the calculation of standard state properties for all t...
Definition: VPSSMgr.h:235
static SpeciesThermoFactory * factory()
Static method to return an instance of this class.
Class XML_Node is a tree-based representation of the contents of an XML file.
Definition: xml.h:100
Virtual base class for the calculation of multiple-species thermodynamic reference-state property man...
Base class for factories.
Definition: FactoryBase.h:18
void installThermoForSpecies(size_t k, const XML_Node &speciesNode, ThermoPhase *th_ptr, SpeciesThermo &spthermo, const XML_Node *phaseNode_ptr=0) const
Install a species thermodynamic property parameterization for the reference state for one species int...
Pure Virtual base class for the species thermo manager classes.
Base class for a phase with thermodynamic properties.
Definition: ThermoPhase.h:97
UnknownSpeciesThermoModel(const std::string &proc, const std::string &spName, const std::string &speciesThermoModel)
constructor
SpeciesThermo * newSpeciesThermoMgr(int type, SpeciesThermoFactory *f)
Create a new species thermo manager instance, by specifying the type and (optionally) a pointer to th...
void installVPThermoForSpecies(size_t k, const XML_Node &speciesNode, VPStandardStateTP *vp_ptr, VPSSMgr *vpss_ptr, SpeciesThermo *spthermo_ptr, const XML_Node *phaseNode_ptr) const
Install a species thermodynamic property parameterization for the standard state for one species into...
SpeciesThermo * newSpeciesThermoManager(const std::string &stype) const
Create a new species thermo property manager given a string.
static SpeciesThermoFactory * s_factory
Pointer to the sole instance of this class, which is static.
Base class for exceptions thrown by Cantera classes.
Definition: ctexceptions.h:99
This is a filter class for ThermoPhase that implements some prepatory steps for efficiently handling ...
SpeciesThermo * newSpeciesThermo(int type) const
Create a new species property manager for the reference state.
void deleteFactory()
Delete static instance of this class.
Throw a named error for an unknown or missing species thermo model.
static mutex_t species_thermo_mutex
Decl of the static mutex variable that locks the SpeciesThermo factory singleton. ...
Definitions for the classes that are thrown when Cantera experiences an error condition (also contain...
File contains the FactoryBase class declarations.