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