예제 #1
0
void IdealMolalSoln::getPartialMolarEntropies(doublereal* sbar) const
{
    getEntropy_R(sbar);
    calcMolalities();
    if (IMS_typeCutoff_ == 0) {
        for (size_t k = 1; k < m_kk; k++) {
            doublereal mm = std::max(SmallNumber, m_molalities[k]);
            sbar[k] -= GasConstant * log(mm);
        }
        double xmolSolvent = moleFraction(0);
        sbar[0] -= (GasConstant * (xmolSolvent - 1.0) / xmolSolvent);
    } else {
        // Update the activity coefficients, This also update the internally
        // stored molalities.
        s_updateIMS_lnMolalityActCoeff();

        // First we will add in the obvious dependence on the T term out front
        // of the log activity term
        doublereal mm;
        for (size_t k = 1; k < m_kk; k++) {
            mm = std::max(SmallNumber, m_molalities[k]);
            sbar[k] -= GasConstant * (log(mm) + IMS_lnActCoeffMolal_[k]);
        }
        double xmolSolvent = moleFraction(0);
        mm = std::max(SmallNumber, xmolSolvent);
        sbar[0] -= GasConstant *(log(mm) + IMS_lnActCoeffMolal_[0]);
    }
}
예제 #2
0
void IdealMolalSoln::getActivities(doublereal* ac) const
{
    _updateStandardStateThermo();

    // Update the molality array, m_molalities(). This requires an update due to
    // mole fractions
    if (IMS_typeCutoff_ == 0) {
        calcMolalities();
        for (size_t k = 0; k < m_kk; k++) {
            ac[k] = m_molalities[k];
        }
        double xmolSolvent = moleFraction(0);
        // Limit the activity coefficient to be finite as the solvent mole
        // fraction goes to zero.
        xmolSolvent = std::max(m_xmolSolventMIN, xmolSolvent);
        ac[0] = exp((xmolSolvent - 1.0)/xmolSolvent);
    } else {

        s_updateIMS_lnMolalityActCoeff();

        // Now calculate the array of activities.
        for (size_t k = 1; k < m_kk; k++) {
            ac[k] = m_molalities[k] * exp(IMS_lnActCoeffMolal_[k]);
        }
        double xmolSolvent = moleFraction(0);
        ac[0] = exp(IMS_lnActCoeffMolal_[0]) * xmolSolvent;
    }
}
예제 #3
0
  void IdealSolnGasVPSS::getActivityConcentrations(doublereal* c) const {
    if (m_idealGas) {
      getConcentrations(c);
    } else {
      int k;
      const vector_fp& vss = m_VPSS_ptr->standardVolumes();
      switch (m_formGC) {
      case 0:
	for (k = 0; k < m_kk; k++) {
	  c[k] = moleFraction(k);
	}
	break;
      case 1:
	for (k = 0; k < m_kk; k++) {
	  c[k] = moleFraction(k) / vss[k];
	}
	break;
      case 2:
	for (k = 0; k < m_kk; k++) {
	  c[k] = moleFraction(k) / vss[0];
	}
	break;
      }
    }
  }
예제 #4
0
    /*!
     * \brief Return the molar density of a fluid phase [mol/m^3].
     */
    Scalar molarDensity(unsigned phaseIdx) const
    {
        const auto& rho = density(phaseIdx);

        if (phaseIdx == waterPhaseIdx)
            return rho/FluidSystem::molarMass(waterCompIdx, pvtRegionIdx_);

        return
            rho*(moleFraction(phaseIdx, gasCompIdx)/FluidSystem::molarMass(gasCompIdx, pvtRegionIdx_)
                 + moleFraction(phaseIdx, oilCompIdx)/FluidSystem::molarMass(oilCompIdx, pvtRegionIdx_));

    }
예제 #5
0
 /*!
  * \brief Return the fugacity of a component in a fluid phase [Pa].
  */
 Scalar fugacity(unsigned phaseIdx, unsigned compIdx) const
 {
     return
         fugacityCoefficient(phaseIdx, compIdx)
         *moleFraction(phaseIdx, compIdx)
         *pressure(phaseIdx);
 }
