48 inline doublereal
Frot(doublereal tr, doublereal sqtr)
51 const doublereal c2 = 0.25*Pi*Pi + 2.0;
53 return 1.0 + c1*sqtr + c2*tr + c3*sqtr*tr;
65 void L_Matrix::mult(
const doublereal* b, doublereal* prod)
const
67 integer n =
static_cast<int>(nRows())/3;
70 ct_dgemv(ctlapack::ColMajor, ctlapack::NoTranspose, n, n2, 1.0,
71 DATA_PTR(data()), static_cast<int>(nRows()), b, 1, 0.0, prod, 1);
72 ct_dgemv(ctlapack::ColMajor, ctlapack::NoTranspose, n, n3, 1.0,
73 DATA_PTR(data()) + n, static_cast<int>(nRows()),
74 b, 1, 0.0, prod+n, 1);
75 ct_dgemv(ctlapack::ColMajor, ctlapack::NoTranspose, n, n, 1.0,
76 DATA_PTR(data()) + n*n3 + n2, static_cast<int>(nRows()),
77 b + n, 1, 0.0, prod+n2, 1);
78 for (
int i = 0; i < n; i++) {
79 prod[i + n2] += b[i + n2] * value(i + n2, i + n2);
85 MultiTransport::MultiTransport(
thermo_t* thermo)
107 m_dipoleDiag.resize(
m_nsp);
108 for (
size_t i = 0; i <
m_nsp; i++) {
109 m_dipoleDiag[i] = tr.
dipole(i,i);
113 m_Lmatrix.
resize(3*m_nsp, 3*m_nsp);
114 m_a.resize(3*m_nsp, 1.0);
115 m_b.resize(3*m_nsp, 0.0);
116 m_aa.
resize(m_nsp, m_nsp, 0.0);
118 m_frot_298.resize(m_nsp);
119 m_rotrelax.resize(m_nsp);
121 m_cinternal.resize(m_nsp);
131 m_lmatrix_soln_ok =
false;
133 m_thermal_tlast = 0.0;
143 m_spwork1.resize(m_nsp);
144 m_spwork2.resize(m_nsp);
145 m_spwork3.resize(m_nsp);
148 m_log_eps_k.
resize(m_nsp, m_nsp);
150 for (
size_t i = 0; i <
m_nsp; i++) {
151 for (
size_t j = i; j <
m_nsp; j++) {
153 m_log_eps_k(j,i) = m_log_eps_k(i,j);
159 const doublereal sq298 = sqrt(298.0);
160 const doublereal kb298 =
Boltzmann * 298.0;
161 m_sqrt_eps_k.resize(m_nsp);
162 for (
size_t k = 0; k <
m_nsp; k++) {
164 m_frot_298[k] =
Frot(tr.
eps[k]/kb298,
165 m_sqrt_eps_k[k]/sq298);
181 doublereal sum = 0.0;
182 for (
size_t k = 0; k < 2*
m_nsp; k++) {
198 for (
size_t k = 0; k <
m_nsp; k++) {
217 for (
size_t k = 0; k <
m_nsp; k++) {
239 for (
size_t k = 0; k <
m_nsp; k++) {
240 if (!hasInternalModes(k)) {
241 m_b[2*m_nsp + k] = 0.0;
246 m_Lmatrix.
resize(3*m_nsp, 3*m_nsp, 0.0);
269 copy(m_b.begin(), m_b.end(), m_a.begin());
275 throw CanteraError(
"MultiTransport::solveLMatrixEquation",
276 "error in solving L matrix.");
278 m_lmatrix_soln_ok =
true;
282 m_lmatrix_soln_ok =
true;
306 size_t ldx,
const doublereal*
const grad_X,
307 size_t ldf, doublereal*
const fluxes)
315 bool addThermalDiffusion =
false;
316 for (
size_t i = 0; i < ndim; i++) {
317 if (grad_T[i] != 0.0) {
318 addThermalDiffusion =
true;
321 if (addThermalDiffusion) {
328 for (
size_t i = 0; i <
m_nsp; i++) {
330 for (
size_t j = 0; j <
m_nsp; j++) {
341 doublereal gradmax = -1.0;
342 for (
size_t j = 0; j <
m_nsp; j++) {
343 if (fabs(grad_X[j]) > gradmax) {
344 gradmax = fabs(grad_X[j]);
351 for (
size_t j = 0; j <
m_nsp; j++) {
355 for (
size_t n = 0; n < ldx*ndim; n++) {
365 const doublereal* gx;
366 for (
size_t n = 0; n < ndim; n++) {
368 copy(gx, gx + m_nsp, fluxes + ldf*n);
369 fluxes[jmax + n*ldf] = 0.0;
374 ct_dgetrf(static_cast<int>(m_aa.
nRows()),
376 static_cast<int>(m_aa.
nRows()),
377 &m_aa.
ipiv()[0], info);
379 ct_dgetrs(ctlapack::NoTranspose,
380 static_cast<int>(m_aa.
nRows()), ndim,
382 &m_aa.
ipiv()[0], fluxes, ldf, info);
394 doublereal pp = pressure_ig();
399 for (
size_t n = 0; n < ndim; n++) {
401 for (
size_t i = 0; i <
m_nsp; i++) {
402 fluxes[i + offset] *= rho * y[i] / pp;
408 if (addThermalDiffusion) {
409 for (
size_t n = 0; n < ndim; n++) {
411 doublereal grad_logt = grad_T[n]/
m_temp;
412 for (
size_t i = 0; i <
m_nsp; i++) {
413 fluxes[i + offset] -=
m_spwork[i]*grad_logt;
442 double t1 = state1[0];
447 double t2 = state2[0];
450 double p = 0.5*(p1 + p2);
451 double t = 0.5*(state1[0] + state2[0]);
453 for (n = 0; n < nsp; n++) {
454 x3[n] = 0.5*(x1[n] + x2[n]);
466 bool addThermalDiffusion =
false;
467 if (state1[0] != state2[0]) {
468 addThermalDiffusion =
true;
475 for (
size_t i = 0; i <
m_nsp; i++) {
476 doublereal sum = 0.0;
477 for (
size_t j = 0; j <
m_nsp; j++) {
488 doublereal gradmax = -1.0;
489 for (
size_t j = 0; j <
m_nsp; j++) {
490 if (fabs(x2[j] - x1[j]) > gradmax) {
491 gradmax = fabs(x1[j] - x2[j]);
499 for (
size_t j = 0; j <
m_nsp; j++) {
501 fluxes[j] = x2[j] - x1[j];
507 size_t nr = m_aa.
nRows();
510 ct_dgetrf(nr, nc, m_aa.
ptrColumn(0), nr, &m_aa.
ipiv()[0], info);
513 ct_dgetrs(ctlapack::NoTranspose, nr, ndim,
517 "Error in DGETRS. Info = "+
int2str(info));
520 "Error in DGETRF. Info = "+
int2str(info));
522 doublereal pp = pressure_ig();
526 for (
size_t i = 0; i <
m_nsp; i++) {
527 fluxes[i] *= rho * y[i] / pp;
531 if (addThermalDiffusion) {
532 doublereal grad_logt = (t2 - t1)/
m_temp;
533 for (
size_t i = 0; i <
m_nsp; i++) {
540 const doublereal*
const state2,
541 const doublereal delta,
542 doublereal*
const fluxes)
546 fluxes[k] /=
m_mw[k];
575 doublereal p = pressure_ig();
593 throw CanteraError(
"MultiTransport::getMultiDiffCoeffs",
594 string(
" invert returned ierr = ")+
int2str(ierr));
599 doublereal prefactor = 16.0 *
m_temp
603 for (
size_t i = 0; i <
m_nsp; i++) {
604 for (
size_t j = 0; j <
m_nsp; j++) {
605 c = prefactor/
m_mw[j];
607 (m_Lmatrix(i,j) - m_Lmatrix(i,i));
620 GasTransport::update_T();
625 m_lmatrix_soln_ok =
false;
635 m_lmatrix_soln_ok =
false;
640 for (
size_t k = 0; k <
m_nsp; k++) {
663 for (
size_t i = 0; i <
m_nsp; i++) {
664 for (
size_t j = i; j <
m_nsp; j++) {
665 z =
m_logt - m_log_eps_k(i,j);
666 ipoly = m_poly[i][j];
688 for (
size_t k = 0; k <
m_nsp; k++) {
689 tr = m_eps[k]/
m_kbt;
691 m_rotrelax[k] =
std::max(1.0,m_zrot[k]) * m_frot_298[k]/
Frot(tr, sqtr);
696 for (
size_t k = 0; k <
m_nsp; k++) {
711 for (
size_t k = 0; k <
m_nsp; k++) {
712 m_cinternal[k] = cp[k] - 2.5;
725 getGasTransportData(int kSpecies) {
730 if (m_crot[kSpecies] == 0.0) {
732 }
else if (m_crot[kSpecies] == 1.0) {
737 td.
diameter = m_diam(kSpecies, kSpecies) * 1.0E10;