Cantera  4.0.0a2
Loading...
Searching...
No Matches
MargulesVPSSTP.h
Go to the documentation of this file.
1/**
2 * @file MargulesVPSSTP.h (see @ref thermoprops and class @link
3 * Cantera::MargulesVPSSTP MargulesVPSSTP@endlink).
4 */
5
6// This file is part of Cantera. See License.txt in the top-level directory or
7// at https://cantera.org/license.txt for license and copyright information.
8
9#ifndef CT_MARGULESVPSSTP_H
10#define CT_MARGULESVPSSTP_H
11
12#include "GibbsExcessVPSSTP.h"
13
14namespace Cantera
15{
16
17//! MargulesVPSSTP is a derived class of GibbsExcessVPSSTP that employs the
18//! Margules approximation for the excess Gibbs free energy
19/*!
20 * MargulesVPSSTP derives from class GibbsExcessVPSSTP which is derived from
21 * VPStandardStateTP, and overloads the virtual methods defined there with ones
22 * that use expressions appropriate for the Margules Excess Gibbs free energy
23 * approximation.
24 *
25 * The independent unknowns are pressure, temperature, and mass fraction.
26 *
27 * ## Specification of Species Standard State Properties
28 *
29 * All species are defined to have standard states that depend upon both the
30 * temperature and the pressure. The Margules approximation assumes symmetric
31 * standard states, where all of the standard state assume that the species are
32 * in pure component states at the temperature and pressure of the solution. I
33 * don't think it prevents, however, some species from being dilute in the
34 * solution.
35 *
36 * ## Specification of Solution Thermodynamic Properties
37 *
38 * The molar excess Gibbs free energy is given by the following formula which is
39 * a sum over interactions *i*. Each of the interactions are binary interactions
40 * involving two of the species in the phase, denoted, *Ai* and *Bi*. This is
41 * the generalization of the Margules formulation for a phase that has more than
42 * 2 species.
43 *
44 * @f[
45 * G^E = \sum_i \left( H_{Ei} - T S_{Ei} + (P - P_{ref}) V^E_i \right)
46 * @f]
47 * @f[
48 * H^E_i = n X_{Ai} X_{Bi} \left( h_{o,i} + h_{1,i} X_{Bi} \right)
49 * @f]
50 * @f[
51 * S^E_i = n X_{Ai} X_{Bi} \left( s_{o,i} + s_{1,i} X_{Bi} \right)
52 * @f]
53 * @f[
54 * V^E_i = n X_{Ai} X_{Bi} \left( v_{o,i} + v_{1,i} X_{Bi} \right)
55 * @f]
56 *
57 * where n is the total moles in the solution, @f$ P_{ref} @f$ is the
58 * standard-state reference pressure (1 atm), and @f$ v_{o,i} = v^{HE}_{o,i} -
59 * T \cdot v^{SE}_{o,i} @f$, @f$ v_{1,i} = v^{HE}_{1,i} - T \cdot
60 * v^{SE}_{1,i} @f$ where @f$ v^{HE} @f$ and @f$ v^{SE} @f$ are the
61 * `excess-volume-enthalpy` and `excess-volume-entropy` interaction parameters.
62 * The @f$ (P - P_{\rm ref}) V^E_i @f$ term is what makes the Maxwell relation
63 * @f$ (\partial S/\partial P)_T = -(\partial V/\partial T)_P @f$ consistent
64 * with the non-zero, temperature-dependent excess volume.
65 *
66 * The activity of a species defined in the phase is given by an excess Gibbs
67 * free energy formulation.
68 *
69 * @f[
70 * a_k = \gamma_k X_k
71 * @f]
72 *
73 * where
74 *
75 * @f[
76 * R T \ln( \gamma_k )= \frac{d(n G^E)}{d(n_k)}\Bigg|_{n_i}
77 * @f]
78 *
79 * Taking the derivatives results in the following expression
80 *
81 * @f[
82 * R T \ln( \gamma_k )= \sum_i \left( \left( \delta_{Ai,k} X_{Bi} + \delta_{Bi,k} X_{Ai} - X_{Ai} X_{Bi} \right)
83 * \left( g^E_{o,i} + g^E_{1,i} X_{Bi} \right) +
84 * \left( \delta_{Bi,k} - X_{Bi} \right) X_{Ai} X_{Bi} g^E_{1,i} \right)
85 * @f]
86 * where
87 * @f$ g^E_{o,i} = h_{o,i} - T s_{o,i} + (P - P_{\rm ref})(v^{HE}_{o,i} - T \cdot v^{SE}_{o,i}) @f$
88 * and
89 * @f$ g^E_{1,i} = h_{1,i} - T s_{1,i} + (P - P_{\rm ref})(v^{HE}_{1,i} - T \cdot v^{SE}_{1,i}) @f$
90 * and where @f$ X_k @f$ is the mole fraction of species *k*.
91 *
92 * This object inherits from the class VPStandardStateTP. Therefore, the
93 * specification and calculation of all standard state and reference state
94 * values are handled at that level. Various functional forms for the standard
95 * state are permissible. The chemical potential for species *k* is equal to
96 *
97 * @f[
98 * \mu_k(T,P) = \mu^o_k(T, P) + R T \ln(\gamma_k X_k)
99 * @f]
100 *
101 * The partial molar entropy for species *k* is given by
102 *
103 * @f[
104 * \tilde{s}_k(T,P) = s^o_k(T,P) - R \ln( \gamma_k X_k )
105 * - R T \frac{d \ln(\gamma_k) }{dT}
106 * @f]
107 *
108 * The partial molar enthalpy for species *k* is given by
109 *
110 * @f[
111 * \tilde{h}_k(T,P) = h^o_k(T,P) - R T^2 \frac{d \ln(\gamma_k)}{dT}
112 * @f]
113 *
114 * The partial molar volume for species *k* is
115 *
116 * @f[
117 * \tilde V_k(T,P) = V^o_k(T,P) + R T \frac{d \ln(\gamma_k) }{dP}
118 * @f]
119 *
120 * The partial molar Heat Capacity for species *k* is
121 *
122 * @f[
123 * \tilde{C}_{p,k}(T,P) = C^o_{p,k}(T,P) - 2 R T \frac{d \ln( \gamma_k )}{dT}
124 * - R T^2 \frac{d^2 \ln(\gamma_k) }{{dT}^2}
125 * @f]
126 *
127 * @ingroup thermoprops
128 */
130{
131public:
132 //! Construct a MargulesVPSSTP object from an input file
133 /*!
134 * @param inputFile Name of the input file containing the phase definition.
135 * If blank, an empty phase will be created.
136 * @param id name (ID) of the phase in the input file. If empty, the
137 * first phase definition in the input file will be used.
138 */
139 explicit MargulesVPSSTP(const string& inputFile="", const string& id="");
140
141 string type() const override {
142 return "Margules";
143 }
144
145 //! @name Molar Thermodynamic Properties
146 //! @{
147
148 //! Molar heat capacity at constant volume.
149 //!
150 //! For a Margules phase with pressure-dependent standard state volumes, the
151 //! thermodynamic identity @f$ c_v = c_p - T v \beta^2 / \kappa_T @f$ is used.
152 //! If @f$ \kappa_T = 0 @f$ (all species have pressure-independent standard state
153 //! volumes), then @f$ c_v = c_p @f$.
154 double cv_mole() const override;
155
156 //! Isothermal compressibility of the mixture.
157 /*!
158 * Computed as
159 * @f[
160 * \kappa_T = -\frac{1}{v} \sum_k X_k \frac{\partial V^\circ_k}{\partial P}\Bigg|_T
161 * @f]
162 * The Margules excess volume has no pressure dependence, so only the standard
163 * state PDSS derivatives contribute.
164 */
165 double isothermalCompressibility() const override;
166
167 //! Thermal expansion coefficient of the mixture.
168 /*!
169 * Computed as
170 * @f[
171 * \beta = \frac{1}{v} \left(
172 * \sum_k X_k \frac{\partial V^\circ_k}{\partial T}\Bigg|_P
173 * + \frac{\partial V_\mathrm{excess}}{\partial T}\Bigg|_{P,X}
174 * \right)
175 * @f]
176 * where the excess volume T-derivative is computed analytically from the
177 * Margules excess-volume-entropy interaction parameters.
178 */
179 double thermalExpansionCoeff() const override;
180
181 //! @}
182 //! @name Activities, Standard States, and Activity Concentrations
183 //!
184 //! The activity @f$ a_k @f$ of a species in solution is related to the
185 //! chemical potential by @f[ \mu_k = \mu_k^0(T) + \hat R T \ln a_k. @f] The
186 //! quantity @f$ \mu_k^0(T,P) @f$ is the chemical potential at unit activity,
187 //! which depends only on temperature and pressure.
188 //! @{
189
190 void getLnActivityCoefficients(span<double> lnac) const override;
191
192 //! @}
193 //! @name Partial Molar Properties of the Solution
194 //! @{
195
196 void getChemPotentials(span<double> mu) const override;
197
198 //! Returns an array of partial molar enthalpies for the species in the
199 //! mixture.
200 /*!
201 * Units (J/kmol)
202 *
203 * For this phase, the partial molar enthalpies are equal to the standard
204 * state enthalpies modified by the derivative of the molality-based
205 * activity coefficient wrt temperature
206 *
207 * @f[
208 * \bar h_k(T,P) = h^o_k(T,P) - R T^2 \frac{d \ln(\gamma_k)}{dT}
209 * @f]
210 *
211 * @param hbar Vector of returned partial molar enthalpies
212 * (length m_kk, units = J/kmol)
213 */
214 void getPartialMolarEnthalpies(span<double> hbar) const override;
215
216 //! Returns an array of partial molar entropies for the species in the
217 //! mixture.
218 /*!
219 * Units (J/kmol/K)
220 *
221 * For this phase, the partial molar entropies are equal to the standard
222 * state entropies modified by the activity and the temperature derivative
223 * of the activity coefficient:
224 *
225 * @f[
226 * \bar s_k(T,P) = s^o_k(T,P) - R \ln( \gamma_k X_k)
227 * - R T \frac{d \ln(\gamma_k) }{dT}
228 * @f]
229 *
230 * @param sbar Vector of returned partial molar entropies
231 * (length m_kk, units = J/kmol/K)
232 */
233 void getPartialMolarEntropies(span<double> sbar) const override;
234
235 //! Returns an array of partial molar heat capacities [J/kmol/K] for the species in
236 //! the mixture.
237 /*!
238 * For this model, the first and second temperature derivative terms of the activity
239 * coefficients cancel, so the partial molar heat capacities are equal to the
240 * standard state heat capacities:
241 *
242 * @f[
243 * \bar C_{p,k}(T,P) = C^o_{p,k}(T,P)
244 * @f]
245 *
246 * @param cpbar Vector of returned partial molar heat capacities
247 * (length m_kk, units = J/kmol/K)
248 */
249 void getPartialMolarCp(span<double> cpbar) const override;
250
251 void getPartialMolarVolumes(span<double> vbar) const override;
252
253 void getdlnActCoeffdT(span<double> dlnActCoeffdT) const override;
254
255 //! @}
256 //! @name Initialization
257 //!
258 //! The following methods are used in the process of constructing the phase
259 //! and setting its parameters from a specification in an input file. They
260 //! are not normally used in application programs. To see how they are used,
261 //! see importPhase()
262 //! @{
263
264 void initThermo() override;
265 void getParameters(AnyMap& phaseNode) const override;
266
267 //! Add a binary species interaction with the specified parameters
268 /*!
269 * @param speciesA name of the first species
270 * @param speciesB name of the second species
271 * @param h0 first excess enthalpy coefficient [J/kmol]
272 * @param h1 second excess enthalpy coefficient [J/kmol]
273 * @param s0 first excess entropy coefficient [J/kmol/K]
274 * @param s1 second excess entropy coefficient [J/kmol/K]
275 * @param vh0 first enthalpy coefficient for excess volume [m^3/kmol]
276 * @param vh1 second enthalpy coefficient for excess volume [m^3/kmol]
277 * @param vs0 first entropy coefficient for excess volume [m^3/kmol/K]
278 * @param vs1 second entropy coefficient for excess volume [m^3/kmol/K]
279 */
280 void addBinaryInteraction(const string& speciesA,
281 const string& speciesB, double h0, double h1, double s0, double s1,
282 double vh0, double vh1, double vs0, double vs1);
283
284 //! @}
285 //! @name Derivatives of Thermodynamic Variables needed for Applications
286 //! @{
287
288 void getdlnActCoeffds(const double dTds, span<const double> dXds,
289 span<double> dlnActCoeffds) const override;
290 void getdlnActCoeffdlnX_diag(span<double> dlnActCoeffdlnX_diag) const override;
291 void getdlnActCoeffdlnN_diag(span<double> dlnActCoeffdlnN_diag) const override;
292 void getdlnActCoeffdlnN(const size_t ld,
293 span<double> const dlnActCoeffdlnN) override;
294
295 //! @}
296
297private:
298 //! Initialize lengths of local variables after all species have been
299 //! identified.
300 void initLengths();
301
302 //! Update the activity coefficients
303 /*!
304 * This function will be called to update the internally stored natural
305 * logarithm of the activity coefficients
306 */
307 void s_update_lnActCoeff() const;
308
309 //! Update the derivative of the log of the activity coefficients wrt T
310 /*!
311 * This function will be called to update the internally stored derivative
312 * of the natural logarithm of the activity coefficients wrt temperature.
313 */
314 void s_update_dlnActCoeff_dT() const;
315
316 //! Update the derivative of the log of the activity coefficients wrt
317 //! log(mole fraction)
318 /*!
319 * This function will be called to update the internally stored derivative
320 * of the natural logarithm of the activity coefficients wrt logarithm of
321 * the mole fractions.
322 */
324
325 //! Update the derivative of the log of the activity coefficients wrt
326 //! log(moles) - diagonal only
327 /*!
328 * This function will be called to update the internally stored diagonal
329 * entries for the derivative of the natural logarithm of the activity
330 * coefficients wrt logarithm of the moles.
331 */
333
334 //! Update the derivative of the log of the activity coefficients wrt
335 //! log(moles_m)
336 /*!
337 * This function will be called to update the internally stored derivative
338 * of the natural logarithm of the activity coefficients wrt logarithm of
339 * the mole number of species
340 */
341 void s_update_dlnActCoeff_dlnN() const;
342
343protected:
344 //! number of binary interaction expressions
346
347 //! Enthalpy term for the binary mole fraction interaction of the
348 //! excess Gibbs free energy expression
349 mutable vector<double> m_HE_b_ij;
350
351 //! Enthalpy term for the ternary mole fraction interaction of the
352 //! excess Gibbs free energy expression
353 mutable vector<double> m_HE_c_ij;
354
355 //! Entropy term for the binary mole fraction interaction of the
356 //! excess Gibbs free energy expression
357 mutable vector<double> m_SE_b_ij;
358
359 //! Entropy term for the ternary mole fraction interaction of the
360 //! excess Gibbs free energy expression
361 mutable vector<double> m_SE_c_ij;
362
363 //! Enthalpy term for the binary mole fraction interaction of the
364 //! excess Gibbs free energy expression
365 mutable vector<double> m_VHE_b_ij;
366
367 //! Enthalpy term for the ternary mole fraction interaction of the
368 //! excess Gibbs free energy expression
369 mutable vector<double> m_VHE_c_ij;
370
371 //! Entropy term for the binary mole fraction interaction of the
372 //! excess Gibbs free energy expression
373 mutable vector<double> m_VSE_b_ij;
374
375 //! Entropy term for the ternary mole fraction interaction of the
376 //! excess Gibbs free energy expression
377 mutable vector<double> m_VSE_c_ij;
378
379 //! vector of species indices representing species A in the interaction
380 /*!
381 * Each Margules excess Gibbs free energy term involves two species, A and
382 * B. This vector identifies species A.
383 */
384 vector<size_t> m_pSpecies_A_ij;
385
386 //! vector of species indices representing species B in the interaction
387 /*!
388 * Each Margules excess Gibbs free energy term involves two species, A and
389 * B. This vector identifies species B.
390 */
391 vector<size_t> m_pSpecies_B_ij;
392
393 //! form of the Margules interaction expression
394 /*!
395 * Currently there is only one form.
396 */
398
399 //! form of the temperature dependence of the Margules interaction expression
400 /*!
401 * Currently there is only one form -> constant wrt temperature.
402 */
404};
405
406}
407
408#endif
Header for intermediate ThermoPhase object for phases which employ Gibbs excess free energy based for...
A map of string keys to values whose type can vary at runtime.
Definition AnyMap.h:431
GibbsExcessVPSSTP is a derived class of ThermoPhase that handles variable pressure standard state met...
MargulesVPSSTP is a derived class of GibbsExcessVPSSTP that employs the Margules approximation for th...
void getLnActivityCoefficients(span< double > lnac) const override
Get the array of non-dimensional molar-based ln activity coefficients at the current solution tempera...
double thermalExpansionCoeff() const override
Thermal expansion coefficient of the mixture.
void getPartialMolarEnthalpies(span< double > hbar) const override
Returns an array of partial molar enthalpies for the species in the mixture.
vector< double > m_VHE_c_ij
Enthalpy term for the ternary mole fraction interaction of the excess Gibbs free energy expression.
vector< double > m_SE_b_ij
Entropy term for the binary mole fraction interaction of the excess Gibbs free energy expression.
int formTempModel_
form of the temperature dependence of the Margules interaction expression
void getdlnActCoeffdlnN_diag(span< double > dlnActCoeffdlnN_diag) const override
Get the array of log species mole number derivatives of the log activity coefficients.
void getPartialMolarCp(span< double > cpbar) const override
Returns an array of partial molar heat capacities [J/kmol/K] for the species in the mixture.
size_t numBinaryInteractions_
number of binary interaction expressions
vector< double > m_SE_c_ij
Entropy term for the ternary mole fraction interaction of the excess Gibbs free energy expression.
void s_update_dlnActCoeff_dlnN_diag() const
Update the derivative of the log of the activity coefficients wrt log(moles) - diagonal only.
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 getdlnActCoeffdlnX_diag(span< double > dlnActCoeffdlnX_diag) const override
Get the array of ln mole fraction derivatives of the log activity coefficients - diagonal component o...
void getdlnActCoeffdlnN(const size_t ld, span< double > const dlnActCoeffdlnN) override
Get the array of derivatives of the log activity coefficients with respect to the log of the species ...
vector< size_t > m_pSpecies_A_ij
vector of species indices representing species A in the interaction
double cv_mole() const override
Molar heat capacity at constant volume.
void s_update_dlnActCoeff_dT() const
Update the derivative of the log of the activity coefficients wrt T.
vector< size_t > m_pSpecies_B_ij
vector of species indices representing species B in the interaction
vector< double > m_VSE_c_ij
Entropy term for the ternary mole fraction interaction of the excess Gibbs free energy expression.
void s_update_dlnActCoeff_dlnN() const
Update the derivative of the log of the activity coefficients wrt log(moles_m)
int formMargules_
form of the Margules interaction expression
double isothermalCompressibility() const override
Isothermal compressibility of the mixture.
vector< double > m_HE_b_ij
Enthalpy term for the binary mole fraction interaction of the excess Gibbs free energy expression.
void getdlnActCoeffds(const double dTds, span< const double > dXds, span< double > dlnActCoeffds) const override
Get the change in activity coefficients wrt changes in state (temp, mole fraction,...
vector< double > m_VSE_b_ij
Entropy term for the binary mole fraction interaction of the excess Gibbs free energy expression.
void getPartialMolarVolumes(span< double > vbar) const override
Return an array of partial molar volumes for the species in the mixture.
void initLengths()
Initialize lengths of local variables after all species have been identified.
void getPartialMolarEntropies(span< double > sbar) const override
Returns an array of partial molar entropies for the species in the mixture.
void s_update_dlnActCoeff_dlnX_diag() const
Update the derivative of the log of the activity coefficients wrt log(mole fraction)
void s_update_lnActCoeff() const
Update the activity coefficients.
void getdlnActCoeffdT(span< double > dlnActCoeffdT) const override
Get the array of temperature derivatives of the log activity coefficients.
vector< double > m_VHE_b_ij
Enthalpy term for the binary mole fraction interaction of the excess Gibbs free energy expression.
void addBinaryInteraction(const string &speciesA, const string &speciesB, double h0, double h1, double s0, double s1, double vh0, double vh1, double vs0, double vs1)
Add a binary species interaction with the specified parameters.
void getChemPotentials(span< double > mu) const override
Get the species chemical potentials. Units: J/kmol.
vector< double > m_HE_c_ij
Enthalpy term for the ternary mole fraction interaction of the excess Gibbs free energy expression.
Namespace for the Cantera kernel.
Definition AnyMap.cpp:595