예제 #6
0
 /*!
  * \brief Return the partial molar density of a fluid phase [kg / mol].
  */
 Scalar averageMolarMass(unsigned phaseIdx) const
 {
     Scalar result(0.0);
     for (unsigned compIdx = 0; compIdx < numComponents; ++ compIdx)
         result += FluidSystem::molarMass(compIdx, pvtRegionIdx_)*moleFraction(phaseIdx, compIdx);
     return result;
 }
예제 #7
0
void MaskellSolidSolnPhase::getActivityConcentrations(doublereal* c) const
{
    getActivityCoefficients(c);
    for (size_t sp = 0; sp < m_kk; ++sp) {
        c[sp] *= moleFraction(sp);
    }
}
예제 #8
0
doublereal Phase::chargeDensity() const
{
    doublereal cdens = 0.0;
    for (size_t k = 0; k < m_kk; k++) {
        cdens += charge(k)*moleFraction(k);
    }
    return cdens * Faraday;
}
예제 #9
0
void IdealGasPhase::getChemPotentials(doublereal* mu) const
{
    getStandardChemPotentials(mu);
    for (size_t k = 0; k < m_kk; k++) {
        double xx = std::max(SmallNumber, moleFraction(k));
        mu[k] += RT() * log(xx);
    }
}
예제 #10
0
doublereal MaskellSolidSolnPhase::enthalpy_mole() const
{
    _updateThermo();
    const doublereal h0 = RT() * mean_X(m_h0_RT);
    const doublereal r = moleFraction(product_species_index);
    const doublereal fmval = fm(r);
    return h0 + r * fmval * h_mixing;
}
예제 #11
0
doublereal Phase::elementalMoleFraction(const size_t m) const
{
    checkElementIndex(m);
    double denom = 0;
    for (size_t k = 0; k < m_kk; k++) {
        double atoms = 0;
        for (size_t j = 0; j < nElements(); j++) {
            atoms += nAtoms(k, j);
        }
        denom += atoms * moleFraction(k);
    }
    doublereal numerator = 0.0;
    for (size_t k = 0; k != m_kk; ++k) {
        numerator += nAtoms(k, m) * moleFraction(k);
    }
    return numerator / denom;
}
void LatticePhase::getPartialMolarEntropies(doublereal* sbar) const
{
    const vector_fp& _s = entropy_R_ref();
    for (size_t k = 0; k < m_kk; k++) {
        double xx = std::max(SmallNumber, moleFraction(k));
        sbar[k] = GasConstant * (_s[k] - log(xx));
    }
}
void MolalityVPSSTP::getActivityCoefficients(doublereal* ac) const
{
    getMolalityActivityCoefficients(ac);
    AssertThrow(m_indexSolvent==0, "MolalityVPSSTP::getActivityCoefficients");
    double xmolSolvent = std::max(moleFraction(m_indexSolvent), m_xmolSolventMIN);
    for (size_t k = 1; k < m_kk; k++) {
        ac[k] /= xmolSolvent;
    }
}
예제 #14
0
 void IdealSolnGasVPSS::getPartialMolarEntropies(doublereal* sbar) const {
   getEntropy_R(sbar);
   doublereal r = GasConstant;
   scale(sbar, sbar+m_kk, sbar, r);
   for (int k = 0; k < m_kk; k++) {
     doublereal xx = fmaxx(SmallNumber, moleFraction(k));
     sbar[k] += r * ( - log(xx));
   }
 }
