Added diffusion velocity returns to SimpleTransport.
Worked on documentation.
This commit is contained in:
parent
cc0b37123e
commit
f59c07606a
3 changed files with 224 additions and 11 deletions
|
|
@ -482,8 +482,7 @@ namespace Cantera {
|
|||
doublereal* current);
|
||||
|
||||
|
||||
//! Get the species diffusive velocities wrt to
|
||||
//! the averaged velocity,
|
||||
//! Get the species diffusive velocities wrt to the averaged velocity,
|
||||
//! given the gradients in mole fraction and temperature
|
||||
/*!
|
||||
* The average velocity can be computed on a mole-weighted
|
||||
|
|
|
|||
|
|
@ -598,6 +598,104 @@ namespace Cantera {
|
|||
dt[k] = 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
//====================================================================================================================
|
||||
//! Get the species diffusive velocities wrt to the averaged velocity,
|
||||
//! given the gradients in mole fraction and temperature
|
||||
/*!
|
||||
* The average velocity can be computed on a mole-weighted
|
||||
* or mass-weighted basis, or the diffusion velocities may
|
||||
* be specified as relative to a specific species (i.e. a
|
||||
* solvent) all according to the velocityBasis input parameter.
|
||||
*
|
||||
* Units for the returned velocities are m s-1.
|
||||
*
|
||||
* @param ndim Number of dimensions in the flux expressions
|
||||
* @param grad_T Gradient of the temperature
|
||||
* (length = ndim)
|
||||
* @param ldx Leading dimension of the grad_X array
|
||||
* (usually equal to m_nsp but not always)
|
||||
* @param grad_X Gradients of the mole fraction
|
||||
* Flat vector with the m_nsp in the inner loop.
|
||||
* length = ldx * ndim
|
||||
* @param ldf Leading dimension of the fluxes array
|
||||
* (usually equal to m_nsp but not always)
|
||||
* @param Vdiff Output of the diffusive velocities.
|
||||
* Flat vector with the m_nsp in the inner loop.
|
||||
* length = ldx * ndim
|
||||
*/
|
||||
void SimpleTransport::getSpeciesVdiff(int ndim,
|
||||
const doublereal* grad_T,
|
||||
int ldx,
|
||||
const doublereal* grad_X,
|
||||
int ldf,
|
||||
doublereal* Vdiff) {
|
||||
set_Grad_T(grad_T);
|
||||
set_Grad_X(grad_X);
|
||||
const doublereal* y = m_thermo->massFractions();
|
||||
const doublereal rho = m_thermo->density();
|
||||
|
||||
getSpeciesFluxesExt(m_nsp, DATA_PTR(Vdiff));
|
||||
|
||||
for (int n = 0; n < m_nDim; n++) {
|
||||
for (int k = 0; k < m_nsp; k++) {
|
||||
if (y[k] > 1.0E-200) {
|
||||
Vdiff[n * m_nsp + k] *= 1.0 / (rho * y[k]);
|
||||
} else {
|
||||
Vdiff[n * m_nsp + k] = 0.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//================================================================================================
|
||||
// Get the species diffusive velocities wrt to the averaged velocity,
|
||||
// given the gradients in mole fraction, temperature and electrostatic potential.
|
||||
/*
|
||||
* The average velocity can be computed on a mole-weighted
|
||||
* or mass-weighted basis, or the diffusion velocities may
|
||||
* be specified as relative to a specific species (i.e. a
|
||||
* solvent) all according to the velocityBasis input parameter.
|
||||
*
|
||||
* Units for the returned velocities are m s-1.
|
||||
*
|
||||
* @param ndim Number of dimensions in the flux expressions
|
||||
* @param grad_T Gradient of the temperature
|
||||
* (length = ndim)
|
||||
* @param ldx Leading dimension of the grad_X array
|
||||
* (usually equal to m_nsp but not always)
|
||||
* @param grad_X Gradients of the mole fraction
|
||||
* Flat vector with the m_nsp in the inner loop.
|
||||
* length = ldx * ndim
|
||||
* @param ldf Leading dimension of the fluxes array
|
||||
* (usually equal to m_nsp but not always)
|
||||
* @param grad_Phi Gradients of the electrostatic potential
|
||||
* (length = ndim)
|
||||
* @param Vdiff Output of the species diffusion velocities
|
||||
* Flat vector with the m_nsp in the inner loop.
|
||||
* length = ldx * ndim
|
||||
*/
|
||||
void SimpleTransport::getSpeciesVdiffES(int ndim, const doublereal* grad_T,
|
||||
int ldx, const doublereal* grad_X,
|
||||
int ldf, const doublereal* grad_Phi,
|
||||
doublereal* Vdiff) {
|
||||
set_Grad_T(grad_T);
|
||||
set_Grad_X(grad_X);
|
||||
set_Grad_V(grad_Phi);
|
||||
const doublereal* y = m_thermo->massFractions();
|
||||
const doublereal rho = m_thermo->density();
|
||||
|
||||
getSpeciesFluxesExt(m_nsp, DATA_PTR(Vdiff));
|
||||
|
||||
for (int n = 0; n < m_nDim; n++) {
|
||||
for (int k = 0; k < m_nsp; k++) {
|
||||
if (y[k] > 1.0E-200) {
|
||||
Vdiff[n * m_nsp + k] *= 1.0 / (rho * y[k]);
|
||||
} else {
|
||||
Vdiff[n * m_nsp + k] = 0.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//================================================================================================
|
||||
// Get the species diffusive mass fluxes wrt to the specified solution averaged velocity,
|
||||
// given the gradients in mole fraction and temperature
|
||||
|
|
@ -673,33 +771,34 @@ namespace Cantera {
|
|||
|
||||
const array_fp& mw = m_thermo->molecularWeights();
|
||||
const doublereal* y = m_thermo->massFractions();
|
||||
doublereal conc = m_thermo->molarDensity();
|
||||
doublereal concTotal = m_thermo->molarDensity();
|
||||
// Unroll wrt ndim
|
||||
|
||||
vector_fp sum(m_nDim, 0.0);
|
||||
|
||||
|
||||
if (doMigration_) {
|
||||
double FRT = ElectronCharge / (Boltzmann * m_temp);
|
||||
for (n = 0; n < m_nDim; n++) {
|
||||
rhoVc[n] = 0.0;
|
||||
for (k = 0; k < m_nsp; k++) {
|
||||
fluxes[n*ldf + k] = -conc * mw[k] * m_spwork[k] *
|
||||
fluxes[n*ldf + k] = - concTotal * mw[k] * m_spwork[k] *
|
||||
( m_Grad_X[n*m_nsp + k] + FRT * m_molefracs[k] * m_chargeSpecies[k] * m_Grad_V[n]);
|
||||
sum[n] += fluxes[n*ldf + k];
|
||||
rhoVc[n] += fluxes[n*ldf + k];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (n = 0; n < m_nDim; n++) {
|
||||
rhoVc[n] = 0.0;
|
||||
for (k = 0; k < m_nsp; k++) {
|
||||
fluxes[n*ldf + k] = -conc * mw[k] * m_spwork[k] * m_Grad_X[n*m_nsp + k];
|
||||
sum[n] += fluxes[n*ldf + k];
|
||||
fluxes[n*ldf + k] = - concTotal * mw[k] * m_spwork[k] * m_Grad_X[n*m_nsp + k];
|
||||
rhoVc[n] += fluxes[n*ldf + k];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// add correction flux to enforce sum to zero
|
||||
// Add correction flux to enforce sum to zero
|
||||
for (n = 0; n < m_nDim; n++) {
|
||||
for (k = 0; k < m_nsp; k++) {
|
||||
fluxes[n*ldf + k] -= y[k]*sum[n];
|
||||
fluxes[n*ldf + k] -= y[k] * rhoVc[n];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -156,6 +156,53 @@ namespace Cantera {
|
|||
* The diffusion coefficients, \f$ D_k \f$ , is calculated from a call to the mixture diffusion
|
||||
* coefficient routine.
|
||||
*
|
||||
* <H2> Species Diffusive Fluxes </H2>
|
||||
*
|
||||
* The diffusive mass flux of species \e k is computed from the following
|
||||
* formula
|
||||
*
|
||||
* Usually the specified solution average velocity is the mass averaged velocity.
|
||||
* This is changed in some subclasses, however.
|
||||
*
|
||||
* \f[
|
||||
* j_k = - c^T M_k D_k \nabla X_k - \rho Y_k V_c
|
||||
* \f]
|
||||
*
|
||||
* where V_c is the correction velocity
|
||||
*
|
||||
* \f[
|
||||
* \rho V_c = - \sum_j {c^T M_j D_j \nabla X_j}
|
||||
* \f]
|
||||
*
|
||||
* In the above equation, \f$ D_k \f$ is the mixture diffusivity for species k calculated for the current
|
||||
* conditions, which may depend on T, P, and X_k. \f$ C^T \f$ is the total concentration of the phase.
|
||||
*
|
||||
* When this is electrical migration, the formulas above are enhanced to
|
||||
*
|
||||
* \f[
|
||||
* j_k = - C^T M_k D_k \nabla X_k + F C^T M_k \frac{D_k}{ R T } X_k z_k \nabla V - \rho Y_k V_c
|
||||
* \f]
|
||||
*
|
||||
* where V_c is the correction velocity
|
||||
*
|
||||
* \f[
|
||||
* \rho V_c = - \sum_j {c^T M_j D_j \nabla X_j} + \sum_j F C^T M_j \frac{D_j}{ R T } X_j z_j \nabla V
|
||||
* \f]
|
||||
*
|
||||
*
|
||||
* <H2> Species Diffusional Velocities </H2>
|
||||
*
|
||||
* Species diffusional velocities are calculated from the species diffusional fluxes, within this object,
|
||||
* using the following formula for the diffusional velocity of the kth species, \f$ V_k^d \f$
|
||||
*
|
||||
* \f[
|
||||
* j_k = \rho Y_k V_k^d
|
||||
* \f]
|
||||
*
|
||||
*
|
||||
* TODO
|
||||
* This object has to be made compatible with different types of reference velocities. Right now, elements
|
||||
* of the formulas are only compatible with the mass-averaged velocity.
|
||||
*
|
||||
* @ingroup tranprops
|
||||
*
|
||||
|
|
@ -364,6 +411,69 @@ namespace Cantera {
|
|||
*/
|
||||
virtual void set_Grad_X(const doublereal * const grad_X);
|
||||
|
||||
//! Get the species diffusive velocities wrt to the averaged velocity,
|
||||
//! given the gradients in mole fraction and temperature
|
||||
/*!
|
||||
* The average velocity can be computed on a mole-weighted
|
||||
* or mass-weighted basis, or the diffusion velocities may
|
||||
* be specified as relative to a specific species (i.e. a
|
||||
* solvent) all according to the velocityBasis input parameter.
|
||||
*
|
||||
* Units for the returned velocities are m s-1.
|
||||
*
|
||||
* @param ndim Number of dimensions in the flux expressions
|
||||
* @param grad_T Gradient of the temperature
|
||||
* (length = ndim)
|
||||
* @param ldx Leading dimension of the grad_X array
|
||||
* (usually equal to m_nsp but not always)
|
||||
* @param grad_X Gradients of the mole fraction
|
||||
* Flat vector with the m_nsp in the inner loop.
|
||||
* length = ldx * ndim
|
||||
* @param ldf Leading dimension of the fluxes array
|
||||
* (usually equal to m_nsp but not always)
|
||||
* @param Vdiff Output of the diffusive velocities.
|
||||
* Flat vector with the m_nsp in the inner loop.
|
||||
* length = ldx * ndim
|
||||
*/
|
||||
virtual void getSpeciesVdiff(int ndim,
|
||||
const doublereal* grad_T,
|
||||
int ldx,
|
||||
const doublereal* grad_X,
|
||||
int ldf,
|
||||
doublereal* Vdiff);
|
||||
|
||||
//! Get the species diffusive velocities wrt to the averaged velocity,
|
||||
//! given the gradients in mole fraction, temperature and electrostatic potential.
|
||||
/*!
|
||||
* The average velocity can be computed on a mole-weighted
|
||||
* or mass-weighted basis, or the diffusion velocities may
|
||||
* be specified as relative to a specific species (i.e. a
|
||||
* solvent) all according to the velocityBasis input parameter.
|
||||
*
|
||||
* Units for the returned velocities are m s-1.
|
||||
*
|
||||
* @param ndim Number of dimensions in the flux expressions
|
||||
* @param grad_T Gradient of the temperature
|
||||
* (length = ndim)
|
||||
* @param ldx Leading dimension of the grad_X array
|
||||
* (usually equal to m_nsp but not always)
|
||||
* @param grad_X Gradients of the mole fraction
|
||||
* Flat vector with the m_nsp in the inner loop.
|
||||
* length = ldx * ndim
|
||||
* @param ldf Leading dimension of the fluxes array
|
||||
* (usually equal to m_nsp but not always)
|
||||
* @param grad_Phi Gradients of the electrostatic potential
|
||||
* (length = ndim)
|
||||
* @param Vdiff Output of the species diffusion velocities
|
||||
* Flat vector with the m_nsp in the inner loop.
|
||||
* length = ldx * ndim
|
||||
*/
|
||||
virtual void getSpeciesVdiffES(int ndim, const doublereal* grad_T,
|
||||
int ldx, const doublereal* grad_X,
|
||||
int ldf, const doublereal* grad_Phi,
|
||||
doublereal* Vdiff);
|
||||
|
||||
|
||||
//! Get the species diffusive mass fluxes wrt to the specified solution averaged velocity,
|
||||
//! given the gradients in mole fraction and temperature
|
||||
/*!
|
||||
|
|
@ -723,6 +833,8 @@ namespace Cantera {
|
|||
*/
|
||||
vector_fp m_spwork;
|
||||
|
||||
vector_fp m_fluxes;
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
|
@ -755,6 +867,9 @@ namespace Cantera {
|
|||
*/
|
||||
int m_nDim;
|
||||
|
||||
//! Temporary variable that stores the rho Vc value
|
||||
double rhoVc[3];
|
||||
|
||||
private:
|
||||
|
||||
//! Throw an exception if this method is invoked.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue