Cantera  2.0
PseudoBinaryVPSSTP.h
Go to the documentation of this file.
1 /**
2  * @file PseudoBinaryVPSSTP.h
3  * Header for intermediate ThermoPhase object for phases which
4  * employ gibbs excess free energy based formulations
5  * (see \ref thermoprops
6  * and class \link Cantera::gibbsExcessVPSSTP gibbsExcessVPSSTP\endlink).
7  *
8  * Header file for a derived class of ThermoPhase that handles
9  * variable pressure standard state methods for calculating
10  * thermodynamic properties that are further based upon activities
11  * based on the molality scale. These include most of the methods for
12  * calculating liquid electrolyte thermodynamics.
13  */
14 /*
15  * Copyright (2006) Sandia Corporation. Under the terms of
16  * Contract DE-AC04-94AL85000 with Sandia Corporation, the
17  * U.S. Government retains certain rights in this software.
18  */
19 #ifndef CT_PSEUDOBINARYVPSSTP_H
20 #define CT_PSEUDOBINARYVPSSTP_H
21 
22 #include "GibbsExcessVPSSTP.h"
23 
24 namespace Cantera
25 {
26 
27 /**
28  * @ingroup thermoprops
29  */
30 
31 /*!
32  * PseudoBinaryVPSSTP is a derived class of ThermoPhase
33  * GibbsExcessVPSSTP that handles
34  * variable pressure standard state methods for calculating
35  * thermodynamic properties that are further based on
36  * expressing the Excess Gibbs free energy as a function of
37  * the mole fractions (or pseudo mole fractions) of constituents.
38  * This category is the workhorse for describing molten salts,
39  * solid-phase mixtures of semiconductors, and mixtures of miscible
40  * and semi-miscible compounds.
41  *
42  * It includes
43  * . regular solutions
44  * . Margules expansions
45  * . NTRL equation
46  * . Wilson's equation
47  * . UNIQUAC equation of state.
48  *
49  * This class adds additional functions onto the %ThermoPhase interface
50  * that handles the calculation of the excess Gibbs free energy. The %ThermoPhase
51  * class includes a member function, ThermoPhase::activityConvention()
52  * that indicates which convention the activities are based on. The
53  * default is to assume activities are based on the molar convention.
54  * That default is used here.
55  *
56  * All of the Excess Gibbs free energy formulations in this area employ
57  * symmetrical formulations.
58  *
59  * This layer will massage the mole fraction vector to implement
60  * cation and anion based mole numbers in an optional manner
61  *
62  * The way that it collects the cation and anion based mole numbers
63  * is via holding two extra ThermoPhase objects. These
64  * can include standard states for salts.
65  *
66  *
67  */
69 {
70 
71 public:
72 
73  /// Constructors
74  /*!
75  * This doesn't do much more than initialize constants with
76  * default values for water at 25C. Water molecular weight
77  * comes from the default elements.xml file. It actually
78  * differs slightly from the IAPWS95 value of 18.015268. However,
79  * density conservation and therefore element conservation
80  * is the more important principle to follow.
81  */
83 
84  //! Copy constructor
85  /*!
86  * Note this stuff will not work until the underlying phase
87  * has a working copy constructor
88  *
89  * @param b class to be copied
90  */
92 
93  /// Assignment operator
94  /*!
95  *
96  * @param b class to be copied.
97  */
99 
100  /// Destructor.
101  virtual ~PseudoBinaryVPSSTP();
102 
103  //! Duplication routine for objects which inherit from ThermoPhase.
104  /*!
105  * This virtual routine can be used to duplicate thermophase objects
106  * inherited from ThermoPhase even if the application only has
107  * a pointer to ThermoPhase to work with.
108  */
109  virtual ThermoPhase* duplMyselfAsThermoPhase() const;
110 
111  /**
112  *
113  * @name Utilities
114  * @{
115  */
116 
117 
118  //! Equation of state type flag.
119  /*!
120  * The ThermoPhase base class returns
121  * zero. Subclasses should define this to return a unique
122  * non-zero value. Known constants defined for this purpose are
123  * listed in mix_defs.h. The MolalityVPSSTP class also returns
124  * zero, as it is a non-complete class.
125  */
126  virtual int eosType() const;
127 
128 
129 
130  /**
131  * @}
132  * @name Molar Thermodynamic Properties
133  * @{
134  */
135 
136 
137  /**
138  * @}
139  * @name Utilities for Solvent ID and Molality
140  * @{
141  */
142 
143 
144 
145 
146  /**
147  * @}
148  * @name Mechanical Properties
149  * @{
150  */
151 
152  /**
153  * @}
154  * @name Potential Energy
155  *
156  * Species may have an additional potential energy due to the
157  * presence of external gravitation or electric fields. These
158  * methods allow specifying a potential energy for individual
159  * species.
160  * @{
161  */
162 
163  /**
164  * @}
165  * @name Activities, Standard States, and Activity Concentrations
166  *
167  * The activity \f$a_k\f$ of a species in solution is
168  * related to the chemical potential by \f[ \mu_k = \mu_k^0(T)
169  * + \hat R T \log a_k. \f] The quantity \f$\mu_k^0(T,P)\f$ is
170  * the chemical potential at unit activity, which depends only
171  * on temperature and pressure.
172  * @{
173  */
174 
175 
176 
177 
178  /**
179  * The standard concentration \f$ C^0_k \f$ used to normalize
180  * the generalized concentration. In many cases, this quantity
181  * will be the same for all species in a phase - for example,
182  * for an ideal gas \f$ C^0_k = P/\hat R T \f$. For this
183  * reason, this method returns a single value, instead of an
184  * array. However, for phases in which the standard
185  * concentration is species-specific (e.g. surface species of
186  * different sizes), this method may be called with an
187  * optional parameter indicating the species.
188  *
189  * @param k species index. Defaults to zero.
190  */
191  virtual doublereal standardConcentration(size_t k=0) const;
192 
193  /**
194  * Returns the natural logarithm of the standard
195  * concentration of the kth species
196  *
197  * @param k species index
198  */
199  virtual doublereal logStandardConc(size_t k=0) const;
200 
201 
202 
203 
204  //@}
205  /// @name Partial Molar Properties of the Solution
206  //@{
207 
208 
209  /**
210  * Get the species electrochemical potentials.
211  * These are partial molar quantities.
212  * This method adds a term \f$ Fz_k \phi_k \f$ to the
213  * to each chemical potential.
214  *
215  * Units: J/kmol
216  *
217  * @param mu output vector containing the species electrochemical potentials.
218  * Length: m_kk.
219  */
220  void getElectrochemPotentials(doublereal* mu) const;
221 
222 
223  //@}
224  /// @name Properties of the Standard State of the Species in the Solution
225  //@{
226 
227 
228 
229  //@}
230  /// @name Thermodynamic Values for the Species Reference States
231  //@{
232 
233 
234  ///////////////////////////////////////////////////////
235  //
236  // The methods below are not virtual, and should not
237  // be overloaded.
238  //
239  //////////////////////////////////////////////////////
240 
241  /**
242  * @name Specific Properties
243  * @{
244  */
245 
246 
247  /**
248  * @name Setting the State
249  *
250  * These methods set all or part of the thermodynamic
251  * state.
252  * @{
253  */
254 
255  //! Calculate pseudo binary mole fractions
256  /*!
257  *
258  */
259  virtual void calcPseudoBinaryMoleFractions() const;
260 
261 
262  //@}
263 
264  /**
265  * @name Chemical Equilibrium
266  * Routines that implement the Chemical equilibrium capability
267  * for a single phase, based on the element-potential method.
268  * @{
269  */
270 
271 
272 
273  //@}
274 
275 
276 
277  /// The following methods are used in the process of constructing
278  /// the phase and setting its parameters from a specification in an
279  /// input file. They are not normally used in application programs.
280  /// To see how they are used, see files importCTML.cpp and
281  /// ThermoFactory.cpp.
282 
283 
284  /*!
285  * @internal Initialize. This method is provided to allow
286  * subclasses to perform any initialization required after all
287  * species have been added. For example, it might be used to
288  * resize internal work arrays that must have an entry for
289  * each species. The base class implementation does nothing,
290  * and subclasses that do not require initialization do not
291  * need to overload this method. When importing a CTML phase
292  * description, this method is called just prior to returning
293  * from function importPhase.
294  *
295  * @see importCTML.cpp
296  */
297  virtual void initThermo();
298 
299 
300  /**
301  * Import and initialize a ThermoPhase object
302  *
303  * @param phaseNode This object must be the phase node of a
304  * complete XML tree
305  * description of the phase, including all of the
306  * species data. In other words while "phase" must
307  * point to an XML phase object, it must have
308  * sibling nodes "speciesData" that describe
309  * the species in the phase.
310  * @param id ID of the phase. If nonnull, a check is done
311  * to see if phaseNode is pointing to the phase
312  * with the correct id.
313  */
314  void initThermoXML(XML_Node& phaseNode, std::string id);
315 
316 
317  //! returns a summary of the state of the phase as a string
318  /*!
319  * @param show_thermo If true, extra information is printed out
320  * about the thermodynamic state of the system.
321  */
322  virtual std::string report(bool show_thermo = true) const;
323 
324 
325 private:
326 
327 
328  //! Initialize lengths of local variables after all species have
329  //! been identified.
330  void initLengths();
331 
332 
333 
334 private:
335  //! Error function
336  /*!
337  * Print an error string and exit
338  *
339  * @param msg Message to be printed
340  */
341  doublereal err(std::string msg) const;
342 
343 protected:
344 
345  int PBType_;
346 
347  //! Number of pseudo binary species
349 
350  //! index of special species
352 
353  mutable std::vector<doublereal> PBMoleFractions_;
354 
355  std::vector<int> cationList_;
356  size_t numCationSpecies_;
357 
358  std::vector<int>anionList_;
359  size_t numAnionSpecies_;
360 
361  std::vector<int> passThroughList_;
362  size_t numPassThroughSpecies_;
363  size_t neutralPBindexStart;
364 
365  ThermoPhase* cationPhase_;
366 
367  ThermoPhase* anionPhase_;
368 
369  mutable std::vector<doublereal> moleFractionsTmp_;
370 
371 private:
372 
373 
374 };
375 
376 #define PBTYPE_PASSTHROUGH 0
377 #define PBTYPE_SINGLEANION 1
378 #define PBTYPE_SINGLECATION 2
379 #define PBTYPE_MULTICATIONANION 3
380 
381 
382 
383 }
384 
385 #endif
386 
387 
388 
389 
390