Cantera  2.0
PDSS_IonsFromNeutral.h
Go to the documentation of this file.
1 /**
2  * @file PDSS_IonsFromNeutral.h
3  * Declarations for the class PDSS_IonsFromNeutral (
4  * which handles calculations for a single ion in a fluid, whose properties
5  * are calculated from another neutral molecule.
6  * (see \ref pdssthermo and class \link Cantera::PDSS_IonsFromNeutral PDSS_IonsFromNeutral\endlink).
7  */
8 /*
9  * Copyright (2006) Sandia Corporation. Under the terms of
10  * Contract DE-AC04-94AL85000 with Sandia Corporation, the
11  * U.S. Government retains certain rights in this software.
12  */
13 #ifndef CT_PDSS_IONSFROMNEUTRAL_H
14 #define CT_PDSS_IONSFROMNEUTRAL_H
15 
16 #include "PDSS.h"
17 
18 
19 namespace Cantera
20 {
21 class XML_Node;
22 class VPStandardStateTP;
23 class ThermoPhase;
24 
25 
26 //! Derived class for pressure dependent standard states of an ideal gas species
27 /*!
28  * This class is for a single Ideal Gas species.
29  *
30  * @ingroup pdssthermo
31  */
32 class PDSS_IonsFromNeutral : public PDSS
33 {
34 
35 public:
36 
37  /**
38  * @name Constructors
39  * @{
40  */
41 
42  //! Constructor
43  /*!
44  * @param tp Pointer to the ThermoPhase object pertaining to the phase
45  * @param spindex Species index of the species in the phase
46  */
47  PDSS_IonsFromNeutral(VPStandardStateTP* tp, size_t spindex);
48 
49  //! Constructor that initializes the object by examining the input file
50  //! of the ThermoPhase object
51  /*!
52  * This function calls the constructPDSSFile member function.
53  *
54  * @param tp Pointer to the ThermoPhase object pertaining to the phase
55  * @param spindex Species index of the species in the phase
56  * @param inputFile String name of the input file
57  * @param id String name of the phase in the input file. The default
58  * is the empty string, in which case the first phase in the
59  * file is used.
60  */
61  PDSS_IonsFromNeutral(VPStandardStateTP* tp, size_t spindex,
62  std::string inputFile, std::string id = "");
63 
64 
65  //! Constructor that initializes the object by examining the input file
66  //! of the ThermoPhase object
67  /*!
68  * This function calls the constructPDSSXML member function.
69  *
70  * @param vptp_ptr Pointer to the ThermoPhase object pertaining to the phase
71  * @param spindex Species index of the species in the phase
72  * @param speciesNode Reference to the species XML tree.
73  * @param phaseRef Reference to the XML tree containing the phase information.
74  * @param spInstalled Boolean indicating whether the species is installed yet
75  * or not.
76  */
77  PDSS_IonsFromNeutral(VPStandardStateTP* vptp_ptr, size_t spindex, const XML_Node& speciesNode,
78  const XML_Node& phaseRef, bool spInstalled);
79 
80  //! Copy Constructor
81  /*!
82  * @param b Object to be copied
83  */
85 
86  //! Assignment operator
87  /*!
88  * @param b Object to be copeid
89  */
91 
92  //! Destructor
93  virtual ~PDSS_IonsFromNeutral();
94 
95  //! Duplicator
96  virtual PDSS* duplMyselfAsPDSS() const;
97 
98  //! Initialize or Reinitialize all shallow pointers in the object
99  /*!
100  * This command is called to reinitialize all shallow pointers in the
101  * object. It's needed for the duplicator capability.
102  * We need to have an inherited function here to set neutralMoleculePhase_ properly.
103  *
104  * @param vptp_ptr Pointer to the Variable pressure %ThermoPhase object
105  * This object must have already been malloced.
106  *
107  * @param vpssmgr_ptr Pointer to the variable pressure standard state
108  * calculator for this phase
109  *
110  * @param spthermo_ptr Pointer to the optional SpeciesThermo object
111  * that will handle the calculation of the reference
112  * state thermodynamic coefficients.
113  */
114  virtual void initAllPtrs(VPStandardStateTP* vptp_ptr, VPSSMgr* vpssmgr_ptr,
115  SpeciesThermo* spthermo_ptr);
116 
117  /**
118  * @}
119  * @name Utilities
120  * @{
121  */
122 
123  /**
124  * @}
125  * @name Molar Thermodynamic Properties of the Species Standard State
126  * in the Solution
127  * @{
128  */
129 
130  //! Return the molar enthalpy in units of J kmol-1
131  /*!
132  * Returns the species standard state enthalpy in J kmol-1 at the
133  * current temperature and pressure.
134  *
135  * @return returns the species standard state enthalpy in J kmol-1
136  */
137  virtual doublereal enthalpy_mole() const;
138 
139  //! Return the standard state molar enthalpy divided by RT
140  /*!
141  * Returns the species standard state enthalpy divided by RT at the
142  * current temperature and pressure.
143  *
144  * @return returns the species standard state enthalpy in unitless form
145  */
146  virtual doublereal enthalpy_RT() const;
147 
148  //! Return the molar internal Energy in units of J kmol-1
149  /*!
150  * Returns the species standard state internal Energy in J kmol-1 at the
151  * current temperature and pressure.
152  *
153  * @return returns the species standard state internal Energy in J kmol-1
154  */
155  virtual doublereal intEnergy_mole() const;
156 
157  //! Return the molar entropy in units of J kmol-1 K-1
158  /*!
159  * Returns the species standard state entropy in J kmol-1 K-1 at the
160  * current temperature and pressure.
161  *
162  * @return returns the species standard state entropy in J kmol-1 K-1
163  */
164  virtual doublereal entropy_mole() const;
165 
166  //! Return the standard state entropy divided by RT
167  /*!
168  * Returns the species standard state entropy divided by RT at the
169  * current temperature and pressure.
170  *
171  * @return returns the species standard state entropy divided by RT
172  */
173  virtual doublereal entropy_R() const;
174 
175  //! Return the molar gibbs free energy in units of J kmol-1
176  /*!
177  * Returns the species standard state gibbs free energy in J kmol-1 at the
178  * current temperature and pressure.
179  *
180  * @return returns the species standard state gibbs free energy in J kmol-1
181  */
182  virtual doublereal gibbs_mole() const;
183 
184  //! Return the molar gibbs free energy divided by <I>RT</I>
185  /*!
186  * Returns the species standard state gibbs free energy divided by <I>RT</I> at the
187  * current temperature and pressure.
188  *
189  * \f[
190  * \frac{\mu^o_k}{RT} = \sum_{m}{ \alpha_{m , k} \frac{\mu^o_{m}}{RT}} + ( 1 - \delta_{k,sp}) 2.0 \ln{2.0}
191  * \f]
192  *
193  * <I>m</I> is the neutral molecule species index. \f$ \alpha_{m , k} \f$ is the stoiciometric
194  * coefficient for the neutral molecule, <I>m</I>, that creates the thermodynamics for the ionic species <I>k</I>.
195  * A factor \f$ 2.0 \ln{2.0} \f$ is added to all ions except for the species ionic species, which in this
196  * case is the single anion species, with species index <I>sp</I>.
197  *
198  * @return Returns the species standard state gibbs free energy divided by <I>RT</I>
199  */
200  virtual doublereal gibbs_RT() const;
201 
202  //! Return the molar const pressure heat capacity in units of J kmol-1 K-1
203  /*!
204  * Returns the species standard state Cp in J kmol-1 K-1 at the
205  * current temperature and pressure.
206  *
207  * @return returns the species standard state Cp in J kmol-1 K-1
208  */
209  virtual doublereal cp_mole() const;
210 
211  //! Return the molar const pressure heat capacity divided by RT
212  /*!
213  * Returns the species standard state Cp divided by RT at the
214  * current temperature and pressure.
215  *
216  * @return returns the species standard state Cp divided by RT
217  */
218  virtual doublereal cp_R() const;
219 
220  //! Return the molar const volume heat capacity in units of J kmol-1 K-1
221  /*!
222  * Returns the species standard state Cv in J kmol-1 K-1 at the
223  * current temperature and pressure.
224  *
225  * @return returns the species standard state Cv in J kmol-1 K-1
226  */
227  virtual doublereal cv_mole() const;
228 
229  //! Return the molar volume at standard state
230  /*!
231  * Returns the species standard state molar volume at the
232  * current temperature and pressure
233  *
234  * @return returns the standard state molar volume divided by R
235  * units are m**3 kmol-1.
236  */
237  virtual doublereal molarVolume() const;
238 
239  //! Return the standard state density at standard state
240  /*!
241  * Returns the species standard state density at the
242  * current temperature and pressure
243  *
244  * @return returns the standard state density
245  * units are kg m-3
246  */
247  virtual doublereal density() const;
248 
249  /**
250  * @}
251  * @name Properties of the Reference State of the Species
252  * in the Solution
253  * @{
254  */
255 
256  //! Return the molar gibbs free energy divided by RT at reference pressure
257  /*!
258  * Returns the species reference state gibbs free energy divided by RT at the
259  * current temperature.
260  *
261  * @return returns the reference state gibbs free energy divided by RT
262  */
263  virtual doublereal gibbs_RT_ref() const;
264 
265  //! Return the molar enthalpy divided by RT at reference pressure
266  /*!
267  * Returns the species reference state enthalpy divided by RT at the
268  * current temperature.
269  *
270  * @return returns the reference state enthalpy divided by RT
271  */
272  virtual doublereal enthalpy_RT_ref() const;
273 
274  //! Return the molar entropy divided by R at reference pressure
275  /*!
276  * Returns the species reference state entropy divided by R at the
277  * current temperature.
278  *
279  * @return returns the reference state entropy divided by R
280  */
281  virtual doublereal entropy_R_ref() const;
282 
283  //! Return the molar heat capacity divided by R at reference pressure
284  /*!
285  * Returns the species reference state heat capacity divided by R at the
286  * current temperature.
287  *
288  * @return returns the reference state heat capacity divided by R
289  */
290  virtual doublereal cp_R_ref() const;
291 
292  //! Return the molar volume at reference pressure
293  /*!
294  * Returns the species reference state molar volume at the
295  * current temperature.
296  *
297  * @return returns the reference state molar volume divided by R
298  * units are m**3 kmol-1.
299  */
300  virtual doublereal molarVolume_ref() const;
301 
302  /*
303  * Get the difference in the standard state thermodynamic properties
304  * between the reference pressure, po, and the current pressure.
305  */
306 
307  /**
308  * @}
309  * @name Mechanical Equation of State Properties
310  * @{
311  */
312 
313  //! Returns the pressure (Pa)
314  virtual doublereal pressure() const;
315 
316  //! Sets the pressure in the object
317  /*!
318  * Currently, this sets the pressure in the PDSS object.
319  * It is indeterminant what happens to the owning VPStandardStateTP
320  * object and to the VPSSMgr object.
321  *
322  * @param pres Pressure to be set (Pascal)
323  */
324  virtual void setPressure(doublereal pres);
325 
326  //! Set the internal temperature
327  /*!
328  * @param temp Temperature (Kelvin)
329  */
330  virtual void setTemperature(doublereal temp);
331 
332  //! Return the current stored temperature
333  doublereal temperature() const;
334 
335  //! Set the internal temperature and pressure
336  /*!
337  * @param temp Temperature (Kelvin)
338  * @param pres pressure (Pascals)
339  */
340  virtual void setState_TP(doublereal temp, doublereal pres);
341 
342  //! Set the internal temperature and density
343  /*!
344  * @param temp Temperature (Kelvin)
345  * @param rho Density (Pascals)
346  */
347  virtual void setState_TR(doublereal temp, doublereal rho);
348 
349  /**
350  * @}
351  * @name Miscellaneous properties of the standard state
352  * @{
353  */
354 
355  /// critical temperature
356  virtual doublereal critTemperature() const;
357 
358  /// critical pressure
359  virtual doublereal critPressure() const;
360 
361  /// critical density
362  virtual doublereal critDensity() const;
363 
364  /// saturation pressure
365  /*!
366  * @param t Temperature (Kelvin)
367  */
368  virtual doublereal satPressure(doublereal t);
369 
370  /**
371  * @}
372  * @name Initialization of the Object
373  * @{
374  */
375 
376  //! Initialization of a PDSS object using an
377  //! input XML file.
378  /*!
379  *
380  * This routine is a precursor to constructPDSSXML(XML_Node*)
381  * routine, which does most of the work.
382  *
383  * @param vptp_ptr Pointer to the Variable pressure %ThermoPhase object
384  * This object must have already been malloced.
385  *
386  * @param spindex Species index within the phase
387  *
388  * @param inputFile XML file containing the description of the
389  * phase
390  *
391  * @param id Optional parameter identifying the name of the
392  * phase. If none is given, the first XML
393  * phase element will be used.
394  */
395  void constructPDSSFile(VPStandardStateTP* vptp_ptr, size_t spindex,
396  std::string inputFile, std::string id);
397 
398  //! Initialization of a PDSS object using an xml tree
399  /*!
400  * This routine is a driver for the initialization of the object.
401  *
402  * basic logic:
403  * initThermo() (cascade)
404  * getStuff from species Part of XML file
405  * initThermoXML(phaseNode) (cascade)
406  *
407  * @param vptp_ptr Pointer to the Variable pressure %ThermoPhase object
408  * This object must have already been malloced.
409  *
410  * @param spindex Species index within the phase
411  *
412  * @param speciesNode Reference to the phase Information for the species
413  * that this standard state refers to
414  *
415  * @param phaseNode Reference to the phase Information for the phase
416  * that owns this species.
417  *
418  * @param id Optional parameter identifying the name of the
419  * phase. If none is given, the first XML
420  * phase element will be used.
421  */
422  void constructPDSSXML(VPStandardStateTP* vptp_ptr, size_t spindex,
423  const XML_Node& speciesNode,
424  const XML_Node& phaseNode, std::string id);
425 
426  //! Initialization routine for the PDSS object based on the phaseNode
427  /*!
428  * This is a cascading call, where each level should call the
429  * the parent level.
430  *
431  * @param phaseNode Reference to the phase Information for the phase
432  * that owns this species.
433  *
434  * @param id Optional parameter identifying the name of the
435  * phase. If none is given, the first XML
436  * phase element will be used.
437  */
438  virtual void initThermoXML(const XML_Node& phaseNode, std::string& id);
439 
440  //! Initialization routine for all of the shallow pointers
441  /*!
442  * This is a cascading call, where each level should call the
443  * the parent level.
444  *
445  * The initThermo() routines get called before the initThermoXML() routines
446  * from the constructPDSSXML() routine.
447  *
448  *
449  * Calls initPtrs();
450  */
451  virtual void initThermo();
452 
453  //@}
454 
455 
456 
457 protected:
458 
459  //! Maximum temperature the standard states are good for
460  doublereal m_tmin;
461 
462  //! Minimum temperature the standard states are good for
463  doublereal m_tmax;
464 
465 
466  //! Pointer to the Neutral Molecule ThermoPhase object
467  /*!
468  * This is a shallow pointer.
469  */
471 
472 public:
473 
474  //! Number of neutral molecule species that make up the stoichiometric vector for
475  //! this species, in terms of calculating thermodynamic functions
476  size_t numMult_;
477 
478  //! Vector of species indices in the neutral molecule ThermoPhase
479  std::vector<size_t> idNeutralMoleculeVec;
480 
481  //! Stoichiometric coefficient for this species using the Neutral Molecule Species
482  //! in the vector idNeutralMoleculeVec
483  std::vector<double> factorVec;
484 
485  //! Add 2RTln2 to the entropy and Gibbs free energies for this species
486  /*!
487  * This is true if this species is not the special species
488  */
490 
491  //! Vector of length equal to the number of species in the neutral molecule phase
492  mutable std::vector<double> tmpNM;
493 
494  //! True if this species is the special species
496 };
497 }
498 
499 #endif
500 
501 
502