Cantera 2.6.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 https://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
16namespace Cantera
17{
18
19//! A phase that is comprised of a fixed additive combination of other lattice
20//! phases
21/*!
22 * This is the main way %Cantera describes semiconductors and other solid
23 * phases. This ThermoPhase object calculates its properties as a sum over other
24 * LatticePhase objects. Each of the LatticePhase objects is a ThermoPhase
25 * object by itself.
26 *
27 * The results from this LatticeSolidPhase model reduces to the LatticePhase
28 * model when there is one lattice phase and the molar densities of the
29 * sublattice and the molar density within the LatticeSolidPhase have the same
30 * values.
31 *
32 * The mole fraction vector is redefined within the LatticeSolidPhase object.
33 * Each of the mole fractions sum to one on each of the sublattices. The
34 * routine getMoleFraction() and setMoleFraction() have been redefined to use
35 * this convention.
36 *
37 * ## Specification of Species Standard State Properties
38 *
39 * The standard state properties are calculated in the normal way for each of
40 * the sublattices. The normal way here means that a thermodynamic polynomial in
41 * temperature is developed. Also, a constant volume approximation for the
42 * pressure dependence is assumed. All of these properties are on a Joules per
43 * kmol of sublattice constituent basis.
44 *
45 * ## Specification of Solution Thermodynamic Properties
46 *
47 * The sum over the LatticePhase objects is carried out by weighting each
48 * LatticePhase object value with the molar density (kmol m-3) of its
49 * LatticePhase. Then the resulting quantity is divided by the molar density of
50 * the total compound. The LatticeSolidPhase object therefore only contains a
51 * listing of the number of LatticePhase object that comprises the solid, and it
52 * contains a value for the molar density of the entire mixture. This is the
53 * same thing as saying that
54 *
55 * \f[
56 * L_i = L^{solid} \theta_i
57 * \f]
58 *
59 * \f$ L_i \f$ is the molar volume of the ith lattice. \f$ L^{solid} \f$ is the
60 * molar volume of the entire solid. \f$ \theta_i \f$ is a fixed weighting
61 * factor for the ith lattice representing the lattice stoichiometric
62 * coefficient. For this object the \f$ \theta_i \f$ values are fixed.
63 *
64 * Let's take FeS2 as an example, which may be thought of as a combination of
65 * two lattices: Fe and S lattice. The Fe sublattice has a molar density of 1
66 * gmol cm-3. The S sublattice has a molar density of 2 gmol cm-3. We then
67 * define the LatticeSolidPhase object as having a nominal composition of FeS2,
68 * and having a molar density of 1 gmol cm-3. All quantities pertaining to the
69 * FeS2 compound will be have weights associated with the sublattices. The Fe
70 * sublattice will have a weight of 1.0 associated with it. The S sublattice
71 * will have a weight of 2.0 associated with it.
72 *
73 * ### Specification of Solution Density Properties
74 *
75 * Currently, molar density is not a constant within the object, even though the
76 * species molar volumes are a constant. The basic idea is that a swelling of
77 * one of the sublattices will result in a swelling of of all of the lattices.
78 * Therefore, the molar volumes of the individual lattices are not independent
79 * of one another.
80 *
81 * The molar volume of the Lattice solid is calculated from the following
82 * formula
83 *
84 * \f[
85 * V = \sum_i{ \theta_i V_i^{lattice}}
86 * \f]
87 *
88 * where \f$ V_i^{lattice} \f$ is the molar volume of the ith sublattice. This
89 * is calculated from the following standard formula.
90 *
91 * \f[
92 * V_i = \sum_k{ X_k V_k}
93 * \f]
94 *
95 * where k is a species in the ith sublattice.
96 *
97 * The mole fraction vector is redefined witin the the LatticeSolidPhase object.
98 * Each of the mole fractions sum to one on each of the sublattices. The
99 * routine getMoleFraction() and setMoleFraction() have been redefined to use
100 * this convention.
101 *
102 * (This object is still under construction)
103 */
105{
106public:
107 //! Base empty constructor
109
110 virtual std::string type() const {
111 return "LatticeSolid";
112 }
113
114 //! String indicating the mechanical phase of the matter in this Phase.
115 /*!
116 * `LatticeSolid` phases only represent solids.
117 */
118 virtual std::string phaseOfMatter() const {
119 return "solid";
120 }
121
122 virtual bool isCompressible() const {
123 return false;
124 }
125
126 std::map<std::string, size_t> nativeState() const {
127 return { {"T", 0}, {"P", 1}, {"X", 2} };
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 {
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 Units standardConcentrationUnits() const;
323
324 virtual void getActivityConcentrations(doublereal* c) const;
325
326 virtual void getActivityCoefficients(doublereal* ac) const;
327
328 //! Get the species chemical potentials. Units: J/kmol.
329 /*!
330 * This function returns a vector of chemical potentials of the species in
331 * solution at the current temperature, pressure and mole fraction of the
332 * solution.
333 *
334 * This returns the underlying lattice chemical potentials, as the units are
335 * kmol-1 of the sublattice species.
336 *
337 * @param mu Output vector of species chemical potentials. Length: m_kk.
338 * Units: J/kmol
339 */
340 virtual void getChemPotentials(doublereal* mu) const;
341
342 //! Returns an array of partial molar enthalpies for the species in the
343 //! mixture.
344 /*!
345 * Units (J/kmol). For this phase, the partial molar enthalpies are equal to
346 * the pure species enthalpies
347 * \f[
348 * \bar h_k(T,P) = \hat h^{ref}_k(T) + (P - P_{ref}) \hat V^0_k
349 * \f]
350 * The reference-state pure-species enthalpies, \f$ \hat h^{ref}_k(T) \f$,
351 * at the reference pressure,\f$ P_{ref} \f$, are computed by the species
352 * thermodynamic property manager. They are polynomial functions of
353 * temperature.
354 * @see MultiSpeciesThermo
355 *
356 * @param hbar Output vector containing partial molar enthalpies.
357 * Length: m_kk.
358 */
359 virtual void getPartialMolarEnthalpies(doublereal* hbar) const;
360
361 /**
362 * Returns an array of partial molar entropies of the species in the
363 * solution. Units: J/kmol/K. For this phase, the partial molar entropies
364 * are equal to the pure species entropies plus the ideal solution
365 * contribution.
366 * \f[
367 * \bar s_k(T,P) = \hat s^0_k(T) - R log(X_k)
368 * \f]
369 * The reference-state pure-species entropies,\f$ \hat s^{ref}_k(T) \f$, at
370 * the reference pressure, \f$ P_{ref} \f$, are computed by the species
371 * thermodynamic property manager. They are polynomial functions of
372 * temperature.
373 * @see MultiSpeciesThermo
374 *
375 * @param sbar Output vector containing partial molar entropies.
376 * Length: m_kk.
377 */
378 virtual void getPartialMolarEntropies(doublereal* sbar) const;
379
380 /**
381 * Returns an array of partial molar Heat Capacities at constant pressure of
382 * the species in the solution. Units: J/kmol/K. For this phase, the partial
383 * molar heat capacities are equal to the standard state heat capacities.
384 *
385 * @param cpbar Output vector of partial heat capacities. Length: m_kk.
386 */
387 virtual void getPartialMolarCp(doublereal* cpbar) const;
388
389 /**
390 * returns an array of partial molar volumes of the species in the solution.
391 * Units: m^3 kmol-1.
392 *
393 * For this solution, the partial molar volumes are equal to the constant
394 * species molar volumes.
395 *
396 * @param vbar Output vector of partial molar volumes. Length: m_kk.
397 */
398 virtual void getPartialMolarVolumes(doublereal* vbar) const;
399
400 //! Get the array of standard state chemical potentials at unit activity for
401 //! the species at their standard states at the current *T* and *P* of the
402 //! solution.
403 /*!
404 * These are the standard state chemical potentials \f$ \mu^0_k(T,P) \f$.
405 * The values are evaluated at the current temperature and pressure of the
406 * solution.
407 *
408 * This returns the underlying lattice standard chemical potentials, as the
409 * units are kmol-1 of the sublattice species.
410 *
411 * @param mu0 Output vector of chemical potentials.
412 * Length: m_kk. Units: J/kmol
413 */
414 virtual void getStandardChemPotentials(doublereal* mu0) const;
415
416 virtual doublereal standardConcentration(size_t k=0) const;
417 virtual doublereal logStandardConc(size_t k=0) const;
418
419 /// @name Thermodynamic Values for the Species Reference States
420 //! @{
421
422 virtual void getGibbs_RT_ref(doublereal* grt) const;
423 virtual void getGibbs_ref(doublereal* g) const;
424 //! @}
425
426 virtual bool addSpecies(shared_ptr<Species> spec);
427
428 //! Add a lattice to this phase
429 void addLattice(shared_ptr<ThermoPhase> lattice);
430
431 //! Set the lattice stoichiometric coefficients, \f$ \theta_i \f$
432 void setLatticeStoichiometry(const compositionMap& comp);
433
434 virtual void setParameters(const AnyMap& phaseNode,
435 const AnyMap& rootNode=AnyMap());
436 virtual void initThermo();
437 virtual void getParameters(AnyMap& phaseNode) const;
438 virtual void getSpeciesParameters(const std::string& name,
439 AnyMap& speciesNode) const;
440
441 virtual void setParametersFromXML(const XML_Node& eosdata);
442
443 //! Set the Lattice mole fractions using a string
444 /*!
445 * @param n Integer value of the lattice whose mole fractions are being set
446 * @param x string containing Name:value pairs that will specify the mole
447 * fractions of species on a particular lattice
448 */
449 void setLatticeMoleFractionsByName(int n, const std::string& x);
450
451 virtual void modifyOneHf298SS(const size_t k, const doublereal Hf298New);
452 virtual void resetHf298(const size_t k=npos);
453
454protected:
455 //! Current value of the pressure
456 doublereal m_press;
457
458 //! Current value of the molar density
459 doublereal m_molar_density;
460
461 //! Vector of sublattic ThermoPhase objects
462 std::vector<shared_ptr<ThermoPhase>> m_lattice;
463
464 //! Vector of mole fractions
465 /*!
466 * Note these mole fractions sum to one when summed over all phases.
467 * However, this is not what's passed down to the lower m_lattice objects.
468 */
469 mutable vector_fp m_x;
470
471 //! Lattice stoichiometric coefficients
473
474 //! Temporary vector
476
477 std::vector<size_t> lkstart_;
478
479 //! Root node of the AnyMap which contains this phase definition.
480 //! Used to look up the phase definitions for the constituent phases.
482
483private:
484 //! Update the reference thermodynamic functions
485 void _updateThermo() const;
486};
487}
488
489#endif
Header file for class ThermoPhase, the base class for phases with thermodynamic properties,...
A map of string keys to values whose type can vary at runtime.
Definition: AnyMap.h:399
A phase that is comprised of a fixed additive combination of other lattice phases.
virtual void setConcentrations(const doublereal *const conc)
Set the concentrations to the specified values within the phase.
virtual void getMoleFractions(doublereal *const x) const
Get the species mole fraction vector.
virtual doublereal minTemp(size_t k=npos) const
Minimum temperature for which the thermodynamic data for the species or phase are valid.
doublereal m_molar_density
Current value of the molar density.
doublereal m_press
Current value of the pressure.
AnyMap m_rootNode
Root node of the AnyMap which contains this phase definition.
virtual bool addSpecies(shared_ptr< Species > spec)
virtual void setMassFractions(const doublereal *const y)
Set the mass fractions to the specified values and normalize them.
LatticeSolidPhase()
Base empty constructor.
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 setParameters(const AnyMap &phaseNode, const AnyMap &rootNode=AnyMap())
Set equation of state parameters from an AnyMap phase description.
virtual int standardStateConvention() const
This method returns the convention used in specification of the standard state, of which there are cu...
virtual void getParameters(AnyMap &phaseNode) const
Store the parameters of a ThermoPhase object such that an identical one could be reconstructed using ...
virtual void getActivityCoefficients(doublereal *ac) const
Get the array of non-dimensional molar-based activity coefficients at the current solution temperatur...
vector_fp m_x
Vector of mole fractions.
std::vector< shared_ptr< ThermoPhase > > m_lattice
Vector of sublattic ThermoPhase objects.
virtual doublereal cp_mole() const
Return the constant pressure heat capacity. Units: J/kmol/K.
virtual void getPartialMolarEnthalpies(doublereal *hbar) const
Returns an array of partial molar enthalpies for the species in the mixture.
virtual void getPartialMolarEntropies(doublereal *sbar) const
Returns an array of partial molar entropies of the species in the solution.
virtual doublereal enthalpy_mole() const
Return the Molar Enthalpy. Units: J/kmol.
virtual doublereal logStandardConc(size_t k=0) const
Natural logarithm of the standard concentration of the kth species.
virtual void getPartialMolarVolumes(doublereal *vbar) const
returns an array of partial molar volumes of the species in the solution.
doublereal calcDensity()
Calculate the density of the solid mixture.
virtual void getActivityConcentrations(doublereal *c) const
This method returns an array of generalized concentrations.
virtual void setMassFractions_NoNorm(const doublereal *const y)
Set the mass fractions to the specified values without normalizing.
std::map< std::string, size_t > nativeState() const
Return a map of properties defining the native state of a substance.
void setLatticeMoleFractionsByName(int n, const std::string &x)
Set the Lattice mole fractions using a string.
virtual void getPartialMolarCp(doublereal *cpbar) const
Returns an array of partial molar Heat Capacities at constant pressure of the species in the solution...
virtual void getStandardChemPotentials(doublereal *mu0) const
Get the array of standard state chemical potentials at unit activity for the species at their standar...
virtual std::string phaseOfMatter() const
String indicating the mechanical phase of the matter in this Phase.
virtual bool isCompressible() const
Return whether phase represents a compressible substance.
virtual doublereal cv_mole() const
Return the constant volume heat capacity. Units: J/kmol/K.
virtual void setPressure(doublereal p)
Set the pressure at constant temperature. Units: Pa.
virtual doublereal entropy_mole() const
Return the Molar Entropy. Units: J/kmol/K.
virtual void initThermo()
Initialize the ThermoPhase object after all species have been set up.
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....
virtual doublereal refPressure() const
Returns the reference pressure in Pa.
virtual std::string type() const
String indicating the thermodynamic model implemented.
virtual void resetHf298(const size_t k=npos)
Restore the original heat of formation of one or more species.
vector_fp theta_
Lattice stoichiometric coefficients.
virtual doublereal gibbs_mole() const
Return the Molar Gibbs energy. Units: J/kmol.
virtual doublereal pressure() const
Report the Pressure. Units: Pa.
virtual Units standardConcentrationUnits() const
Returns the units of the "standard concentration" for this phase.
virtual void setParametersFromXML(const XML_Node &eosdata)
Set equation of state parameter values from XML entries.
virtual void getSpeciesParameters(const std::string &name, AnyMap &speciesNode) const
Get phase-specific parameters of a Species object such that an identical one could be reconstructed a...
void setLatticeStoichiometry(const compositionMap &comp)
Set the lattice stoichiometric coefficients, .
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)
void addLattice(shared_ptr< ThermoPhase > lattice)
Add a lattice to this phase.
void _updateThermo() const
Update the reference thermodynamic functions.
virtual void getChemPotentials(doublereal *mu) const
Get the species chemical potentials. Units: J/kmol.
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...
vector_fp tmpV_
Temporary vector.
virtual doublereal maxTemp(size_t k=npos) const
Maximum temperature for which the thermodynamic data for the species are valid.
virtual doublereal intEnergy_mole() const
Return the Molar Internal Energy. Units: J/kmol.
virtual doublereal standardConcentration(size_t k=0) const
Return the standard concentration for the kth species.
An error indicating that an unimplemented function has been called.
Definition: ctexceptions.h:187
std::string name() const
Return the name of the phase.
Definition: Phase.cpp:70
Base class for a phase with thermodynamic properties.
Definition: ThermoPhase.h:102
A representation of the units associated with a dimensional quantity.
Definition: Units.h:30
Class XML_Node is a tree-based representation of the contents of an XML file.
Definition: xml.h:103
Namespace for the Cantera kernel.
Definition: AnyMap.h:29
const size_t npos
index returned by functions to indicate "no position"
Definition: ct_defs.h:192
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:184
const int cSS_CONVENTION_SLAVE
Standard state thermodynamics is obtained from slave ThermoPhase objects.
Definition: ThermoPhase.h:41
std::map< std::string, double > compositionMap
Map connecting a string name with a double.
Definition: ct_defs.h:176