32 inline doublereal
Frot(doublereal tr, doublereal sqtr)
35 const doublereal c2 = 0.25*Pi*Pi + 2.0;
37 return 1.0 + c1*sqtr + c2*tr + c3*sqtr*tr;
42 MultiTransport::MultiTransport(
thermo_t* thermo)
67 m_a.resize(3*
m_nsp, 1.0);
68 m_b.resize(3*
m_nsp, 0.0);
72 m_frot_298.resize(
m_nsp);
73 m_rotrelax.resize(
m_nsp);
75 m_cinternal.resize(
m_nsp);
85 m_lmatrix_soln_ok =
false;
87 m_thermal_tlast = 0.0;
90 m_spwork1.resize(
m_nsp);
91 m_spwork2.resize(
m_nsp);
92 m_spwork3.resize(
m_nsp);
97 for (
size_t i = 0; i <
m_nsp; i++) {
98 for (
size_t j = i; j <
m_nsp; j++) {
100 m_log_eps_k(j,i) = m_log_eps_k(i,j);
106 const doublereal sq298 = sqrt(298.0);
107 const doublereal kb298 =
Boltzmann * 298.0;
108 m_sqrt_eps_k.resize(m_nsp);
109 for (
size_t k = 0; k <
m_nsp; k++) {
111 m_frot_298[k] =
Frot(tr.
eps[k]/kb298,
112 m_sqrt_eps_k[k]/sq298);
120 solveLMatrixEquation();
121 doublereal sum = 0.0;
122 for (
size_t k = 0; k < 2*
m_nsp; k++) {
130 solveLMatrixEquation();
132 for (
size_t k = 0; k <
m_nsp; k++) {
137 void MultiTransport::solveLMatrixEquation()
142 if (m_lmatrix_soln_ok) {
150 for (
size_t k = 0; k <
m_nsp; k++) {
169 for (
size_t k = 0; k <
m_nsp; k++) {
170 if (!hasInternalModes(k)) {
171 m_b[2*m_nsp + k] = 0.0;
176 m_Lmatrix.
resize(3*m_nsp, 3*m_nsp, 0.0);
200 copy(m_b.begin(), m_b.end(), m_a.begin());
203 }
catch (CanteraError&
err) {
206 throw CanteraError(
"MultiTransport::solveLMatrixEquation",
207 "error in solving L matrix.");
209 m_lmatrix_soln_ok =
true;
216 size_t ldx,
const doublereal*
const grad_X,
217 size_t ldf, doublereal*
const fluxes)
225 bool addThermalDiffusion =
false;
226 for (
size_t i = 0; i < ndim; i++) {
227 if (grad_T[i] != 0.0) {
228 addThermalDiffusion =
true;
231 if (addThermalDiffusion) {
238 for (
size_t i = 0; i <
m_nsp; i++) {
240 for (
size_t j = 0; j <
m_nsp; j++) {
251 doublereal gradmax = -1.0;
252 for (
size_t j = 0; j <
m_nsp; j++) {
253 if (fabs(grad_X[j]) > gradmax) {
254 gradmax = fabs(grad_X[j]);
261 for (
size_t j = 0; j <
m_nsp; j++) {
265 for (
size_t n = 0; n < ldx*ndim; n++) {
275 const doublereal* gx;
276 for (
size_t n = 0; n < ndim; n++) {
278 copy(gx, gx + m_nsp, fluxes + ldf*n);
279 fluxes[jmax + n*ldf] = 0.0;
284 ct_dgetrf(static_cast<int>(m_aa.
nRows()),
286 static_cast<int>(m_aa.
nRows()),
287 &m_aa.
ipiv()[0], info);
289 ct_dgetrs(ctlapack::NoTranspose,
290 static_cast<int>(m_aa.
nRows()), ndim,
292 &m_aa.
ipiv()[0], fluxes, ldf, info);
304 doublereal pp = pressure_ig();
309 for (
size_t n = 0; n < ndim; n++) {
311 for (
size_t i = 0; i <
m_nsp; i++) {
312 fluxes[i + offset] *= rho * y[i] / pp;
318 if (addThermalDiffusion) {
319 for (
size_t n = 0; n < ndim; n++) {
321 doublereal grad_logt = grad_T[n]/
m_temp;
322 for (
size_t i = 0; i <
m_nsp; i++) {
323 fluxes[i + offset] -=
m_spwork[i]*grad_logt;
338 double t1 = state1[0];
343 double t2 = state2[0];
346 double p = 0.5*(p1 + p2);
347 double t = 0.5*(state1[0] + state2[0]);
349 for (n = 0; n < nsp; n++) {
350 x3[n] = 0.5*(x1[n] + x2[n]);
362 bool addThermalDiffusion =
false;
363 if (state1[0] != state2[0]) {
364 addThermalDiffusion =
true;
371 for (
size_t i = 0; i <
m_nsp; i++) {
372 doublereal sum = 0.0;
373 for (
size_t j = 0; j <
m_nsp; j++) {
384 doublereal gradmax = -1.0;
385 for (
size_t j = 0; j <
m_nsp; j++) {
386 if (fabs(x2[j] - x1[j]) > gradmax) {
387 gradmax = fabs(x1[j] - x2[j]);
395 for (
size_t j = 0; j <
m_nsp; j++) {
397 fluxes[j] = x2[j] - x1[j];
403 size_t nr = m_aa.
nRows();
406 ct_dgetrf(nr, nc, m_aa.
ptrColumn(0), nr, &m_aa.
ipiv()[0], info);
409 ct_dgetrs(ctlapack::NoTranspose, nr, ndim,
413 "Error in DGETRS. Info = "+
int2str(info));
416 "Error in DGETRF. Info = "+
int2str(info));
418 doublereal pp = pressure_ig();
422 for (
size_t i = 0; i <
m_nsp; i++) {
423 fluxes[i] *= rho * y[i] / pp;
427 if (addThermalDiffusion) {
428 doublereal grad_logt = (t2 - t1)/
m_temp;
429 for (
size_t i = 0; i <
m_nsp; i++) {
436 const doublereal*
const state2,
437 const doublereal delta,
438 doublereal*
const fluxes)
442 fluxes[k] /=
m_mw[k];
448 doublereal p = pressure_ig();
464 int ierr =
invert(m_Lmatrix, m_nsp);
466 throw CanteraError(
"MultiTransport::getMultiDiffCoeffs",
467 string(
" invert returned ierr = ")+
int2str(ierr));
470 m_lmatrix_soln_ok =
false;
473 doublereal prefactor = 16.0 *
m_temp
477 for (
size_t i = 0; i <
m_nsp; i++) {
478 for (
size_t j = 0; j <
m_nsp; j++) {
479 c = prefactor/
m_mw[j];
481 (m_Lmatrix(i,j) - m_Lmatrix(i,i));
492 GasTransport::update_T();
497 m_lmatrix_soln_ok =
false;
506 for (
size_t k = 0; k <
m_nsp; k++) {
513 m_lmatrix_soln_ok =
false;
530 for (
size_t i = 0; i <
m_nsp; i++) {
531 for (
size_t j = i; j <
m_nsp; j++) {
532 z =
m_logt - m_log_eps_k(i,j);
533 ipoly = m_poly[i][j];
555 for (
size_t k = 0; k <
m_nsp; k++) {
556 tr = m_eps[k]/
m_kbt;
558 m_rotrelax[k] = std::max(1.0,m_zrot[k]) * m_frot_298[k]/
Frot(tr, sqtr);
563 for (
size_t k = 0; k <
m_nsp; k++) {
578 for (
size_t k = 0; k <
m_nsp; k++) {
579 m_cinternal[k] = cp[k] - 2.5;
virtual doublereal thermalConductivity()
Returns the mixture thermal conductivity in W/m/K.
void eval_L1000()
Evaluate the L1000 matrices.
size_t nRows() const
Number of rows.
virtual void updateSpeciesViscosities()
Update the pure-species viscosities.
virtual doublereal density() const
Density (kg/m^3).
std::string int2str(const int n, const std::string &fmt)
Convert an int to a string using a format converter.
DenseMatrix m_bstar
Dense matrix for bstar.
int invert(DenseMatrix &A, size_t nn)
invert A. A is overwritten with A^-1.
void restoreState(const vector_fp &state)
Restore a state saved on a previous call to saveState.
This structure holds transport model parameters relevant to transport in ideal gases with a kinetic t...
vector_fp alpha
Polarizability of each species in the phase.
virtual void getThermalDiffCoeffs(doublereal *const dt)
Return the thermal diffusion coefficients (kg/m/s)
std::vector< vector_fp > omega22_poly
This is vector of vectors containing the astar fit.
Various templated functions that carry out common vector operations (see Templated Utility Functions)...
std::vector< vector_fp > astar_poly
This is vector of vectors containing the astar fit.
virtual void setState_TPX(doublereal t, doublereal p, const doublereal *x)
Set the temperature (K), pressure (Pa), and mole fractions.
Class IdealGasPhase represents low-density gases that obey the ideal gas equation of state...
Interface for class MultiTransport.
DenseMatrix m_astar
Dense matrix for astar.
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...
thermo_t * m_thermo
pointer to the object representing the phase
DenseMatrix m_cstar
Dense matrix for cstar.
void update_T()
Update basic temperature-dependent quantities if the temperature has changed.
vector_fp sigma
Lennard-Jones diameter of the species in the current phase.
int solve(DenseMatrix &A, double *b)
Solve Ax = b. Array b is overwritten on exit with x.
DenseMatrix m_bdiff
Matrix of binary diffusion coefficients at the reference pressure and the current temperature Size is...
doublereal * ptrColumn(size_t j)
Return a pointer to the top of column j, columns are contiguous in memory.
void getMoleFractions(doublereal *const x) const
Get the species mole fraction vector.
doublereal m_temp
Current value of the temperature at which the properties in this object are calculated (Kelvin)...
std::vector< vector_fp > cstar_poly
This is vector of vectors containing the astar fit.
Header file defining class TransportFactory (see TransportFactory)
doublereal Frot(doublereal tr, doublereal sqtr)
The Parker temperature correction to the rotational collision number.
Base class for a phase with thermodynamic properties.
Functions to evaluate portions of the L matrix needed for multicomponent transport properties...
int m_mode
Type of the polynomial fits to temperature.
doublereal err(const std::string &msg) const
Error routine.
vector_fp zrot
Rotational relaxation number for the species in the current phase.
R poly8(D x, R *c)
Templated evaluation of a polynomial of order 8.
void resize(size_t n, size_t m, doublereal v=0.0)
Resize the matrix.
vector_fp eps
Lennard-Jones well-depth of the species in the current phase.
ThermoPhase object for the ideal gas equation of state - workhorse for Cantera (see Thermodynamic Pro...
R poly6(D x, R *c)
Templated evaluation of a polynomial of order 6.
vector_fp m_molefracs_last
Mole fraction vector from last L-matrix evaluation.
virtual void updateDiff_T()
Update the binary diffusion coefficients.
vector_fp m_visc
vector of species viscosities (kg /m /s).
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_spwork
work space length = m_kk
size_t nColumns() const
Number of columns.
void eval_L0000(const doublereal *const x)
Evaluate the L0000 matrices.
const doublereal * massFractions() const
Return a const pointer to the mass fraction array.
virtual void getMultiDiffCoeffs(const size_t ld, doublereal *const d)
Return the Multicomponent diffusion coefficients. Units: [m^2/s].
Base class for exceptions thrown by Cantera classes.
virtual bool initGas(GasTransportParams &tr)
Initialize the transport operator with parameters from GasTransportParams object. ...
void updateThermal_T()
Update the temperature-dependent terms needed to compute the thermal conductivity and thermal diffusi...
vector_fp crot
Dimensionless rotational heat capacity of the species in the current phase.
DenseMatrix epsilon
The effective well depth for (i,j) collisions.
virtual bool initGas(GasTransportParams &tr)
Called by TransportFactory to set parameters.
std::vector< vector_fp > bstar_poly
This is vector of vectors containing the astar fit.
size_t nSpecies() const
Returns the number of species in the phase.
std::vector< std::vector< int > > poly
This is vector of vectors containing the integer lookup value for the (i,j) interaction.
virtual doublereal pressure() const
Return the thermodynamic pressure (Pa).
doublereal temperature() const
Temperature (K).
std::vector< double > vector_fp
Turn on the use of stl vectors for the basic array type within cantera Vector of doubles.
DenseMatrix dipole
The effective dipole moment for (i,j) collisions.
doublereal m_sqrt_t
current value of temperature to 1/2 power
const doublereal Tiny
Small number to compare differences of mole fractions against.
const doublereal SqrtPi
sqrt(Pi)
doublereal meanMolecularWeight() const
The mean molecular weight. Units: (kg/kmol)
const doublereal GasConstant
Universal Gas Constant. [J/kmol/K].
Contains declarations for string manipulation functions within Cantera.
#define DATA_PTR(vec)
Creates a pointer to the start of the raw data for a vector.
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 ...
size_t m_nsp
Number of species.
doublereal m_logt
Current value of the log of the temperature.
bool m_abc_ok
Boolean indicating viscosity is up to date.
doublereal m_kbt
Current value of Boltzman's constant times the temperature (Joules)
void eval_L0010(const doublereal *const x)
Evaluate the L0010 matrices.
Class that holds the data that is read in from the xml file, and which is used for processing of the ...
const doublereal Boltzmann
Boltzmann's constant [J/K].
DenseMatrix m_om22
Dense matrix for omega22.
vector_int & ipiv()
Return a changeable value of the pivot vector.
vector_fp m_molefracs
Vector of species mole fractions.
Class GasTransport implements some functions and properties that are shared by the MixTransport and M...
void update_C()
Update basic concentration-dependent quantities if the concentrations have changed.
vector_fp m_mw
Local copy of the species molecular weights.