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
12namespace Cantera
13{
14/**
15 * Implementation of a multi-species Redlich-Kwong equation of state
16 *
17 * @ingroup thermoprops
18 */
20{
21public:
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
57public:
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
114public:
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
161protected:
162 // Special functions inherited from MixtureFugacityTP
163 double sresid() const override;
164 double hresid() const override;
165
166public:
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
212protected:
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 */
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
275private:
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
Header file for class Cantera::Array2D.
Header file for a derived class of ThermoPhase that handles non-ideal mixtures based on the fugacity ...
A map of string keys to values whose type can vary at runtime.
Definition AnyMap.h:427
A class for 2D arrays stored in column-major (Fortran-compatible) form.
Definition Array.h:32
This is a filter class for ThermoPhase that implements some preparatory steps for efficiently handlin...
An error indicating that an unimplemented function has been called.
shared_ptr< Species > species(const string &name) const
Return the Species object for the named species.
Definition Phase.cpp:977
string name() const
Return the name of the phase.
Definition Phase.cpp:20
Implementation of a multi-species Redlich-Kwong equation of state.
double dpdT_
The derivative of the pressure wrt the temperature.
void calculateAB(double temp, double &aCalc, double &bCalc) const
Calculate the a and the b parameters given the temperature.
double thermalExpansionCoeff() const override
Return the volumetric thermal expansion coefficient. Units: 1/K.
void setBinaryCoeffs(const string &species_i, const string &species_j, double a0, double a1)
Set values for the interaction parameter between two species.
double densSpinodalLiquid() const override
Return the value of the density at the liquid spinodal point (on the liquid side) for the current tem...
void getPartialMolarEnthalpies(double *hbar) const override
Returns an array of partial molar enthalpies for the species in the mixture.
void getChemPotentials(double *mu) const override
Get the species chemical potentials. Units: J/kmol.
double sresid() const override
Calculate the deviation terms for the total entropy of the mixture from the ideal gas mixture.
double soundSpeed() const override
Return the speed of sound. Units: m/s.
double pressure() const override
Return the thermodynamic pressure (Pa).
int m_formTempParam
Form of the temperature parameterization.
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...
static const double omega_b
Omega constant for b.
vector< double > m_pp
Temporary storage - length = m_kk.
string type() const override
String indicating the thermodynamic model implemented.
void initThermo() override
Initialize the ThermoPhase object after all species have been set up.
double densSpinodalGas() const override
Return the value of the density at the gas spinodal point (on the gas side) for the current temperatu...
void getPartialMolarVolumes(double *vbar) const override
Return an array of partial molar volumes for the species in the mixture.
double cv_mole() const override
Molar heat capacity at constant volume. Units: J/kmol/K.
void pressureDerivatives() const
Calculate dpdV and dpdT at the current conditions.
double isothermalCompressibility() const override
Returns the isothermal compressibility. Units: 1/Pa.
double hresid() const override
Calculate the deviation terms for the total enthalpy of the mixture from the ideal gas mixture.
static const double omega_a
Omega constant for a -> value of a in terms of critical properties.
double liquidVolEst(double TKelvin, double &pres) const override
Estimate for the molar volume of the liquid.
double dpdVCalc(double TKelvin, double molarVol, double &presCalc) const override
Calculate the pressure and the pressure derivative given the temperature and the molar volume.
static const double omega_vc
Omega constant for the critical molar volume.
vector< CoeffSource > m_coeffSource
For each species, specifies the source of the a and b coefficients.
void getPartialMolarIntEnergies(double *ubar) const override
Return an array of partial molar internal energies for the species in the mixture.
void updateMixingExpressions() override
Update the a and b parameters.
double cp_mole() const override
Molar heat capacity at constant pressure. Units: J/kmol/K.
void getPartialMolarCp(double *cpbar) const override
Return an array of partial molar heat capacities for the species in the mixture.
double m_a_current
Value of a in the equation of state.
double standardConcentration(size_t k=0) const override
Returns the standard concentration , which is used to normalize the generalized concentration.
double dpdV_
The derivative of the pressure wrt the volume.
bool addSpecies(shared_ptr< Species > spec) override
Add a Species to this Phase.
double m_b_current
Value of b in the equation of state.
void getChemPotentials_RT(double *mu) const override
Get the array of non-dimensional species chemical potentials.
void getActivityCoefficients(double *ac) const override
Get the array of non-dimensional activity coefficients at the current solution temperature,...
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.
vector< double > dpdni_
Vector of derivatives of pressure wrt mole number.
void getPartialMolarEntropies(double *sbar) const override
Returns an array of partial molar entropies of the species in the solution.
map< string, map< string, pair< double, double > > > m_binaryParameters
Explicitly-specified binary interaction parameters.
void setSpeciesCoeffs(const string &species, double a0, double a1, double b)
Set the pure fluid interaction parameters for a species.
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.
Namespace for the Cantera kernel.
Definition AnyMap.cpp:564