Ejemplo n.º 1
0
void IdealGasPhase::setToEquilState(const doublereal* mu_RT)
{
    const vector_fp& grt = gibbs_RT_ref();

    /*
     * Within the method, we protect against inf results if the
     * exponent is too high.
     *
     * If it is too low, we set
     * the partial pressure to zero. This capability is needed
     * by the elemental potential method.
     */
    doublereal pres = 0.0;
    for (size_t k = 0; k < m_kk; k++) {
        double tmp = -grt[k] + mu_RT[k];
        if (tmp < -600.) {
            m_pp[k] = 0.0;
        } else if (tmp > 300.0) {
            double tmp2 = tmp / 300.;
            tmp2 *= tmp2;
            m_pp[k] = m_p0 * exp(300.) * tmp2;
        } else {
            m_pp[k] = m_p0 * exp(tmp);
        }
        pres += m_pp[k];
    }
    // set state
    setState_PX(pres, &m_pp[0]);
}
void LatticePhase::getGibbs_RT(doublereal* grt) const
{
    const vector_fp& gibbsrt = gibbs_RT_ref();
    doublereal delta_prt = (m_Pcurrent - m_Pref) / RT();
    for (size_t k = 0; k < m_kk; k++) {
        grt[k] = gibbsrt[k] + delta_prt * m_speciesMolarVolume[k];
    }
}
void LatticePhase::getPureGibbs(doublereal* gpure) const
{
    const vector_fp& gibbsrt = gibbs_RT_ref();
    doublereal delta_p = (m_Pcurrent - m_Pref);
    for (size_t k = 0; k < m_kk; k++) {
        gpure[k] = RT() * gibbsrt[k] + delta_p * m_speciesMolarVolume[k];
    }
}
Ejemplo n.º 4
0
 /*
  * Get the nondimensional gibbs function for the species
  * standard states at the current T and P of the solution.
  */
 void PecosGasPhase::getGibbs_RT(doublereal* grt) const {
   const array_fp& gibbsrt = gibbs_RT_ref();
   copy(gibbsrt.begin(), gibbsrt.end(), grt);
   double tmp = log (pressure() /m_spthermo->refPressure());
   for (int k = 0; k < m_kk; k++) {
     grt[k] += tmp;
   }
 }
Ejemplo n.º 5
0
 /*
  * get the pure Gibbs free energies of each species assuming
  * it is in its standard state. This is the same as
  * getStandardChemPotentials().
  */
 void PecosGasPhase::getPureGibbs(doublereal* gpure) const {
   const array_fp& gibbsrt = gibbs_RT_ref();
   scale(gibbsrt.begin(), gibbsrt.end(), gpure, _RT());
   double tmp = log (pressure() /m_spthermo->refPressure());
   tmp *= _RT();
   for (int k = 0; k < m_kk; k++) {
     gpure[k] += tmp;
   }
 }
Ejemplo n.º 6
0
void IdealGasPhase::getPureGibbs(doublereal* gpure) const
{
    const vector_fp& gibbsrt = gibbs_RT_ref();
    scale(gibbsrt.begin(), gibbsrt.end(), gpure, RT());
    double tmp = log(pressure() / m_spthermo->refPressure()) * RT();
    for (size_t k = 0; k < m_kk; k++) {
        gpure[k] += tmp;
    }
}
Ejemplo n.º 7
0
 /*
  * Get the array of chemical potentials at unit activity \f$
  * \mu^0_k(T,P) \f$.
  */
 void PecosGasPhase::getStandardChemPotentials(doublereal* muStar) const {
   const array_fp& gibbsrt = gibbs_RT_ref();
   scale(gibbsrt.begin(), gibbsrt.end(), muStar, _RT());
   double tmp = log (pressure() /m_spthermo->refPressure());
   tmp *=  GasConstant * temperature();
   for (int k = 0; k < m_kk; k++) {
     muStar[k] += tmp;  // add RT*ln(P/P_0)
   }
 }
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];
    }
}
Ejemplo n.º 9
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];
    }
}
Ejemplo n.º 10
0
  void LatticePhase::getChemPotentials(doublereal* mu) const {
    doublereal vdp = ((pressure() - m_spthermo->refPressure())/
		      molarDensity());
    doublereal xx;
    doublereal rt = temperature() * GasConstant;
    const array_fp& g_RT = gibbs_RT_ref();
    for (size_t k = 0; k < m_kk; k++) {
      xx = fmaxx(SmallNumber, moleFraction(k));
      mu[k] = rt*(g_RT[k] + log(xx)) + vdp;
    }
  }