예제 #15
0
void IdealGasPhase::getChemPotentials(doublereal* mu) const
{
    getStandardChemPotentials(mu);
    doublereal rt = temperature() * GasConstant;
    for (size_t k = 0; k < m_kk; k++) {
        double xx = std::max(SmallNumber, moleFraction(k));
        mu[k] += rt * (log(xx));
    }
}
예제 #16
0
doublereal MaskellSolidSolnPhase::entropy_mole() const
{
    _updateThermo();
    const doublereal s0 = GasConstant * mean_X(m_s0_R);
    const doublereal r = moleFraction(product_species_index);
    const doublereal fmval = fm(r);
    const doublereal rfm = r * fmval;
    return s0 + GasConstant * (xlogx(1-rfm) - xlogx(rfm) - xlogx(1-r-rfm) - xlogx((1-fmval)*r) - xlogx(1-r) - xlogx(r));
}
예제 #17
0
doublereal Phase::moleFraction(const std::string& nameSpec) const
{
    size_t iloc = speciesIndex(nameSpec);
    if (iloc != npos) {
        return moleFraction(iloc);
    } else {
        return 0.0;
    }
}
예제 #18
0
 void IdealSolnGasVPSS::getChemPotentials(doublereal* mu) const {
   getStandardChemPotentials(mu);
   doublereal xx;
   doublereal rt = temperature() * GasConstant;
   for (int k = 0; k < m_kk; k++) {
     xx = fmaxx(SmallNumber, moleFraction(k));
     mu[k] += rt*(log(xx));
   }
 }
예제 #19
0
 /*
  * Get the array of partial molar entropies of the species 
  * units = J / kmol / K
  */
 void PecosGasPhase::getPartialMolarEntropies(doublereal* sbar) const {
   const array_fp& _s = entropy_R_ref();
   doublereal r = GasConstant;
   scale(_s.begin(), _s.end(), sbar, r);
   doublereal logp = log(pressure()/m_spthermo->refPressure());
   for (int k = 0; k < m_kk; k++) {
     doublereal xx = fmaxx(SmallNumber, moleFraction(k));
     sbar[k] += r * (- logp - log(xx));
   }
 }
void LatticePhase::getChemPotentials(doublereal* mu) const
{
    doublereal delta_p = m_Pcurrent - m_Pref;
    const vector_fp& g_RT = gibbs_RT_ref();
    for (size_t k = 0; k < m_kk; k++) {
        double xx = std::max(SmallNumber, moleFraction(k));
        mu[k] = RT() * (g_RT[k] + log(xx))
                + delta_p * m_speciesMolarVolume[k];
    }
}
예제 #21
0
doublereal SurfPhase::entropy_mole() const
{
    _updateThermo();
    doublereal s = 0.0;
    for (size_t k = 0; k < m_kk; k++) {
        s += moleFraction(k) * (m_s0[k] -
            GasConstant * log(std::max(concentration(k) * size(k)/m_n0, SmallNumber)));
    }
    return s;
}
예제 #22
0
파일: Phase.cpp 프로젝트: anujg1991/cantera
doublereal Phase::chargeDensity() const
{
    size_t kk = nSpecies();
    doublereal cdens = 0.0;
    for (size_t k = 0; k < kk; k++) {
        cdens += charge(k)*moleFraction(k);
    }
    cdens *= Faraday;
    return cdens;
}
예제 #23
0
void IdealGasPhase::getPartialMolarEntropies(doublereal* sbar) const
{
    const vector_fp& _s = entropy_R_ref();
    scale(_s.begin(), _s.end(), sbar, GasConstant);
    doublereal logp = log(pressure() / m_spthermo->refPressure());
    for (size_t k = 0; k < m_kk; k++) {
        doublereal xx = std::max(SmallNumber, moleFraction(k));
        sbar[k] += GasConstant * (-logp - log(xx));
    }
}
예제 #24
0
void IdealSolidSolnPhase::getChemPotentials_RT(doublereal* mu) const
{
    doublereal delta_pdRT = (m_Pcurrent - m_Pref) / (temperature() * GasConstant);
    const vector_fp& g_RT = gibbs_RT_ref();
    for (size_t k = 0; k < m_kk; k++) {
        double xx = std::max(SmallNumber, moleFraction(k));
        mu[k] = (g_RT[k] + log(xx))
                + delta_pdRT * m_speciesMolarVolume[k];
    }
}
예제 #25
0
 void PecosGasPhase::getChemPotentials(doublereal* mu) const {
   getStandardChemPotentials(mu);
   //doublereal logp = log(pressure()/m_spthermo->refPressure());
   doublereal xx;
   doublereal rt = temperature() * GasConstant;
   //const array_fp& g_RT = gibbs_RT_ref();
   for (int k = 0; k < m_kk; k++) {
     xx = fmaxx(SmallNumber, moleFraction(k));
     mu[k] += rt*(log(xx));
   }
 }
