示例#1
0
void DustyGasTransport::getMolarFluxes(const doublereal* const state1,
                                       const doublereal* const state2,
                                       const doublereal delta,
                                       doublereal* const fluxes)
{
    doublereal conc1, conc2;
    // cbar will be the average concentration between the two points
    doublereal* const cbar = m_spwork.data();
    doublereal* const gradc = m_spwork2.data();
    const doublereal t1 = state1[0];
    const doublereal t2 = state2[0];
    const doublereal rho1 = state1[1];
    const doublereal rho2 = state2[1];
    const doublereal* const y1 = state1 + 2;
    const doublereal* const y2 = state2 + 2;
    doublereal c1sum = 0.0, c2sum = 0.0;

    for (size_t k = 0; k < m_nsp; k++) {
        conc1 = rho1 * y1[k] / m_mw[k];
        conc2 = rho2 * y2[k] / m_mw[k];
        cbar[k] = 0.5*(conc1 + conc2);
        gradc[k] = (conc2 - conc1) / delta;
        c1sum += conc1;
        c2sum += conc2;
    }

    // Calculate the pressures at p1 p2 and pbar
    doublereal p1 = c1sum * GasConstant * t1;
    doublereal p2 = c2sum * GasConstant * t2;
    doublereal pbar = 0.5*(p1 + p2);
    doublereal gradp = (p2 - p1)/delta;
    doublereal tbar = 0.5*(t1 + t2);
    m_thermo->setState_TPX(tbar, pbar, cbar);
    updateMultiDiffCoeffs();

    // Multiply m_multidiff and gradc together and store the result in fluxes[]
    multiply(m_multidiff, gradc, fluxes);
    divide_each(cbar, cbar + m_nsp, m_dk.begin());

    // if no permeability has been specified, use result for
    // close-packed spheres
    double b = 0.0;
    if (m_perm < 0.0) {
        double p = m_porosity;
        double d = m_diam;
        double t = m_tortuosity;
        b = p*p*p*d*d/(72.0*t*(1.0-p)*(1.0-p));
    } else {
        b = m_perm;
    }
    b *= gradp / m_gastran->viscosity();
    scale(cbar, cbar + m_nsp, cbar, b);

    // Multiply m_multidiff with cbar and add it to fluxes
    increment(m_multidiff, cbar, fluxes);
    scale(fluxes, fluxes + m_nsp, fluxes, -1.0);
}
示例#2
0
    void DustyGasTransport::getMolarFluxes(const doublereal* state1,
        const doublereal* state2, double delta, double* fluxes) {
        int k;
        doublereal conc1, conc2;
        doublereal* cbar = DATA_PTR(m_spwork);
        doublereal* gradc = DATA_PTR(m_spwork2);
        doublereal t1 = state1[0];
        doublereal t2 = state2[0];
        doublereal rho1 = state1[1];
        doublereal rho2 = state2[1];
        const doublereal* y1 = state1 + 2;
        const doublereal* y2 = state2 + 2;
        doublereal c1sum = 0.0, c2sum = 0.0;
        for (k = 0; k < m_nsp; k++) {
            conc1 = rho1*y1[k]/m_mw[k];
            conc2 = rho2*y2[k]/m_mw[k];
            cbar[k] = 0.5*(conc1 + conc2);
            gradc[k] = (conc2 - conc1)/delta;
            c1sum += conc1;
            c2sum += conc2;
        }
        doublereal p1 = c1sum * GasConstant * state1[0];
        doublereal p2 = c2sum * GasConstant * state2[0];
        doublereal pbar = 0.5*(p1 + p2);
        doublereal gradp = (p2 - p1)/delta;
        doublereal tbar = 0.5*(t1 + t2);

        m_thermo->setState_TPX(tbar, pbar, cbar);

        updateMultiDiffCoeffs();

        multiply(m_multidiff, gradc, fluxes);
        divide_each(cbar, cbar + m_nsp, m_dk.begin());

        // if no permeability has been specified, use result for 
        // close-packed spheres
        double b = 0.0;
        if (m_perm < 0.0) {
            double p = m_porosity;
            double d = m_diam;
            double t = m_tortuosity;
            b = p*p*p*d*d/(72.0*t*(1.0-p)*(1.0-p));
        }
        else {
            b = m_perm;
        }
        b *= gradp / m_gastran->viscosity();
        scale(cbar, cbar + m_nsp, cbar, b);
        increment(m_multidiff, cbar, fluxes);
        scale(fluxes, fluxes + m_nsp, fluxes, -1.0);
    }