Cantera  4.0.0a1
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(span<double> ac) const override;
85
86 //! @name Partial Molar Properties of the Solution
87 //! @{
88
89 void getChemPotentials(span<double> mu) const override;
90 void getPartialMolarEnthalpies(span<double> hbar) const override;
91 void getPartialMolarEntropies(span<double> sbar) const override;
92 void getPartialMolarIntEnergies(span<double> ubar) const override;
93 void getPartialMolarCp(span<double> cpbar) const override {
94 throw NotImplementedError("RedlichKwongMFTP::getPartialMolarCp");
95 }
96 void getPartialMolarVolumes(span<double> vbar) const override;
97 //! @}
98
99public:
100 //! @name Initialization Methods - For Internal use
101 //!
102 //! The following methods are used in the process of constructing
103 //! the phase and setting its parameters from a specification in an
104 //! input file. They are not normally used in application programs.
105 //! To see how they are used, see importPhase().
106 //! @{
107
108 bool addSpecies(shared_ptr<Species> spec) override;
109 void initThermo() override;
110 void getSpeciesParameters(const string& name, AnyMap& speciesNode) const override;
111
112 //! Set the pure fluid interaction parameters for a species
113 /*!
114 * The "a" parameter for species *i* in the Redlich-Kwong model is assumed
115 * to be a linear function of temperature:
116 * @f[ a = a_0 + a_1 T @f]
117 *
118 * @param species Name of the species
119 * @param a0 constant term in the expression for the "a" parameter
120 * of the specified species [Pa-m^6/kmol^2]
121 * @param a1 temperature-proportional term in the expression for the
122 * "a" parameter of the specified species [Pa-m^6/kmol^2/K]
123 * @param b "b" parameter in the Redlich-Kwong model [m^3/kmol]
124 */
125 void setSpeciesCoeffs(const string& species, double a0, double a1, double b);
126
127 //! Set values for the interaction parameter between two species
128 /*!
129 * The "a" parameter for interactions between species *i* and *j* is
130 * assumed by default to be computed as:
131 * @f[ a_{ij} = \sqrt(a_{i,0} a_{j,0}) + \sqrt(a_{i,1} a_{j,1}) T @f]
132 *
133 * This function overrides the defaults with the specified parameters:
134 * @f[ a_{ij} = a_{ij,0} + a_{ij,1} T @f]
135 *
136 * @param species_i Name of one species
137 * @param species_j Name of the other species
138 * @param a0 constant term in the "a" expression [Pa-m^6/kmol^2]
139 * @param a1 temperature-proportional term in the "a" expression
140 * [Pa-m^6/kmol^2/K]
141 */
142 void setBinaryCoeffs(const string& species_i,
143 const string& species_j, double a0, double a1);
144 //! @}
145
146protected:
147 // Special functions inherited from MixtureFugacityTP
148 double sresid() const override;
149 double hresid() const override;
150
151public:
152 double liquidVolEst(double TKelvin, double& pres) const override;
153 double densityCalc(double T, double pressure, int phase, double rhoguess) override;
154 double dpdVCalc(double TKelvin, double molarVol, double& presCalc) const override;
155
156 double isothermalCompressibility() const override;
157 double thermalExpansionCoeff() const override;
158 double soundSpeed() const override;
159
160 //! Calculate dpdV and dpdT at the current conditions
161 /*!
162 * These are stored internally.
163 */
164 void pressureDerivatives() const;
165
166 //! Update the a and b parameters
167 /*!
168 * The a and the b parameters depend on the mole fraction and the
169 * temperature. This function updates the internal numbers based on the
170 * state of the object.
171 */
172 void updateMixingExpressions() override;
173
174 //! Calculate the a and the b parameters given the temperature
175 /*!
176 * This function doesn't change the internal state of the object, so it is a
177 * const function. It does use the stored mole fractions in the object.
178 *
179 * @param temp Temperature (TKelvin)
180 * @param aCalc (output) Returns the a value
181 * @param bCalc (output) Returns the b value.
182 */
183 void calculateAB(double temp, double& aCalc, double& bCalc) const;
184
185 // Special functions not inherited from MixtureFugacityTP
186
187 double da_dt() const;
188
189 void calcCriticalConditions(double& pc, double& tc, double& vc) const override;
190
191 //! Prepare variables and call the function to solve the cubic equation of state
192 int solveCubic(double T, double pres, double a, double b, span<double> Vroot) const;
193
194protected:
195 //! Form of the temperature parameterization
196 /*!
197 * - 0 = There is no temperature parameterization of a or b
198 * - 1 = The a_ij parameter is a linear function of the temperature
199 */
201
202 //! Value of b in the equation of state
203 /*!
204 * m_b is a function of the temperature and the mole fraction.
205 */
206 double m_b_current = 0.0;
207
208 //! Value of a in the equation of state
209 /*!
210 * a_b is a function of the temperature and the mole fraction.
211 */
212 double m_a_current = 0.0;
213
214 vector<double> a_vec_Curr_;
215 vector<double> b_vec_Curr_;
216
217 Array2D a_coeff_vec;
218
219 //! Explicitly-specified binary interaction parameters
220 map<string, map<string, pair<double, double>>> m_binaryParameters;
221
222 enum class CoeffSource { EoS, CritProps, Database };
223 //! For each species, specifies the source of the a and b coefficients
224 vector<CoeffSource> m_coeffSource;
225
226 int NSolns_ = 0;
227
228 double Vroot_[3] = {0.0, 0.0, 0.0};
229
230 //! Temporary storage - length = m_kk.
231 mutable vector<double> m_pp;
232
233 // Partial molar volumes of the species
234 mutable vector<double> m_partialMolarVolumes;
235
236 //! The derivative of the pressure wrt the volume
237 /*!
238 * Calculated at the current conditions. temperature and mole number kept
239 * constant
240 */
241 mutable double dpdV_ = 0.0;
242
243 //! The derivative of the pressure wrt the temperature
244 /*!
245 * Calculated at the current conditions. Total volume and mole number kept
246 * constant
247 */
248 mutable double dpdT_ = 0.0;
249
250 //! Vector of derivatives of pressure wrt mole number
251 /*!
252 * Calculated at the current conditions. Total volume, temperature and
253 * other mole number kept constant
254 */
255 mutable vector<double> dpdni_;
256
257private:
258 //! Omega constant for a -> value of a in terms of critical properties
259 /*!
260 * this was calculated from a small nonlinear solve
261 */
262 static const double omega_a;
263
264 //! Omega constant for b
265 static const double omega_b;
266
267 //! Omega constant for the critical molar volume
268 static const double omega_vc;
269};
270}
271
272#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:431
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:881
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 sresid() const override
Calculate the deviation terms for the total entropy of the mixture from the ideal gas mixture.
void getPartialMolarEnthalpies(span< double > hbar) const override
Returns an array of partial molar enthalpies for the species in the 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...
void getPartialMolarCp(span< double > cpbar) const override
Return an array of partial molar heat capacities for the species in the mixture.
static const double omega_b
Omega constant for b.
vector< double > m_pp
Temporary storage - length = m_kk.
void getActivityCoefficients(span< double > ac) const override
Get the array of non-dimensional activity coefficients at the current solution temperature,...
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 cv_mole() const override
Molar heat capacity at constant volume and composition [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 updateMixingExpressions() override
Update the a and b parameters.
double cp_mole() const override
Molar heat capacity at constant pressure and composition [J/kmol/K].
void getPartialMolarVolumes(span< double > vbar) const override
Return an array of partial molar volumes for the species in the mixture.
double m_a_current
Value of a in the equation of state.
void getPartialMolarEntropies(span< double > sbar) const override
Returns an array of partial molar entropies of the species in the solution.
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(span< double > mu) const override
Get the species chemical potentials. Units: J/kmol.
int solveCubic(double T, double pres, double a, double b, span< double > Vroot) const
Prepare variables and call the function to solve the cubic equation of state.
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.
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.
void getPartialMolarIntEnergies(span< double > ubar) const override
Return an array of partial molar internal energies for the species in the mixture.
Namespace for the Cantera kernel.
Definition AnyMap.cpp:595