Cantera  4.0.0a2
Loading...
Searching...
No Matches
GibbsExcessVPSSTP.h
Go to the documentation of this file.
1/**
2 * @file GibbsExcessVPSSTP.h
3 * Header for intermediate ThermoPhase object for phases which
4 * employ Gibbs excess free energy based formulations
5 * (see @ref thermoprops
6 * and class @link Cantera::GibbsExcessVPSSTP GibbsExcessVPSSTP@endlink).
7 */
8
9// This file is part of Cantera. See License.txt in the top-level directory or
10// at https://cantera.org/license.txt for license and copyright information.
11
12#ifndef CT_GIBBSEXCESSVPSSTP_H
13#define CT_GIBBSEXCESSVPSSTP_H
14
15#include "VPStandardStateTP.h"
16#include "cantera/base/Array.h"
17
18namespace Cantera
19{
20
21/**
22 * GibbsExcessVPSSTP is a derived class of ThermoPhase that handles variable
23 * pressure standard state methods for calculating thermodynamic properties that
24 * are further based on expressing the Excess Gibbs free energy as a function of
25 * the mole fractions (or pseudo mole fractions) of constituents. This category
26 * is the workhorse for describing molten salts, solid-phase mixtures of
27 * semiconductors, and mixtures of miscible and semi-miscible compounds.
28 *
29 * It includes
30 * - regular solutions
31 * - Margules expansions
32 * - NTRL equation
33 * - Wilson's equation
34 * - UNIQUAC equation of state.
35 *
36 * This class adds additional functions onto the ThermoPhase interface that
37 * handles the calculation of the excess Gibbs free energy. The ThermoPhase
38 * class includes a member function, ThermoPhase::activityConvention() that
39 * indicates which convention the activities are based on. The default is to
40 * assume activities are based on the molar convention. That default is used
41 * here.
42 *
43 * All of the Excess Gibbs free energy formulations in this area employ
44 * symmetrical formulations.
45 *
46 * Chemical potentials of species k have the following general format:
47 *
48 * @f[
49 * \mu_k = \mu^o_k(T,P) + R T \ln( \gamma_k X_k )
50 * @f]
51 *
52 * where @f$ \gamma_k @f$ is a molar based activity coefficient for species
53 * @f$ k @f$, and @f$ X_k @f$ is the mole fraction.
54 *
55 * GibbsExcessVPSSTP contains an internal vector with the current mole fraction
56 * vector. That's one of its primary usages. In order to keep the mole fraction
57 * vector constant, all of the setState functions are redesigned at this layer.
58 *
59 * ### Activity Concentrations: Relationship of ThermoPhase to Kinetics Expressions
60 *
61 * As explained in a similar discussion in the ThermoPhase class, the actual
62 * units used in kinetics expressions must be specified in the ThermoPhase class
63 * for the corresponding species. These units vary with the field of study.
64 * %Cantera uses the concept of activity concentrations to represent this.
65 * Activity concentrations are used directly in the expressions for kinetics.
66 * Standard concentrations are used as the multiplicative constant that takes
67 * the activity of a species and turns it into an activity concentration.
68 * Standard concentrations must not depend on the composition of the phase.
69 *
70 * Here we set a convention for the specification of the standard concentrations
71 * for this class and all child classes underneath it. We specify here that the
72 * standard concentration is equal to 1 for all species. Therefore, the
73 * activity concentrations used in kinetics expressions are dimensionless and
74 * equal to the thermodynamic activities:
75 *
76 * @f[
77 * C^a_k = a_k = \gamma_k X_k
78 * @f]
79 *
80 * ### SetState Strategy
81 *
82 * All setState functions that set the internal state of the ThermoPhase object
83 * are overloaded at this level, so that a current mole fraction vector is
84 * maintained within the object.
85 */
87{
88public:
89 //! @name Constructors
90 //! @{
91
93
94 //! @}
95 //! @name Activities, Standard States, and Activity Concentrations
96 //!
97 //! The activity @f$ a_k @f$ of a species in solution is related to the
98 //! chemical potential by @f[ \mu_k = \mu_k^0(T,P) + \hat R T \ln a_k. @f] The
99 //! quantity @f$ \mu_k^0(T,P) @f$ is the chemical potential at unit activity,
100 //! which depends only on temperature and pressure.
101 //! @{
102
103 Units standardConcentrationUnits() const override;
104 void getActivityConcentrations(span<double> c) const override;
105
106 /**
107 * The standard concentration @f$ C^0_k @f$ used to normalize the
108 * generalized concentration. In many cases, this quantity will be the same
109 * for all species in a phase - for example, for an ideal gas
110 * @f$ C^0_k = P/\hat R T @f$. For this reason, this method returns a single
111 * value, instead of an array. However, for phases in which the standard
112 * concentration is species-specific (for example, surface species of different
113 * sizes), this method may be called with an optional parameter indicating
114 * the species.
115 *
116 * The standard concentration is 1. In other words, the activity
117 * concentration is equal to the thermodynamic activity.
118 *
119 * @param k species index. Defaults to zero.
120 */
121 double standardConcentration(size_t k=0) const override;
122 double logStandardConc(size_t k=0) const override;
123
124 //! Get the array of non-dimensional molar-based activities at the current
125 //! solution temperature, pressure, and composition.
126 /*!
127 * @f[
128 * a_k = \gamma_k X_k
129 * @f]
130 *
131 * This function is implemented using the activity coefficients calculated
132 * by derived classes.
133 *
134 * @param ac Output vector of molar-based activities. Length: m_kk.
135 */
136 void getActivities(span<double> ac) const override;
137
138 void getActivityCoefficients(span<double> ac) const override;
139
140 //! Get the array of temperature derivatives of the log activity coefficients
141 /*!
142 *
143 * units = 1/Kelvin
144 *
145 * @param dlnActCoeffdT Output vector of temperature derivatives of the
146 * log Activity Coefficients. length = m_kk
147 */
148 virtual void getdlnActCoeffdT(span<double> dlnActCoeffdT) const {
149 throw NotImplementedError("GibbsExcessVPSSTP::getdlnActCoeffdT");
150 }
151
152 void getdlnActCoeffdlnN(const size_t ld,
153 span<double> const dlnActCoeffdlnN) override {
154 throw NotImplementedError("GibbsExcessVPSSTP::getdlnActCoeffdlnN: "
155 "nonzero and nonimplemented");
156 }
157
158 //! Get the array of log concentration-like derivatives of the log activity
159 //! coefficients
160 /*!
161 * This function is a virtual method. For ideal mixtures (unity activity
162 * coefficients), this can return zero. Implementations should take the
163 * derivative of the logarithm of the activity coefficient with respect to
164 * the logarithm of the concentration-like variable (for example, number of moles in
165 * in a unit volume. ) that represents the standard state. This quantity is
166 * to be used in conjunction with derivatives of that concentration-like
167 * variable when the derivative of the chemical potential is taken.
168 *
169 * units = dimensionless
170 *
171 * @param dlnActCoeffdlnX Output vector of derivatives of the
172 * log Activity Coefficients. length = m_kk
173 */
174 virtual void getdlnActCoeffdlnX(span<double> dlnActCoeffdlnX) const {
175 throw NotImplementedError("GibbsExcessVPSSTP::getdlnActCoeffdlnX");
176 }
177
178 //! @}
179 //! @name Partial Molar Properties of the Solution
180 //! @{
181
182 //! Return an array of partial molar volumes for the
183 //! species in the mixture. Units: m^3/kmol.
184 /*!
185 * Frequently, for this class of thermodynamics representations,
186 * the excess Volume due to mixing is zero. Here, we set it as
187 * a default. It may be overridden in derived classes.
188 *
189 * @param vbar Output vector of species partial molar volumes.
190 * Length = m_kk. units are m^3/kmol.
191 */
192 void getPartialMolarVolumes(span<double> vbar) const override;
193 //! @}
194
195 bool addSpecies(shared_ptr<Species> spec) override;
196
197protected:
198 void compositionChanged() override;
199
200 //! Storage for the current values of the mole fractions of the species
201 /*!
202 * This vector is kept up-to-date when the setState functions are called.
203 * Therefore, it may be considered to be an independent variable.
204 *
205 * Note in order to do this, the setState functions are redefined to always
206 * keep this vector current.
207 */
208 mutable vector<double> moleFractions_;
209
210 //! Storage for the current values of the activity coefficients of the
211 //! species
212 mutable vector<double> lnActCoeff_Scaled_;
213
214 //! Storage for the current derivative values of the gradients with respect
215 //! to temperature of the log of the activity coefficients of the species
216 mutable vector<double> dlnActCoeffdT_Scaled_;
217
218 //! Storage for the current derivative values of the gradients with respect
219 //! to logarithm of the mole fraction of the log of the activity
220 //! coefficients of the species
221 mutable vector<double> dlnActCoeffdlnN_diag_;
222
223 //! Storage for the current derivative values of the gradients with respect
224 //! to logarithm of the mole fraction of the log of the activity
225 //! coefficients of the species
226 mutable vector<double> dlnActCoeffdlnX_diag_;
227
228 //! Storage for the current derivative values of the gradients with respect
229 //! to logarithm of the species mole number of the log of the activity
230 //! coefficients of the species
231 /*!
232 * dlnActCoeffdlnN_(k, m) is the derivative of ln(gamma_k) wrt ln mole
233 * number of species m
234 */
236};
237
238}
239
240#endif
Header file for class Cantera::Array2D.
Header file for a derived class of ThermoPhase that handles variable pressure standard state methods ...
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...
double logStandardConc(size_t k=0) const override
Natural logarithm of the standard concentration of the kth species.
Array2D dlnActCoeffdlnN_
Storage for the current derivative values of the gradients with respect to logarithm of the species m...
virtual void getdlnActCoeffdT(span< double > dlnActCoeffdT) const
Get the array of temperature derivatives of the log activity coefficients.
void getActivityCoefficients(span< double > ac) const override
Get the array of non-dimensional molar-based activity coefficients at the current solution temperatur...
vector< double > lnActCoeff_Scaled_
Storage for the current values of the activity coefficients of the species.
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< double > dlnActCoeffdlnX_diag_
Storage for the current derivative values of the gradients with respect to logarithm of the mole frac...
void getActivities(span< double > ac) const override
Get the array of non-dimensional molar-based activities at the current solution temperature,...
vector< double > moleFractions_
Storage for the current values of the mole fractions of the species.
vector< double > dlnActCoeffdT_Scaled_
Storage for the current derivative values of the gradients with respect to temperature of the log of ...
void getPartialMolarVolumes(span< double > vbar) const override
Return an array of partial molar volumes for the species in the mixture.
Units standardConcentrationUnits() const override
Returns the units of the "standard concentration" for this phase.
void compositionChanged() override
Apply changes to the state which are needed after the composition changes.
double standardConcentration(size_t k=0) const override
The standard concentration used to normalize the generalized concentration.
bool addSpecies(shared_ptr< Species > spec) override
Add a Species to this Phase.
virtual void getdlnActCoeffdlnX(span< double > dlnActCoeffdlnX) const
Get the array of log concentration-like derivatives of the log activity coefficients.
void getActivityConcentrations(span< double > c) const override
This method returns an array of generalized concentrations.
vector< double > dlnActCoeffdlnN_diag_
Storage for the current derivative values of the gradients with respect to logarithm of the mole frac...
An error indicating that an unimplemented function has been called.
A representation of the units associated with a dimensional quantity.
Definition Units.h:35
This is a filter class for ThermoPhase that implements some preparatory steps for efficiently handlin...
Namespace for the Cantera kernel.
Definition AnyMap.cpp:595