Ejemplo n.º 1
0
 /*!
  *   This function returns the fluid mobilities. Usually, you have
  *   to multiply Faraday's constant into the resulting expression
  *   to general a species flux expression.
  *
  *   Frequently, but not always, the mobility is calculated from the
  *   diffusion coefficient using the Einstein relation
  *
  *     \f[ 
  *          \mu^f_k = \frac{D_k}{R T}
  *     \f]
  *
  *
  * @param mobil_f  Returns the mobilities of
  *               the species in array \c mobil. The array must be
  *               dimensioned at least as large as the number of species.
  */
 void  LiquidTransport::getFluidMobilities(doublereal* const mobil_f) {
   getMixDiffCoeffs(DATA_PTR(m_spwork));
   doublereal c1 = 1.0 / (GasConstant * m_temp);
   for (size_t k = 0; k < m_nsp; k++) {
     mobil_f[k] = c1 * m_spwork[k];
   }
 } 
Ejemplo n.º 2
0
void AqueousTransport::getSpeciesFluxesExt(size_t ldf, doublereal* const fluxes)
{
    update_T();
    update_C();

    getMixDiffCoeffs(DATA_PTR(m_spwork));

    const vector_fp& mw = m_thermo->molecularWeights();
    const doublereal* y  = m_thermo->massFractions();
    doublereal rhon = m_thermo->molarDensity();
    // Unroll wrt ndim
    vector_fp sum(m_nDim,0.0);
    for (size_t n = 0; n < m_nDim; n++) {
        for (size_t k = 0; k < m_nsp; k++) {
            fluxes[n*ldf + k] = -rhon * mw[k] * m_spwork[k] * m_Grad_X[n*m_nsp + k];
            sum[n] += fluxes[n*ldf + k];
        }
    }
    // add correction flux to enforce sum to zero
    for (size_t n = 0; n < m_nDim; n++) {
        for (size_t k = 0; k < m_nsp; k++) {
            fluxes[n*ldf + k] -= y[k]*sum[n];
        }
    }
}
Ejemplo n.º 3
0
 /*
  *   This function returns the mobilities. In some formulations
  *   this is equal to the normal mobility multiplied by faraday's constant.
  *
  *   Frequently, but not always, the mobility is calculated from the
  *   diffusion coefficient using the Einstein relation
  *
  *     \f[
  *          \mu^e_k = \frac{F D_k}{R T}
  *     \f]
  *
  * @param mobil_e  Returns the mobilities of
  *               the species in array \c mobil_e. The array must be
  *               dimensioned at least as large as the number of species.
  */
 void LiquidTransport::getMobilities(doublereal* const mobil) {
   getMixDiffCoeffs(DATA_PTR(m_spwork));
   doublereal c1 = ElectronCharge / (Boltzmann * m_temp);
   for (size_t k = 0; k < m_nsp; k++) {
     mobil[k] = c1 * m_spwork[k];
   }
 } 
Ejemplo n.º 4
0
  void LiquidTransport::getSpeciesDiffusiveMassFluxes(doublereal* const fluxes) {
    int n, k;

    update_temp();
    update_conc();


    getMixDiffCoeffs(DATA_PTR(m_spwork));


    const array_fp& mw = m_thermo->molecularWeights();
    const doublereal* const y  = m_thermo->massFractions();
    const doublereal rhon = m_thermo->molarDensity();
    // Unroll wrt ndim
    vector_fp sum(m_nDim,0.0);
    for (n = 0; n < m_nDim; n++) {
      for (k = 0; k < m_nsp; k++) {
	fluxes[n*m_nsp + k] = -rhon * mw[k] * m_spwork[k] * m_Grad_X[n*m_nsp + k];
	sum[n] += fluxes[n*m_nsp + k];
      }
    }
    // add correction flux to enforce sum to zero
    for (n = 0; n < m_nDim; n++) {
      for (k = 0; k < m_nsp; k++) {
	fluxes[n*m_nsp + k] -= y[k]*sum[n];
      }
    }
  }
Ejemplo n.º 5
0
  /*
   *  Units for the returned fluxes are kg m-2 s-1.
   *
   *
   * The diffusive mass flux of species \e k is computed from
   * \f[
   *          \vec{j}_k = -n M_k D_k \nabla X_k.
   * \f]
   *
   *  @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 fluxes  Output of the diffusive mass fluxes
   *             Flat vector with the m_nsp in the inner loop.
   *             length = ldx * ndim
   */
  void MixTransport::getSpeciesFluxes(int ndim, 
				      const doublereal* grad_T, int ldx, const doublereal* grad_X, 
				      int ldf, doublereal* fluxes) {
    int n, k;

    update_T();
    update_C();

    getMixDiffCoeffs(DATA_PTR(m_spwork));

    const array_fp& mw = m_thermo->molecularWeights();
    const doublereal* y  = m_thermo->massFractions();
    doublereal rhon = m_thermo->molarDensity();

    vector_fp sum(ndim,0.0);
    for (n = 0; n < ndim; n++) {
      for (k = 0; k < m_nsp; k++) {
	fluxes[n*ldf + k] = -rhon * mw[k] * m_spwork[k] * grad_X[n*ldx + k];
	sum[n] += fluxes[n*ldf + k];
      }
    }
    // add correction flux to enforce sum to zero
    for (n = 0; n < ndim; n++) {
      for (k = 0; k < m_nsp; k++) {
	fluxes[n*ldf + k] -= y[k]*sum[n];
      }
    }
  }
