Cantera  4.0.0a2
Loading...
Searching...
No Matches
RedlichKisterVPSSTP.h
Go to the documentation of this file.
1/**
2 * @file RedlichKisterVPSSTP.h (see @ref thermoprops and class @link
3 * Cantera::RedlichKisterVPSSTP RedlichKisterVPSSTP@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_REDLICHKISTERVPSSTP_H
10#define CT_REDLICHKISTERVPSSTP_H
11
13
14namespace Cantera
15{
16
17//! RedlichKisterVPSSTP is a derived class of GibbsExcessVPSSTP that employs the
18//! Redlich-Kister approximation for the excess Gibbs free energy
19/*!
20 * RedlichKisterVPSSTP derives from class GibbsExcessVPSSTP which is derived
21 * from VPStandardStateTP, and overloads the virtual methods defined there with
22 * ones that use expressions appropriate for the Redlich Kister Excess Gibbs
23 * free energy 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 Redlich-Kister approximation assumes
31 * symmetric standard states, where all of the standard state assume that the
32 * species are in pure component states at the temperature and pressure of the
33 * solution. I don't think it prevents, however, some species from being dilute
34 * in the 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 Redlich-Kister formulation for a phase that has
42 * more than 2 species.
43 *
44 * @f[
45 * G^E = \sum_{i} G^E_{i}
46 * @f]
47 *
48 * where
49 *
50 * @f[
51 * G^E_{i} = n X_{Ai} X_{Bi} \sum_m \left( A^{i}_m {\left( X_{Ai} - X_{Bi} \right)}^m \right)
52 * @f]
53 *
54 * where n is the total moles in the solution and where we can break down the Gibbs free
55 * energy contributions into enthalpy and entropy contributions by defining
56 * @f$ A^i_m = H^i_m - T S^i_m @f$ :
57 *
58 * @f[
59 * H^E_i = n X_{Ai} X_{Bi} \sum_m \left( H^{i}_m {\left( X_{Ai} - X_{Bi} \right)}^m \right)
60 * @f]
61 *
62 * @f[
63 * S^E_i = n X_{Ai} X_{Bi} \sum_m \left( S^{i}_m {\left( X_{Ai} - X_{Bi} \right)}^m \right)
64 * @f]
65 *
66 * The activity of a species defined in the phase is given by an excess Gibbs free
67 * 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 * @f[
81 * R T \ln( \gamma_k )= \sum_i \delta_{Ai,k} (1 - X_{Ai}) X_{Bi} \sum_m \left( A^{i}_m {\left( X_{Ai} - X_{Bi} \right)}^m \right)
82 * + \sum_i \delta_{Ai,k} X_{Ai} X_{Bi} \sum_m \left( A^{i}_0 + A^{i}_m {\left( X_{Ai} - X_{Bi} \right)}^{m-1} (1 - X_{Ai} + X_{Bi}) \right)
83 * @f]
84 *
85 * Evaluating thermodynamic properties requires the following derivatives of
86 * @f$ \ln(\gamma_k) @f$:
87 *
88 * @f[
89 * \frac{d \ln( \gamma_k )}{dT} = - \frac{1}{RT^2} \left( \sum_i \delta_{Ai,k} (1 - X_{Ai}) X_{Bi} \sum_m \left( H^{i}_m {\left( X_{Ai} - X_{Bi} \right)}^m \right)
90 * + \sum_i \delta_{Ai,k} X_{Ai} X_{Bi} \sum_m \left( H^{i}_0 + H^{i}_m {\left( X_{Ai} - X_{Bi} \right)}^{m-1} (1 - X_{Ai} + X_{Bi}) \right) \right)
91 * @f]
92 *
93 * and
94 *
95 * @f[
96 * \frac{d^2 \ln( \gamma_k )}{dT^2} = -\frac{2}{T} \frac{d \ln( \gamma_k )}{dT}
97 * @f]
98 *
99 * This object inherits from the class VPStandardStateTP. Therefore, the
100 * specification and calculation of all standard state and reference state
101 * values are handled at that level. Various functional forms for the standard
102 * state are permissible. The chemical potential for species *k* is equal to
103 *
104 * @f[
105 * \mu_k(T,P) = \mu^o_k(T, P) + R T \ln(\gamma_k X_k)
106 * @f]
107 *
108 * The partial molar entropy for species *k* is given by the following relation,
109 *
110 * @f[
111 * \tilde{s}_k(T,P) = s^o_k(T,P) - R \ln( \gamma_k X_k )
112 * - R T \frac{d \ln(\gamma_k) }{dT}
113 * @f]
114 *
115 * The partial molar enthalpy for species *k* is given by
116 *
117 * @f[
118 * \tilde{h}_k(T,P) = h^o_k(T,P) - R T^2 \frac{d \ln(\gamma_k)}{dT}
119 * @f]
120 *
121 * The partial molar volume for species *k* is
122 *
123 * @f[
124 * \tilde V_k(T,P) = V^o_k(T,P) + R T \frac{d \ln(\gamma_k) }{dP}
125 * @f]
126 *
127 * The partial molar Heat Capacity for species *k* is
128 *
129 * @f[
130 * \tilde{C}_{p,k}(T,P) = C^o_{p,k}(T,P) - 2 R T \frac{d \ln( \gamma_k )}{dT}
131 * - R T^2 \frac{d^2 \ln(\gamma_k) }{{dT}^2} = C^o_{p,k}(T,P)
132 * @f]
133 *
134 * @ingroup thermoprops
135 */
137{
138public:
139 //! Construct a RedlichKisterVPSSTP object from an input file
140 /*!
141 * @param inputFile Name of the input file containing the phase definition.
142 * If blank, an empty phase will be created.
143 * @param id name (ID) of the phase in the input file. If empty, the
144 * first phase definition in the input file will be used.
145 */
146 explicit RedlichKisterVPSSTP(const string& inputFile="", const string& id="");
147
148 string type() const override {
149 return "Redlich-Kister";
150 }
151
152 //! @name Molar Thermodynamic Properties
153 //! @{
154
155 double cv_mole() const override;
156
157 //! @}
158 //! @name Activities, Standard States, and Activity Concentrations
159 //!
160 //! The activity @f$ a_k @f$ of a species in solution is
161 //! related to the chemical potential by @f[ \mu_k = \mu_k^0(T)
162 //! + \hat R T \ln a_k. @f] The quantity @f$ \mu_k^0(T,P) @f$ is
163 //! the chemical potential at unit activity, which depends only
164 //! on temperature and pressure.
165 //! @{
166
167 void getLnActivityCoefficients(span<double> lnac) const override;
168
169 //! @}
170 //! @name Partial Molar Properties of the Solution
171 //! @{
172
173 void getChemPotentials(span<double> mu) const override;
174
175 //! Returns an array of partial molar enthalpies for the species in the
176 //! mixture.
177 /*!
178 * Units (J/kmol)
179 *
180 * For this phase, the partial molar enthalpies are equal to the standard
181 * state enthalpies modified by the derivative of the molality-based
182 * activity coefficient wrt temperature
183 *
184 * @f[
185 * \bar h_k(T,P) = h^o_k(T,P) - R T^2 \frac{d \ln(\gamma_k)}{dT}
186 * @f]
187 *
188 * @param hbar Vector of returned partial molar enthalpies
189 * (length m_kk, units = J/kmol)
190 */
191 void getPartialMolarEnthalpies(span<double> hbar) const override;
192
193 //! Returns an array of partial molar entropies for the species in the
194 //! mixture.
195 /*!
196 * For this phase, the partial molar entropies are equal to the standard
197 * state entropies modified by the derivative of the activity coefficient
198 * with respect to temperature:
199 *
200 * @f[
201 * \bar s_k(T,P) = s^o_k(T,P) - R \ln( \gamma_k X_k)
202 * - R T \frac{d \ln(\gamma_k) }{dT}
203 * @f]
204 *
205 * @param sbar Vector of returned partial molar entropies
206 * (length m_kk, units = J/kmol/K)
207 */
208 void getPartialMolarEntropies(span<double> sbar) const override;
209
210 //! Returns an array of partial molar heat capacities for the species in the
211 //! mixture.
212 /*!
213 * Units (J/kmol/K)
214 *
215 * For this phase, the first and second temperature derivative terms of
216 * the activity coefficients cancel, so the partial molar heat capacities
217 * are equal to the standard state heat capacities:
218 *
219 * @f[
220 * \tilde{C}_{p,k}(T,P) = C^o_{p,k}(T,P)
221 * @f]
222 *
223 * @param cpbar Vector of returned partial molar heat capacities
224 * (length m_kk, units = J/kmol/K)
225 */
226 void getPartialMolarCp(span<double> cpbar) const override;
227
228 void getPartialMolarVolumes(span<double> vbar) const override;
229 //! @}
230
231 void getdlnActCoeffdT(span<double> dlnActCoeffdT) const override;
232
233 //! @name Initialization
234 //!
235 //! The following methods are used in the process of constructing
236 //! the phase and setting its parameters from a specification in an
237 //! input file. They are not normally used in application programs.
238 //! To see how they are used, see importPhase().
239
240 void initThermo() override;
241 void getParameters(AnyMap& phaseNode) const override;
242
243 //! Add a binary species interaction with the specified parameters
244 /*!
245 * @param speciesA name of the first species
246 * @param speciesB name of the second species
247 * @param excess_enthalpy coefficients of the excess enthalpy polynomial
248 * @param excess_entropy coefficients of the excess entropy polynomial
249 */
250 void addBinaryInteraction(const string& speciesA, const string& speciesB,
251 span<const double> excess_enthalpy, span<const double> excess_entropy);
252
253 //! @name Derivatives of Thermodynamic Variables needed for Applications
254 //! @{
255
256 void getdlnActCoeffds(const double dTds, span<const double> dXds,
257 span<double> dlnActCoeffds) const override;
258 void getdlnActCoeffdlnX_diag(span<double> dlnActCoeffdlnX_diag) const override;
259 void getdlnActCoeffdlnN_diag(span<double> dlnActCoeffdlnN_diag) const override;
260 void getdlnActCoeffdlnN(const size_t ld, span<double> const dlnActCoeffdlnN) override;
261 //! @}
262
263private:
264 //! Initialize lengths of local variables after all species have been
265 //! identified.
266 void initLengths();
267
268 //! Update the activity coefficients
269 /*!
270 * This function will be called to update the internally stored natural
271 * logarithm of the activity coefficients
272 */
273 void s_update_lnActCoeff() const;
274
275 //! Update the derivative of the log of the activity coefficients wrt T
276 /*!
277 * This function will be called to update the internally stored derivative
278 * of the natural logarithm of the activity coefficients wrt temperature.
279 */
280 void s_update_dlnActCoeff_dT() const;
281
282 //! Internal routine that calculates the derivative of the activity
283 //! coefficients wrt the mole fractions.
284 /*!
285 * This routine calculates the the derivative of the activity coefficients
286 * wrt to mole fraction with all other mole fractions held constant. This is
287 * strictly not permitted. However, if the resulting matrix is multiplied by
288 * a permissible deltaX vector then everything is ok.
289 *
290 * This is the natural way to handle concentration derivatives in this
291 * routine.
292 */
293 void s_update_dlnActCoeff_dX_() const;
294
295 //! Internal routine that calculates the total derivative of the activity
296 //! coefficients with respect to the log of the mole fractions.
297 /*!
298 * This function will be called to update the internally stored vector of
299 * the total derivatives (that is, not assuming other mole fractions are
300 * constant) of the natural logarithm of the activity coefficients with
301 * respect to the log of the mole fraction.
302 */
304
305protected:
306 //! vector of species indices representing species A in the interaction
307 /*!
308 * Each Redlich-Kister excess Gibbs free energy term involves two species,
309 * A and B. This vector identifies species A.
310 */
311 vector<size_t> m_pSpecies_A_ij;
312
313 //! vector of species indices representing species B in the interaction
314 /*!
315 * Each Redlich-Kister excess Gibbs free energy term involves two species,
316 * A and B. This vector identifies species B.
317 */
318 vector<size_t> m_pSpecies_B_ij;
319
320 //! Enthalpy term for the binary mole fraction interaction of the excess
321 //! Gibbs free energy expression
322 vector<vector<double>> m_HE_m_ij;
323
324 //! Entropy term for the binary mole fraction interaction of the excess
325 //! Gibbs free energy expression
326 vector<vector<double>> m_SE_m_ij;
327
328 //! Two dimensional array of derivatives of activity coefficients wrt mole
329 //! fractions
331};
332
333}
334
335#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
A class for 2D arrays stored in column-major (Fortran-compatible) form.
Definition Array.h:32
GibbsExcessVPSSTP is a derived class of ThermoPhase that handles variable pressure standard state met...
RedlichKisterVPSSTP is a derived class of GibbsExcessVPSSTP that employs the Redlich-Kister approxima...
void getLnActivityCoefficients(span< double > lnac) const override
Get the array of non-dimensional molar-based ln activity coefficients at the current solution tempera...
void s_update_dlnActCoeff_dX_() const
Internal routine that calculates the derivative of the activity coefficients wrt the mole fractions.
Array2D dlnActCoeff_dX_
Two dimensional array of derivatives of activity coefficients wrt mole fractions.
vector< vector< double > > m_SE_m_ij
Entropy term for the binary mole fraction interaction of the excess Gibbs free energy expression.
void getPartialMolarEnthalpies(span< double > hbar) const override
Returns an array of partial molar enthalpies for the species in the mixture.
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 for the species in the mixture.
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 and composition [J/kmol/K].
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< vector< double > > m_HE_m_ij
Enthalpy term for the binary mole fraction interaction of the excess Gibbs free energy expression.
void addBinaryInteraction(const string &speciesA, const string &speciesB, span< const double > excess_enthalpy, span< const double > excess_entropy)
Add a binary species interaction with the specified parameters.
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,...
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
Internal routine that calculates the total derivative of the activity coefficients with respect to th...
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.
void getChemPotentials(span< double > mu) const override
Get the species chemical potentials. Units: J/kmol.
Namespace for the Cantera kernel.
Definition AnyMap.cpp:595