Cantera  2.1.2
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::PseudoBinaryVPSSTP PseudoBinaryVPSSTP\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  * @ingroup thermoprops
28  */
29 
30 /*!
31  * PseudoBinaryVPSSTP is a derived class of ThermoPhase
32  * GibbsExcessVPSSTP that handles
33  * variable pressure standard state methods for calculating
34  * thermodynamic properties that are further based on
35  * expressing the Excess Gibbs free energy as a function of
36  * the mole fractions (or pseudo mole fractions) of constituents.
37  * This category is the workhorse for describing molten salts,
38  * solid-phase mixtures of semiconductors, and mixtures of miscible
39  * and semi-miscible compounds.
40  *
41  * It includes
42  * - regular solutions
43  * - Margules expansions
44  * - NTRL equation
45  * - Wilson's equation
46  * - UNIQUAC equation of state.
47  *
48  * This class adds additional functions onto the ThermoPhase interface
49  * that handles the calculation of the excess Gibbs free energy. The ThermoPhase
50  * class includes a member function, ThermoPhase::activityConvention()
51  * that indicates which convention the activities are based on. The
52  * default is to assume activities are based on the molar convention.
53  * That default is used here.
54  *
55  * All of the Excess Gibbs free energy formulations in this area employ
56  * symmetrical formulations.
57  *
58  * This layer will massage the mole fraction vector to implement
59  * cation and anion based mole numbers in an optional manner
60  *
61  * The way that it collects the cation and anion based mole numbers
62  * is via holding two extra ThermoPhase objects. These
63  * can include standard states for salts.
64  */
66 {
67 public:
68  /// Constructor
69  /*!
70  * This doesn't do much more than initialize constants with
71  * default values for water at 25C. Water molecular weight
72  * comes from the default elements.xml file. It actually
73  * differs slightly from the IAPWS95 value of 18.015268. However,
74  * density conservation and therefore element conservation
75  * is the more important principle to follow.
76  */
78 
79  //! Copy constructor
80  /*!
81  * @param b class to be copied
82  */
84 
85  /// Assignment operator
86  /*!
87  * @param b class to be copied.
88  */
90 
91  //! Duplication routine for objects which inherit from ThermoPhase.
92  /*!
93  * This virtual routine can be used to duplicate thermophase objects
94  * inherited from ThermoPhase even if the application only has
95  * a pointer to ThermoPhase to work with.
96  */
97  virtual ThermoPhase* duplMyselfAsThermoPhase() const;
98 
99  //! @name Utilities
100  //! @{
101 
102  //! Equation of state type flag.
103  /*!
104  * The ThermoPhase base class returns
105  * zero. Subclasses should define this to return a unique
106  * non-zero value. Known constants defined for this purpose are
107  * listed in mix_defs.h.
108  */
109  virtual int eosType() const;
110 
111  /**
112  * @}
113  * @name Activities, Standard States, and Activity Concentrations
114  *
115  * The activity \f$a_k\f$ of a species in solution is
116  * related to the chemical potential by \f[ \mu_k = \mu_k^0(T)
117  * + \hat R T \log a_k. \f] The quantity \f$\mu_k^0(T,P)\f$ is
118  * the chemical potential at unit activity, which depends only
119  * on temperature and pressure.
120  * @{
121  */
122 
123  /**
124  * The standard concentration \f$ C^0_k \f$ used to normalize
125  * the generalized concentration. In many cases, this quantity
126  * will be the same for all species in a phase - for example,
127  * for an ideal gas \f$ C^0_k = P/\hat R T \f$. For this
128  * reason, this method returns a single value, instead of an
129  * array. However, for phases in which the standard
130  * concentration is species-specific (e.g. surface species of
131  * different sizes), this method may be called with an
132  * optional parameter indicating the species.
133  *
134  * @param k species index. Defaults to zero.
135  */
136  virtual doublereal standardConcentration(size_t k=0) const;
137 
138  /**
139  * Returns the natural logarithm of the standard
140  * concentration of the kth species
141  *
142  * @param k species index
143  */
144  virtual doublereal logStandardConc(size_t k=0) const;
145  //@}
146  /// @name Partial Molar Properties of the Solution
147  //@{
148 
149  /**
150  * Get the species electrochemical potentials.
151  * These are partial molar quantities.
152  * This method adds a term \f$ Fz_k \phi_k \f$ to the
153  * to each chemical potential.
154  *
155  * Units: J/kmol
156  *
157  * @param mu output vector containing the species electrochemical potentials.
158  * Length: m_kk.
159  */
160  void getElectrochemPotentials(doublereal* mu) const;
161  //@}
162 
163  //! Calculate pseudo binary mole fractions
164  virtual void calcPseudoBinaryMoleFractions() const;
165 
166  //@}
167  /// @name Initialization
168  /// The following methods are used in the process of constructing
169  /// the phase and setting its parameters from a specification in an
170  /// input file. They are not normally used in application programs.
171  /// To see how they are used, see files importCTML.cpp and
172  /// ThermoFactory.cpp.
173 
174  /*!
175  * @internal Initialize. This method is provided to allow
176  * subclasses to perform any initialization required after all
177  * species have been added. For example, it might be used to
178  * resize internal work arrays that must have an entry for
179  * each species. The base class implementation does nothing,
180  * and subclasses that do not require initialization do not
181  * need to overload this method. When importing a CTML phase
182  * description, this method is called just prior to returning
183  * from function importPhase.
184  *
185  * @see importCTML.cpp
186  */
187  virtual void initThermo();
188 
189  /**
190  * Import and initialize a ThermoPhase object
191  *
192  * @param phaseNode This object must be the phase node of a
193  * complete XML tree
194  * description of the phase, including all of the
195  * species data. In other words while "phase" must
196  * point to an XML phase object, it must have
197  * sibling nodes "speciesData" that describe
198  * the species in the phase.
199  * @param id ID of the phase. If nonnull, a check is done
200  * to see if phaseNode is pointing to the phase
201  * with the correct id.
202  */
203  void initThermoXML(XML_Node& phaseNode, const std::string& id);
204 
205  //! returns a summary of the state of the phase as a string
206  /*!
207  * @param show_thermo If true, extra information is printed out
208  * about the thermodynamic state of the system.
209  */
210  virtual std::string report(bool show_thermo = true) const;
211 
212 private:
213  //! Initialize lengths of local variables after all species have
214  //! been identified.
215  void initLengths();
216 
217  //! Error function
218  /*!
219  * Print an error string and exit
220  *
221  * @param msg Message to be printed
222  */
223  doublereal err(const std::string& msg) const;
224 
225 protected:
226  int PBType_;
227 
228  //! Number of pseudo binary species
230 
231  //! index of special species
233 
234  mutable std::vector<doublereal> PBMoleFractions_;
235 
236  std::vector<int> cationList_;
237  size_t numCationSpecies_;
238 
239  std::vector<int>anionList_;
240  size_t numAnionSpecies_;
241 
242  std::vector<int> passThroughList_;
243  size_t numPassThroughSpecies_;
244  size_t neutralPBindexStart;
245 
246  ThermoPhase* cationPhase_;
247 
248  ThermoPhase* anionPhase_;
249 
250  mutable std::vector<doublereal> moleFractionsTmp_;
251 };
252 
253 #define PBTYPE_PASSTHROUGH 0
254 #define PBTYPE_SINGLEANION 1
255 #define PBTYPE_SINGLECATION 2
256 #define PBTYPE_MULTICATIONANION 3
257 
258 
259 
260 }
261 
262 #endif
virtual doublereal standardConcentration(size_t k=0) const
The standard concentration used to normalize the generalized concentration.
PseudoBinaryVPSSTP & operator=(const PseudoBinaryVPSSTP &b)
Assignment operator.
void initThermoXML(XML_Node &phaseNode, const std::string &id)
Import and initialize a ThermoPhase object.
void initLengths()
Initialize lengths of local variables after all species have been identified.
virtual std::string report(bool show_thermo=true) const
returns a summary of the state of the phase as a string
virtual int eosType() const
Equation of state type flag.
size_t numPBSpecies_
Number of pseudo binary species.
Class XML_Node is a tree-based representation of the contents of an XML file.
Definition: xml.h:100
virtual ThermoPhase * duplMyselfAsThermoPhase() const
Duplication routine for objects which inherit from ThermoPhase.
Base class for a phase with thermodynamic properties.
Definition: ThermoPhase.h:101
virtual doublereal logStandardConc(size_t k=0) const
Returns the natural logarithm of the standard concentration of the kth species.
void getElectrochemPotentials(doublereal *mu) const
Get the species electrochemical potentials.
virtual void calcPseudoBinaryMoleFractions() const
Calculate pseudo binary mole fractions.
Header for intermediate ThermoPhase object for phases which employ gibbs excess free energy based for...
doublereal err(const std::string &msg) const
Error function.
size_t indexSpecialSpecies_
index of special species