Ejemplo n.º 6
0
 void LiquidTransport::getMobilities(doublereal* const mobil) {
   // this needs to be checked out. 
   int k;
   getMixDiffCoeffs(DATA_PTR(m_spwork));
   doublereal c1 = ElectronCharge / (Boltzmann * m_temp);
   for (k = 0; k < m_nsp; k++) {
     mobil[k] = c1 * m_spwork[k] * m_thermo->charge(k);
   }
 } 
Ejemplo n.º 7
0
 /**
  * Compute the mobilities of the species from the diffusion coefficients, 
  * using the Einstein relation.
  */
 void SolidTransport::getMobilities(doublereal* const mobil) {
     int k;
     getMixDiffCoeffs(mobil);
     doublereal t = m_thermo->temperature();
     int nsp = m_thermo->nSpecies();
     doublereal c1 = ElectronCharge / (Boltzmann * t);
     for (k = 0; k < nsp; k++) {
         mobil[k] *= c1 * fabs(m_thermo->charge(k));
     }
 } 
Ejemplo n.º 8
0
/*
 *
 *  units = kg/m2/s
 *
 * Internally, gradients in the in mole fraction, temperature
 * and electrostatic potential contribute to the diffusive flux
 *
 *
 * The diffusive mass flux of species \e k is computed from the following
 * formula
 *
 *    \f[
 *         j_k = - M_k z_k u^f_k F c_k \nabla \Psi  - c M_k D_k \nabla X_k  - Y_k V_c
 *    \f]
 *
 *    where V_c is the correction velocity
 *
 *    \f[
 *         V_c =  - \sum_j {M_k z_k u^f_k F c_k \nabla \Psi + c M_j D_j \nabla X_j}
 *    \f]
 *
 *  @param ldf     stride of the fluxes array. Must be equal to
 *                 or greater than the number of species.
 *  @param fluxes  Vector of calculated fluxes
 */
void SimpleTransport::getSpeciesFluxesExt(size_t ldf, doublereal* fluxes)
{
    AssertThrow(ldf >= m_nsp ,"SimpleTransport::getSpeciesFluxesExt: Stride must be greater than m_nsp");
    update_T();
    update_C();

    getMixDiffCoeffs(DATA_PTR(m_spwork));

    const vector_fp& mw = m_thermo->molecularWeights();
    const doublereal* y  = m_thermo->massFractions();

    doublereal concTotal = m_thermo->molarDensity();

    // Unroll wrt ndim


    if (doMigration_) {
        double FRT =  ElectronCharge / (Boltzmann * m_temp);
        for (size_t n = 0; n < m_nDim; n++) {
            rhoVc[n] = 0.0;
            for (size_t k = 0; k < m_nsp; 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]);
                rhoVc[n] += fluxes[n*ldf + k];
            }
        }
    } else {
        for (size_t n = 0; n < m_nDim; n++) {
            rhoVc[n] = 0.0;
            for (size_t k = 0; k < m_nsp; k++) {
                fluxes[n*ldf + k] = - concTotal * mw[k] * m_spwork[k] * m_Grad_X[n*m_nsp + k];
                rhoVc[n] += fluxes[n*ldf + k];
            }
        }
    }

    if (m_velocityBasis == VB_MASSAVG) {
        for (size_t n = 0; n < m_nDim; n++) {
            rhoVc[n] = 0.0;
            for (size_t k = 0; k < m_nsp; k++) {
                rhoVc[n] += fluxes[n*ldf + k];
            }
        }
        for (size_t n = 0; n < m_nDim; n++) {
            for (size_t k = 0; k < m_nsp; k++) {
                fluxes[n*ldf + k] -= y[k] * rhoVc[n];
            }
        }
    } else if (m_velocityBasis == VB_MOLEAVG) {
        for (size_t n = 0; n < m_nDim; n++) {
            rhoVc[n] = 0.0;
            for (size_t k = 0; k < m_nsp; k++) {
                rhoVc[n] += fluxes[n*ldf + k] / mw[k];
            }
        }
        for (size_t n = 0; n < m_nDim; n++) {
            for (size_t k = 0; k < m_nsp; k++) {
                fluxes[n*ldf + k] -= m_molefracs[k] * rhoVc[n] * mw[k];
            }
        }
    } else if (m_velocityBasis >= 0) {
        for (size_t n = 0; n < m_nDim; n++) {
            rhoVc[n] = - fluxes[n*ldf + m_velocityBasis] / mw[m_velocityBasis];
            for (size_t k = 0; k < m_nsp; k++) {
                rhoVc[n] += fluxes[n*ldf + k] / mw[k];
            }
        }
        for (size_t n = 0; n < m_nDim; n++) {
            for (size_t k = 0; k < m_nsp; k++) {
                fluxes[n*ldf + k] -= m_molefracs[k] * rhoVc[n] * mw[k];
            }
            fluxes[n*ldf + m_velocityBasis] = 0.0;
        }

    } else {
        throw CanteraError("SimpleTransport::getSpeciesFluxesExt()",
                           "unknown velocity basis");
    }
}