Cantera  2.1.2
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  * @ingroup thermoprops
73  */
75 {
76 
77 public:
78 
79  //! Static method to return an instance of this class
80  /*!
81  * This class is implemented as a singleton -- one in which only one
82  * instance is needed. The recommended way to access the factory is to
83  * call this static method, which instantiates the class if it is the
84  * first call, but otherwise simply returns the pointer to the existing
85  * instance.
86  */
87  static SpeciesThermoFactory* factory();
88 
89  //! Delete static instance of this class
90  /**
91  * If it is necessary to explicitly delete the factory before
92  * the process terminates (for example, when checking for
93  * memory leaks) then this method can be called to delete it.
94  */
95  void deleteFactory();
96 
97  //! Create a new species property manager for the reference state.
98  /*!
99  * @param type the integer type to be created.
100  * @return Returns the pointer to the newly allocated species property
101  * manager for the reference state
102  */
103  SpeciesThermo* newSpeciesThermo(int type) const;
104 
105  //! Create a new species thermo property manager given a string
106  /*!
107  * @param stype String name for the species thermo type
108  * @return Returns the pointer to the newly malloced species
109  * property manager for the reference state
110  */
111  SpeciesThermo* newSpeciesThermoManager(std::string& stype) const;
112 
113  //! Create a new species property manager for the reference
114  //! state for a group of species
115  /*!
116  * This routine will look through species nodes. It will discover what
117  * each species needs for its species property managers. Then,
118  * it will malloc and return the proper species property manager to use.
119  *
120  * @param spDataNodeList This vector contains a list of species XML
121  * nodes that will be in the phase
122  * @return Returns the pointer to the newly malloced species property
123  * manager for the reference state
124  */
125  SpeciesThermo* newSpeciesThermo(std::vector<XML_Node*> & spDataNodeList) const;
126 
127  //! Install a species thermodynamic property parameterization
128  //! for the reference state for one species into a species thermo manager.
129  /*!
130  * @param k Species number
131  * @param speciesNode Reference to the XML node specifying the species
132  * standard state information
133  * @param th_ptr Pointer to the %ThermoPhase object for the species
134  * @param spthermo Species reference state thermo manager
135  * @param phaseNode_ptr Optional pointer to the XML phase information for
136  * the phase in which the species resides
137  */
138  void installThermoForSpecies(size_t k, const XML_Node& speciesNode,
139  ThermoPhase* th_ptr, SpeciesThermo& spthermo,
140  const XML_Node* phaseNode_ptr = 0) const;
141 
142  //! Install a species thermodynamic property parameterization
143  //! for the standard state for one species into a species thermo manager, VPSSMgr
144  /*!
145  * This is a wrapper around the createInstallVPSS() function in the
146  * VPStandardStateTP object.
147  *
148  * This serves to install the species into vpss_ptr, create a PDSS file. We also
149  * read the xml database to extract the constants for these steps.
150  *
151  * @param k species number
152  * @param speciesNode Reference to the XML node specifying the species
153  * standard state information
154  * @param vp_ptr variable pressure ThermoPhase object
155  * @param vpss_ptr Pointer to the Manager for calculating variable
156  * pressure substances.
157  * @param spthermo_ptr Species reference state thermo manager
158  * @param phaseNode_ptr Optional Pointer to the XML phase information for
159  * the phase in which the species resides
160  */
161  void installVPThermoForSpecies(size_t k, const XML_Node& speciesNode,
162  VPStandardStateTP* vp_ptr,
163  VPSSMgr* vpss_ptr,
164  SpeciesThermo* spthermo_ptr,
165  const XML_Node* phaseNode_ptr) const;
166 
167 private:
168 
169  //! Pointer to the sole instance of this class, which is static
171 
172  //! Decl of the static mutex variable that locks the %SpeciesThermo factory singleton
173  static mutex_t species_thermo_mutex;
174 
175  //! Constructor. This is made private, so that only the static
176  //! method factory() can instantiate the class.
178 };
179 
180 
181 ////////////////////// Convenience functions ////////////////////
182 //
183 // These functions allow using a different factory class that
184 // derives from SpeciesThermoFactory.
185 //
186 //////////////////////////////////////////////////////////////////
187 
188 
189 //! Create a new species thermo manager instance, by specifying the type and
190 //! (optionally) a pointer to the factory to use to create it.
191 /*!
192  * This utility program will look through species nodes. It will discover what
193  * each species needs for its species property managers. Then,
194  * it will malloc and return the proper species property manager to use.
195  *
196  * These functions allow using a different factory class that
197  * derives from SpeciesThermoFactory.
198  *
199  * @param type Species thermo type.
200  * @param f Pointer to a SpeciesThermoFactory. optional parameter.
201  * Defaults to NULL.
202  */
203 SpeciesThermo* newSpeciesThermoMgr(int type, SpeciesThermoFactory* f=0);
204 
205 //! Create a new species thermo manager instance, by specifying the type and
206 //! (optionally) a pointer to the factory to use to create it.
207 /*!
208  * This utility program is a basic factory operation for spawning a
209  * new species reference-state thermo manager
210  *
211  * These functions allows for using a different factory class that
212  * derives from SpeciesThermoFactory. However, no applications of this
213  * have been done yet.
214  *
215  * @param stype String specifying the species thermo type
216  * @param f Pointer to a SpeciesThermoFactory. optional parameter.
217  * Defaults to NULL.
218  */
219 SpeciesThermo* newSpeciesThermoMgr(std::string& stype,
220  SpeciesThermoFactory* f=0);
221 
222 //! Function to return SpeciesThermo manager
223 /*!
224  * This utility program will look through species nodes. It will discover what
225  * each species needs for its species property managers. Then,
226  * it will malloc and return the proper species reference state manager to use.
227  *
228  * These functions allow using a different factory class that
229  * derives from SpeciesThermoFactory.
230  *
231  * @param spDataNodeList This vector contains a list of species XML nodes that
232  * will be in the phase
233  * @param f Pointer to a SpeciesThermoFactory. optional
234  * parameter. Defaults to NULL.
235  */
236 SpeciesThermo* newSpeciesThermoMgr(std::vector<XML_Node*> spDataNodeList,
237  SpeciesThermoFactory* f=0);
238 
239 }
240 
241 #endif
242 
243 
Factory to build instances of classes that manage the standard-state thermodynamic properties of a se...
Virtual base class for the classes that manage the calculation of standard state properties for all t...
Definition: VPSSMgr.h:238
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:101
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...
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:68
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.
SpeciesThermo * newSpeciesThermoManager(std::string &stype) const
Create a new species thermo property manager given a string.
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.