| Cantera 3.0.0

Loading...
Searching...
No Matches
RedlichKwongMFTP.h
Go to the documentation of this file.
1//! @file RedlichKwongMFTP.h
2
3// This file is part of Cantera. See License.txt in the top-level directory or
4// at https://cantera.org/license.txt for license and copyright information.
5
6#ifndef CT_REDLICHKWONGMFTP_H
7#define CT_REDLICHKWONGMFTP_H
8
9#include "MixtureFugacityTP.h"
10#include "cantera/base/Array.h"
11
12 namespace Cantera
13{
14/**
15 * Implementation of a multi-species Redlich-Kwong equation of state
16 *
17 * @ingroup thermoprops
18 */
19 class RedlichKwongMFTP : public MixtureFugacityTP
20{
21 public:
22 //! Construct a RedlichKwongMFTP object from an input file
23 /*!
24 * @param infile Name of the input file containing the phase definition.
25 * If blank, an empty phase will be created.
26 * @param id name (ID) of the phase in the input file. If empty, the
27 * first phase definition in the input file will be used.
28 */
29 explicit RedlichKwongMFTP(const string& infile="", const string& id="");
30
31 string type() const override {
32 return "Redlich-Kwong";
33 }
34
35 //! @name Molar Thermodynamic properties
36 //! @{
37 double cp_mole() const override;
38 double cv_mole() const override;
39 //! @}
40 //! @name Mechanical Properties
41 //! @{
42
43 //! Return the thermodynamic pressure (Pa).
44 /*!
45 * Since the mass density, temperature, and mass fractions are stored,
46 * this method uses these values to implement the
47 * mechanical equation of state @f$ P(T, \rho, Y_1, \dots, Y_K) @f$.
48 *
49 * @f[
50 * P = \frac{RT}{v-b_{mix}} - \frac{a_{mix}}{T^{0.5} v \left( v + b_{mix} \right) }
51 * @f]
52 */
53 double pressure() const override;
54
55 //! @}
56
57 public:
58
59 //! Returns the standard concentration @f$ C^0_k @f$, which is used to
60 //! normalize the generalized concentration.
61 /*!
62 * This is defined as the concentration by which the generalized
63 * concentration is normalized to produce the activity. In many cases, this
64 * quantity will be the same for all species in a phase. Since the activity
65 * for an ideal gas mixture is simply the mole fraction, for an ideal gas
66 * @f$ C^0_k = P/\hat R T @f$.
67 *
68 * @param k Optional parameter indicating the species. The default is to
69 * assume this refers to species 0.
70 * @return
71 * Returns the standard Concentration in units of m3 kmol-1.
72 */
73 double standardConcentration(size_t k=0) const override;
74
75 //! Get the array of non-dimensional activity coefficients at the current
76 //! solution temperature, pressure, and solution concentration.
77 /*!
78 * For all objects with the Mixture Fugacity approximation, we define the
79 * standard state as an ideal gas at the current temperature and pressure of
80 * the solution. The activities are based on this standard state.
81 *
82 * @param ac Output vector of activity coefficients. Length: m_kk.
83 */
84 void getActivityCoefficients(double* ac) const override;
85
86 //! @name Partial Molar Properties of the Solution
87 //! @{
88
89 //! Get the array of non-dimensional species chemical potentials.
90 //! These are partial molar Gibbs free energies.
91 /*!
92 * @f$ \mu_k / \hat R T @f$.
93 * Units: unitless
94 *
95 * We close the loop on this function, here, calling getChemPotentials() and
96 * then dividing by RT. No need for child classes to handle.
97 *
98 * @param mu Output vector of non-dimensional species chemical potentials
99 * Length: m_kk.
100 * @deprecated To be removed after %Cantera 3.0. Use getChemPotentials() instead.
101 */
102 void getChemPotentials_RT(double* mu) const override;
103
104 void getChemPotentials(double* mu) const override;
105 void getPartialMolarEnthalpies(double* hbar) const override;
106 void getPartialMolarEntropies(double* sbar) const override;
107 void getPartialMolarIntEnergies(double* ubar) const override;
108 void getPartialMolarCp(double* cpbar) const override {
109 throw NotImplementedError("RedlichKwongMFTP::getPartialMolarCp");
110 }
111 void getPartialMolarVolumes(double* vbar) const override;
112 //! @}
113
114 public:
115 //! @name Initialization Methods - For Internal use
116 //!
117 //! The following methods are used in the process of constructing
118 //! the phase and setting its parameters from a specification in an
119 //! input file. They are not normally used in application programs.
120 //! To see how they are used, see importPhase().
121 //! @{
122
123 bool addSpecies(shared_ptr<Species> spec) override;
124 void initThermo() override;
125 void getSpeciesParameters(const string& name, AnyMap& speciesNode) const override;
126
127 //! Set the pure fluid interaction parameters for a species
128 /*!
129 * The "a" parameter for species *i* in the Redlich-Kwong model is assumed
130 * to be a linear function of temperature:
131 * @f[ a = a_0 + a_1 T @f]
132 *
133 * @param species Name of the species
134 * @param a0 constant term in the expression for the "a" parameter
135 * of the specified species [Pa-m^6/kmol^2]
136 * @param a1 temperature-proportional term in the expression for the
137 * "a" parameter of the specified species [Pa-m^6/kmol^2/K]
138 * @param b "b" parameter in the Redlich-Kwong model [m^3/kmol]
139 */
140 void setSpeciesCoeffs(const string& species, double a0, double a1, double b);
141
142 //! Set values for the interaction parameter between two species
143 /*!
144 * The "a" parameter for interactions between species *i* and *j* is
145 * assumed by default to be computed as:
146 * @f[ a_{ij} = \sqrt(a_{i,0} a_{j,0}) + \sqrt(a_{i,1} a_{j,1}) T @f]
147 *
148 * This function overrides the defaults with the specified parameters:
149 * @f[ a_{ij} = a_{ij,0} + a_{ij,1} T @f]
150 *
151 * @param species_i Name of one species
152 * @param species_j Name of the other species
153 * @param a0 constant term in the "a" expression [Pa-m^6/kmol^2]
154 * @param a1 temperature-proportional term in the "a" expression
155 * [Pa-m^6/kmol^2/K]
156 */
157 void setBinaryCoeffs(const string& species_i,
158 const string& species_j, double a0, double a1);
159 //! @}
160
161 protected:
162 // Special functions inherited from MixtureFugacityTP
163 double sresid() const override;
164 double hresid() const override;
165
166 public:
167 double liquidVolEst(double TKelvin, double& pres) const override;
168 double densityCalc(double T, double pressure, int phase, double rhoguess) override;
169
170 double densSpinodalLiquid() const override;
171 double densSpinodalGas() const override;
172 double dpdVCalc(double TKelvin, double molarVol, double& presCalc) const override;
173
174 double isothermalCompressibility() const override;
175 double thermalExpansionCoeff() const override;
176 double soundSpeed() const override;
177
178 //! Calculate dpdV and dpdT at the current conditions
179 /*!
180 * These are stored internally.
181 */
182 void pressureDerivatives() const;
183
184 //! Update the a and b parameters
185 /*!
186 * The a and the b parameters depend on the mole fraction and the
187 * temperature. This function updates the internal numbers based on the
188 * state of the object.
189 */
190 void updateMixingExpressions() override;
191
192 //! Calculate the a and the b parameters given the temperature
193 /*!
194 * This function doesn't change the internal state of the object, so it is a
195 * const function. It does use the stored mole fractions in the object.
196 *
197 * @param temp Temperature (TKelvin)
198 * @param aCalc (output) Returns the a value
199 * @param bCalc (output) Returns the b value.
200 */
201 void calculateAB(double temp, double& aCalc, double& bCalc) const;
202
203 // Special functions not inherited from MixtureFugacityTP
204
205 double da_dt() const;
206
207 void calcCriticalConditions(double& pc, double& tc, double& vc) const override;
208
209 //! Prepare variables and call the function to solve the cubic equation of state
210 int solveCubic(double T, double pres, double a, double b, double Vroot[3]) const;
211
212 protected:
213 //! Form of the temperature parameterization
214 /*!
215 * - 0 = There is no temperature parameterization of a or b
216 * - 1 = The a_ij parameter is a linear function of the temperature
217 */
218 int m_formTempParam = 0;
219
220 //! Value of b in the equation of state
221 /*!
222 * m_b is a function of the temperature and the mole fraction.
223 */
224 double m_b_current = 0.0;
225
226 //! Value of a in the equation of state
227 /*!
228 * a_b is a function of the temperature and the mole fraction.
229 */
230 double m_a_current = 0.0;
231
232 vector<double> a_vec_Curr_;
233 vector<double> b_vec_Curr_;
234
235 Array2D a_coeff_vec;
236
237 //! Explicitly-specified binary interaction parameters
238 map<string, map<string, pair<double, double>>> m_binaryParameters;
239
240 enum class CoeffSource { EoS, CritProps, Database };
241 //! For each species, specifies the source of the a and b coefficients
242 vector<CoeffSource> m_coeffSource;
243
244 int NSolns_ = 0;
245
246 double Vroot_[3] = {0.0, 0.0, 0.0};
247
248 //! Temporary storage - length = m_kk.
249 mutable vector<double> m_pp;
250
251 // Partial molar volumes of the species
252 mutable vector<double> m_partialMolarVolumes;
253
254 //! The derivative of the pressure wrt the volume
255 /*!
256 * Calculated at the current conditions. temperature and mole number kept
257 * constant
258 */
259 mutable double dpdV_ = 0.0;
260
261 //! The derivative of the pressure wrt the temperature
262 /*!
263 * Calculated at the current conditions. Total volume and mole number kept
264 * constant
265 */
266 mutable double dpdT_ = 0.0;
267
268 //! Vector of derivatives of pressure wrt mole number
269 /*!
270 * Calculated at the current conditions. Total volume, temperature and
271 * other mole number kept constant
272 */
273 mutable vector<double> dpdni_;
274
275 private:
276 //! Omega constant for a -> value of a in terms of critical properties
277 /*!
278 * this was calculated from a small nonlinear solve
279 */
280 static const double omega_a;
281
282 //! Omega constant for b
283 static const double omega_b;
284
285 //! Omega constant for the critical molar volume
286 static const double omega_vc;
287};
288}
289
290#endif
Array.h
Header file for class Cantera::Array2D.
MixtureFugacityTP.h
Header file for a derived class of ThermoPhase that handles non-ideal mixtures based on the fugacity ...
Cantera::AnyMap
A map of string keys to values whose type can vary at runtime.
Definition AnyMap.h:427
Cantera::Array2D
A class for 2D arrays stored in column-major (Fortran-compatible) form.
Definition Array.h:32
Cantera::MixtureFugacityTP
This is a filter class for ThermoPhase that implements some preparatory steps for efficiently handlin...
Definition MixtureFugacityTP.h:66
Cantera::NotImplementedError
An error indicating that an unimplemented function has been called.
Definition ctexceptions.h:195
Cantera::Phase::species
shared_ptr< Species > species(const string &name) const
Return the Species object for the named species.
Definition Phase.cpp:977
Cantera::Phase::name
string name() const
Return the name of the phase.
Definition Phase.cpp:20
Cantera::RedlichKwongMFTP
Implementation of a multi-species Redlich-Kwong equation of state.
Definition RedlichKwongMFTP.h:20
Cantera::RedlichKwongMFTP::dpdT_
double dpdT_
The derivative of the pressure wrt the temperature.
Definition RedlichKwongMFTP.h:266
Cantera::RedlichKwongMFTP::calculateAB
void calculateAB(double temp, double &aCalc, double &bCalc) const
Calculate the a and the b parameters given the temperature.
Definition RedlichKwongMFTP.cpp:775
Cantera::RedlichKwongMFTP::thermalExpansionCoeff
double thermalExpansionCoeff() const override
Return the volumetric thermal expansion coefficient. Units: 1/K.
Definition RedlichKwongMFTP.cpp:711
Cantera::RedlichKwongMFTP::setBinaryCoeffs
void setBinaryCoeffs(const string &species_i, const string &species_j, double a0, double a1)
Set values for the interaction parameter between two species.
Definition RedlichKwongMFTP.cpp:71
Cantera::RedlichKwongMFTP::densSpinodalLiquid
double densSpinodalLiquid() const override
Return the value of the density at the liquid spinodal point (on the liquid side) for the current tem...
Definition RedlichKwongMFTP.cpp:648
Cantera::RedlichKwongMFTP::getPartialMolarEnthalpies
void getPartialMolarEnthalpies(double *hbar) const override
Returns an array of partial molar enthalpies for the species in the mixture.
Definition RedlichKwongMFTP.cpp:223
Cantera::RedlichKwongMFTP::getChemPotentials
void getChemPotentials(double *mu) const override
Get the species chemical potentials. Units: J/kmol.
Definition RedlichKwongMFTP.cpp:189
Cantera::RedlichKwongMFTP::sresid
double sresid() const override
Calculate the deviation terms for the total entropy of the mixture from the ideal gas mixture.
Definition RedlichKwongMFTP.cpp:530
Cantera::RedlichKwongMFTP::soundSpeed
double soundSpeed() const override
Return the speed of sound. Units: m/s.
Definition RedlichKwongMFTP.cpp:717
Cantera::RedlichKwongMFTP::pressure
double pressure() const override
Return the thermodynamic pressure (Pa).
Definition RedlichKwongMFTP.cpp:130
Cantera::RedlichKwongMFTP::m_formTempParam
int m_formTempParam
Form of the temperature parameterization.
Definition RedlichKwongMFTP.h:218
Cantera::RedlichKwongMFTP::getSpeciesParameters
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...
Definition RedlichKwongMFTP.cpp:481
Cantera::RedlichKwongMFTP::omega_b
static const double omega_b
Omega constant for b.
Definition RedlichKwongMFTP.h:283
Cantera::RedlichKwongMFTP::m_pp
vector< double > m_pp
Temporary storage - length = m_kk.
Definition RedlichKwongMFTP.h:249
Cantera::RedlichKwongMFTP::type
string type() const override
String indicating the thermodynamic model implemented.
Definition RedlichKwongMFTP.h:31
Cantera::RedlichKwongMFTP::initThermo
void initThermo() override
Initialize the ThermoPhase object after all species have been set up.
Definition RedlichKwongMFTP.cpp:382
Cantera::RedlichKwongMFTP::densSpinodalGas
double densSpinodalGas() const override
Return the value of the density at the gas spinodal point (on the gas side) for the current temperatu...
Definition RedlichKwongMFTP.cpp:670
Cantera::RedlichKwongMFTP::getPartialMolarVolumes
void getPartialMolarVolumes(double *vbar) const override
Return an array of partial molar volumes for the species in the mixture.
Definition RedlichKwongMFTP.cpp:330
Cantera::RedlichKwongMFTP::cv_mole
double cv_mole() const override
Molar heat capacity at constant volume. Units: J/kmol/K.
Definition RedlichKwongMFTP.cpp:116
Cantera::RedlichKwongMFTP::pressureDerivatives
void pressureDerivatives() const
Calculate dpdV and dpdT at the current conditions.
Definition RedlichKwongMFTP.cpp:723
Cantera::RedlichKwongMFTP::isothermalCompressibility
double isothermalCompressibility() const override
Returns the isothermal compressibility. Units: 1/Pa.
Definition RedlichKwongMFTP.cpp:705
Cantera::RedlichKwongMFTP::hresid
double hresid() const override
Calculate the deviation terms for the total enthalpy of the mixture from the ideal gas mixture.
Definition RedlichKwongMFTP.cpp:546
Cantera::RedlichKwongMFTP::omega_a
static const double omega_a
Omega constant for a -> value of a in terms of critical properties.
Definition RedlichKwongMFTP.h:280
Cantera::RedlichKwongMFTP::liquidVolEst
double liquidVolEst(double TKelvin, double &pres) const override
Estimate for the molar volume of the liquid.
Definition RedlichKwongMFTP.cpp:561
Cantera::RedlichKwongMFTP::dpdVCalc
double dpdVCalc(double TKelvin, double molarVol, double &presCalc) const override
Calculate the pressure and the pressure derivative given the temperature and the molar volume.
Definition RedlichKwongMFTP.cpp:692
Cantera::RedlichKwongMFTP::omega_vc
static const double omega_vc
Omega constant for the critical molar volume.
Definition RedlichKwongMFTP.h:286
Cantera::RedlichKwongMFTP::m_coeffSource
vector< CoeffSource > m_coeffSource
For each species, specifies the source of the a and b coefficients.
Definition RedlichKwongMFTP.h:242
Cantera::RedlichKwongMFTP::getPartialMolarIntEnergies
void getPartialMolarIntEnergies(double *ubar) const override
Return an array of partial molar internal energies for the species in the mixture.
Definition RedlichKwongMFTP.cpp:319
Cantera::RedlichKwongMFTP::updateMixingExpressions
void updateMixingExpressions() override
Update the a and b parameters.
Definition RedlichKwongMFTP.cpp:738
Cantera::RedlichKwongMFTP::cp_mole
double cp_mole() const override
Molar heat capacity at constant pressure. Units: J/kmol/K.
Definition RedlichKwongMFTP.cpp:100
Cantera::RedlichKwongMFTP::getPartialMolarCp
void getPartialMolarCp(double *cpbar) const override
Return an array of partial molar heat capacities for the species in the mixture.
Definition RedlichKwongMFTP.h:108
Cantera::RedlichKwongMFTP::m_a_current
double m_a_current
Value of a in the equation of state.
Definition RedlichKwongMFTP.h:230
Cantera::RedlichKwongMFTP::standardConcentration
double standardConcentration(size_t k=0) const override
Returns the standard concentration , which is used to normalize the generalized concentration.
Definition RedlichKwongMFTP.cpp:141
Cantera::RedlichKwongMFTP::dpdV_
double dpdV_
The derivative of the pressure wrt the volume.
Definition RedlichKwongMFTP.h:259
Cantera::RedlichKwongMFTP::addSpecies
bool addSpecies(shared_ptr< Species > spec) override
Add a Species to this Phase.
Definition RedlichKwongMFTP.cpp:363
Cantera::RedlichKwongMFTP::m_b_current
double m_b_current
Value of b in the equation of state.
Definition RedlichKwongMFTP.h:224
Cantera::RedlichKwongMFTP::getChemPotentials_RT
void getChemPotentials_RT(double *mu) const override
Get the array of non-dimensional species chemical potentials.
Definition RedlichKwongMFTP.cpp:179
Cantera::RedlichKwongMFTP::getActivityCoefficients
void getActivityCoefficients(double *ac) const override
Get the array of non-dimensional activity coefficients at the current solution temperature,...
Definition RedlichKwongMFTP.cpp:147
Cantera::RedlichKwongMFTP::densityCalc
double densityCalc(double T, double pressure, int phase, double rhoguess) override
Calculates the density given the temperature and the pressure and a guess at the density.
Definition RedlichKwongMFTP.cpp:593
Cantera::RedlichKwongMFTP::dpdni_
vector< double > dpdni_
Vector of derivatives of pressure wrt mole number.
Definition RedlichKwongMFTP.h:273
Cantera::RedlichKwongMFTP::getPartialMolarEntropies
void getPartialMolarEntropies(double *sbar) const override
Returns an array of partial molar entropies of the species in the solution.
Definition RedlichKwongMFTP.cpp:268
Cantera::RedlichKwongMFTP::m_binaryParameters
map< string, map< string, pair< double, double > > > m_binaryParameters
Explicitly-specified binary interaction parameters.
Definition RedlichKwongMFTP.h:238
Cantera::RedlichKwongMFTP::setSpeciesCoeffs
void setSpeciesCoeffs(const string &species, double a0, double a1, double b)
Set the pure fluid interaction parameters for a species.
Definition RedlichKwongMFTP.cpp:29
Cantera::RedlichKwongMFTP::solveCubic
int solveCubic(double T, double pres, double a, double b, double Vroot[3]) const
Prepare variables and call the function to solve the cubic equation of state.
Definition RedlichKwongMFTP.cpp:867
Cantera
Namespace for the Cantera kernel.
Definition AnyMap.cpp:564