Cantera  2.3.0
LatticeSolidPhase.h
Go to the documentation of this file.
1 /**
2  * @file LatticeSolidPhase.h Header for a simple thermodynamics model of a bulk
3  * solid phase derived from ThermoPhase, assuming an ideal solution model
4  * based on a lattice of solid atoms (see \ref thermoprops and class \link
5  * Cantera::LatticeSolidPhase LatticeSolidPhase\endlink).
6  */
7 
8 // This file is part of Cantera. See License.txt in the top-level directory or
9 // at http://www.cantera.org/license.txt for license and copyright information.
10 
11 #ifndef CT_LATTICESOLID_H
12 #define CT_LATTICESOLID_H
13 
14 #include "ThermoPhase.h"
15 #include "LatticePhase.h"
16 
17 namespace Cantera
18 {
19 
20 //! A phase that is comprised of a fixed additive combination of other lattice
21 //! phases
22 /*!
23  * This is the main way %Cantera describes semiconductors and other solid
24  * phases. This ThermoPhase object calculates its properties as a sum over other
25  * LatticePhase objects. Each of the LatticePhase objects is a ThermoPhase
26  * object by itself.
27  *
28  * The results from this LatticeSolidPhase model reduces to the LatticePhase
29  * model when there is one lattice phase and the molar densities of the
30  * sublattice and the molar density within the LatticeSolidPhase have the same
31  * values.
32  *
33  * The mole fraction vector is redefined witin the the LatticeSolidPhase object.
34  * Each of the mole fractions sum to one on each of the sublattices. The
35  * routine getMoleFraction() and setMoleFraction() have been redefined to use
36  * this convention.
37  *
38  * ## Specification of Species Standard State Properties
39  *
40  * The standard state properties are calculated in the normal way for each of
41  * the sublattices. The normal way here means that a thermodynamic polynomial in
42  * temperature is developed. Also, a constant volume approximation for the
43  * pressure dependence is assumed. All of these properties are on a Joules per
44  * kmol of sublattice constituent basis.
45  *
46  * ## Specification of Solution Thermodynamic Properties
47  *
48  * The sum over the LatticePhase objects is carried out by weighting each
49  * LatticePhase object value with the molar density (kmol m-3) of its
50  * LatticePhase. Then the resulting quantity is divided by the molar density of
51  * the total compound. The LatticeSolidPhase object therefore only contains a
52  * listing of the number of LatticePhase object that comprises the solid, and it
53  * contains a value for the molar density of the entire mixture. This is the
54  * same thing as saying that
55  *
56  * \f[
57  * L_i = L^{solid} \theta_i
58  * \f]
59  *
60  * \f$ L_i \f$ is the molar volume of the ith lattice. \f$ L^{solid} \f$ is the
61  * molar volume of the entire solid. \f$ \theta_i \f$ is a fixed weighting
62  * factor for the ith lattice representing the lattice stoichiometric
63  * coefficient. For this object the \f$ \theta_i \f$ values are fixed.
64  *
65  * Let's take FeS2 as an example, which may be thought of as a combination of
66  * two lattices: Fe and S lattice. The Fe sublattice has a molar density of 1
67  * gmol cm-3. The S sublattice has a molar density of 2 gmol cm-3. We then
68  * define the LatticeSolidPhase object as having a nominal composition of FeS2,
69  * and having a molar density of 1 gmol cm-3. All quantities pertaining to the
70  * FeS2 compound will be have weights associated with the sublattices. The Fe
71  * sublattice will have a weight of 1.0 associated with it. The S sublattice
72  * will have a weight of 2.0 associated with it.
73  *
74  * ### Specification of Solution Density Properties
75  *
76  * Currently, molar density is not a constant within the object, even though the
77  * species molar volumes are a constant. The basic idea is that a swelling of
78  * one of the sublattices will result in a swelling of of all of the lattices.
79  * Therefore, the molar volumes of the individual lattices are not independent
80  * of one another.
81  *
82  * The molar volume of the Lattice solid is calculated from the following
83  * formula
84  *
85  * \f[
86  * V = \sum_i{ \theta_i V_i^{lattice}}
87  * \f]
88  *
89  * where \f$ V_i^{lattice} \f$ is the molar volume of the ith sublattice. This
90  * is calculated from the following standard formula.
91  *
92  * \f[
93  * V_i = \sum_k{ X_k V_k}
94  * \f]
95  *
96  * where k is a species in the ith sublattice.
97  *
98  * The mole fraction vector is redefined witin the the LatticeSolidPhase object.
99  * Each of the mole fractions sum to one on each of the sublattices. The
100  * routine getMoleFraction() and setMoleFraction() have been redefined to use
101  * this convention.
102  *
103  * (This object is still under construction)
104  */
106 {
107 public:
108  //! Base empty constructor
110 
111  LatticeSolidPhase(const LatticeSolidPhase& right);
112  LatticeSolidPhase& operator=(const LatticeSolidPhase& right);
113  virtual ~LatticeSolidPhase();
114  virtual ThermoPhase* duplMyselfAsThermoPhase() const;
115 
116  //! Equation of state type flag.
117  /*!
118  * Returns cLatticeSolid, listed in mix_defs.h.
119  * @deprecated To be removed after Cantera 2.3.
120  */
121  virtual int eosType() const {
122  warn_deprecated("LatticeSolidPhase::eosType",
123  "To be removed after Cantera 2.3.");
124  return cLatticeSolid;
125  }
126  virtual std::string type() const {
127  return "LatticeSolid";
128  }
129 
130  virtual doublereal minTemp(size_t k = npos) const;
131  virtual doublereal maxTemp(size_t k = npos) const;
132  virtual doublereal refPressure() const;
133 
134  //! This method returns the convention used in specification of the standard
135  //! state, of which there are currently two, temperature based, and variable
136  //! pressure based.
137  /*!
138  * All of the thermo is determined by slave ThermoPhase routines.
139  */
140  virtual int standardStateConvention() const {
141  return cSS_CONVENTION_SLAVE;
142  }
143 
144  //! Return the Molar Enthalpy. Units: J/kmol.
145  /*!
146  * The molar enthalpy is determined by the following formula, where \f$
147  * \theta_n \f$ is the lattice stoichiometric coefficient of the nth lattice
148  *
149  * \f[
150  * \tilde h(T,P) = {\sum_n \theta_n \tilde h_n(T,P) }
151  * \f]
152  *
153  * \f$ \tilde h_n(T,P) \f$ is the enthalpy of the nth lattice.
154  *
155  * units J/kmol
156  */
157  virtual doublereal enthalpy_mole() const;
158 
159  //! Return the Molar Internal Energy. Units: J/kmol.
160  /*!
161  * The molar enthalpy is determined by the following formula, where \f$
162  * \theta_n \f$ is the lattice stoichiometric coefficient of the nth lattice
163  *
164  * \f[
165  * \tilde u(T,P) = {\sum_n \theta_n \tilde u_n(T,P) }
166  * \f]
167  *
168  * \f$ \tilde u_n(T,P) \f$ is the internal energy of the nth lattice.
169  *
170  * units J/kmol
171  */
172  virtual doublereal intEnergy_mole() const;
173 
174  //! Return the Molar Entropy. Units: J/kmol/K.
175  /*!
176  * The molar enthalpy is determined by the following formula, where \f$
177  * \theta_n \f$ is the lattice stoichiometric coefficient of the nth lattice
178  *
179  * \f[
180  * \tilde s(T,P) = \sum_n \theta_n \tilde s_n(T,P)
181  * \f]
182  *
183  * \f$ \tilde s_n(T,P) \f$ is the molar entropy of the nth lattice.
184  *
185  * units J/kmol/K
186  */
187  virtual doublereal entropy_mole() const;
188 
189  //! Return the Molar Gibbs energy. Units: J/kmol.
190  /*!
191  * The molar Gibbs free energy is determined by the following formula, where
192  * \f$ \theta_n \f$ is the lattice stoichiometric coefficient of the nth
193  * lattice
194  *
195  * \f[
196  * \tilde h(T,P) = {\sum_n \theta_n \tilde h_n(T,P) }
197  * \f]
198  *
199  * \f$ \tilde h_n(T,P) \f$ is the enthalpy of the nth lattice.
200  *
201  * units J/kmol
202  */
203  virtual doublereal gibbs_mole() const;
204 
205  //! Return the constant pressure heat capacity. Units: J/kmol/K
206  /*!
207  * The molar constant pressure heat capacity is determined by the following
208  * formula, where \f$ C_n \f$ is the lattice molar density of the nth
209  * lattice, and \f$ C_T \f$ is the molar density of the solid compound.
210  *
211  * \f[
212  * \tilde c_{p,n}(T,P) = \frac{\sum_n C_n \tilde c_{p,n}(T,P) }{C_T},
213  * \f]
214  *
215  * \f$ \tilde c_{p,n}(T,P) \f$ is the heat capacity of the nth lattice.
216  *
217  * units J/kmol/K
218  */
219  virtual doublereal cp_mole() const;
220 
221  //! Return the constant volume heat capacity. Units: J/kmol/K
222  /*!
223  * The molar constant volume heat capacity is determined by the following
224  * formula, where \f$ C_n \f$ is the lattice molar density of the nth
225  * lattice, and \f$ C_T \f$ is the molar density of the solid compound.
226  *
227  * \f[
228  * \tilde c_{v,n}(T,P) = \frac{\sum_n C_n \tilde c_{v,n}(T,P) }{C_T},
229  * \f]
230  *
231  * \f$ \tilde c_{v,n}(T,P) \f$ is the heat capacity of the nth lattice.
232  *
233  * units J/kmol/K
234  */
235  virtual doublereal cv_mole() const {
236  return cp_mole();
237  }
238 
239  //! Report the Pressure. Units: Pa.
240  /*!
241  * This method simply returns the stored pressure value.
242  */
243  virtual doublereal pressure() const {
244  return m_press;
245  }
246 
247  //! Set the pressure at constant temperature. Units: Pa.
248  /*!
249  * @param p Pressure (units - Pa)
250  */
251  virtual void setPressure(doublereal p);
252 
253  //! Calculate the density of the solid mixture
254  /*!
255  * The formula for this is
256  *
257  * \f[
258  * \rho = \sum_n{ \rho_n \theta_n }
259  * \f]
260  *
261  * where \f$ \rho_n \f$ is the density of the nth sublattice
262  */
263  doublereal calcDensity();
264 
265  //! Set the mole fractions to the specified values, and then normalize them
266  //! so that they sum to 1.0 for each of the subphases
267  /*!
268  * On input, the mole fraction vector is assumed to sum to one for each of
269  * the sublattices. The sublattices are updated with this mole fraction
270  * vector. The mole fractions are also stored within this object, after they
271  * are normalized to one by dividing by the number of sublattices.
272  *
273  * @param x Input vector of mole fractions. There is no restriction on the
274  * sum of the mole fraction vector. Internally, this object will
275  * pass portions of this vector to the sublattices which assume
276  * that the portions individually sum to one. Length is m_kk.
277  */
278  virtual void setMoleFractions(const doublereal* const x);
279 
280  //! Get the species mole fraction vector.
281  /*!
282  * On output the mole fraction vector will sum to one for each of the
283  * subphases which make up this phase.
284  *
285  * @param x On return, x contains the mole fractions. Must have a length
286  * greater than or equal to the number of species.
287  */
288  virtual void getMoleFractions(doublereal* const x) const;
289 
290  virtual doublereal moleFraction(const int k) const {
291  throw NotImplementedError("LatticeSolidPhase::moleFraction");
292  }
293 
294  virtual void getMassFractions(doublereal* const y) const {
295  throw NotImplementedError("LatticeSolidPhase::getMassFractions");
296  }
297 
298  virtual doublereal massFraction(const int k) const {
299  throw NotImplementedError("LatticeSolidPhase::massFraction");
300  }
301 
302  virtual void setMassFractions(const doublereal* const y) {
303  throw NotImplementedError("LatticeSolidPhase::setMassFractions");
304  }
305 
306  virtual void setMassFractions_NoNorm(const doublereal* const y) {
307  throw NotImplementedError("LatticeSolidPhase::setMassFractions_NoNorm");
308  }
309 
310  virtual void getConcentrations(doublereal* const c) const {
311  throw NotImplementedError("LatticeSolidPhase::getConcentrations");
312  }
313 
314  virtual doublereal concentration(int k) const {
315  throw NotImplementedError("LatticeSolidPhase::concentration");
316  }
317 
318  virtual void setConcentrations(const doublereal* const conc) {
319  throw NotImplementedError("LatticeSolidPhase::setConcentrations");
320  }
321 
322  virtual void getActivityConcentrations(doublereal* c) const;
323 
324  virtual void getActivityCoefficients(doublereal* ac) const;
325 
326  //! Get the species chemical potentials. Units: J/kmol.
327  /*!
328  * This function returns a vector of chemical potentials of the species in
329  * solution at the current temperature, pressure and mole fraction of the
330  * solution.
331  *
332  * This returns the underlying lattice chemical potentials, as the units are
333  * kmol-1 of the sublattice species.
334  *
335  * @param mu Output vector of species chemical potentials. Length: m_kk.
336  * Units: J/kmol
337  */
338  virtual void getChemPotentials(doublereal* mu) const;
339 
340  //! Returns an array of partial molar enthalpies for the species in the
341  //! mixture.
342  /*!
343  * Units (J/kmol). For this phase, the partial molar enthalpies are equal to
344  * the pure species enthalpies
345  * \f[
346  * \bar h_k(T,P) = \hat h^{ref}_k(T) + (P - P_{ref}) \hat V^0_k
347  * \f]
348  * The reference-state pure-species enthalpies, \f$ \hat h^{ref}_k(T) \f$,
349  * at the reference pressure,\f$ P_{ref} \f$, are computed by the species
350  * thermodynamic property manager. They are polynomial functions of
351  * temperature.
352  * @see MultiSpeciesThermo
353  *
354  * @param hbar Output vector containing partial molar enthalpies.
355  * Length: m_kk.
356  */
357  virtual void getPartialMolarEnthalpies(doublereal* hbar) const;
358 
359  /**
360  * Returns an array of partial molar entropies of the species in the
361  * solution. Units: J/kmol/K. For this phase, the partial molar entropies
362  * are equal to the pure species entropies plus the ideal solution
363  * contribution.
364  * \f[
365  * \bar s_k(T,P) = \hat s^0_k(T) - R log(X_k)
366  * \f]
367  * The reference-state pure-species entropies,\f$ \hat s^{ref}_k(T) \f$, at
368  * the reference pressure, \f$ P_{ref} \f$, are computed by the species
369  * thermodynamic property manager. They are polynomial functions of
370  * temperature.
371  * @see MultiSpeciesThermo
372  *
373  * @param sbar Output vector containing partial molar entropies.
374  * Length: m_kk.
375  */
376  virtual void getPartialMolarEntropies(doublereal* sbar) const;
377 
378  /**
379  * Returns an array of partial molar Heat Capacities at constant pressure of
380  * the species in the solution. Units: J/kmol/K. For this phase, the partial
381  * molar heat capacities are equal to the standard state heat capacities.
382  *
383  * @param cpbar Output vector of partial heat capacities. Length: m_kk.
384  */
385  virtual void getPartialMolarCp(doublereal* cpbar) const;
386 
387  /**
388  * returns an array of partial molar volumes of the species in the solution.
389  * Units: m^3 kmol-1.
390  *
391  * For this solution, the partial molar volumes are equal to the constant
392  * species molar volumes.
393  *
394  * @param vbar Output vector of partial molar volumes. Length: m_kk.
395  */
396  virtual void getPartialMolarVolumes(doublereal* vbar) const;
397 
398  //! Get the array of standard state chemical potentials at unit activity for
399  //! the species at their standard states at the current *T* and *P* of the
400  //! solution.
401  /*!
402  * These are the standard state chemical potentials \f$ \mu^0_k(T,P) \f$.
403  * The values are evaluated at the current temperature and pressure of the
404  * solution.
405  *
406  * This returns the underlying lattice standard chemical potentials, as the
407  * units are kmol-1 of the sublattice species.
408  *
409  * @param mu0 Output vector of chemical potentials.
410  * Length: m_kk. Units: J/kmol
411  */
412  virtual void getStandardChemPotentials(doublereal* mu0) const;
413 
414  virtual doublereal standardConcentration(size_t k=0) const;
415  virtual doublereal logStandardConc(size_t k=0) const;
416 
417  //@}
418  /// @name Thermodynamic Values for the Species Reference States
419  //@{
420 
421  virtual void getGibbs_RT_ref(doublereal* grt) const;
422  virtual void getGibbs_ref(doublereal* g) const;
423 
424  virtual bool addSpecies(shared_ptr<Species> spec);
425  virtual void initThermo();
426 
427  virtual void setParametersFromXML(const XML_Node& eosdata);
428 
429  //! Set the Lattice mole fractions using a string
430  /*!
431  * @param n Integer value of the lattice whose mole fractions are being set
432  * @param x string containing Name:value pairs that will specify the mole
433  * fractions of species on a particular lattice
434  */
435  void setLatticeMoleFractionsByName(int n, const std::string& x);
436 
437  virtual void modifyOneHf298SS(const size_t k, const doublereal Hf298New);
438  virtual void resetHf298(const size_t k=npos);
439 
440 protected:
441  //! Current value of the pressure
442  doublereal m_press;
443 
444  //! Current value of the molar density
445  doublereal m_molar_density;
446 
447  //! Vector of sublattic ThermoPhase objects
448  std::vector<LatticePhase*> m_lattice;
449 
450  //! Vector of mole fractions
451  /*!
452  * Note these mole fractions sum to one when summed over all phases.
453  * However, this is not what's passed down to the lower m_lattice objects.
454  */
455  mutable vector_fp m_x;
456 
457  //! Lattice stoichiometric coefficients
459 
460  //! Temporary vector
461  mutable vector_fp tmpV_;
462 
463  std::vector<size_t> lkstart_;
464 
465 private:
466  //! Update the reference thermodynamic functions
467  void _updateThermo() const;
468 };
469 }
470 
471 #endif
virtual void getGibbs_RT_ref(doublereal *grt) const
Returns the vector of nondimensional Gibbs Free Energies of the reference state at the current temper...
virtual void modifyOneHf298SS(const size_t k, const doublereal Hf298New)
Modify the value of the 298 K Heat of Formation of one species in the phase (J kmol-1) ...
virtual void getPartialMolarEntropies(doublereal *sbar) const
Returns an array of partial molar entropies of the species in the solution.
virtual void getMoleFractions(doublereal *const x) const
Get the species mole fraction vector.
virtual doublereal logStandardConc(size_t k=0) const
Natural logarithm of the standard concentration of the kth species.
std::vector< LatticePhase * > m_lattice
Vector of sublattic ThermoPhase objects.
virtual void initThermo()
Initialize the ThermoPhase object after all species have been set up.
An error indicating that an unimplemented function has been called.
Definition: ctexceptions.h:193
doublereal calcDensity()
Calculate the density of the solid mixture.
virtual std::string type() const
String indicating the thermodynamic model implemented.
const size_t npos
index returned by functions to indicate "no position"
Definition: ct_defs.h:165
vector_fp theta_
Lattice stoichiometric coefficients.
LatticeSolidPhase()
Base empty constructor.
virtual void getGibbs_ref(doublereal *g) const
Returns the vector of the Gibbs function of the reference state at the current temperature of the sol...
virtual void setMoleFractions(const doublereal *const x)
Set the mole fractions to the specified values, and then normalize them so that they sum to 1...
Class XML_Node is a tree-based representation of the contents of an XML file.
Definition: xml.h:97
void warn_deprecated(const std::string &method, const std::string &extra)
Print a warning indicating that method is deprecated.
Definition: global.cpp:54
virtual void getPartialMolarCp(doublereal *cpbar) const
Returns an array of partial molar Heat Capacities at constant pressure of the species in the solution...
virtual doublereal intEnergy_mole() const
Return the Molar Internal Energy. Units: J/kmol.
virtual void getPartialMolarEnthalpies(doublereal *hbar) const
Returns an array of partial molar enthalpies for the species in the mixture.
virtual ThermoPhase * duplMyselfAsThermoPhase() const
Duplication routine for objects which inherit from ThermoPhase.
virtual void setMassFractions_NoNorm(const doublereal *const y)
Set the mass fractions to the specified values without normalizing.
virtual void setPressure(doublereal p)
Set the pressure at constant temperature. Units: Pa.
Base class for a phase with thermodynamic properties.
Definition: ThermoPhase.h:93
virtual doublereal standardConcentration(size_t k=0) const
Return the standard concentration for the kth species.
void _updateThermo() const
Update the reference thermodynamic functions.
virtual void resetHf298(const size_t k=npos)
Restore the original heat of formation of one or more species.
doublereal m_molar_density
Current value of the molar density.
virtual void getChemPotentials(doublereal *mu) const
Get the species chemical potentials. Units: J/kmol.
vector_fp tmpV_
Temporary vector.
virtual void getActivityCoefficients(doublereal *ac) const
Get the array of non-dimensional molar-based activity coefficients at the current solution temperatur...
doublereal m_press
Current value of the pressure.
virtual doublereal entropy_mole() const
Return the Molar Entropy. Units: J/kmol/K.
void setLatticeMoleFractionsByName(int n, const std::string &x)
Set the Lattice mole fractions using a string.
virtual void getActivityConcentrations(doublereal *c) const
This method returns an array of generalized concentrations.
virtual int eosType() const
Equation of state type flag.
vector_fp m_x
Vector of mole fractions.
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
Definition: ct_defs.h:157
virtual void setParametersFromXML(const XML_Node &eosdata)
Set equation of state parameter values from XML entries.
A phase that is comprised of a fixed additive combination of other lattice phases.
virtual int standardStateConvention() const
This method returns the convention used in specification of the standard state, of which there are cu...
virtual bool addSpecies(shared_ptr< Species > spec)
virtual doublereal maxTemp(size_t k=npos) const
Maximum temperature for which the thermodynamic data for the species are valid.
virtual doublereal cv_mole() const
Return the constant volume heat capacity. Units: J/kmol/K.
virtual doublereal refPressure() const
Returns the reference pressure in Pa.
virtual doublereal pressure() const
Report the Pressure. Units: Pa.
virtual doublereal minTemp(size_t k=npos) const
Minimum temperature for which the thermodynamic data for the species or phase are valid...
virtual void getPartialMolarVolumes(doublereal *vbar) const
returns an array of partial molar volumes of the species in the solution.
Namespace for the Cantera kernel.
Definition: application.cpp:29
virtual doublereal cp_mole() const
Return the constant pressure heat capacity. Units: J/kmol/K.
virtual void getStandardChemPotentials(doublereal *mu0) const
Get the array of standard state chemical potentials at unit activity for the species at their standar...
Header file for class ThermoPhase, the base class for phases with thermodynamic properties, and the text for the Module thermoprops (see Thermodynamic Properties and class ThermoPhase).
virtual doublereal enthalpy_mole() const
Return the Molar Enthalpy. Units: J/kmol.
virtual doublereal gibbs_mole() const
Return the Molar Gibbs energy. Units: J/kmol.
Header for a simple thermodynamics model of a bulk phase derived from ThermoPhase, assuming a lattice of solid atoms (see Thermodynamic Properties and class LatticePhase).
virtual void setMassFractions(const doublereal *const y)
Set the mass fractions to the specified values and normalize them.
const int cSS_CONVENTION_SLAVE
Standard state thermodynamics is obtained from slave ThermoPhase objects.
Definition: ThermoPhase.h:40
virtual void setConcentrations(const doublereal *const conc)
Set the concentrations to the specified values within the phase.