Cantera  2.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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  *
65  * @deprecated Incomplete and untested. To be removed after Cantera 2.2.
66  */
68 {
69 public:
70  /// Constructor
71  /*!
72  * This doesn't do much more than initialize constants with
73  * default values for water at 25C. Water molecular weight
74  * comes from the default elements.xml file. It actually
75  * differs slightly from the IAPWS95 value of 18.015268. However,
76  * density conservation and therefore element conservation
77  * is the more important principle to follow.
78  */
80 
81  //! Copy constructor
82  /*!
83  * @param b class to be copied
84  */
86 
87  /// Assignment operator
88  /*!
89  * @param b class to be copied.
90  */
92 
93  //! Duplication routine for objects which inherit from ThermoPhase.
94  /*!
95  * This virtual routine can be used to duplicate ThermoPhase objects
96  * inherited from ThermoPhase even if the application only has
97  * a pointer to ThermoPhase to work with.
98  */
99  virtual ThermoPhase* duplMyselfAsThermoPhase() const;
100 
101  /**
102  * @name Activities, Standard States, and Activity Concentrations
103  *
104  * The activity \f$a_k\f$ of a species in solution is
105  * related to the chemical potential by \f[ \mu_k = \mu_k^0(T)
106  * + \hat R T \log a_k. \f] The quantity \f$\mu_k^0(T,P)\f$ is
107  * the chemical potential at unit activity, which depends only
108  * on temperature and pressure.
109  * @{
110  */
111 
112  /**
113  * The standard concentration \f$ C^0_k \f$ used to normalize
114  * the generalized concentration. In many cases, this quantity
115  * will be the same for all species in a phase - for example,
116  * for an ideal gas \f$ C^0_k = P/\hat R T \f$. For this
117  * reason, this method returns a single value, instead of an
118  * array. However, for phases in which the standard
119  * concentration is species-specific (e.g. surface species of
120  * different sizes), this method may be called with an
121  * optional parameter indicating the species.
122  *
123  * @param k species index. Defaults to zero.
124  */
125  virtual doublereal standardConcentration(size_t k=0) const;
126 
127  //@}
128  /// @name Partial Molar Properties of the Solution
129  //@{
130 
131  /**
132  * Get the species electrochemical potentials.
133  * These are partial molar quantities.
134  * This method adds a term \f$ Fz_k \phi_k \f$ to the
135  * to each chemical potential.
136  *
137  * Units: J/kmol
138  *
139  * @param mu output vector containing the species electrochemical potentials.
140  * Length: m_kk.
141  */
142  void getElectrochemPotentials(doublereal* mu) const;
143  //@}
144 
145  //! Calculate pseudo binary mole fractions
146  virtual void calcPseudoBinaryMoleFractions() const;
147 
148  //@}
149  /// @name Initialization
150  /// The following methods are used in the process of constructing
151  /// the phase and setting its parameters from a specification in an
152  /// input file. They are not normally used in application programs.
153  /// To see how they are used, see importPhase().
154 
155  /*!
156  * @internal Initialize. This method is provided to allow
157  * subclasses to perform any initialization required after all
158  * species have been added. For example, it might be used to
159  * resize internal work arrays that must have an entry for
160  * each species. The base class implementation does nothing,
161  * and subclasses that do not require initialization do not
162  * need to overload this method. When importing a CTML phase
163  * description, this method is called just prior to returning
164  * from function importPhase().
165  */
166  virtual void initThermo();
167 
168  /**
169  * Import and initialize a ThermoPhase object
170  *
171  * @param phaseNode This object must be the phase node of a
172  * complete XML tree
173  * description of the phase, including all of the
174  * species data. In other words while "phase" must
175  * point to an XML phase object, it must have
176  * sibling nodes "speciesData" that describe
177  * the species in the phase.
178  * @param id ID of the phase. If nonnull, a check is done
179  * to see if phaseNode is pointing to the phase
180  * with the correct id.
181  */
182  void initThermoXML(XML_Node& phaseNode, const std::string& id);
183 
184  virtual std::string report(bool show_thermo=true,
185  doublereal threshold=1e-14) const;
186 
187 private:
188  //! Initialize lengths of local variables after all species have
189  //! been identified.
190  void initLengths();
191 
192 protected:
193  int PBType_;
194 
195  //! Number of pseudo binary species
197 
198  //! index of special species
200 
201  mutable std::vector<doublereal> PBMoleFractions_;
202 
203  std::vector<int> cationList_;
204  size_t numCationSpecies_;
205 
206  std::vector<int>anionList_;
207  size_t numAnionSpecies_;
208 
209  std::vector<int> passThroughList_;
210  size_t numPassThroughSpecies_;
211  size_t neutralPBindexStart;
212 
213  ThermoPhase* cationPhase_;
214 
215  ThermoPhase* anionPhase_;
216 
217  mutable std::vector<doublereal> moleFractionsTmp_;
218 };
219 
220 #define PBTYPE_PASSTHROUGH 0
221 #define PBTYPE_SINGLEANION 1
222 #define PBTYPE_SINGLECATION 2
223 #define PBTYPE_MULTICATIONANION 3
224 
225 }
226 
227 #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.
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:97
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...
size_t indexSpecialSpecies_
index of special species
virtual std::string report(bool show_thermo=true, doublereal threshold=1e-14) const
returns a summary of the state of the phase as a string