27double Frot(
double tr,
double sqtr)
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;
43 m_a.resize(3*
m_nsp, 1.0);
44 m_b.resize(3*
m_nsp, 0.0);
47 m_frot_298.resize(
m_nsp);
48 m_rotrelax.resize(
m_nsp);
49 m_cinternal.resize(
m_nsp);
56 m_lmatrix_soln_ok =
false;
57 m_thermal_tlast = 0.0;
60 m_spwork1.resize(
m_nsp);
61 m_spwork2.resize(
m_nsp);
62 m_spwork3.resize(
m_nsp);
66 for (
size_t i = 0; i <
m_nsp; i++) {
67 for (
size_t j = i; j <
m_nsp; j++) {
69 m_log_eps_k(j,i) = m_log_eps_k(i,j);
75 const double sq298 = sqrt(298.0);
77 m_sqrt_eps_k.resize(
m_nsp);
78 for (
size_t k = 0; k <
m_nsp; k++) {
80 m_frot_298[k] =
Frot(
m_eps[k]/kb298, m_sqrt_eps_k[k]/sq298);
86 solveLMatrixEquation();
88 for (
size_t k = 0; k < 2*
m_nsp; k++) {
96 solveLMatrixEquation();
98 for (
size_t k = 0; k <
m_nsp; k++) {
103double MultiTransport::pressure_ig()
108void MultiTransport::solveLMatrixEquation()
113 if (m_lmatrix_soln_ok) {
120 for (
size_t k = 0; k <
m_nsp; k++) {
135 for (
size_t k = 0; k <
m_nsp; k++) {
136 if (!hasInternalModes(k)) {
137 m_b[2*
m_nsp + k] = 0.0;
158 solve(m_Lmatrix, m_a.data());
159 m_lmatrix_soln_ok =
true;
166 size_t ldx,
const double*
const grad_X,
167 size_t ldf,
double*
const fluxes)
175 bool addThermalDiffusion =
false;
176 for (
size_t i = 0; i < ndim; i++) {
177 if (grad_T[i] != 0.0) {
178 addThermalDiffusion =
true;
181 if (addThermalDiffusion) {
188 for (
size_t i = 0; i <
m_nsp; i++) {
190 for (
size_t j = 0; j <
m_nsp; j++) {
201 double gradmax = -1.0;
202 for (
size_t j = 0; j <
m_nsp; j++) {
203 if (fabs(grad_X[j]) > gradmax) {
204 gradmax = fabs(grad_X[j]);
211 for (
size_t j = 0; j <
m_nsp; j++) {
214 vector<double> gsave(ndim), grx(ldx*
m_nsp);
215 for (
size_t n = 0; n < ldx*ndim; n++) {
220 for (
size_t n = 0; n < ndim; n++) {
221 const double* gx = grad_X + ldx*n;
222 copy(gx, gx +
m_nsp, fluxes + ldf*n);
223 fluxes[jmax + n*ldf] = 0.0;
227 solve(m_aa, fluxes, ndim, ldf);
228 double pp = pressure_ig();
232 for (
size_t n = 0; n < ndim; n++) {
234 for (
size_t i = 0; i <
m_nsp; i++) {
235 fluxes[i +
offset] *= rho * y[i] / pp;
240 if (addThermalDiffusion) {
241 for (
size_t n = 0; n < ndim; n++) {
243 double grad_logt = grad_T[n]/
m_temp;
244 for (
size_t i = 0; i <
m_nsp; i++) {
252 double delta,
double* fluxes)
254 double* x1 = m_spwork1.data();
255 double* x2 = m_spwork2.data();
256 double* x3 = m_spwork3.data();
260 double t1 = state1[0];
265 double t2 = state2[0];
268 double p = 0.5*(p1 + p2);
269 double t = 0.5*(state1[0] + state2[0]);
271 for (
size_t n = 0; n < nsp; n++) {
272 x3[n] = 0.5*(x1[n] + x2[n]);
283 bool addThermalDiffusion =
false;
284 if (state1[0] != state2[0]) {
285 addThermalDiffusion =
true;
291 for (
size_t i = 0; i <
m_nsp; i++) {
293 for (
size_t j = 0; j <
m_nsp; j++) {
304 double gradmax = -1.0;
305 for (
size_t j = 0; j <
m_nsp; j++) {
306 if (fabs(x2[j] - x1[j]) > gradmax) {
307 gradmax = fabs(x1[j] - x2[j]);
314 for (
size_t j = 0; j <
m_nsp; j++) {
316 fluxes[j] = x2[j] - x1[j];
323 double pp = pressure_ig();
326 for (
size_t i = 0; i <
m_nsp; i++) {
327 fluxes[i] *= rho * y[i] / pp;
331 if (addThermalDiffusion) {
332 double grad_logt = (t2 - t1)/
m_temp;
333 for (
size_t i = 0; i <
m_nsp; i++) {
340 const double*
const state2,
342 double*
const fluxes)
346 fluxes[k] /=
m_mw[k];
352 double p = pressure_ig();
370 throw CanteraError(
"MultiTransport::getMultiDiffCoeffs",
371 "invert returned ierr = {}", ierr);
374 m_lmatrix_soln_ok =
false;
376 double prefactor = 16.0 *
m_temp
378 for (
size_t i = 0; i <
m_nsp; i++) {
379 for (
size_t j = 0; j <
m_nsp; j++) {
380 double c = prefactor/
m_mw[j];
382 (m_Lmatrix(i,j) - m_Lmatrix(i,i));
393 GasTransport::update_T();
396 m_lmatrix_soln_ok =
false;
405 for (
size_t k = 0; k <
m_nsp; k++) {
412 m_lmatrix_soln_ok =
false;
427 for (
size_t i = 0; i <
m_nsp; i++) {
428 for (
size_t j = i; j <
m_nsp; j++) {
447 for (
size_t k = 0; k <
m_nsp; k++) {
449 double sqtr = m_sqrt_eps_k[k] /
m_sqrt_t;
450 m_rotrelax[k] = std::max(1.0,
m_zrot[k]) * m_frot_298[k]/
Frot(tr, sqtr);
454 for (
size_t k = 0; k <
m_nsp; k++) {
469 for (
size_t k = 0; k <
m_nsp; k++) {
470 m_cinternal[k] = cp[k] - 2.5;
478bool MultiTransport::hasInternalModes(
size_t j)
485 double prefactor = 16.0*
m_temp/25.0;
487 for (
size_t i = 0; i <
m_nsp; i++) {
491 for (
size_t k = 0; k <
m_nsp; k++) {
496 for (
size_t j = 0; j !=
m_nsp; ++j) {
497 m_Lmatrix(i,j) = prefactor * x[j]
501 m_Lmatrix(i,i) = 0.0;
507 double prefactor = 1.6*
m_temp;
508 for (
size_t j = 0; j <
m_nsp; j++) {
512 for (
size_t i = 0; i <
m_nsp; i++) {
513 m_Lmatrix(i,j +
m_nsp) = - prefactor * x[i] * xj *
m_mw[i] *
519 sum -= m_Lmatrix(i,j+
m_nsp);
521 m_Lmatrix(j,j+
m_nsp) += sum;
527 for (
size_t j = 0; j <
m_nsp; j++) {
528 for (
size_t i = 0; i <
m_nsp; i++) {
534void MultiTransport::eval_L1010(
const double* x)
536 const double fiveover3pi = 5.0/(3.0*
Pi);
537 double prefactor = (16.0*
m_temp)/25.0;
539 for (
size_t j = 0; j <
m_nsp; j++) {
541 double constant1 = prefactor*x[j];
543 double constant2 = 13.75*wjsq;
544 double constant3 =
m_crot[j]/m_rotrelax[j];
545 double constant4 = 7.5*wjsq;
546 double fourmj = 4.0*
m_mw[j];
547 double threemjsq = 3.0*
m_mw[j]*
m_mw[j];
549 for (
size_t i = 0; i <
m_nsp; i++) {
551 double term1 =
m_bdiff(i,j) * sumwij*sumwij;
552 double term2 = fourmj*
m_astar(i,j)*(1.0 + fiveover3pi*
553 (constant3 + (
m_crot[i]/m_rotrelax[i])));
556 (constant2 - threemjsq*
m_bstar(i,j)
559 sum += x[i] /(term1) *
568void MultiTransport::eval_L1001(
const double* x)
570 double prefactor = 32.00*
m_temp/(5.00*
Pi);
571 for (
size_t j = 0; j <
m_nsp; j++) {
573 if (hasInternalModes(j)) {
574 double constant = prefactor*
m_mw[j]*x[j]*
m_crot[j]/(m_cinternal[j]*m_rotrelax[j]);
576 for (
size_t i = 0; i <
m_nsp; i++) {
584 for (
size_t i = 0; i <
m_nsp; i++) {
591void MultiTransport::eval_L0001()
593 for (
size_t j = 0; j <
m_nsp; j++) {
594 for (
size_t i = 0; i <
m_nsp; i++) {
595 m_Lmatrix(i,j+2*
m_nsp) = 0.0;
600void MultiTransport::eval_L0100()
602 for (
size_t j = 0; j <
m_nsp; j++) {
603 for (
size_t i = 0; i <
m_nsp; i++) {
604 m_Lmatrix(i+2*
m_nsp,j) = 0.0;
609void MultiTransport::eval_L0110()
611 for (
size_t j = 0; j <
m_nsp; j++) {
612 for (
size_t i = 0; i <
m_nsp; i++) {
618void MultiTransport::eval_L0101(
const double* x)
620 for (
size_t i = 0; i <
m_nsp; i++) {
621 if (hasInternalModes(i)) {
623 double constant1 = 4*
m_temp*x[i]/m_cinternal[i];
625 (5*
Pi*m_cinternal[i]*m_rotrelax[i]);
627 for (
size_t k = 0; k <
m_nsp; k++) {
629 double diff_int =
m_bdiff(i,k);
631 sum += x[k]/diff_int;
633 sum += x[k]*
m_astar(i,k)*constant2 / (
m_mw[k]*diff_int);
642 for (
size_t k = 0; k <
m_nsp; k++) {
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.
void resize(size_t n, size_t m, double v=0.0) override
Resize the matrix.
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 at which the properties in this object are calculated (Kelvin).
vector< double > m_eps
Lennard-Jones well-depth of the species in the current phase.
virtual void updateDiff_T()
Update the binary diffusion coefficients.
DenseMatrix m_epsilon
The effective well depth for (i,j) collisions.
vector< double > m_spwork
work space length = m_kk
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 (kg /m /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.
double m_kbt
Current value of Boltzmann constant times the temperature (Joules)
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.
vector< vector< double > > m_cstar_poly
Fit for cstar collision integral.
void init(ThermoPhase *thermo, int mode=0, int log_level=0) override
Initialize a transport manager.
void getMassFluxes(const double *state1, const double *state2, double delta, double *fluxes) override
Get the mass diffusional fluxes [kg/m^2/s] of the species, given the thermodynamic state at two nearb...
void getMolarFluxes(const double *const state1, const double *const state2, const double delta, double *const fluxes) override
Get the molar diffusional fluxes [kmol/m^2/s] of the species, given the thermodynamic state at two ne...
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
Returns the mixture thermal conductivity in W/m/K.
void eval_L0010(const double *const x)
Evaluate the L0010 matrices.
void eval_L0000(const double *const x)
Evaluate the L0000 matrices.
DenseMatrix m_astar
Dense matrix for astar.
void getSpeciesFluxes(size_t ndim, const double *const grad_T, size_t ldx, const double *const grad_X, size_t ldf, double *const fluxes) override
Get the species diffusive mass fluxes wrt to the mass averaged velocity, given the gradients in mole ...
void updateThermal_T()
Update the temperature-dependent terms needed to compute the thermal conductivity and thermal diffusi...
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 getThermalDiffCoeffs(double *const dt) override
Return the thermal diffusion coefficients (kg/m/s)
void getMultiDiffCoeffs(const size_t ld, double *const d) override
Return the Multicomponent diffusion coefficients. Units: [m^2/s].
void init(ThermoPhase *thermo, int mode=0, int log_level=0) override
Initialize a transport manager.
DenseMatrix m_bstar
Dense matrix for bstar.
void eval_L1000()
Evaluate the L1000 matrices.
virtual double molarDensity() const
Molar density (kmol/m^3).
void restoreState(const vector< double > &state)
Restore a state saved on a previous call to saveState.
size_t nSpecies() const
Returns the number of species in the phase.
double temperature() const
Temperature (K).
double meanMolecularWeight() const
The mean molecular weight. Units: (kg/kmol)
void getMoleFractions(double *const x) const
Get the species mole fraction vector.
const double * massFractions() const
Return a const pointer to the mass fraction array.
virtual double density() const
Density (kg/m^3).
virtual double pressure() const
Return the thermodynamic pressure (Pa).
Base class for a phase with thermodynamic properties.
virtual void getCp_R_ref(double *cprt) const
Returns the vector of nondimensional constant pressure heat capacities of the reference state at the ...
virtual void setState_TPX(double t, double p, const double *x)
Set the temperature (K), pressure (Pa), and mole fractions.
ThermoPhase * m_thermo
pointer to the object representing the phase
size_t m_nsp
Number of species.
ThermoPhase & thermo()
Phase object.
R poly6(D x, R *c)
Templated evaluation of a polynomial of order 6.
R poly8(D x, R *c)
Templated evaluation of a polynomial of order 8.
const double Boltzmann
Boltzmann constant [J/K].
const double GasConstant
Universal Gas Constant [J/kmol/K].
Namespace for the Cantera kernel.
const double Tiny
Small number to compare differences of mole fractions against.
int invert(DenseMatrix &A, size_t nn)
invert A. A is overwritten with A^-1.
offset
Offsets of solution components in the 1D solution array.
static const double Min_C_Internal
Constant to compare dimensionless heat capacities against zero.
int solve(DenseMatrix &A, double *b, size_t nrhs, size_t ldb)
Solve Ax = b. Array b is overwritten on exit with x.
double Frot(double tr, double sqtr)
The Parker temperature correction to the rotational collision number.
Contains declarations for string manipulation functions within Cantera.
Various templated functions that carry out common vector and polynomial operations (see Templated Arr...