Cantera  2.0
PecosTransport.h
Go to the documentation of this file.
1 /**
2  * @file PecosTransport.h
3  * Header file defining class PecosTransport
4  */
5 
6 // Copyright 2001 California Institute of Technology
7 
8 
9 #ifndef CT_PECOSTRAN_H
10 #define CT_PECOSTRAN_H
11 
12 // STL includes
13 #include <vector>
14 #include <string>
15 #include <map>
16 #include <numeric>
17 #include <algorithm>
18 
19 #include <iostream>
20 #include <cstdlib>
21 #include <fstream>
22 #include <sstream>
23 #include <stdlib.h>
24 #include <math.h>
25 #include <stdio.h>
26 
27 // Cantera includes
28 #include "TransportBase.h"
30 
31 namespace Cantera
32 {
33 
34 
35 class GasTransportParams;
36 
37 /**
38  *
39  * Class PecosTransport implements mixture-averaged transport
40  * properties for ideal gas mixtures.
41  *
42  */
43 class PecosTransport : public Transport
44 {
45 
46 public:
47 
48  virtual ~PecosTransport() {}
49 
50  virtual int model() const {
51  return cPecosTransport;
52  }
53 
54  //! Viscosity of the mixture
55  /*!
56  *
57  */
58  virtual doublereal viscosity();
59 
60  virtual void getSpeciesViscosities(doublereal* const visc) {
61  update_T();
63  copy(m_visc.begin(), m_visc.end(), visc);
64  }
65 
66  //! Return the thermal diffusion coefficients
67  /*!
68  * For this approximation, these are all zero.
69  */
70  virtual void getThermalDiffCoeffs(doublereal* const dt);
71 
72  /*! returns the mixture thermal conductivity
73  *
74  * This is computed using the lumped model,
75  * \f[
76  * k = k^{tr} + k^{ve}
77  * \f]
78  * where,
79  * \f[
80  * k^{tr}= 5/2 \mu_s C_{v,s}^{trans} + \mu_s C_{v,s}^{rot}
81  * \f]
82  * and,
83  * \f[
84  * k^{ve}= \mu_s C_{v,s}^{vib} + \mu_s C_{v,s}^{elec}
85  * \f]
86  *
87  */
88  virtual doublereal thermalConductivity();
89 
90  virtual void getBinaryDiffCoeffs(const size_t ld, doublereal* const d);
91 
92 
93  //! Mixture-averaged diffusion coefficients [m^2/s].
94  /*!
95  * For the single species case or the pure fluid case
96  * the routine returns the self-diffusion coefficient.
97  * This is need to avoid a Nan result in the formula
98  * below.
99  */
100  virtual void getMixDiffCoeffs(doublereal* const d);
101 
102  //! Returns the mixture-averaged diffusion coefficients [m^2/s].
103  //! These are the coefficients for calculating the molar diffusive fluxes
104  //! from the species mole fraction gradients, computed according to
105  //! Eq. 12.176 in "Chemically Reacting Flow":
106  //!
107  //! \f[ D_{km}^* = \frac{1-X_k}{\sum_{j \ne k}^K X_j/\mathcal{D}_{kj}} \f]
108  //!
109  //! @param[out] d vector of mixture-averaged diffusion coefficients for
110  //! each species, length m_nsp.
111  void getMixDiffCoeffsMole(doublereal* const d);
112 
113  //! Returns the mixture-averaged diffusion coefficients [m^2/s].
114  //! These are the coefficients for calculating the diffusive mass fluxes
115  //! from the species mass fraction gradients, computed according to
116  //! Eq. 12.178 in "Chemically Reacting Flow":
117  //!
118  //! \f[ \frac{1}{D_{km}} = \sum_{j \ne k}^K \frac{X_j}{\mathcal{D}_{kj}} +
119  //! \frac{X_k}{1-Y_k} \sum_{j \ne k}^K \frac{Y_j}{\mathcal{D}_{kj}} \f]
120  //!
121  //! @param[out] d vector of mixture-averaged diffusion coefficients for
122  //! each species, length m_nsp.
123  void getMixDiffCoeffsMass(doublereal* const d);
124 
125  virtual void getMobilities(doublereal* const mobil);
126  virtual void update_T();
127  virtual void update_C();
128 
129  //! Get the species diffusive mass fluxes wrt to
130  //! the mass averaged velocity,
131  //! given the gradients in mole fraction and temperature
132  /*!
133  * Units for the returned fluxes are kg m-2 s-1.
134  *
135  * @param ndim Number of dimensions in the flux expressions
136  * @param grad_T Gradient of the temperature
137  * (length = ndim)
138  * @param ldx Leading dimension of the grad_X array
139  * (usually equal to m_nsp but not always)
140  * @param grad_X Gradients of the mole fraction
141  * Flat vector with the m_nsp in the inner loop.
142  * length = ldx * ndim
143  * @param ldf Leading dimension of the fluxes array
144  * (usually equal to m_nsp but not always)
145  * @param fluxes Output of the diffusive mass fluxes
146  * Flat vector with the m_nsp in the inner loop.
147  * length = ldx * ndim
148  */
149  virtual void getSpeciesFluxes(size_t ndim,
150  const doublereal* const grad_T,
151  size_t ldx,
152  const doublereal* const grad_X,
153  size_t ldf, doublereal* const fluxes);
154 
155  //! Initialize the transport object
156  /*!
157  *
158  * Here we change all of the internal dimensions to be sufficient.
159  * We get the object ready to do property evaluations.
160  *
161  * @param tr Transport parameters for all of the species
162  * in the phase.
163  *
164  */
165  virtual bool initGas(GasTransportParams& tr);
166 
167 
168  /**
169  *
170  * Reads the transport table specified (currently defaults to internal file)
171  *
172  * Reads the user-specified transport table, appending new species
173  * data and/or replacing default species data.
174  *
175  */
177 
178  friend class TransportFactory;
179 
180  /**
181  * Return a structure containing all of the pertinent parameters
182  * about a species that was used to construct the Transport
183  * properties in this object.
184  *
185  * @param k Species number to obtain the properties from.
186  */
187  struct GasTransportData getGasTransportData(int);
188 
189 protected:
190 
191  /// default constructor
192  PecosTransport();
193 
194 private:
195 
196  //! Calculate the pressure from the ideal gas law
197  doublereal pressure_ig() const {
198  return (m_thermo->molarDensity() * GasConstant *
199  m_thermo->temperature());
200  }
201 
202  // mixture attributes
203  int m_nsp;
204  vector_fp m_mw;
205 
206  // polynomial fits
207  std::vector<vector_fp> m_visccoeffs;
208  std::vector<vector_fp> m_condcoeffs;
209  std::vector<vector_fp> m_diffcoeffs;
210  vector_fp m_polytempvec;
211 
212  // blottner fits
213  //int species = 20;
214  double a[500], b[500], c[500];
215 
216  // property values
217  DenseMatrix m_bdiff;
218  vector_fp m_visc;
219  vector_fp m_sqvisc;
220  vector_fp m_cond;
221 
222  vector_fp m_molefracs;
223 
224  std::vector<std::vector<int> > m_poly;
225  std::vector<vector_fp> m_astar_poly;
226  std::vector<vector_fp> m_bstar_poly;
227  std::vector<vector_fp> m_cstar_poly;
228  std::vector<vector_fp> m_om22_poly;
229  DenseMatrix m_astar;
230  DenseMatrix m_bstar;
231  DenseMatrix m_cstar;
232  DenseMatrix m_om22;
233 
234  DenseMatrix m_phi; // viscosity weighting functions
235  DenseMatrix m_wratjk, m_wratkj1;
236 
237  vector_fp m_zrot;
238  vector_fp m_crot;
239  vector_fp m_cinternal;
240  vector_fp m_eps;
241  vector_fp m_alpha;
242  vector_fp m_dipoleDiag;
243 
244  doublereal m_temp, m_logt, m_kbt, m_t14, m_t32;
245  doublereal m_sqrt_kbt, m_sqrt_t;
246 
247  vector_fp m_sqrt_eps_k;
248  DenseMatrix m_log_eps_k;
249  vector_fp m_frot_298;
250  vector_fp m_rotrelax;
251 
252  doublereal m_lambda;
253  doublereal m_viscmix;
254 
255  // work space
256  vector_fp m_spwork;
257 
258  void updateThermal_T();
259  void updateViscosity_T();
260  void updateCond_T();
262  void updateDiff_T();
263  void correctBinDiffCoeffs();
264  bool m_viscmix_ok;
265  bool m_viscwt_ok;
266  bool m_spvisc_ok;
267  bool m_diffmix_ok;
268  bool m_bindiff_ok;
269  bool m_abc_ok;
270  bool m_spcond_ok;
271  bool m_condmix_ok;
272 
273  int m_mode;
274 
275  DenseMatrix m_epsilon;
276  DenseMatrix m_diam;
277  DenseMatrix incl;
278  bool m_debug;
279 
280  // specific heats
281  vector_fp cv_rot;
282  vector_fp cp_R;
283  vector_fp cv_int;
284 
285 };
286 }
287 #endif