| Cantera 3.0.0

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
18 namespace 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, @f$ \mu_o @f$, has the following general
47 * format:
48 *
49 * @f[
50 * \mu_k = \mu^o_k(T,P) + R T \ln( \gamma_k X_k )
51 * @f]
52 *
53 * where @f$ \gamma_k^{\triangle} @f$ is a molar based activity coefficient for
54 * species @f$ k @f$.
55 *
56 * GibbsExcessVPSSTP contains an internal vector with the current mole fraction
57 * vector. That's one of its primary usages. In order to keep the mole fraction
58 * vector constant, all of the setState functions are redesigned at this layer.
59 *
60 * ### Activity Concentrations: Relationship of ThermoPhase to Kinetics Expressions
61 *
62 * As explained in a similar discussion in the ThermoPhase class, the actual
63 * units used in kinetics expressions must be specified in the ThermoPhase class
64 * for the corresponding species. These units vary with the field of study.
65 * %Cantera uses the concept of activity concentrations to represent this.
66 * Activity concentrations are used directly in the expressions for kinetics.
67 * Standard concentrations are used as the multiplicative constant that takes
68 * the activity of a species and turns it into an activity concentration.
69 * Standard concentrations must not depend on the concentration of the species
70 * in the phase.
71 *
72 * Here we set a standard for the specification of the standard concentrations
73 * for this class and all child classes underneath it. We specify here that the
74 * standard concentration is equal to 1 for all species. Therefore, the
75 * activities appear directly in kinetics expressions involving species in
76 * underlying GibbsExcessVPSSTP phases.
77 *
78 * ### SetState Strategy
79 *
80 * All setState functions that set the internal state of the ThermoPhase object
81 * are overloaded at this level, so that a current mole fraction vector is
82 * maintained within the object.
83 */
84 class GibbsExcessVPSSTP : public VPStandardStateTP
85{
86 public:
87 //! @name Constructors
88 //! @{
89
90 GibbsExcessVPSSTP() {}
91
92 //! @}
93 //! @name Mechanical Properties
94 //! @{
95
96 protected:
97 void calcDensity() override;
98
99 public:
100 //! @}
101 //! @name Activities, Standard States, and Activity Concentrations
102 //!
103 //! The activity @f$ a_k @f$ of a species in solution is related to the
104 //! chemical potential by @f[ \mu_k = \mu_k^0(T) + \hat R T \ln a_k. @f] The
105 //! quantity @f$ \mu_k^0(T,P) @f$ is the chemical potential at unit activity,
106 //! which depends only on temperature and pressure.
107 //! @{
108
109 Units standardConcentrationUnits() const override;
110 void getActivityConcentrations(double* c) const override;
111
112 /**
113 * The standard concentration @f$ C^0_k @f$ used to normalize the
114 * generalized concentration. In many cases, this quantity will be the same
115 * for all species in a phase - for example, for an ideal gas
116 * @f$ C^0_k = P/\hat R T @f$. For this reason, this method returns a single
117 * value, instead of an array. However, for phases in which the standard
118 * concentration is species-specific (for example, surface species of different
119 * sizes), this method may be called with an optional parameter indicating
120 * the species.
121 *
122 * The standard concentration for defaulted to 1. In other words
123 * the activity concentration is assumed to be 1.
124 *
125 * @param k species index. Defaults to zero.
126 */
127 double standardConcentration(size_t k=0) const override;
128 double logStandardConc(size_t k=0) const override;
129
130 //! Get the array of non-dimensional activities (molality based for this
131 //! class and classes that derive from it) at the current solution
132 //! temperature, pressure, and solution concentration.
133 /*!
134 * @f[
135 * a_i^\triangle = \gamma_k^{\triangle} \frac{m_k}{m^\triangle}
136 * @f]
137 *
138 * This function must be implemented in derived classes.
139 *
140 * @param ac Output vector of molality-based activities. Length: m_kk.
141 */
142 void getActivities(double* ac) const override;
143
144 void getActivityCoefficients(double* ac) const override;
145
146 //! Get the array of temperature derivatives of the log activity coefficients
147 /*!
148 *
149 * units = 1/Kelvin
150 *
151 * @param dlnActCoeffdT Output vector of temperature derivatives of the
152 * log Activity Coefficients. length = m_kk
153 */
154 virtual void getdlnActCoeffdT(double* dlnActCoeffdT) const {
155 throw NotImplementedError("GibbsExcessVPSSTP::getdlnActCoeffdT");
156 }
157
158 void getdlnActCoeffdlnN(const size_t ld, double* const dlnActCoeffdlnN) override {
159 throw NotImplementedError("GibbsExcessVPSSTP::getdlnActCoeffdlnN: "
160 "nonzero and nonimplemented");
161 }
162
163 //! Get the array of log concentration-like derivatives of the log activity
164 //! coefficients
165 /*!
166 * This function is a virtual method. For ideal mixtures (unity activity
167 * coefficients), this can return zero. Implementations should take the
168 * derivative of the logarithm of the activity coefficient with respect to
169 * the logarithm of the concentration-like variable (for example, number of moles in
170 * in a unit volume. ) that represents the standard state. This quantity is
171 * to be used in conjunction with derivatives of that concentration-like
172 * variable when the derivative of the chemical potential is taken.
173 *
174 * units = dimensionless
175 *
176 * @param dlnActCoeffdlnX Output vector of derivatives of the
177 * log Activity Coefficients. length = m_kk
178 */
179 virtual void getdlnActCoeffdlnX(double* dlnActCoeffdlnX) const {
180 throw NotImplementedError("GibbsExcessVPSSTP::getdlnActCoeffdlnX");
181 }
182
183 //! @}
184 //! @name Partial Molar Properties of the Solution
185 //! @{
186
187 //! Return an array of partial molar volumes for the
188 //! species in the mixture. Units: m^3/kmol.
189 /*!
190 * Frequently, for this class of thermodynamics representations,
191 * the excess Volume due to mixing is zero. Here, we set it as
192 * a default. It may be overridden in derived classes.
193 *
194 * @param vbar Output vector of species partial molar volumes.
195 * Length = m_kk. units are m^3/kmol.
196 */
197 void getPartialMolarVolumes(double* vbar) const override;
198 //! @deprecated Unused. To be removed after %Cantera 3.0.
199 virtual const vector<double>& getPartialMolarVolumesVector() const;
200 //! @}
201
202 bool addSpecies(shared_ptr<Species> spec) override;
203
204 protected:
205 void compositionChanged() override;
206
207 //! utility routine to check mole fraction sum
208 /*!
209 * @param x vector of mole fractions.
210 * @deprecated Unused. To be removed after %Cantera 3.0.
211 */
212 double checkMFSum(const double* const x) const;
213
214 //! Storage for the current values of the mole fractions of the species
215 /*!
216 * This vector is kept up-to-date when the setState functions are called.
217 * Therefore, it may be considered to be an independent variable.
218 *
219 * Note in order to do this, the setState functions are redefined to always
220 * keep this vector current.
221 */
222 mutable vector<double> moleFractions_;
223
224 //! Storage for the current values of the activity coefficients of the
225 //! species
226 mutable vector<double> lnActCoeff_Scaled_;
227
228 //! Storage for the current derivative values of the gradients with respect
229 //! to temperature of the log of the activity coefficients of the species
230 mutable vector<double> dlnActCoeffdT_Scaled_;
231
232 //! Storage for the current derivative values of the gradients with respect
233 //! to temperature of the log of the activity coefficients of the species
234 mutable vector<double> d2lnActCoeffdT2_Scaled_;
235
236 //! Storage for the current derivative values of the gradients with respect
237 //! to logarithm of the mole fraction of the log of the activity
238 //! coefficients of the species
239 mutable vector<double> dlnActCoeffdlnN_diag_;
240
241 //! Storage for the current derivative values of the gradients with respect
242 //! to logarithm of the mole fraction of the log of the activity
243 //! coefficients of the species
244 mutable vector<double> dlnActCoeffdlnX_diag_;
245
246 //! Storage for the current derivative values of the gradients with respect
247 //! to logarithm of the species mole number of the log of the activity
248 //! coefficients of the species
249 /*!
250 * dlnActCoeffdlnN_(k, m) is the derivative of ln(gamma_k) wrt ln mole
251 * number of species m
252 */
253 mutable Array2D dlnActCoeffdlnN_;
254};
255
256}
257
258#endif
Array.h
Header file for class Cantera::Array2D.
VPStandardStateTP.h
Header file for a derived class of ThermoPhase that handles variable pressure standard state methods ...
Cantera::Array2D
A class for 2D arrays stored in column-major (Fortran-compatible) form.
Definition Array.h:32
Cantera::GibbsExcessVPSSTP
GibbsExcessVPSSTP is a derived class of ThermoPhase that handles variable pressure standard state met...
Definition GibbsExcessVPSSTP.h:85
Cantera::GibbsExcessVPSSTP::d2lnActCoeffdT2_Scaled_
vector< double > d2lnActCoeffdT2_Scaled_
Storage for the current derivative values of the gradients with respect to temperature of the log of ...
Definition GibbsExcessVPSSTP.h:234
Cantera::GibbsExcessVPSSTP::logStandardConc
double logStandardConc(size_t k=0) const override
Natural logarithm of the standard concentration of the kth species.
Definition GibbsExcessVPSSTP.cpp:60
Cantera::GibbsExcessVPSSTP::dlnActCoeffdlnN_
Array2D dlnActCoeffdlnN_
Storage for the current derivative values of the gradients with respect to logarithm of the species m...
Definition GibbsExcessVPSSTP.h:253
Cantera::GibbsExcessVPSSTP::getPartialMolarVolumesVector
virtual const vector< double > & getPartialMolarVolumesVector() const
Definition GibbsExcessVPSSTP.cpp:96
Cantera::GibbsExcessVPSSTP::checkMFSum
double checkMFSum(const double *const x) const
utility routine to check mole fraction sum
Definition GibbsExcessVPSSTP.cpp:103
Cantera::GibbsExcessVPSSTP::lnActCoeff_Scaled_
vector< double > lnActCoeff_Scaled_
Storage for the current values of the activity coefficients of the species.
Definition GibbsExcessVPSSTP.h:226
Cantera::GibbsExcessVPSSTP::getActivityConcentrations
void getActivityConcentrations(double *c) const override
This method returns an array of generalized concentrations.
Definition GibbsExcessVPSSTP.cpp:50
Cantera::GibbsExcessVPSSTP::getPartialMolarVolumes
void getPartialMolarVolumes(double *vbar) const override
Return an array of partial molar volumes for the species in the mixture.
Definition GibbsExcessVPSSTP.cpp:90
Cantera::GibbsExcessVPSSTP::dlnActCoeffdlnX_diag_
vector< double > dlnActCoeffdlnX_diag_
Storage for the current derivative values of the gradients with respect to logarithm of the mole frac...
Definition GibbsExcessVPSSTP.h:244
Cantera::GibbsExcessVPSSTP::moleFractions_
vector< double > moleFractions_
Storage for the current values of the mole fractions of the species.
Definition GibbsExcessVPSSTP.h:222
Cantera::GibbsExcessVPSSTP::dlnActCoeffdT_Scaled_
vector< double > dlnActCoeffdT_Scaled_
Storage for the current derivative values of the gradients with respect to temperature of the log of ...
Definition GibbsExcessVPSSTP.h:230
Cantera::GibbsExcessVPSSTP::calcDensity
void calcDensity() override
Calculate the density of the mixture using the partial molar volumes and mole fractions as input.
Definition GibbsExcessVPSSTP.cpp:32
Cantera::GibbsExcessVPSSTP::getdlnActCoeffdT
virtual void getdlnActCoeffdT(double *dlnActCoeffdT) const
Get the array of temperature derivatives of the log activity coefficients.
Definition GibbsExcessVPSSTP.h:154
Cantera::GibbsExcessVPSSTP::getActivities
void getActivities(double *ac) const override
Get the array of non-dimensional activities (molality based for this class and classes that derive fr...
Definition GibbsExcessVPSSTP.cpp:65
Cantera::GibbsExcessVPSSTP::standardConcentrationUnits
Units standardConcentrationUnits() const override
Returns the units of the "standard concentration" for this phase.
Definition GibbsExcessVPSSTP.cpp:45
Cantera::GibbsExcessVPSSTP::compositionChanged
void compositionChanged() override
Apply changes to the state which are needed after the composition changes.
Definition GibbsExcessVPSSTP.cpp:24
Cantera::GibbsExcessVPSSTP::standardConcentration
double standardConcentration(size_t k=0) const override
The standard concentration used to normalize the generalized concentration.
Definition GibbsExcessVPSSTP.cpp:55
Cantera::GibbsExcessVPSSTP::addSpecies
bool addSpecies(shared_ptr< Species > spec) override
Add a Species to this Phase.
Definition GibbsExcessVPSSTP.cpp:115
Cantera::GibbsExcessVPSSTP::getActivityCoefficients
void getActivityCoefficients(double *ac) const override
Get the array of non-dimensional molar-based activity coefficients at the current solution temperatur...
Definition GibbsExcessVPSSTP.cpp:74
Cantera::GibbsExcessVPSSTP::dlnActCoeffdlnN_diag_
vector< double > dlnActCoeffdlnN_diag_
Storage for the current derivative values of the gradients with respect to logarithm of the mole frac...
Definition GibbsExcessVPSSTP.h:239
Cantera::GibbsExcessVPSSTP::getdlnActCoeffdlnX
virtual void getdlnActCoeffdlnX(double *dlnActCoeffdlnX) const
Get the array of log concentration-like derivatives of the log activity coefficients.
Definition GibbsExcessVPSSTP.h:179
Cantera::GibbsExcessVPSSTP::getdlnActCoeffdlnN
void getdlnActCoeffdlnN(const size_t ld, double *const dlnActCoeffdlnN) override
Get the array of derivatives of the log activity coefficients with respect to the log of the species ...
Definition GibbsExcessVPSSTP.h:158
Cantera::NotImplementedError
An error indicating that an unimplemented function has been called.
Definition ctexceptions.h:195
Cantera::Units
A representation of the units associated with a dimensional quantity.
Definition Units.h:35
Cantera::VPStandardStateTP
This is a filter class for ThermoPhase that implements some preparatory steps for efficiently handlin...
Definition VPStandardStateTP.h:44
Cantera
Namespace for the Cantera kernel.
Definition AnyMap.cpp:564