Cantera  2.0
MultiTransport.h
Go to the documentation of this file.
1 /**
2  * @file MultiTransport.h
3  * Interface for class MultiTransport
4  */
5 
6 // Copyright 2001 California Institute of Technology
7 
8 #ifndef CT_MULTITRAN_H
9 #define CT_MULTITRAN_H
10 
11 // Define this for better agreement with Chemkin TRANLIB results, even
12 // if the results are less correct.
13 //#undef CHEMKIN_COMPATIBILITY_MODE
14 
15 // Cantera includes
16 #include "GasTransport.h"
18 
19 namespace Cantera
20 {
21 
22 //====================================================================================================================
23 //! Transport solve options
24 //! @deprecated GMRES option is unimplemented.
26  //! Solve the dense matrix via a gmres iteration
28  //! Solve the dense matrix via an LU gauss elimination
30 };
31 //====================================================================================================================
32 class GasTransportParams;
33 //====================================================================================================================
34 //! Class L_Matrix is used to represent the "L" matrix.
35 /*!
36  * This class is used instead of DenseMatrix so that a version of mult can be
37  * used that knows about the structure of the L matrix,
38  * specifically that the upper-right and lower-left blocks are
39  * zero.
40  * @ingroup transportProps
41  */
42 class L_Matrix : public DenseMatrix
43 {
44 public:
45 
46  //! default constructor
47  L_Matrix() {}
48 
49  //! destructor
50  virtual ~L_Matrix() {}
51 
52  //! Conduct a multiply with the Dense matrix
53  /*!
54  * This method is used by GMRES to multiply the L matrix by a
55  * vector b. The L matrix has a 3x3 block structure, where each
56  * block is a K x K matrix. The elements of the upper-right and
57  * lower-left blocks are all zero. This method is defined so
58  * that the multiplication only involves the seven non-zero
59  * blocks.
60  *
61  * @param b
62  * @param prod
63  * @deprecated GMRES method is not implemented
64  */
65  DEPRECATED(virtual void mult(const doublereal* b, doublereal* prod) const);
66 };
67 
68 
69 //====================================================================================================================
70 //! Class MultiTransport implements multicomponent transport
71 //! properties for ideal gas mixtures.
72 /*!
73  *
74  * The implementation generally
75  * follows the procedure outlined in Kee, Coltrin, and Glarborg,
76  * "Theoretical and Practical Aspects of Chemically Reacting Flow
77  * Modeling," Wiley Interscience.
78  *
79  * @ingroup transportProps
80  */
82 {
83 
84 protected:
85 
86  //! default constructor
87  /*!
88  * @param thermo Optional parameter for the pointer to the ThermoPhase object
89  */
91 
92 public:
93 
94  //! Destructor
95  virtual ~MultiTransport() {}
96 
97  // overloaded base class methods
98  virtual int model() const {
99  if (m_mode == CK_Mode) {
100  return CK_Multicomponent;
101  } else {
102  return cMulticomponent;
103  }
104  }
105 
106  //! Return the thermal diffusion coefficients (kg/m/s)
107  /*!
108  * Eqn. (12.126) displays how they are calculated. The reference work is from
109  * Dixon-Lewis.
110  *
111  * Eqns. (12.168) shows how they are used in an expression for the species flux.
112  *
113  * @param dt Vector of thermal diffusion coefficients. Units = kg/m/s
114  */
115  virtual void getThermalDiffCoeffs(doublereal* const dt);
116 
117  virtual doublereal thermalConductivity();
118 
119  virtual void getMultiDiffCoeffs(const size_t ld, doublereal* const d);
120 
121  //! Get the species diffusive mass fluxes wrt to the mass averaged velocity,
122  //! given the gradients in mole fraction and temperature
123  /*!
124  * Units for the returned fluxes are kg m-2 s-1.
125  *
126  * @param ndim Number of dimensions in the flux expressions
127  * @param grad_T Gradient of the temperature
128  * (length = ndim)
129  * @param ldx Leading dimension of the grad_X array
130  * (usually equal to m_nsp but not always)
131  * @param grad_X Gradients of the mole fraction
132  * Flat vector with the m_nsp in the inner loop.
133  * length = ldx * ndim
134  * @param ldf Leading dimension of the fluxes array
135  * (usually equal to m_nsp but not always)
136  * @param fluxes Output of the diffusive mass fluxes
137  * Flat vector with the m_nsp in the inner loop.
138  * length = ldx * ndim
139  */
140  virtual void getSpeciesFluxes(size_t ndim, const doublereal* const grad_T,
141  size_t ldx, const doublereal* const grad_X,
142  size_t ldf, doublereal* const fluxes);
143 
144  //! Get the molar diffusional fluxes [kmol/m^2/s] of the species, given the thermodynamic
145  //! state at two nearby points.
146  /*!
147  * The molar diffusional fluxes are calculated with reference to the mass averaged
148  * velocity. This is a one-dimensional vector
149  *
150  * @param state1 Array of temperature, density, and mass
151  * fractions for state 1.
152  * @param state2 Array of temperature, density, and mass
153  * fractions for state 2.
154  * @param delta Distance from state 1 to state 2 (m).
155  * @param fluxes Output molar fluxes of the species.
156  * (length = m_nsp)
157  */
158  virtual void getMolarFluxes(const doublereal* const state1,
159  const doublereal* const state2,
160  const doublereal delta,
161  doublereal* const fluxes);
162 
163  //! Get the mass diffusional fluxes [kg/m^2/s] of the species, given the thermodynamic
164  //! state at two nearby points.
165  /*!
166  * The specific diffusional fluxes are calculated with reference to the mass averaged
167  * velocity. This is a one-dimensional vector
168  *
169  * @param state1 Array of temperature, density, and mass
170  * fractions for state 1.
171  * @param state2 Array of temperature, density, and mass
172  * fractions for state 2.
173  * @param delta Distance from state 1 to state 2 (m).
174  * @param fluxes Output mass fluxes of the species.
175  * (length = m_nsp)
176  */
177  virtual void getMassFluxes(const doublereal* state1,
178  const doublereal* state2, doublereal delta,
179  doublereal* fluxes);
180 
181  //! Set the solution method for inverting the L matrix
182  /*!
183  * @param method enum TRANSOLVE_TYPE Either use direct or TRANSOLVE_GMRES
184  * @deprecated GMRES option is unimplemented.
185  */
186  DEPRECATED(virtual void setSolutionMethod(TRANSOLVE_TYPE method));
187 
188  //! Set the options for the GMRES solution
189  /*!
190  * @param m set the mgmres param
191  * @param eps Set the eps parameter
192  * @deprecated GMRES option is unimplemented.
193  */
194  DEPRECATED(virtual void setOptions_GMRES(int m, doublereal eps));
195 
196  //! Initialize the transport operator with parameters from GasTransportParams object
197  /*!
198  * @param tr input GasTransportParams object
199  */
200  virtual bool initGas(GasTransportParams& tr);
201 
202  friend class TransportFactory;
203 
204  //! Return a structure containing all of the pertinent parameters
205  //! about a species that was used to construct the Transport properties in this object
206  /*!
207  * @param k Species index
208  * @deprecated
209  */
210  DEPRECATED(struct GasTransportData getGasTransportData(int k));
211 
212 protected:
213 
214  //! Update basic temperature-dependent quantities if the temperature has changed.
215  void update_T();
216 
217  //! Update basic concentration-dependent quantities if the concentrations have changed.
218  void update_C();
219 
220  //! Update the temperature-dependent terms needed to compute the thermal
221  //! conductivity and thermal diffusion coefficients.
222  void updateThermal_T();
223 
224 private:
225 
226  doublereal m_thermal_tlast;
227 
228  doublereal m_tmin;
229  doublereal m_tmax;
230 
231  // property values
232  std::vector<std::vector<int> > m_poly;
233  std::vector<vector_fp> m_astar_poly;
234  std::vector<vector_fp> m_bstar_poly;
235  std::vector<vector_fp> m_cstar_poly;
236  std::vector<vector_fp> m_om22_poly;
237 
238  //! Dense matrix for astar
240 
241  //! Dense matrix for bstar
243 
244  //! Dense matrix for cstar
246 
247  //! Dense matrix for omega22
249 
250  vector_fp m_zrot;
251  vector_fp m_crot;
252  vector_fp m_cinternal;
253  vector_fp m_eps;
254  vector_fp m_alpha;
255  vector_fp m_dipoleDiag;
256 
257  vector_fp m_sqrt_eps_k;
258  DenseMatrix m_log_eps_k;
259  vector_fp m_frot_298;
260  vector_fp m_rotrelax;
261 
262  doublereal m_lambda;
263 
264  // L matrix quantities
265  L_Matrix m_Lmatrix;
266  DenseMatrix m_aa;
267  //DenseMatrix m_Lmatrix;
268  vector_fp m_a;
269  vector_fp m_b;
270 
271  bool m_gmres; //!< @deprecated
272  int m_mgmres; //!< @deprecated
273  doublereal m_eps_gmres; //!< @deprecated
274 
275  // work space
276  vector_fp m_spwork1, m_spwork2, m_spwork3;
277 
278  void correctBinDiffCoeffs();
279 
280  //! Boolean indicating viscosity is up to date
281  bool m_abc_ok;
282  bool m_l0000_ok;
283  bool m_lmatrix_soln_ok;
284 
285  //! Evaluate the L0000 matrices
286  /*!
287  * Evaluate the upper-left block of the L matrix.
288  * @param x vector of species mole fractions
289  */
290  void eval_L0000(const doublereal* const x);
291 
292  //! Evaluate the L0010 matrices
293  /*!
294  * @param x vector of species mole fractions
295  */
296  void eval_L0010(const doublereal* const x);
297 
298  //! Evaluate the L1000 matrices
299  void eval_L1000();
300 
301  void eval_L0100();
302  void eval_L0001();
303  void eval_L1010(const doublereal* x);
304  void eval_L1001(const doublereal* x);
305  void eval_L0110();
306  void eval_L0101(const doublereal* x);
307  bool hasInternalModes(size_t j);
308 
309  doublereal pressure_ig() {
311  }
312 
313  void solveLMatrixEquation();
314  DenseMatrix m_epsilon;
315  DenseMatrix m_diam;
316  DenseMatrix incl;
317  bool m_debug;
318 };
319 }
320 #endif