27doublereal
Frot(doublereal tr, doublereal sqtr)
29 const doublereal c1 = 0.5*sqrt(
Pi)*
Pi;
30 const doublereal c2 = 0.25*
Pi*
Pi + 2.0;
31 const doublereal c3 = sqrt(
Pi)*
Pi;
32 return 1.0 + c1*sqtr + c2*tr + c3*sqtr*tr;
48 m_a.resize(3*
m_nsp, 1.0);
49 m_b.resize(3*
m_nsp, 0.0);
52 m_frot_298.resize(
m_nsp);
53 m_rotrelax.resize(
m_nsp);
54 m_cinternal.resize(
m_nsp);
62 m_lmatrix_soln_ok =
false;
63 m_thermal_tlast = 0.0;
66 m_spwork1.resize(
m_nsp);
67 m_spwork2.resize(
m_nsp);
68 m_spwork3.resize(
m_nsp);
72 for (
size_t i = 0; i <
m_nsp; i++) {
73 for (
size_t j = i; j <
m_nsp; j++) {
75 m_log_eps_k(j,i) = m_log_eps_k(i,j);
81 const doublereal sq298 = sqrt(298.0);
82 const doublereal kb298 =
Boltzmann * 298.0;
83 m_sqrt_eps_k.resize(
m_nsp);
84 for (
size_t k = 0; k <
m_nsp; k++) {
86 m_frot_298[k] =
Frot(
m_eps[k]/kb298, m_sqrt_eps_k[k]/sq298);
92 solveLMatrixEquation();
94 for (
size_t k = 0; k < 2*
m_nsp; k++) {
102 solveLMatrixEquation();
104 for (
size_t k = 0; k <
m_nsp; k++) {
109double MultiTransport::pressure_ig()
114void MultiTransport::solveLMatrixEquation()
119 if (m_lmatrix_soln_ok) {
126 for (
size_t k = 0; k <
m_nsp; k++) {
141 for (
size_t k = 0; k <
m_nsp; k++) {
142 if (!hasInternalModes(k)) {
143 m_b[2*
m_nsp + k] = 0.0;
164 solve(m_Lmatrix, m_a.data());
165 m_lmatrix_soln_ok =
true;
172 size_t ldx,
const doublereal*
const grad_X,
173 size_t ldf, doublereal*
const fluxes)
181 bool addThermalDiffusion =
false;
182 for (
size_t i = 0; i < ndim; i++) {
183 if (grad_T[i] != 0.0) {
184 addThermalDiffusion =
true;
187 if (addThermalDiffusion) {
194 for (
size_t i = 0; i <
m_nsp; i++) {
196 for (
size_t j = 0; j <
m_nsp; j++) {
207 doublereal gradmax = -1.0;
208 for (
size_t j = 0; j <
m_nsp; j++) {
209 if (fabs(grad_X[j]) > gradmax) {
210 gradmax = fabs(grad_X[j]);
217 for (
size_t j = 0; j <
m_nsp; j++) {
221 for (
size_t n = 0; n < ldx*ndim; n++) {
226 for (
size_t n = 0; n < ndim; n++) {
227 const double* gx = grad_X + ldx*n;
228 copy(gx, gx +
m_nsp, fluxes + ldf*n);
229 fluxes[jmax + n*ldf] = 0.0;
233 solve(m_aa, fluxes, ndim, ldf);
234 doublereal pp = pressure_ig();
238 for (
size_t n = 0; n < ndim; n++) {
239 size_t offset = n*ldf;
240 for (
size_t i = 0; i <
m_nsp; i++) {
241 fluxes[i + offset] *= rho * y[i] / pp;
246 if (addThermalDiffusion) {
247 for (
size_t n = 0; n < ndim; n++) {
248 size_t offset = n*ldf;
249 doublereal grad_logt = grad_T[n]/
m_temp;
250 for (
size_t i = 0; i <
m_nsp; i++) {
251 fluxes[i + offset] -=
m_spwork[i]*grad_logt;
260 double* x1 = m_spwork1.data();
261 double* x2 = m_spwork2.data();
262 double* x3 = m_spwork3.data();
266 double t1 = state1[0];
271 double t2 = state2[0];
274 double p = 0.5*(p1 + p2);
275 double t = 0.5*(state1[0] + state2[0]);
277 for (
size_t n = 0; n < nsp; n++) {
278 x3[n] = 0.5*(x1[n] + x2[n]);
289 bool addThermalDiffusion =
false;
290 if (state1[0] != state2[0]) {
291 addThermalDiffusion =
true;
297 for (
size_t i = 0; i <
m_nsp; i++) {
298 doublereal sum = 0.0;
299 for (
size_t j = 0; j <
m_nsp; j++) {
310 doublereal gradmax = -1.0;
311 for (
size_t j = 0; j <
m_nsp; j++) {
312 if (fabs(x2[j] - x1[j]) > gradmax) {
313 gradmax = fabs(x1[j] - x2[j]);
320 for (
size_t j = 0; j <
m_nsp; j++) {
322 fluxes[j] = x2[j] - x1[j];
329 doublereal pp = pressure_ig();
332 for (
size_t i = 0; i <
m_nsp; i++) {
333 fluxes[i] *= rho * y[i] / pp;
337 if (addThermalDiffusion) {
338 doublereal grad_logt = (t2 - t1)/
m_temp;
339 for (
size_t i = 0; i <
m_nsp; i++) {
346 const doublereal*
const state2,
347 const doublereal delta,
348 doublereal*
const fluxes)
352 fluxes[k] /=
m_mw[k];
358 doublereal p = pressure_ig();
376 throw CanteraError(
"MultiTransport::getMultiDiffCoeffs",
377 "invert returned ierr = {}", ierr);
380 m_lmatrix_soln_ok =
false;
382 doublereal prefactor = 16.0 *
m_temp
384 for (
size_t i = 0; i <
m_nsp; i++) {
385 for (
size_t j = 0; j <
m_nsp; j++) {
386 double c = prefactor/
m_mw[j];
388 (m_Lmatrix(i,j) - m_Lmatrix(i,i));
399 GasTransport::update_T();
403 m_lmatrix_soln_ok =
false;
412 for (
size_t k = 0; k <
m_nsp; k++) {
419 m_lmatrix_soln_ok =
false;
434 for (
size_t i = 0; i <
m_nsp; i++) {
435 for (
size_t j = i; j <
m_nsp; j++) {
455 for (
size_t k = 0; k <
m_nsp; k++) {
457 double sqtr = m_sqrt_eps_k[k] /
m_sqrt_t;
458 m_rotrelax[k] = std::max(1.0,
m_zrot[k]) * m_frot_298[k]/
Frot(tr, sqtr);
462 for (
size_t k = 0; k <
m_nsp; k++) {
477 for (
size_t k = 0; k <
m_nsp; k++) {
478 m_cinternal[k] = cp[k] - 2.5;
486bool MultiTransport::hasInternalModes(
size_t j)
493 doublereal prefactor = 16.0*
m_temp/25.0;
495 for (
size_t i = 0; i <
m_nsp; i++) {
499 for (
size_t k = 0; k <
m_nsp; k++) {
504 for (
size_t j = 0; j !=
m_nsp; ++j) {
505 m_Lmatrix(i,j) = prefactor * x[j]
509 m_Lmatrix(i,i) = 0.0;
515 doublereal prefactor = 1.6*
m_temp;
516 for (
size_t j = 0; j <
m_nsp; j++) {
520 for (
size_t i = 0; i <
m_nsp; i++) {
521 m_Lmatrix(i,j +
m_nsp) = - prefactor * x[i] * xj *
m_mw[i] *
527 sum -= m_Lmatrix(i,j+
m_nsp);
529 m_Lmatrix(j,j+
m_nsp) += sum;
535 for (
size_t j = 0; j <
m_nsp; j++) {
536 for (
size_t i = 0; i <
m_nsp; i++) {
542void MultiTransport::eval_L1010(
const doublereal* x)
544 const doublereal fiveover3pi = 5.0/(3.0*
Pi);
545 doublereal prefactor = (16.0*
m_temp)/25.0;
547 for (
size_t j = 0; j <
m_nsp; j++) {
549 double constant1 = prefactor*x[j];
551 double constant2 = 13.75*wjsq;
552 double constant3 =
m_crot[j]/m_rotrelax[j];
553 double constant4 = 7.5*wjsq;
554 double fourmj = 4.0*
m_mw[j];
555 double threemjsq = 3.0*
m_mw[j]*
m_mw[j];
557 for (
size_t i = 0; i <
m_nsp; i++) {
559 double term1 =
m_bdiff(i,j) * sumwij*sumwij;
560 double term2 = fourmj*
m_astar(i,j)*(1.0 + fiveover3pi*
561 (constant3 + (
m_crot[i]/m_rotrelax[i])));
564 (constant2 - threemjsq*
m_bstar(i,j)
567 sum += x[i] /(term1) *
576void MultiTransport::eval_L1001(
const doublereal* x)
578 doublereal prefactor = 32.00*
m_temp/(5.00*
Pi);
579 for (
size_t j = 0; j <
m_nsp; j++) {
581 if (hasInternalModes(j)) {
582 double constant = prefactor*
m_mw[j]*x[j]*
m_crot[j]/(m_cinternal[j]*m_rotrelax[j]);
584 for (
size_t i = 0; i <
m_nsp; i++) {
592 for (
size_t i = 0; i <
m_nsp; i++) {
599void MultiTransport::eval_L0001()
601 for (
size_t j = 0; j <
m_nsp; j++) {
602 for (
size_t i = 0; i <
m_nsp; i++) {
603 m_Lmatrix(i,j+2*
m_nsp) = 0.0;
608void MultiTransport::eval_L0100()
610 for (
size_t j = 0; j <
m_nsp; j++) {
611 for (
size_t i = 0; i <
m_nsp; i++) {
612 m_Lmatrix(i+2*
m_nsp,j) = 0.0;
617void MultiTransport::eval_L0110()
619 for (
size_t j = 0; j <
m_nsp; j++) {
620 for (
size_t i = 0; i <
m_nsp; i++) {
626void MultiTransport::eval_L0101(
const doublereal* x)
628 for (
size_t i = 0; i <
m_nsp; i++) {
629 if (hasInternalModes(i)) {
631 double constant1 = 4*
m_temp*x[i]/m_cinternal[i];
633 (5*
Pi*m_cinternal[i]*m_rotrelax[i]);
635 for (
size_t k = 0; k <
m_nsp; k++) {
637 double diff_int =
m_bdiff(i,k);
639 sum += x[k]/diff_int;
641 sum += x[k]*
m_astar(i,k)*constant2 / (
m_mw[k]*diff_int);
650 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, doublereal v=0.0)
Resize the matrix.
Class GasTransport implements some functions and properties that are shared by the MixTransport and M...
doublereal m_logt
Current value of the log of the temperature.
vector_fp m_mw
Local copy of the species molecular weights.
vector_fp m_molefracs
Vector of species mole fractions.
std::vector< vector_fp > m_cstar_poly
Fit for cstar collision integral.
virtual void updateDiff_T()
Update the binary diffusion coefficients.
doublereal m_kbt
Current value of Boltzmann constant times the temperature (Joules)
DenseMatrix m_epsilon
The effective well depth for (i,j) collisions.
doublereal m_temp
Current value of the temperature at which the properties in this object are calculated (Kelvin).
std::vector< vector_fp > m_bstar_poly
Fit for bstar collision integral.
int m_mode
Type of the polynomial fits to temperature.
virtual void updateSpeciesViscosities()
Update the pure-species viscosities.
std::vector< vector_int > m_poly
Indices for the (i,j) interaction in collision integral fits.
DenseMatrix m_bdiff
Matrix of binary diffusion coefficients at the reference pressure and the current temperature Size is...
vector_fp m_visc
vector of species viscosities (kg /m /s).
vector_fp m_zrot
Rotational relaxation number for each species.
virtual void init(ThermoPhase *thermo, int mode=0, int log_level=0)
Initialize a transport manager.
std::vector< vector_fp > m_astar_poly
Fit for astar collision integral.
vector_fp m_eps
Lennard-Jones well-depth of the species in the current phase.
vector_fp m_crot
Dimensionless rotational heat capacity of each species.
vector_fp m_spwork
work space length = m_kk
std::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...
doublereal m_sqrt_t
current value of temperature to 1/2 power
virtual void getThermalDiffCoeffs(doublereal *const dt)
Return the thermal diffusion coefficients (kg/m/s)
void eval_L0000(const doublereal *const x)
Evaluate the L0000 matrices.
MultiTransport(ThermoPhase *thermo=0)
default constructor
virtual doublereal thermalConductivity()
Returns the mixture thermal conductivity in W/m/K.
virtual void getMultiDiffCoeffs(const size_t ld, doublereal *const d)
Return the Multicomponent diffusion coefficients. Units: [m^2/s].
void update_T()
Update basic temperature-dependent quantities if the temperature has changed.
virtual void getMolarFluxes(const doublereal *const state1, const doublereal *const state2, const doublereal delta, doublereal *const fluxes)
Get the molar diffusional fluxes [kmol/m^2/s] of the species, given the thermodynamic state at two ne...
vector_fp m_molefracs_last
Mole fraction vector from last L-matrix evaluation.
DenseMatrix m_astar
Dense matrix for astar.
void updateThermal_T()
Update the temperature-dependent terms needed to compute the thermal conductivity and thermal diffusi...
DenseMatrix m_cstar
Dense matrix for cstar.
virtual void init(ThermoPhase *thermo, int mode=0, int log_level=0)
Initialize a transport manager.
void update_C()
Update basic concentration-dependent quantities if the concentrations have changed.
void eval_L0010(const doublereal *const x)
Evaluate the L0010 matrices.
virtual void getSpeciesFluxes(size_t ndim, const doublereal *const grad_T, size_t ldx, const doublereal *const grad_X, size_t ldf, doublereal *const fluxes)
Get the species diffusive mass fluxes wrt to the mass averaged velocity, given the gradients in mole ...
bool m_abc_ok
Boolean indicating viscosity is up to date.
virtual void getMassFluxes(const doublereal *state1, const doublereal *state2, doublereal delta, doublereal *fluxes)
Get the mass diffusional fluxes [kg/m^2/s] of the species, given the thermodynamic state at two nearb...
DenseMatrix m_bstar
Dense matrix for bstar.
void eval_L1000()
Evaluate the L1000 matrices.
double molarDensity() const
Molar density (kmol/m^3).
size_t nSpecies() const
Returns the number of species in the phase.
doublereal 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).
doublereal temperature() const
Temperature (K).
void restoreState(const vector_fp &state)
Restore a state saved on a previous call to saveState.
virtual double pressure() const
Return the thermodynamic pressure (Pa).
Base class for a phase with thermodynamic properties.
virtual void getCp_R_ref(doublereal *cprt) const
Returns the vector of nondimensional constant pressure heat capacities of the reference state at the ...
virtual void setState_TPX(doublereal t, doublereal p, const doublereal *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.
Namespace for the Cantera kernel.
const double Tiny
Small number to compare differences of mole fractions against.
const double Boltzmann
Boltzmann constant [J/K].
static const doublereal Min_C_Internal
Constant to compare dimensionless heat capacities against zero.
int invert(DenseMatrix &A, size_t nn=npos)
invert A. A is overwritten with A^-1.
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
const double GasConstant
Universal Gas Constant [J/kmol/K].
doublereal Frot(doublereal tr, doublereal sqtr)
The Parker temperature correction to the rotational collision number.
R poly8(D x, R *c)
Templated evaluation of a polynomial of order 8.
int solve(DenseMatrix &A, double *b, size_t nrhs=1, size_t ldb=0)
Solve Ax = b. Array b is overwritten on exit with x.
R poly6(D x, R *c)
Templated evaluation of a polynomial of order 6.
Contains declarations for string manipulation functions within Cantera.
Various templated functions that carry out common vector operations (see Templated Utility Functions)...