예제 #26
0
compositionMap Phase::getMoleFractionsByName(double threshold) const
{
    compositionMap comp;
    for (size_t k = 0; k < m_kk; k++) {
        double x = moleFraction(k);
        if (x > threshold) {
            comp[speciesName(k)] = x;
        }
    }
    return comp;
}
예제 #27
0
 void ConstDensityThermo::getChemPotentials(doublereal* mu) const {
     doublereal vdp = (pressure() - m_spthermo->refPressure())/
                      molarDensity();
     doublereal xx;
     doublereal rt = temperature() * GasConstant;
     const array_fp& g_RT = gibbs_RT();
     for (int k = 0; k < m_kk; k++) {
         xx = fmaxx(SmallNumber, moleFraction(k));
         mu[k] = rt*(g_RT[k] + log(xx)) + vdp;
     }
 }
예제 #28
0
void MaskellSolidSolnPhase::getChemPotentials(doublereal* mu) const
{
    _updateThermo();
    const doublereal r = moleFraction(product_species_index);
    const doublereal pval = p(r);
    const doublereal rfm = r * fm(r);
    const doublereal DgbarDr = pval * h_mixing +
                               RT() *
                               std::log( (std::pow(1 - rfm, pval) * std::pow(rfm, pval) * std::pow(r - rfm, 1 - pval) * r) /
                               (std::pow(1 - r - rfm, 1 + pval) * (1 - r)) );
    mu[product_species_index] = RT() * m_g0_RT[product_species_index] + DgbarDr;
    mu[reactant_species_index] = RT() * m_g0_RT[reactant_species_index] - DgbarDr;
}
예제 #29
0
void MaskellSolidSolnPhase::getActivityCoefficients(doublereal* ac) const
{
    _updateThermo();
    static const int cacheId = m_cache.getId();
    CachedArray cached = m_cache.getArray(cacheId);
    if (!cached.validate(temperature(), pressure(), stateMFNumber())) {
        cached.value.resize(2);

        const doublereal r = moleFraction(product_species_index);
        const doublereal pval = p(r);
        const doublereal rfm = r * fm(r);
        const doublereal A = (std::pow(1 - rfm, pval) * std::pow(rfm, pval) * std::pow(r - rfm, 1 - pval)) /
                             (std::pow(1 - r - rfm, 1 + pval) * (1 - r));
        const doublereal B = pval * h_mixing / RT();
        cached.value[product_species_index] = A * std::exp(B);
        cached.value[reactant_species_index] = 1 / (A * r * (1-r) ) * std::exp(-B);
    }
    std::copy(cached.value.begin(), cached.value.end(), ac);
}
예제 #30
0
void IdealMolalSoln::getMolalityActivityCoefficients(doublereal* acMolality) const
{
    if (IMS_typeCutoff_ == 0) {
        for (size_t k = 0; k < m_kk; k++) {
            acMolality[k] = 1.0;
        }
        double xmolSolvent = moleFraction(0);
        // Limit the activity coefficient to be finite as the solvent mole
        // fraction goes to zero.
        xmolSolvent = std::max(m_xmolSolventMIN, xmolSolvent);
        acMolality[0] = exp((xmolSolvent - 1.0)/xmolSolvent) / xmolSolvent;
    } else {
        s_updateIMS_lnMolalityActCoeff();
        std::copy(IMS_lnActCoeffMolal_.begin(), IMS_lnActCoeffMolal_.end(), acMolality);
        for (size_t k = 0; k < m_kk; k++) {
            acMolality[k] = exp(acMolality[k]);
        }
    }
}