Cantera
Loading...
Searching...
No Matches
MultiTransport.cpp
Go to the documentation of this file.
1/**
2 * @file MultiTransport.cpp
3 * Implementation file for class MultiTransport
4 */
5
6// This file is part of Cantera. See License.txt in the top-level directory or
7// at https://cantera.org/license.txt for license and copyright information.
8
13
14using namespace std;
15
16namespace Cantera
17{
18
19///////////////////// helper functions /////////////////////////
20
21/**
22 * The Parker temperature correction to the rotational collision number.
23 *
24 * @param tr Reduced temperature @f$ \epsilon/kT @f$
25 * @param sqtr square root of tr.
26 */
27double Frot(double tr, double sqtr)
28{
29 const double c1 = 0.5*sqrt(Pi)*Pi;
30 const double c2 = 0.25*Pi*Pi + 2.0;
31 const double c3 = sqrt(Pi)*Pi;
32 return 1.0 + c1*sqtr + c2*tr + c3*sqtr*tr;
33}
34
35//////////////////// class MultiTransport methods //////////////
36
37void MultiTransport::init(shared_ptr<ThermoPhase> thermo, int mode)
38{
40
41 // the L matrix
42 m_Lmatrix.resize(3*m_nsp, 3*m_nsp);
43 m_a.resize(3*m_nsp, 1.0);
44 m_b.resize(3*m_nsp, 0.0);
45 m_aa.resize(m_nsp, m_nsp, 0.0);
46 m_molefracs_last.resize(m_nsp, -1.0);
47 m_frot_298.resize(m_nsp);
48 m_rotrelax.resize(m_nsp);
49 m_cinternal.resize(m_nsp);
50 m_astar.resize(m_nsp, m_nsp);
51 m_bstar.resize(m_nsp, m_nsp);
52 m_cstar.resize(m_nsp, m_nsp);
53
54 // set flags all false
55 m_l0000_ok = false;
56 m_lmatrix_soln_ok = false;
57 m_thermal_tlast = Undef;
58
59 // some work space
60 m_spwork1.resize(m_nsp);
61 m_spwork2.resize(m_nsp);
62 m_spwork3.resize(m_nsp);
63
64 // precompute and store log(epsilon_ij/k_B)
65 m_log_eps_k.resize(m_nsp, m_nsp);
66 for (size_t i = 0; i < m_nsp; i++) {
67 for (size_t j = i; j < m_nsp; j++) {
68 m_log_eps_k(i,j) = log(m_epsilon(i,j)/Boltzmann);
69 m_log_eps_k(j,i) = m_log_eps_k(i,j);
70 }
71 }
72
73 // precompute and store constant parts of the Parker rotational
74 // collision number temperature correction
75 const double sq298 = sqrt(298.0);
76 const double kb298 = Boltzmann * 298.0;
77 m_sqrt_eps_k.resize(m_nsp);
78 for (size_t k = 0; k < m_nsp; k++) {
79 m_sqrt_eps_k[k] = sqrt(m_eps[k]/Boltzmann);
80 m_frot_298[k] = Frot(m_eps[k]/kb298, m_sqrt_eps_k[k]/sq298);
81 }
82}
83
85{
87 m_thermal_tlast = Undef;
88 m_l0000_ok = false;
89 m_lmatrix_soln_ok = false;
90 m_molefracs_last[0] += 1.23e-4;
91}
92
94{
95 solveLMatrixEquation();
96 double sum = 0.0;
97 for (size_t k = 0; k < 2*m_nsp; k++) {
98 sum += m_b[k + m_nsp] * m_a[k + m_nsp];
99 }
100 return -4.0*sum;
101}
102
104{
105 checkArraySize("MultiTransport::getThermalDiffCoeffs", dt.size(), m_nsp);
106 solveLMatrixEquation();
107 const double c = 1.6/GasConstant;
108 for (size_t k = 0; k < m_nsp; k++) {
109 dt[k] = c * m_mw[k] * m_molefracs[k] * m_a[k];
110 }
111}
112
113double MultiTransport::pressure_ig()
114{
115 return m_thermo->molarDensity() * GasConstant * m_thermo->temperature();
116}
117
118void MultiTransport::solveLMatrixEquation()
119{
120 // if T has changed, update the temperature-dependent properties.
122 update_C();
123 if (m_lmatrix_soln_ok) {
124 return;
125 }
126
127 // Copy the mole fractions twice into the last two blocks of the right-hand-
128 // side vector m_b. The first block of m_b was set to zero when it was
129 // created, and is not modified so doesn't need to be reset to zero.
130 for (size_t k = 0; k < m_nsp; k++) {
131 m_b[k] = 0.0;
132 m_b[k + m_nsp] = m_molefracs[k];
133 m_b[k + 2*m_nsp] = m_molefracs[k];
134 }
135
136 // Set the right-hand side vector to zero in the 3rd block for all species
137 // with no internal energy modes. The corresponding third-block rows and
138 // columns will be set to zero, except on the diagonal of L01,01, where they
139 // are set to 1.0. This has the effect of eliminating these equations from
140 // the system, since the equation becomes: m_a[2*m_nsp + k] = 0.0.
141
142 // Note that this differs from the Chemkin procedure, where all *monatomic*
143 // species are excluded. Since monatomic radicals can have non-zero internal
144 // heat capacities due to electronic excitation, they should be retained.
145 for (size_t k = 0; k < m_nsp; k++) {
146 if (!hasInternalModes(k)) {
147 m_b[2*m_nsp + k] = 0.0;
148 }
149 }
150
151 // evaluate the submatrices of the L matrix
152 m_Lmatrix.resize(3*m_nsp, 3*m_nsp, 0.0);
153
154 //! Evaluate the upper-left block of the L matrix.
157 eval_L0001();
158 eval_L1000();
159 eval_L1010(m_molefracs);
160 eval_L1001(m_molefracs);
161 eval_L0100();
162 eval_L0110();
163 eval_L0101(m_molefracs);
164 // With one species, the diffusion row and column are all zero
165 if (m_nsp == 1) {
166 m_Lmatrix(0,0) = 1.0;
167 }
168
169 // Solve it using GMRES or LU decomposition. The last solution in m_a should
170 // provide a good starting guess, so convergence should be fast.
171 m_a = m_b;
172 solve(m_Lmatrix, m_a);
173 m_lmatrix_soln_ok = true;
175 // L matrix is overwritten with LU decomposition
176 m_l0000_ok = false;
177}
178
179void MultiTransport::getSpeciesFluxes(size_t ndim, span<const double> grad_T,
180 size_t ldx, span<const double> grad_X,
181 size_t ldf, span<double> fluxes)
182{
183 if (ldx < m_nsp) {
184 throw CanteraError("MultiTransport::getSpeciesFluxes", "ldx is too small");
185 }
186 if (ldf < m_nsp) {
187 throw CanteraError("MultiTransport::getSpeciesFluxes", "ldf is too small");
188 }
189 checkArraySize("MultiTransport::getSpeciesFluxes: grad_T", grad_T.size(), ndim);
190 checkArraySize("MultiTransport::getSpeciesFluxes: grad_X", grad_X.size(), ldx * ndim);
191 checkArraySize("MultiTransport::getSpeciesFluxes: fluxes", fluxes.size(), ldf * ndim);
192 // update the binary diffusion coefficients if necessary
193 update_T();
194 updateDiff_T();
195
196 // If any component of grad_T is non-zero, then get the
197 // thermal diffusion coefficients
198 bool addThermalDiffusion = false;
199 for (size_t i = 0; i < ndim; i++) {
200 if (grad_T[i] != 0.0) {
201 addThermalDiffusion = true;
202 }
203 }
204 if (addThermalDiffusion) {
206 }
207
208 auto y = m_thermo->massFractions();
209 double rho = m_thermo->density();
210
211 for (size_t i = 0; i < m_nsp; i++) {
212 double sum = 0.0;
213 for (size_t j = 0; j < m_nsp; j++) {
214 m_aa(i,j) = m_molefracs[j]*m_molefracs[i]/m_bdiff(i,j);
215 sum += m_aa(i,j);
216 }
217 m_aa(i,i) -= sum;
218 }
219
220 // enforce the condition \sum Y_k V_k = 0. This is done by replacing
221 // the flux equation with the largest gradx component in the first
222 // coordinate direction with the flux balance condition.
223 size_t jmax = 0;
224 double gradmax = -1.0;
225 for (size_t j = 0; j < m_nsp; j++) {
226 if (fabs(grad_X[j]) > gradmax) {
227 gradmax = fabs(grad_X[j]);
228 jmax = j;
229 }
230 }
231
232 // set the matrix elements in this row to the mass fractions,
233 // and set the entry in gradx to zero
234 for (size_t j = 0; j < m_nsp; j++) {
235 m_aa(jmax,j) = y[j];
236 }
237 vector<double> gsave(ndim), grx(ldx*m_nsp);
238 for (size_t n = 0; n < ldx*ndim; n++) {
239 grx[n] = grad_X[n];
240 }
241
242 // copy grad_X to fluxes
243 for (size_t n = 0; n < ndim; n++) {
244 auto gx = grad_X.subspan(ldx * n, m_nsp);
245 auto fx = fluxes.subspan(ldf * n, m_nsp);
246 std::copy(gx.begin(), gx.end(), fx.begin());
247 fx[jmax] = 0.0;
248 }
249
250 // solve the equations
251 solve(m_aa, fluxes, ndim, ldf);
252 double pp = pressure_ig();
253
254 // multiply diffusion velocities by rho * V to create mass fluxes, and
255 // restore the gradx elements that were modified
256 for (size_t n = 0; n < ndim; n++) {
257 size_t offset = n*ldf;
258 for (size_t i = 0; i < m_nsp; i++) {
259 fluxes[i + offset] *= rho * y[i] / pp;
260 }
261 }
262
263 // thermal diffusion
264 if (addThermalDiffusion) {
265 for (size_t n = 0; n < ndim; n++) {
266 size_t offset = n*ldf;
267 double grad_logt = grad_T[n]/m_temp;
268 for (size_t i = 0; i < m_nsp; i++) {
269 fluxes[i + offset] -= m_spwork[i]*grad_logt;
270 }
271 }
272 }
273}
274
275void MultiTransport::getMassFluxes(span<const double> state1,
276 span<const double> state2,
277 double delta, span<double> fluxes)
278{
279 checkArraySize("MultiTransport::getMassFluxes: state1", state1.size(), m_nsp + 2);
280 checkArraySize("MultiTransport::getMassFluxes: state2", state2.size(), m_nsp + 2);
281 checkArraySize("MultiTransport::getMassFluxes: fluxes", fluxes.size(), m_nsp);
282 span<double> x1(m_spwork1);
283 span<double> x2(m_spwork2);
284 span<double> x3(m_spwork3);
285 size_t nsp = m_thermo->nSpecies();
286 m_thermo->restoreState(state1);
287 double p1 = m_thermo->pressure();
288 double t1 = state1[0];
289 m_thermo->getMoleFractions(x1);
290
291 m_thermo->restoreState(state2);
292 double p2 = m_thermo->pressure();
293 double t2 = state2[0];
294 m_thermo->getMoleFractions(x2);
295
296 double p = 0.5*(p1 + p2);
297 double t = 0.5*(state1[0] + state2[0]);
298
299 for (size_t n = 0; n < nsp; n++) {
300 x3[n] = 0.5*(x1[n] + x2[n]);
301 }
302 m_thermo->setState_TPX(t, p, x3);
303 m_thermo->getMoleFractions(m_molefracs);
304
305 // update the binary diffusion coefficients if necessary
306 update_T();
307 updateDiff_T();
308
309 // If there is a temperature gradient, then get the
310 // thermal diffusion coefficients
311 bool addThermalDiffusion = false;
312 if (state1[0] != state2[0]) {
313 addThermalDiffusion = true;
315 }
316
317 auto y = m_thermo->massFractions();
318 double rho = m_thermo->density();
319 for (size_t i = 0; i < m_nsp; i++) {
320 double sum = 0.0;
321 for (size_t j = 0; j < m_nsp; j++) {
322 m_aa(i,j) = m_molefracs[j]*m_molefracs[i]/m_bdiff(i,j);
323 sum += m_aa(i,j);
324 }
325 m_aa(i,i) -= sum;
326 }
327
328 // enforce the condition \sum Y_k V_k = 0. This is done by replacing the
329 // flux equation with the largest gradx component with the flux balance
330 // condition.
331 size_t jmax = 0;
332 double gradmax = -1.0;
333 for (size_t j = 0; j < m_nsp; j++) {
334 if (fabs(x2[j] - x1[j]) > gradmax) {
335 gradmax = fabs(x1[j] - x2[j]) / delta;
336 jmax = j;
337 }
338 }
339
340 // set the matrix elements in this row to the mass fractions,
341 // and set the entry in gradx to zero
342 for (size_t j = 0; j < m_nsp; j++) {
343 m_aa(jmax,j) = y[j];
344 fluxes[j] = (x2[j] - x1[j]) / delta;
345 }
346 fluxes[jmax] = 0.0;
347
348 // Solve the equations
349 solve(m_aa, fluxes);
350
351 double pp = pressure_ig();
352 // multiply diffusion velocities by rho * Y_k to create
353 // mass fluxes, and divide by pressure
354 for (size_t i = 0; i < m_nsp; i++) {
355 fluxes[i] *= rho * y[i] / pp;
356 }
357
358 // thermal diffusion
359 if (addThermalDiffusion) {
360 double grad_logt = (t2 - t1) / m_temp / delta;
361 for (size_t i = 0; i < m_nsp; i++) {
362 fluxes[i] -= m_spwork[i]*grad_logt;
363 }
364 }
365}
366
367void MultiTransport::getMolarFluxes(span<const double> state1,
368 span<const double> state2, const double delta, span<double> fluxes)
369{
370 getMassFluxes(state1, state2, delta, fluxes);
371 for (size_t k = 0; k < m_thermo->nSpecies(); k++) {
372 fluxes[k] /= m_mw[k];
373 }
374}
375
376void MultiTransport::getMultiDiffCoeffs(const size_t ld, span<double> d)
377{
378 if (ld < m_nsp) {
379 throw CanteraError("MultiTransport::getMultiDiffCoeffs", "ld is too small");
380 }
381 checkArraySize("MultiTransport::getMultiDiffCoeffs", d.size(), ld * m_nsp);
382 // diffusion coefficients are zero for a single species
383 if (m_nsp == 1) {
384 d[0] = 0.0;
385 return;
386 }
387 double p = pressure_ig();
388
389 // update the mole fractions
390 update_C();
391
392 // update the binary diffusion coefficients
393 update_T();
395
396 // evaluate L0000 if the temperature or concentrations have
397 // changed since it was last evaluated.
398 if (!m_l0000_ok) {
400 }
401
402 // invert L00,00
403 invert(m_Lmatrix, m_nsp);
404 m_l0000_ok = false; // matrix is overwritten by inverse
405 m_lmatrix_soln_ok = false;
406
407 double prefactor = 16.0 * m_temp
408 * m_thermo->meanMolecularWeight()/(25.0 * p);
409 for (size_t i = 0; i < m_nsp; i++) {
410 for (size_t j = 0; j < m_nsp; j++) {
411 double c = prefactor/m_mw[j];
412 d[ld*j + i] = c*m_molefracs[i]*
413 (m_Lmatrix(i,j) - m_Lmatrix(i,i));
414 }
415 }
416
417}
418
420{
421 if (m_temp == m_thermo->temperature() && m_nsp == m_thermo->nSpecies()) {
422 return;
423 }
424 GasTransport::update_T();
425 // temperature has changed, so polynomial fits will need to be
426 // redone, and the L matrix reevaluated.
427 m_lmatrix_soln_ok = false;
428 m_l0000_ok = false;
429}
430
432{
433 // Update the local mole fraction array
434 m_thermo->getMoleFractions(m_molefracs);
435
436 for (size_t k = 0; k < m_nsp; k++) {
437 // add an offset to avoid a pure species condition
438 m_molefracs[k] = std::max(Tiny, m_molefracs[k]);
439 if (m_molefracs[k] != m_molefracs_last[k]) {
440 // If any mole fractions have changed, signal that concentration-
441 // dependent quantities will need to be recomputed before use.
442 m_l0000_ok = false;
443 m_lmatrix_soln_ok = false;
444 }
445 }
446}
447
449{
450 if (m_thermal_tlast == m_thermo->temperature()) {
451 return;
452 }
453 // we need species viscosities and binary diffusion coefficients
455 updateDiff_T();
456
457 // evaluate polynomial fits for A*, B*, C*
458 for (size_t i = 0; i < m_nsp; i++) {
459 for (size_t j = i; j < m_nsp; j++) {
460 double z = m_star_poly_uses_actualT[i][j] == 1 ? m_logt : m_logt - m_log_eps_k(i,j);
461 int ipoly = m_poly[i][j];
462 if (m_mode == CK_Mode) {
463 m_astar(i,j) = poly6(z, m_astar_poly[ipoly]);
464 m_bstar(i,j) = poly6(z, m_bstar_poly[ipoly]);
465 m_cstar(i,j) = poly6(z, m_cstar_poly[ipoly]);
466 } else {
467 m_astar(i,j) = poly8(z, m_astar_poly[ipoly]);
468 m_bstar(i,j) = poly8(z, m_bstar_poly[ipoly]);
469 m_cstar(i,j) = poly8(z, m_cstar_poly[ipoly]);
470 }
471 m_astar(j,i) = m_astar(i,j);
472 m_bstar(j,i) = m_bstar(i,j);
473 m_cstar(j,i) = m_cstar(i,j);
474 }
475 }
476
477 // evaluate the temperature-dependent rotational relaxation rate
478 for (size_t k = 0; k < m_nsp; k++) {
479 double tr = m_eps[k]/ m_kbt;
480 double sqtr = m_sqrt_eps_k[k] / m_sqrt_t;
481 m_rotrelax[k] = std::max(1.0,m_zrot[k]) * m_frot_298[k]/Frot(tr, sqtr);
482 }
483
484 double c = 1.2*GasConstant*m_temp;
485 for (size_t k = 0; k < m_nsp; k++) {
486 m_bdiff(k,k) = c * m_visc[k] * m_astar(k,k)/m_mw[k];
487 }
488
489 // Calculate the internal heat capacities by subtracting off the translational contributions
490 /*
491 * HKM Exploratory comment:
492 * The translational component is 1.5
493 * The rotational component is 1.0 for a linear molecule and 1.5 for a nonlinear molecule
494 * and zero for a monatomic.
495 * Chemkin has traditionally subtracted 1.5 here (SAND86-8246).
496 * The original Dixon-Lewis paper subtracted 1.5 here.
497 */
498 vector<double> cp(m_thermo->nSpecies());
499 m_thermo->getCp_R_ref(cp);
500 for (size_t k = 0; k < m_nsp; k++) {
501 m_cinternal[k] = cp[k] - 2.5;
502 }
503 m_thermal_tlast = m_thermo->temperature();
504}
505
506//! Constant to compare dimensionless heat capacities against zero
507static const double Min_C_Internal = 0.001;
508
509bool MultiTransport::hasInternalModes(size_t j)
510{
511 return (m_cinternal[j] > Min_C_Internal);
512}
513
514void MultiTransport::eval_L0000(span<const double> x)
515{
516 double prefactor = 16.0*m_temp/25.0;
517 double sum;
518 for (size_t i = 0; i < m_nsp; i++) {
519 // subtract-off the k=i term to account for the first delta
520 // function in Eq. (12.121)
521 sum = -x[i]/m_bdiff(i,i);
522 for (size_t k = 0; k < m_nsp; k++) {
523 sum += x[k]/m_bdiff(i,k);
524 }
525
526 sum /= m_mw[i];
527 for (size_t j = 0; j != m_nsp; ++j) {
528 m_Lmatrix(i,j) = prefactor * x[j]
529 * (m_mw[j] * sum + x[i]/m_bdiff(i,j));
530 }
531 // diagonal term is zero
532 m_Lmatrix(i,i) = 0.0;
533 }
534}
535
536void MultiTransport::eval_L0010(span<const double> x)
537{
538 double prefactor = 1.6*m_temp;
539 for (size_t j = 0; j < m_nsp; j++) {
540 double xj = x[j];
541 double wj = m_mw[j];
542 double sum = 0.0;
543 for (size_t i = 0; i < m_nsp; i++) {
544 m_Lmatrix(i,j + m_nsp) = - prefactor * x[i] * xj * m_mw[i] *
545 (1.2 * m_cstar(j,i) - 1.0) /
546 ((wj + m_mw[i]) * m_bdiff(j,i));
547
548 // the next term is independent of "j";
549 // need to do it for the "j,j" term
550 sum -= m_Lmatrix(i,j+m_nsp);
551 }
552 m_Lmatrix(j,j+m_nsp) += sum;
553 }
554}
555
557{
558 for (size_t j = 0; j < m_nsp; j++) {
559 for (size_t i = 0; i < m_nsp; i++) {
560 m_Lmatrix(i+m_nsp,j) = m_Lmatrix(j,i+m_nsp);
561 }
562 }
563}
564
565void MultiTransport::eval_L1010(span<const double> x)
566{
567 const double fiveover3pi = 5.0/(3.0*Pi);
568 double prefactor = (16.0*m_temp)/25.0;
569
570 for (size_t j = 0; j < m_nsp; j++) {
571 // get constant terms that depend on just species "j"
572 double constant1 = prefactor*x[j];
573 double wjsq = m_mw[j]*m_mw[j];
574 double constant2 = 13.75*wjsq;
575 double constant3 = m_crot[j]/m_rotrelax[j];
576 double constant4 = 7.5*wjsq;
577 double fourmj = 4.0*m_mw[j];
578 double threemjsq = 3.0*m_mw[j]*m_mw[j];
579 double sum = 0.0;
580 for (size_t i = 0; i < m_nsp; i++) {
581 double sumwij = m_mw[i] + m_mw[j];
582 double term1 = m_bdiff(i,j) * sumwij*sumwij;
583 double term2 = fourmj*m_astar(i,j)*(1.0 + fiveover3pi*
584 (constant3 + (m_crot[i]/m_rotrelax[i]))); // see Eq. (12.125)
585
586 m_Lmatrix(i+m_nsp,j+m_nsp) = constant1*x[i]*m_mw[i] /(m_mw[j]*term1) *
587 (constant2 - threemjsq*m_bstar(i,j)
588 - term2*m_mw[j]);
589
590 sum += x[i] /(term1) *
591 (constant4 + m_mw[i]*m_mw[i]*
592 (6.25 - 3.0*m_bstar(i,j)) + term2*m_mw[i]);
593 }
594
595 m_Lmatrix(j+m_nsp,j+m_nsp) -= sum*constant1;
596 }
597}
598
599void MultiTransport::eval_L1001(span<const double> x)
600{
601 double prefactor = 32.00*m_temp/(5.00*Pi);
602 for (size_t j = 0; j < m_nsp; j++) {
603 // collect terms that depend only on "j"
604 if (hasInternalModes(j)) {
605 double constant = prefactor*m_mw[j]*x[j]*m_crot[j]/(m_cinternal[j]*m_rotrelax[j]);
606 double sum = 0.0;
607 for (size_t i = 0; i < m_nsp; i++) {
608 // see Eq. (12.127)
609 m_Lmatrix(i+m_nsp,j+2*m_nsp) = constant * m_astar(j,i) * x[i] /
610 ((m_mw[j] + m_mw[i]) * m_bdiff(j,i));
611 sum += m_Lmatrix(i+m_nsp,j+2*m_nsp);
612 }
613 m_Lmatrix(j+m_nsp,j+2*m_nsp) += sum;
614 } else {
615 for (size_t i = 0; i < m_nsp; i++) {
616 m_Lmatrix(i+m_nsp,j+2*m_nsp) = 0.0;
617 }
618 }
619 }
620}
621
622void MultiTransport::eval_L0001()
623{
624 for (size_t j = 0; j < m_nsp; j++) {
625 for (size_t i = 0; i < m_nsp; i++) {
626 m_Lmatrix(i,j+2*m_nsp) = 0.0;
627 }
628 }
629}
630
631void MultiTransport::eval_L0100()
632{
633 for (size_t j = 0; j < m_nsp; j++) {
634 for (size_t i = 0; i < m_nsp; i++) {
635 m_Lmatrix(i+2*m_nsp,j) = 0.0; // see Eq. (12.123)
636 }
637 }
638}
639
640void MultiTransport::eval_L0110()
641{
642 for (size_t j = 0; j < m_nsp; j++) {
643 for (size_t i = 0; i < m_nsp; i++) {
644 m_Lmatrix(i+2*m_nsp,j+m_nsp) = m_Lmatrix(j+m_nsp,i+2*m_nsp); // see Eq. (12.123)
645 }
646 }
647}
648
649void MultiTransport::eval_L0101(span<const double> x)
650{
651 for (size_t i = 0; i < m_nsp; i++) {
652 if (hasInternalModes(i)) {
653 // collect terms that depend only on "i"
654 double constant1 = 4*m_temp*x[i]/m_cinternal[i];
655 double constant2 = 12*m_mw[i]*m_crot[i] /
656 (5*Pi*m_cinternal[i]*m_rotrelax[i]);
657 double sum = 0.0;
658 for (size_t k = 0; k < m_nsp; k++) {
659 // see Eq. (12.131)
660 double diff_int = m_bdiff(i,k);
661 m_Lmatrix(k+2*m_nsp,i+2*m_nsp) = 0.0;
662 sum += x[k]/diff_int;
663 if (k != i) {
664 sum += x[k]*m_astar(i,k)*constant2 / (m_mw[k]*diff_int);
665 }
666 }
667 // see Eq. (12.130)
668 m_Lmatrix(i+2*m_nsp,i+2*m_nsp) =
669 - 8/Pi*m_mw[i]*x[i]*x[i]*m_crot[i] /
670 (m_cinternal[i]*m_cinternal[i]*GasConstant*m_visc[i]*m_rotrelax[i])
671 - constant1*sum;
672 } else {
673 for (size_t k = 0; k < m_nsp; k++) {
674 m_Lmatrix(i+2*m_nsp,i+2*m_nsp) = 1.0;
675 }
676 }
677 }
678}
679
680}
ThermoPhase object for the ideal gas equation of state - workhorse for Cantera (see Thermodynamic Pro...
Interface for class MultiTransport.
Base class for exceptions thrown by Cantera classes.
vector< double > m_mw
Local copy of the species molecular weights.
vector< double > m_molefracs
Vector of species mole fractions.
double m_temp
Current value of the temperature [K] at which the properties in this object are calculated.
vector< double > m_eps
Lennard-Jones well-depth [J] of the species in the current phase.
virtual void updateDiff_T()
Update the binary diffusion coefficients.
DenseMatrix m_epsilon
The effective well depth [J] for (i,j) collisions.
vector< double > m_spwork
work space length = m_nsp
vector< double > m_zrot
Rotational relaxation number for each species.
int m_mode
Type of the polynomial fits to temperature.
double m_logt
Current value of the log of the temperature.
vector< double > m_visc
vector of species viscosities [Pa·s].
virtual void updateSpeciesViscosities()
Update the pure-species viscosities.
double m_sqrt_t
current value of temperature to 1/2 power
DenseMatrix m_bdiff
Matrix of binary diffusion coefficients at the reference pressure and the current temperature Size is...
vector< double > m_crot
Dimensionless rotational heat capacity of each species.
void invalidateCache() override
Invalidate any cached values which are normally updated only when a change in state is detected.
double m_kbt
Current value of Boltzmann constant times the temperature [J].
vector< vector< int > > m_star_poly_uses_actualT
Flag to indicate for which (i,j) interaction pairs the actual temperature is used instead of the redu...
vector< vector< double > > m_bstar_poly
Fit for bstar collision integral.
vector< vector< double > > m_astar_poly
Fit for astar collision integral.
vector< vector< int > > m_poly
Indices for the (i,j) interaction in collision integral fits.
void init(shared_ptr< ThermoPhase > thermo, int mode=0) override
Initialize a transport manager.
vector< vector< double > > m_cstar_poly
Fit for cstar collision integral.
bool m_l0000_ok
Boolean indicating viscosity is up to date.
void update_T() override
Update basic temperature-dependent quantities if the temperature has changed.
double thermalConductivity() override
Get the mixture thermal conductivity [W/m/K].
DenseMatrix m_astar
Dense matrix for astar.
void updateThermal_T()
Update the temperature-dependent terms needed to compute the thermal conductivity and thermal diffusi...
void eval_L0010(span< const double > x)
Evaluate the L0010 matrices.
vector< double > m_molefracs_last
Mole fraction vector from last L-matrix evaluation.
DenseMatrix m_cstar
Dense matrix for cstar.
void update_C() override
Update basic concentration-dependent quantities if the concentrations have changed.
void invalidateCache() override
Invalidate any cached values which are normally updated only when a change in state is detected.
void getThermalDiffCoeffs(span< double > dt) override
Return the thermal diffusion coefficients [kg/m/s].
void getMolarFluxes(span< const double > state1, span< const double > state2, const double delta, span< double > fluxes) override
Get the molar diffusional fluxes [kmol/m²/s] of the species, given the thermodynamic state at two nea...
void init(shared_ptr< ThermoPhase > thermo, int mode=0) override
Initialize a transport manager.
void getSpeciesFluxes(size_t ndim, span< const double > grad_T, size_t ldx, span< const double > grad_X, size_t ldf, span< double > fluxes) override
Get the species diffusive mass fluxes [kg/m²/s] with respect to the mass averaged velocity,...
void eval_L0000(span< const double > x)
Evaluate the L0000 matrices.
void getMassFluxes(span< const double > state1, span< const double > state2, double delta, span< double > fluxes) override
Get the mass diffusional fluxes [kg/m²/s] of the species, given the thermodynamic state at two nearby...
DenseMatrix m_bstar
Dense matrix for bstar.
void eval_L1000()
Evaluate the L1000 matrices.
void getMultiDiffCoeffs(const size_t ld, span< double > d) override
Return the multicomponent diffusion coefficients [m²/s].
shared_ptr< ThermoPhase > m_thermo
pointer to the object representing the phase
Definition Transport.h:432
size_t m_nsp
Number of species in the phase.
Definition Transport.h:435
ThermoPhase & thermo()
Phase object.
Definition Transport.h:111
auto poly8(D x, const C &c)
Templated evaluation of a polynomial of order 8.
Definition utilities.h:147
auto poly6(D x, const C &c)
Templated evaluation of a polynomial of order 6.
Definition utilities.h:131
const double Boltzmann
Boltzmann constant [J/K].
Definition ct_defs.h:87
const double GasConstant
Universal Gas Constant [J/kmol/K].
Definition ct_defs.h:123
const double Pi
Pi.
Definition ct_defs.h:71
Namespace for the Cantera kernel.
Definition AnyMap.cpp:595
const double Tiny
Small number to compare differences of mole fractions against.
Definition ct_defs.h:176
const double Undef
Fairly random number to be used to initialize variables against to see if they are subsequently defin...
Definition ct_defs.h:167
void solve(DenseMatrix &A, span< double > b, size_t nrhs, size_t ldb)
Solve Ax = b. Array b is overwritten on exit with x.
offset
Offsets of solution components in the 1D solution array.
Definition Flow1D.h:25
static const double Min_C_Internal
Constant to compare dimensionless heat capacities against zero.
void invert(DenseMatrix &A, size_t nn)
invert A. A is overwritten with A^-1.
double Frot(double tr, double sqtr)
The Parker temperature correction to the rotational collision number.
void checkArraySize(const char *procedure, size_t available, size_t required)
Wrapper for throwing ArraySizeError.
Contains declarations for string manipulation functions within Cantera.
Various templated functions that carry out common vector and polynomial operations (see Templated Arr...