Cantera  2.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AqueousTransport.h
Go to the documentation of this file.
1 /**
2  * @file AqueousTransport.h
3  * Header file defining class AqueousTransport
4  */
5 // Copyright 2001 California Institute of Technology
6 
7 #ifndef CT_AQUEOUSTRAN_H
8 #define CT_AQUEOUSTRAN_H
9 
10 // Cantera includes
11 #include "TransportBase.h"
13 
14 namespace Cantera
15 {
16 //! Class AqueousTransport implements mixture-averaged transport
17 //! properties for brine phases.
18 /*!
19  * The model is based on that described by Newman, Electrochemical Systems
20  *
21  * The velocity of species i may be described by the
22  * following equation p. 297 (12.1)
23  *
24  * \f[
25  * c_i \nabla \mu_i = R T \sum_j \frac{c_i c_j}{c_T D_{ij}}
26  * (\mathbf{v}_j - \mathbf{v}_i)
27  * \f]
28  *
29  * This as written is degenerate by 1 dof.
30  *
31  * To fix this we must add in the definition of the mass averaged
32  * velocity of the solution. We will call the simple bold-faced
33  * \f$\mathbf{v} \f$
34  * symbol the mass-averaged velocity. Then, the relation
35  * between \f$\mathbf{v}\f$ and the individual species velocities is
36  * \f$\mathbf{v}_i\f$
37  *
38  * \f[
39  * \rho_i \mathbf{v}_i = \rho_i \mathbf{v} + \mathbf{j}_i
40  * \f]
41  * where \f$\mathbf{j}_i\f$ are the diffusional fluxes of species i
42  * with respect to the mass averaged velocity and
43  *
44  * \f[
45  * \sum_i \mathbf{j}_i = 0
46  * \f]
47  *
48  * and
49  *
50  * \f[
51  * \sum_i \rho_i \mathbf{v}_i = \rho \mathbf{v}
52  * \f]
53  *
54  * Using these definitions, we can write
55  *
56  * \f[
57  * \mathbf{v}_i = \mathbf{v} + \frac{\mathbf{j}_i}{\rho_i}
58  * \f]
59  *
60  * \f[
61  * c_i \nabla \mu_i = R T \sum_j \frac{c_i c_j}{c_T D_{ij}}
62  * (\frac{\mathbf{j}_j}{\rho_j} - \frac{\mathbf{j}_i}{\rho_i})
63  * = R T \sum_j \frac{1}{D_{ij}}
64  * (\frac{x_i \mathbf{j}_j}{M_j} - \frac{x_j \mathbf{j}_i}{M_i})
65  * \f]
66  *
67  * The equations that we actually solve are
68  *
69  * \f[
70  * c_i \nabla \mu_i =
71  * = R T \sum_j \frac{1}{D_{ij}}
72  * (\frac{x_i \mathbf{j}_j}{M_j} - \frac{x_j \mathbf{j}_i}{M_i})
73  * \f]
74  * and we replace the 0th equation with the following:
75  *
76  * \f[
77  * \sum_i \mathbf{j}_i = 0
78  * \f]
79  *
80  * When there are charged species, we replace the RHS with the
81  * gradient of the electrochemical potential to obtain the
82  * modified equation
83  *
84  * \f[
85  * c_i \nabla \mu_i + c_i F z_i \nabla \Phi
86  * = R T \sum_j \frac{1}{D_{ij}}
87  * (\frac{x_i \mathbf{j}_j}{M_j} - \frac{x_j \mathbf{j}_i}{M_i})
88  * \f]
89  *
90  * With this formulation we may solve for the diffusion velocities, without
91  * having to worry about what the mass averaged velocity is.
92  *
93  * <H2> Viscosity Calculation </H2>
94  *
95  * The viscosity calculation may be broken down into two parts.
96  * In the first part, the viscosity of the pure species are calculated
97  * In the second part, a mixing rule is applied, based on the
98  * Wilkes correlation, to yield the mixture viscosity.
99  * @ingroup tranprops
100  * @deprecated Non-functional. To be removed after Cantera 2.2.
101  */
103 {
104 public:
106 
107  virtual int model() const {
108  return cAqueousTransport;
109  }
110 
111  //! Returns the viscosity of the solution
112  /*!
113  * The viscosity is computed using the Wilke mixture rule.
114  * \f[
115  * \mu = \sum_k \frac{\mu_k X_k}{\sum_j \Phi_{k,j} X_j}.
116  * \f]
117  * Here \f$ \mu_k \f$ is the viscosity of pure species \e k,
118  * and
119  * \f[
120  * \Phi_{k,j} = \frac{\left[1
121  * + \sqrt{\left(\frac{\mu_k}{\mu_j}\sqrt{\frac{M_j}{M_k}}\right)}\right]^2}
122  * {\sqrt{8}\sqrt{1 + M_k/M_j}}
123  * \f]
124  * @see updateViscosity_T();
125  *
126  * Controlling update boolean m_viscmix_ok
127  */
128  virtual doublereal viscosity();
129 
130  //! Returns the pure species viscosities
131  /*!
132  * Controlling update boolean = m_viscwt_ok
133  *
134  * @param visc Vector of species viscosities
135  */
136  virtual void getSpeciesViscosities(doublereal* const visc);
137 
138  //! Return a vector of Thermal diffusion coefficients [kg/m/sec].
139  /*!
140  * The thermal diffusion coefficient \f$ D^T_k \f$ is defined
141  * so that the diffusive mass flux of species <I>k</I> induced by the
142  * local temperature gradient is given by the following formula
143  *
144  * \f[
145  * M_k J_k = -D^T_k \nabla \ln T.
146  * \f]
147  *
148  * The thermal diffusion coefficient can be either positive or negative.
149  *
150  * In this method we set it to zero.
151  *
152  * @param dt On return, dt will contain the species thermal
153  * diffusion coefficients. Dimension dt at least as large as
154  * the number of species. Units are kg/m/s.
155  */
156  virtual void getThermalDiffCoeffs(doublereal* const dt);
157 
158  //! Return the thermal conductivity of the solution
159  /*!
160  * The thermal conductivity is computed from the following mixture rule:
161  * \f[
162  * \lambda = 0.5 \left( \sum_k X_k \lambda_k
163  * + \frac{1}{\sum_k X_k/\lambda_k}\right)
164  * \f]
165  *
166  * Controlling update boolean = m_condmix_ok
167  */
168  virtual doublereal thermalConductivity();
169 
170  virtual void getBinaryDiffCoeffs(const size_t ld, doublereal* const d);
171 
172  //! Get the Mixture diffusion coefficients
173  /*!
174  * For the single species case or the pure fluid case the routine returns
175  * the self-diffusion coefficient. This is need to avoid a NaN result.
176  * @param d vector of mixture diffusion coefficients
177  * units = m2 s-1. length = number of species
178  */
179  virtual void getMixDiffCoeffs(doublereal* const d);
180 
181  virtual void getMobilities(doublereal* const mobil_e);
182 
183  virtual void getFluidMobilities(doublereal* const mobil_f);
184 
185  //! Specify the value of the gradient of the voltage
186  /*!
187  * @param grad_V Gradient of the voltage (length num dimensions);
188  */
189  virtual void set_Grad_V(const doublereal* const grad_V);
190 
191  //! Specify the value of the gradient of the temperature
192  /*!
193  * @param grad_T Gradient of the temperature (length num dimensions);
194  */
195  virtual void set_Grad_T(const doublereal* const grad_T);
196 
197  //! Specify the value of the gradient of the MoleFractions
198  /*!
199  * @param grad_X Gradient of the mole fractions(length nsp * num dimensions);
200  */
201  virtual void set_Grad_X(const doublereal* const grad_X);
202 
203  //! Handles the effects of changes in the Temperature, internally
204  //! within the object.
205  /*!
206  * This is called whenever a transport property is requested. The first
207  * task is to check whether the temperature has changed since the last
208  * call to update_T(). If it hasn't then an immediate return is carried
209  * out.
210  */
211  virtual void update_T();
212 
213  //! Handles the effects of changes in the mixture concentration
214  /*!
215  * This is called the first time any transport property is requested from
216  * Mixture after the concentrations have changed.
217  */
218  virtual void update_C();
219 
220  virtual void getSpeciesFluxes(size_t ndim, const doublereal* const grad_T,
221  size_t ldx, const doublereal* const grad_X,
222  size_t ldf, doublereal* const fluxes);
223 
224  //! Return the species diffusive mass fluxes wrt to the specified averaged velocity,
225  /*!
226  * This method acts similarly to getSpeciesFluxesES() but
227  * requires all gradients to be preset using methods set_Grad_X(), set_Grad_V(), set_Grad_T().
228  * See the documentation of getSpeciesFluxesES() for details.
229  *
230  * units = kg/m2/s
231  *
232  * Internally, gradients in the in mole fraction, temperature
233  * and electrostatic potential contribute to the diffusive flux
234  *
235  * The diffusive mass flux of species \e k is computed from the following formula
236  *
237  * \f[
238  * j_k = - \rho M_k D_k \nabla X_k - Y_k V_c
239  * \f]
240  *
241  * where V_c is the correction velocity
242  *
243  * \f[
244  * V_c = - \sum_j {\rho M_j D_j \nabla X_j}
245  * \f]
246  *
247  * @param ldf Stride of the fluxes array. Must be equal to or greater than the number of species.
248  * @param fluxes Output of the diffusive fluxes. Flat vector with the m_nsp in the inner loop.
249  * length = ldx * ndim
250  */
251  virtual void getSpeciesFluxesExt(size_t ldf, doublereal* const fluxes);
252 
253  //! Initialize the transport object
254  /*!
255  * Here we change all of the internal dimensions to be sufficient.
256  * We get the object ready to do property evaluations.
257  *
258  * @param tr Transport parameters for all of the species in the phase.
259  */
260  virtual bool initLiquid(LiquidTransportParams& tr);
261 
262  friend class TransportFactory;
263 
264  /**
265  * Return a structure containing all of the pertinent parameters
266  * about a species that was used to construct the Transport
267  * properties in this object.
268  *
269  * @param k Species number to obtain the properties about.
270  */
272 
273  //! Solve the Stefan-Maxwell equations for the diffusive fluxes.
274  void stefan_maxwell_solve();
275 
276 private:
277  //! Local Copy of the molecular weights of the species
278  /*!
279  * Length is Equal to the number of species in the mechanism.
280  */
282 
283  //! Polynomial coefficients of the viscosity
284  /*!
285  * These express the temperature dependence of the pure species viscosities.
286  */
287  std::vector<vector_fp> m_visccoeffs;
288 
289  //! Polynomial coefficients of the conductivities
290  /*!
291  * These express the temperature dependence of the pure species conductivities
292  */
293  std::vector<vector_fp> m_condcoeffs;
294 
295  //! Polynomial coefficients of the binary diffusion coefficients
296  /*!
297  * These express the temperature dependence of the binary diffusivities.
298  * An overall pressure dependence is then added.
299  */
300  std::vector<vector_fp> m_diffcoeffs;
301 
302  //! Internal value of the gradient of the mole fraction vector
303  /*!
304  * m_nsp is the number of species in the fluid
305  * k is the species index
306  * n is the dimensional index (x, y, or z). It has a length
307  * equal to m_nDim
308  *
309  * m_Grad_X[n*m_nsp + k]
310  */
312 
313  //! Internal value of the gradient of the Temperature vector
314  /*!
315  * Generally, if a transport property needs this in its evaluation it
316  * will look to this place to get it.
317  *
318  * No internal property is precalculated based on gradients. Gradients
319  * are assumed to be freshly updated before every property call.
320  */
322 
323  //! Internal value of the gradient of the Electric Voltage
324  /*!
325  * Generally, if a transport property needs this in its evaluation it
326  * will look to this place to get it.
327  *
328  * No internal property is precalculated based on gradients. Gradients
329  * are assumed to be freshly updated before every property call.
330  */
332 
333  //! Gradient of the electrochemical potential
334  /*!
335  * m_nsp is the number of species in the fluid
336  * k is the species index
337  * n is the dimensional index (x, y, or z)
338  *
339  * m_Grad_mu[n*m_nsp + k]
340  */
342 
343  // property values
344 
345  //! Array of Binary Diffusivities
346  /*!
347  * This has a size equal to nsp x nsp
348  * It is a symmetric matrix.
349  * D_ii is undefined.
350  *
351  * units m2/sec
352  */
354 
355  //! Species viscosities
356  /*!
357  * Viscosity of the species
358  * Length = number of species
359  *
360  * Depends on the temperature and perhaps pressure, but
361  * not the species concentrations
362  *
363  * controlling update boolean -> m_spvisc_ok
364  */
366 
367  //! Sqrt of the species viscosities
368  /*!
369  * The sqrt(visc) is used in the mixing formulas
370  * Length = m_nsp
371  *
372  * Depends on the temperature and perhaps pressure, but
373  * not the species concentrations
374  *
375  * controlling update boolean m_spvisc_ok
376  */
378 
379  //! Internal value of the species individual thermal conductivities
380  /*!
381  * Then a mixture rule is applied to get the solution conductivities
382  *
383  * Depends on the temperature and perhaps pressure, but
384  * not the species concentrations
385  *
386  * controlling update boolean -> m_spcond_ok
387  */
389 
390  //! Polynomials of the log of the temperature
392 
393  //! State of the mole fraction vector.
395 
396  //! Local copy of the mole fractions of the species in the phase
397  /*!
398  * Update info?
399  * length = m_nsp
400  */
402 
403  //! Local copy of the concentrations of the species in the phase
404  /*!
405  * Update info?
406  * length = m_nsp
407  */
409 
410  //! Local copy of the charge of each species
411  /*!
412  * Contains the charge of each species (length m_nsp)
413  */
415 
416  //! Stefan-Maxwell Diffusion Coefficients at T, P and C
417  /*!
418  * These diffusion coefficients are considered to be
419  * a function of Temperature, Pressure, and Concentration.
420  */
422 
423  //! viscosity weighting functions
425 
426  //! Matrix of the ratios of the species molecular weights
427  /*!
428  * m_wratjk(i,j) = (m_mw[j]/m_mw[k])**0.25
429  */
431 
432  //! Matrix of the ratios of the species molecular weights
433  /*!
434  * m_wratkj1(i,j) = (1.0 + m_mw[k]/m_mw[j])**0.5
435  */
437 
438  //! RHS to the Stefan-Maxwell equation
440 
441  //! Matrix for the Stefan-Maxwell equation.
443 
444  //! Internal storage for the species LJ well depth
446 
447  //! Internal storage for species polarizability
449 
450  //! Current Temperature -> locally stored
451  /*!
452  * This is used to test whether new temperature computations
453  * should be performed.
454  */
455  doublereal m_temp;
456 
457  //! Current log(T)
458  doublereal m_logt;
459 
460  //! Current value of kT
461  doublereal m_kbt;
462 
463  //! Current Temperature **0.5
464  doublereal m_sqrt_t;
465 
466  //! Current Temperature **0.25
467  doublereal m_t14;
468 
469  //! Current Temperature **1.5
470  doublereal m_t32;
471 
472  //! Current temperature function
473  /*!
474  * This is equal to sqrt(Boltzmann * T)
475  */
476  doublereal m_sqrt_kbt;
477 
478  //! Current value of the pressure
479  doublereal m_press;
480 
481  //! Solution of the flux system
483 
484  //! saved value of the mixture thermal conductivity
485  doublereal m_lambda;
486 
487  //! Saved value of the mixture viscosity
488  doublereal m_viscmix;
489 
490  //! work space of size m_nsp
492 
493  //! Update the temperature-dependent viscosity terms.
494  /*!
495  * Updates the array of pure species viscosities, and the weighting
496  * functions in the viscosity mixture rule. The flag m_visc_ok is set to
497  * true.
498  */
499  void updateViscosity_T();
500 
501  //! Update the temperature-dependent parts of the mixture-averaged
502  //! thermal conductivity.
503  void updateCond_T();
504 
505  //! Update the species viscosities
506  /*!
507  * Internal routine is run whenever the update_boolean
508  * m_spvisc_ok is false. This routine will calculate
509  * internal values for the species viscosities.
510  */
512 
513  //! Update the binary diffusion coefficients wrt T.
514  /*!
515  * These are evaluated from the polynomial fits at unit pressure (1 Pa).
516  */
517  void updateDiff_T();
518 
519  //! Boolean indicating that mixture viscosity is current
521 
522  //! Boolean indicating that weight factors wrt viscosity is current
524 
525  //! Flag to indicate that the pure species viscosities
526  //! are current wrt the temperature
528 
529  //! Boolean indicating that mixture diffusion coeffs are current
531 
532  //! Boolean indicating that binary diffusion coeffs are current
534 
535  //! Flag to indicate that the pure species conductivities
536  //! are current wrt the temperature
538 
539  //! Boolean indicating that mixture conductivity is current
541 
542  //! Mode for fitting the species viscosities
543  /*!
544  * Either it's CK_Mode or it's cantera mode
545  * in CK_Mode visc is fitted to a polynomial
546  * in Cantera mode sqrt(visc) is fitted.
547  */
548  int m_mode;
549 
550  //! Internal storage for the diameter - diameter
551  //! species interactions
553 
554  //! Debugging flags
555  /*!
556  * Turn on to get debugging information
557  */
558  bool m_debug;
559 
560  //! Number of dimensions
561  /*!
562  * Either 1, 2, or 3
563  */
564  size_t m_nDim;
565 };
566 }
567 #endif
DenseMatrix m_wratkj1
Matrix of the ratios of the species molecular weights.
virtual int model() const
Transport model.
virtual void getThermalDiffCoeffs(doublereal *const dt)
Return a vector of Thermal diffusion coefficients [kg/m/sec].
bool m_bindiff_ok
Boolean indicating that binary diffusion coeffs are current.
doublereal m_t14
Current Temperature **0.25.
vector_fp m_mw
Local Copy of the molecular weights of the species.
bool m_spvisc_ok
Flag to indicate that the pure species viscosities are current wrt the temperature.
virtual void set_Grad_X(const doublereal *const grad_X)
Specify the value of the gradient of the MoleFractions.
DenseMatrix m_phi
viscosity weighting functions
vector_fp m_alpha
Internal storage for species polarizability.
std::vector< vector_fp > m_condcoeffs
Polynomial coefficients of the conductivities.
doublereal m_viscmix
Saved value of the mixture viscosity.
DenseMatrix m_bdiff
Array of Binary Diffusivities.
Factory class for creating new instances of classes derived from Transport.
doublereal m_sqrt_kbt
Current temperature function.
bool m_condmix_ok
Boolean indicating that mixture conductivity is current.
Headers for the Transport object, which is the virtual base class for all transport property evaluato...
bool m_viscwt_ok
Boolean indicating that weight factors wrt viscosity is current.
Base class for transport property managers.
Class LiquidTransportData holds transport parameters for a specific liquid-phase species.
vector_fp m_spwork
work space of size m_nsp
bool m_viscmix_ok
Boolean indicating that mixture viscosity is current.
DenseMatrix m_A
Matrix for the Stefan-Maxwell equation.
virtual void getMobilities(doublereal *const mobil_e)
Get the Electrical mobilities (m^2/V/s).
doublereal m_lambda
saved value of the mixture thermal conductivity
A class for 2D arrays stored in column-major (Fortran-compatible) form.
Definition: Array.h:29
virtual void getBinaryDiffCoeffs(const size_t ld, doublereal *const d)
Returns the matrix of binary diffusion coefficients [m^2/s].
vector_fp m_cond
Internal value of the species individual thermal conductivities.
Class LiquidTransportParams holds transport model parameters relevant to transport in mixtures...
void updateSpeciesViscosities()
Update the species viscosities.
virtual void update_C()
Handles the effects of changes in the mixture concentration.
void updateViscosity_T()
Update the temperature-dependent viscosity terms.
int m_iStateMF
State of the mole fraction vector.
doublereal m_press
Current value of the pressure.
DenseMatrix m_DiffCoeff_StefMax
Stefan-Maxwell Diffusion Coefficients at T, P and C.
std::vector< vector_fp > m_diffcoeffs
Polynomial coefficients of the binary diffusion coefficients.
DenseMatrix m_wratjk
Matrix of the ratios of the species molecular weights.
bool m_diffmix_ok
Boolean indicating that mixture diffusion coeffs are current.
DenseMatrix m_diam
Internal storage for the diameter - diameter species interactions.
doublereal m_sqrt_t
Current Temperature **0.5.
vector_fp m_Grad_X
Internal value of the gradient of the mole fraction vector.
virtual void set_Grad_T(const doublereal *const grad_T)
Specify the value of the gradient of the temperature.
virtual void getFluidMobilities(doublereal *const mobil_f)
Get the fluid mobilities (s kmol/kg).
Array2D m_B
RHS to the Stefan-Maxwell equation.
vector_fp m_Grad_mu
Gradient of the electrochemical potential.
virtual doublereal thermalConductivity()
Return the thermal conductivity of the solution.
virtual bool initLiquid(LiquidTransportParams &tr)
Initialize the transport object.
doublereal m_logt
Current log(T)
size_t m_nDim
Number of dimensions.
virtual void getSpeciesFluxes(size_t ndim, const doublereal *const grad_T, size_t ldx, const doublereal *const grad_X, size_t ldf, doublereal *const fluxes)
Get the species diffusive mass fluxes wrt to the specified solution averaged velocity, given the gradients in mole fraction and temperature.
virtual void getSpeciesViscosities(doublereal *const visc)
Returns the pure species viscosities.
virtual void getSpeciesFluxesExt(size_t ldf, doublereal *const fluxes)
Return the species diffusive mass fluxes wrt to the specified averaged velocity,. ...
vector_fp m_concentrations
Local copy of the concentrations of the species in the phase.
int m_mode
Mode for fitting the species viscosities.
doublereal m_t32
Current Temperature **1.5.
vector_fp m_sqvisc
Sqrt of the species viscosities.
vector_fp m_eps
Internal storage for the species LJ well depth.
std::vector< vector_fp > m_visccoeffs
Polynomial coefficients of the viscosity.
void updateDiff_T()
Update the binary diffusion coefficients wrt T.
vector_fp m_polytempvec
Polynomials of the log of the temperature.
vector_fp m_visc
Species viscosities.
bool m_debug
Debugging flags.
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
Definition: ct_defs.h:157
doublereal m_kbt
Current value of kT.
void updateCond_T()
Update the temperature-dependent parts of the mixture-averaged thermal conductivity.
doublereal m_temp
Current Temperature -> locally stored.
Headers for the DenseMatrix object, which deals with dense rectangular matrices and description of th...
class LiquidTransportData getLiquidTransportData(int k)
Return a structure containing all of the pertinent parameters about a species that was used to constr...
bool m_spcond_ok
Flag to indicate that the pure species conductivities are current wrt the temperature.
void stefan_maxwell_solve()
Solve the Stefan-Maxwell equations for the diffusive fluxes.
vector_fp m_chargeSpecies
Local copy of the charge of each species.
virtual doublereal viscosity()
Returns the viscosity of the solution.
vector_fp m_Grad_V
Internal value of the gradient of the Electric Voltage.
vector_fp m_Grad_T
Internal value of the gradient of the Temperature vector.
Array2D m_flux
Solution of the flux system.
virtual void set_Grad_V(const doublereal *const grad_V)
Specify the value of the gradient of the voltage.
A class for full (non-sparse) matrices with Fortran-compatible data storage, which adds matrix operat...
Definition: DenseMatrix.h:71
vector_fp m_molefracs
Local copy of the mole fractions of the species in the phase.
virtual void getMixDiffCoeffs(doublereal *const d)
Get the Mixture diffusion coefficients.
Class AqueousTransport implements mixture-averaged transport properties for brine phases...
virtual void update_T()
Handles the effects of changes in the Temperature, internally within the object.