Ejemplo n.º 11
0
void IdealSolidSolnPhase::setToEquilState(const doublereal* lambda_RT)
{
    const vector_fp& grt = gibbs_RT_ref();

    // set the pressure and composition to be consistent with
    // the temperature,
    doublereal pres = 0.0;
    for (size_t k = 0; k < m_kk; k++) {
        m_pp[k] = -grt[k];
        for (size_t m = 0; m < nElements(); m++) {
            m_pp[k] += nAtoms(k,m)*lambda_RT[m];
        }
        m_pp[k] = m_Pref * exp(m_pp[k]);
        pres += m_pp[k];
    }
    setState_PX(pres, &m_pp[0]);
}
Ejemplo n.º 12
0
doublereal IdealSolidSolnPhase::gibbs_mole() const
{
    return GasConstant * temperature() * (mean_X(gibbs_RT_ref()) + sum_xlogx());
}
Ejemplo n.º 13
0
void IdealGasPhase::getGibbs_RT_ref(doublereal* grt) const
{
    const vector_fp& gibbsrt = gibbs_RT_ref();
    copy(gibbsrt.begin(), gibbsrt.end(), grt);
}
Ejemplo n.º 14
0
void IdealGasPhase::getGibbs_ref(doublereal* g) const
{
    const vector_fp& gibbsrt = gibbs_RT_ref();
    scale(gibbsrt.begin(), gibbsrt.end(), g, _RT());
}
Ejemplo n.º 15
0
 void LatticePhase::getPureGibbs(doublereal* gpure) const {
   const array_fp& gibbsrt = gibbs_RT_ref();
   scale(gibbsrt.begin(), gibbsrt.end(), gpure, _RT());
 }
Ejemplo n.º 16
0
/**
 * Calculate the difference in Gibbs free energy between current p and
 * the ref p0, in mks units of
 * J kmol-1 K-1.
 */
doublereal PDSS::gibbsDelp_mole() const {
    doublereal RT = m_temp * GasConstant;
    doublereal tmp = gibbs_RT_ref();
    return(gibbs_mole() - RT * tmp);
}
Ejemplo n.º 17
0
 /*
  *  Returns the vector of the 
  *  gibbs function of the reference state at the current temperature
  *  and reference pressure.
  *  units = J/kmol
  */
 void PecosGasPhase::getGibbs_ref(doublereal *g) const {
   const array_fp& gibbsrt = gibbs_RT_ref();
   scale(gibbsrt.begin(), gibbsrt.end(), g, _RT());
 }
Ejemplo n.º 18
0
 /*
  *  Returns the vector of nondimensional
  *  enthalpies of the reference state at the current temperature
  *  and reference pressure.
  */
 void PecosGasPhase::getGibbs_RT_ref(doublereal *grt) const {
   const array_fp& gibbsrt = gibbs_RT_ref();
   copy(gibbsrt.begin(), gibbsrt.end(), grt);
 }
Ejemplo n.º 19
0
 void LatticePhase::getGibbs_RT(doublereal* grt) const {
   const array_fp& gibbsrt = gibbs_RT_ref();
   std::copy(gibbsrt.begin(), gibbsrt.end(), grt);
 }
void LatticePhase::getStandardChemPotentials(doublereal* mu0) const
{
    const vector_fp& gibbsrt = gibbs_RT_ref();
    scale(gibbsrt.begin(), gibbsrt.end(), mu0, RT());
}
void MixtureFugacityTP::getGibbs_ref(doublereal* g) const
{
    const vector_fp& gibbsrt = gibbs_RT_ref();
    scale(gibbsrt.begin(), gibbsrt.end(), g, _RT());
}