Cantera  3.1.0a1
Loading...
Searching...
No Matches
LatticePhase.h
Go to the documentation of this file.
1/**
2 * @file LatticePhase.h Header for a simple thermodynamics model of a bulk
3 * phase derived from ThermoPhase, assuming a lattice of solid atoms (see
4 * @ref thermoprops and class @link Cantera::LatticePhase
5 * LatticePhase@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_LATTICE_H
12#define CT_LATTICE_H
13
14#include "ThermoPhase.h"
15
16namespace Cantera
17{
18
19//! A simple thermodynamic model for a bulk phase, assuming a lattice of solid
20//! atoms
21/*!
22 * See [`lattice` Phase Model](../reference/science/phasethermo/lattice.html)
23 * for scientific model documentation.
24 *
25 * @ingroup thermoprops
26 */
28{
29public:
30 //! Full constructor for a lattice phase
31 /*!
32 * @param inputFile String name of the input file. If blank,
33 * an empty phase will be created.
34 * @param id string id of the phase name
35 */
36 explicit LatticePhase(const string& inputFile="", const string& id="");
37
38 string type() const override {
39 return "lattice";
40 }
41
42 bool isCompressible() const override {
43 return false;
44 }
45
46 map<string, size_t> nativeState() const override {
47 return { {"T", 0}, {"P", 1}, {"X", 2} };
48 }
49
50 //! @name Molar Thermodynamic Properties of the Solution
51 //! @{
52
53 //! Return the Molar Enthalpy. Units: J/kmol.
54 /*!
55 * For an ideal solution,
56 *
57 * @f[
58 * \hat h(T,P) = \sum_k X_k \hat h^0_k(T,P),
59 * @f]
60 *
61 * The standard-state pure-species Enthalpies @f$ \hat h^0_k(T,P) @f$ are
62 * computed first by the species reference state thermodynamic property
63 * manager and then a small pressure dependent term is added in.
64 *
65 * \see MultiSpeciesThermo
66 */
67 double enthalpy_mole() const override;
68
69 //! Molar entropy of the solution. Units: J/kmol/K
70 /*!
71 * For an ideal, constant partial molar volume solution mixture with
72 * pure species phases which exhibit zero volume expansivity:
73 * @f[
74 * \hat s(T, P, X_k) = \sum_k X_k \hat s^0_k(T) - \hat R \sum_k X_k \ln(X_k)
75 * @f]
76 * The reference-state pure-species entropies @f$ \hat s^0_k(T,p_{ref}) @f$
77 * are computed by the species thermodynamic property manager. The pure
78 * species entropies are independent of pressure since the volume
79 * expansivities are equal to zero.
80 *
81 * Units: J/kmol/K.
82 *
83 * @see MultiSpeciesThermo
84 */
85 double entropy_mole() const override;
86
87 //! Molar heat capacity at constant pressure of the solution.
88 //! Units: J/kmol/K.
89 /*!
90 * For an ideal, constant partial molar volume solution mixture with
91 * pure species phases which exhibit zero volume expansivity:
92 * @f[
93 * \hat c_p(T,P) = \sum_k X_k \hat c^0_{p,k}(T) .
94 * @f]
95 * The heat capacity is independent of pressure. The reference-state pure-
96 * species heat capacities @f$ \hat c^0_{p,k}(T) @f$ are computed by the
97 * species thermodynamic property manager.
98 *
99 * @see MultiSpeciesThermo
100 */
101 double cp_mole() const override;
102
103 //! Molar heat capacity at constant volume of the solution.
104 //! Units: J/kmol/K.
105 /*!
106 * For an ideal, constant partial molar volume solution mixture with
107 * pure species phases which exhibit zero volume expansivity:
108 * @f[
109 * \hat c_v(T,P) = \hat c_p(T,P)
110 * @f]
111 *
112 * The two heat capacities are equal.
113 */
114 double cv_mole() const override;
115
116 //! @}
117 //! @name Mechanical Equation of State Properties
118 //!
119 //! In this equation of state implementation, the density is a function only
120 //! of the mole fractions. Therefore, it can't be an independent variable.
121 //! Instead, the pressure is used as the independent variable. Functions
122 //! which try to set the thermodynamic state by calling setDensity() may
123 //! cause an exception to be thrown.
124 //! @{
125
126 //! Pressure. Units: Pa.
127 /*!
128 * For this incompressible system, we return the internally stored
129 * independent value of the pressure.
130 */
131 double pressure() const override {
132 return m_Pcurrent;
133 }
134
135 //! Set the internally stored pressure (Pa) at constant temperature and
136 //! composition
137 /*!
138 * This method sets the pressure within the object. The mass density is not
139 * a function of pressure.
140 *
141 * @param p Input Pressure (Pa)
142 */
143 void setPressure(double p) override;
144
145 //! Calculate the density of the mixture using the partial molar volumes and
146 //! mole fractions as input
147 /*!
148 * The formula for this is
149 *
150 * @f[
151 * \rho = \frac{\sum_k{X_k W_k}}{\sum_k{X_k V_k}}
152 * @f]
153 *
154 * where @f$ X_k @f$ are the mole fractions, @f$ W_k @f$ are the molecular
155 * weights, and @f$ V_k @f$ are the pure species molar volumes.
156 *
157 * Note, the basis behind this formula is that in an ideal solution the
158 * partial molar volumes are equal to the pure species molar volumes. We
159 * have additionally specified in this class that the pure species molar
160 * volumes are independent of temperature and pressure.
161 */
162 double calcDensity();
163
164 //! @}
165 //! @name Activities, Standard States, and Activity Concentrations
166 //!
167 //! The activity @f$ a_k @f$ of a species in solution is related to the
168 //! chemical potential by @f[ \mu_k = \mu_k^0(T) + \hat R T \ln a_k. @f] The
169 //! quantity @f$ \mu_k^0(T,P) @f$ is the chemical potential at unit activity,
170 //! which depends only on temperature and the pressure. Activity is assumed
171 //! to be molality-based here.
172 //! @{
173
174 Units standardConcentrationUnits() const override;
175 void getActivityConcentrations(double* c) const override;
176
177 //! Return the standard concentration for the kth species
178 /*!
179 * The standard concentration @f$ C^0_k @f$ used to normalize
180 * the activity (that is, generalized) concentration for use
181 *
182 * For the time being, we will use the concentration of pure solvent for the
183 * the standard concentration of all species. This has the effect of making
184 * mass-action reaction rates based on the molality of species proportional
185 * to the molality of the species.
186 *
187 * @param k Optional parameter indicating the species. The default is to
188 * assume this refers to species 0.
189 * @returns the standard Concentration in units of m^3/kmol.
190 */
191 double standardConcentration(size_t k=0) const override;
192 double logStandardConc(size_t k=0) const override;
193
194 //! Get the array of non-dimensional activity coefficients at
195 //! the current solution temperature, pressure, and solution concentration.
196 /*!
197 * For this phase, the activity coefficients are all equal to one.
198 *
199 * @param ac Output vector of activity coefficients. Length: m_kk.
200 */
201 void getActivityCoefficients(double* ac) const override;
202
203 //! @}
204 //! @name Partial Molar Properties of the Solution
205 //! @{
206
207 //! Get the species chemical potentials. Units: J/kmol.
208 /*!
209 * This function returns a vector of chemical potentials of the species in
210 * solid solution at the current temperature, pressure and mole fraction of
211 * the solid solution.
212 *
213 * @param mu Output vector of species chemical
214 * potentials. Length: m_kk. Units: J/kmol
215 */
216 void getChemPotentials(double* mu) const override;
217
218 /**
219 * Returns an array of partial molar enthalpies for the species in the
220 * mixture. Units (J/kmol). For this phase, the partial molar enthalpies are
221 * equal to the pure species enthalpies
222 * @f[
223 * \bar h_k(T,P) = \hat h^{ref}_k(T) + (P - P_{ref}) \hat V^0_k
224 * @f]
225 * The reference-state pure-species enthalpies, @f$ \hat h^{ref}_k(T) @f$,
226 * at the reference pressure,@f$ P_{ref} @f$, are computed by the species
227 * thermodynamic property manager. They are polynomial functions of
228 * temperature.
229 * @see MultiSpeciesThermo
230 *
231 * @param hbar Output vector containing partial molar enthalpies.
232 * Length: m_kk.
233 */
234 void getPartialMolarEnthalpies(double* hbar) const override;
235
236 /**
237 * Returns an array of partial molar entropies of the species in the
238 * solution. Units: J/kmol/K. For this phase, the partial molar entropies
239 * are equal to the pure species entropies plus the ideal solution
240 * contribution.
241 * @f[
242 * \bar s_k(T,P) = \hat s^0_k(T) - R \ln(X_k)
243 * @f]
244 * The reference-state pure-species entropies,@f$ \hat s^{ref}_k(T) @f$, at
245 * the reference pressure, @f$ P_{ref} @f$, are computed by the species
246 * thermodynamic property manager. They are polynomial functions of
247 * temperature.
248 * @see MultiSpeciesThermo
249 *
250 * @param sbar Output vector containing partial molar entropies.
251 * Length: m_kk.
252 */
253 void getPartialMolarEntropies(double* sbar) const override;
254
255 /**
256 * Returns an array of partial molar Heat Capacities at constant pressure of
257 * the species in the solution. Units: J/kmol/K. For this phase, the partial
258 * molar heat capacities are equal to the standard state heat capacities.
259 *
260 * @param cpbar Output vector of partial heat capacities. Length: m_kk.
261 */
262 void getPartialMolarCp(double* cpbar) const override;
263
264 void getPartialMolarVolumes(double* vbar) const override;
265 void getStandardChemPotentials(double* mu) const override;
266 void getPureGibbs(double* gpure) const override;
267
268 //! @}
269 //! @name Properties of the Standard State of the Species in the Solution
270 //! @{
271
272 //! Get the nondimensional Enthalpy functions for the species standard
273 //! states at their standard states at the current *T* and *P* of the
274 //! solution.
275 /*!
276 * A small pressure dependent term is added onto the reference state enthalpy
277 * to get the pressure dependence of this term.
278 *
279 * @f[
280 * h^o_k(T,P) = h^{ref}_k(T) + \left( \frac{P - P_{ref}}{C_o} \right)
281 * @f]
282 *
283 * The reference state thermodynamics is obtained by a pointer to a
284 * populated species thermodynamic property manager class (see
285 * ThermoPhase::m_spthermo). How to relate pressure changes to the reference
286 * state thermodynamics is resolved at this level.
287 *
288 * @param hrt Output vector of nondimensional standard state enthalpies.
289 * Length: m_kk.
290 */
291 void getEnthalpy_RT(double* hrt) const override;
292
293 //! Get the array of nondimensional Entropy functions for the species
294 //! standard states at the current *T* and *P* of the solution.
295 /*!
296 * The entropy of the standard state is defined as independent of
297 * pressure here.
298 *
299 * @f[
300 * s^o_k(T,P) = s^{ref}_k(T)
301 * @f]
302 *
303 * The reference state thermodynamics is obtained by a pointer to a
304 * populated species thermodynamic property manager class (see
305 * ThermoPhase::m_spthermo). How to relate pressure changes to the reference
306 * state thermodynamics is resolved at this level.
307 *
308 * @param sr Output vector of nondimensional standard state entropies.
309 * Length: m_kk.
310 */
311 void getEntropy_R(double* sr) const override;
312
313 //! Get the nondimensional Gibbs functions for the species standard states
314 //! at the current *T* and *P* of the solution.
315 /*!
316 * The standard Gibbs free energies are obtained from the enthalpy and
317 * entropy formulation.
318 *
319 * @f[
320 * g^o_k(T,P) = h^{o}_k(T,P) - T s^{o}_k(T,P)
321 * @f]
322 *
323 * @param grt Output vector of nondimensional standard state Gibbs free
324 * energies. Length: m_kk.
325 */
326 void getGibbs_RT(double* grt) const override;
327
328 //! Get the nondimensional Heat Capacities at constant pressure for the
329 //! species standard states at the current *T* and *P* of the solution
330 /*!
331 * The heat capacity of the standard state is independent of pressure
332 *
333 * @f[
334 * Cp^o_k(T,P) = Cp^{ref}_k(T)
335 * @f]
336 *
337 * The reference state thermodynamics is obtained by a pointer to a
338 * populated species thermodynamic property manager class (see
339 * ThermoPhase::m_spthermo). How to relate pressure changes to the reference
340 * state thermodynamics is resolved at this level.
341 *
342 * @param cpr Output vector of nondimensional standard state heat
343 * capacities. Length: m_kk.
344 */
345 void getCp_R(double* cpr) const override;
346
347 void getStandardVolumes(double* vol) const override;
348
349 //! @}
350 //! @name Thermodynamic Values for the Species Reference States
351 //! @{
352
353 const vector<double>& enthalpy_RT_ref() const;
354
355 //! Returns a reference to the dimensionless reference state Gibbs free
356 //! energy vector.
357 /*!
358 * This function is part of the layer that checks/recalculates the reference
359 * state thermo functions.
360 */
361 const vector<double>& gibbs_RT_ref() const;
362
363 void getGibbs_RT_ref(double* grt) const override;
364 void getGibbs_ref(double* g) const override;
365
366 //! Returns a reference to the dimensionless reference state Entropy vector.
367 /*!
368 * This function is part of the layer that checks/recalculates the reference
369 * state thermo functions.
370 */
371 const vector<double>& entropy_R_ref() const;
372
373 //! Returns a reference to the dimensionless reference state Heat Capacity
374 //! vector.
375 /*!
376 * This function is part of the layer that checks/recalculates the reference
377 * state thermo functions.
378 */
379 const vector<double>& cp_R_ref() const;
380
381 //! @}
382 //! @name Utilities for Initialization of the Object
383 //! @{
384
385 bool addSpecies(shared_ptr<Species> spec) override;
386
387 //! Set the density of lattice sites [kmol/m^3]
388 void setSiteDensity(double sitedens);
389
390 void initThermo() override;
391 void getParameters(AnyMap& phaseNode) const override;
392 void getSpeciesParameters(const string& name, AnyMap& speciesNode) const override;
393
394 //! @}
395
396protected:
397 void compositionChanged() override;
398
399 //! Reference state pressure
400 double m_Pref = OneAtm;
401
402 //! The current pressure
403 /*!
404 * Since the density isn't a function of pressure, but only of the mole
405 * fractions, we need to independently specify the pressure. The density
406 * variable which is inherited as part of the State class, m_dens, is always
407 * kept current whenever T, P, or X[] change.
408 */
410
411 //! Reference state enthalpies / RT
412 mutable vector<double> m_h0_RT;
413
414 //! Temporary storage for the reference state heat capacities
415 mutable vector<double> m_cp0_R;
416
417 //! Temporary storage for the reference state Gibbs energies
418 mutable vector<double> m_g0_RT;
419
420 //! Temporary storage for the reference state entropies at the current
421 //! temperature
422 mutable vector<double> m_s0_R;
423
424 //! Vector of molar volumes for each species in the solution
425 /**
426 * Species molar volumes @f$ m^3 kmol^-1 @f$
427 */
428 vector<double> m_speciesMolarVolume;
429
430 //! Site Density of the lattice solid
431 /*!
432 * Currently, this is imposed as a function of T, P or composition
433 *
434 * units are kmol m-3
435 */
436 double m_site_density = 0.0;
437
438private:
439 //! Update the species reference state thermodynamic functions
440 /*!
441 * The polynomials for the standard state functions are only reevaluated if
442 * the temperature has changed.
443 */
444 void _updateThermo() const;
445};
446}
447
448#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:427
A simple thermodynamic model for a bulk phase, assuming a lattice of solid atoms.
const vector< double > & entropy_R_ref() const
Returns a reference to the dimensionless reference state Entropy vector.
double enthalpy_mole() const override
Return the Molar Enthalpy. Units: J/kmol.
double logStandardConc(size_t k=0) const override
Natural logarithm of the standard concentration of the kth species.
void getPartialMolarEnthalpies(double *hbar) const override
Returns an array of partial molar enthalpies for the species in the mixture.
void getChemPotentials(double *mu) const override
Get the species chemical potentials. Units: J/kmol.
double m_site_density
Site Density of the lattice solid.
double pressure() const override
Pressure. Units: Pa.
vector< double > m_g0_RT
Temporary storage for the reference state Gibbs energies.
bool isCompressible() const override
Return whether phase represents a compressible substance.
void getSpeciesParameters(const string &name, AnyMap &speciesNode) const override
Get phase-specific parameters of a Species object such that an identical one could be reconstructed a...
map< string, size_t > nativeState() const override
Return a map of properties defining the native state of a substance.
void getEntropy_R(double *sr) const override
Get the array of nondimensional Entropy functions for the species standard states at the current T an...
vector< double > m_h0_RT
Reference state enthalpies / RT.
void getGibbs_ref(double *g) const override
Returns the vector of the Gibbs function of the reference state at the current temperature of the sol...
double m_Pref
Reference state pressure.
void getStandardChemPotentials(double *mu) const override
Get the array of chemical potentials at unit activity for the species at their standard states at the...
void getCp_R(double *cpr) const override
Get the nondimensional Heat Capacities at constant pressure for the species standard states at the cu...
void getParameters(AnyMap &phaseNode) const override
Store the parameters of a ThermoPhase object such that an identical one could be reconstructed using ...
string type() const override
String indicating the thermodynamic model implemented.
void initThermo() override
Initialize the ThermoPhase object after all species have been set up.
void getActivityConcentrations(double *c) const override
This method returns an array of generalized concentrations.
void setPressure(double p) override
Set the internally stored pressure (Pa) at constant temperature and composition.
const vector< double > & gibbs_RT_ref() const
Returns a reference to the dimensionless reference state Gibbs free energy vector.
void getPartialMolarVolumes(double *vbar) const override
Return an array of partial molar volumes for the species in the mixture.
double cv_mole() const override
Molar heat capacity at constant volume of the solution.
void getPureGibbs(double *gpure) const override
Get the Gibbs functions for the standard state of the species at the current T and P of the solution.
void getEnthalpy_RT(double *hrt) const override
Get the nondimensional Enthalpy functions for the species standard states at their standard states at...
vector< double > m_s0_R
Temporary storage for the reference state entropies at the current temperature.
void getGibbs_RT(double *grt) const override
Get the nondimensional Gibbs functions for the species standard states at the current T and P of the ...
double entropy_mole() const override
Molar entropy of the solution. Units: J/kmol/K.
void setSiteDensity(double sitedens)
Set the density of lattice sites [kmol/m^3].
vector< double > m_speciesMolarVolume
Vector of molar volumes for each species in the solution.
void getStandardVolumes(double *vol) const override
Get the molar volumes of the species standard states at the current T and P of the solution.
double cp_mole() const override
Molar heat capacity at constant pressure of the solution.
Units standardConcentrationUnits() const override
Returns the units of the "standard concentration" for this phase.
void getPartialMolarCp(double *cpbar) const override
Returns an array of partial molar Heat Capacities at constant pressure of the species in the solution...
void compositionChanged() override
Apply changes to the state which are needed after the composition changes.
double standardConcentration(size_t k=0) const override
Return the standard concentration for the kth species.
vector< double > m_cp0_R
Temporary storage for the reference state heat capacities.
double calcDensity()
Calculate the density of the mixture using the partial molar volumes and mole fractions as input.
bool addSpecies(shared_ptr< Species > spec) override
Add a Species to this Phase.
void _updateThermo() const
Update the species reference state thermodynamic functions.
void getGibbs_RT_ref(double *grt) const override
Returns the vector of nondimensional Gibbs Free Energies of the reference state at the current temper...
void getActivityCoefficients(double *ac) const override
Get the array of non-dimensional activity coefficients at the current solution temperature,...
void getPartialMolarEntropies(double *sbar) const override
Returns an array of partial molar entropies of the species in the solution.
const vector< double > & cp_R_ref() const
Returns a reference to the dimensionless reference state Heat Capacity vector.
double m_Pcurrent
The current pressure.
string name() const
Return the name of the phase.
Definition Phase.cpp:20
Base class for a phase with thermodynamic properties.
A representation of the units associated with a dimensional quantity.
Definition Units.h:35
const double OneAtm
One atmosphere [Pa].
Definition ct_defs.h:96
Namespace for the Cantera kernel.
Definition AnyMap.cpp:564