Exemple #1
0
    def gammas(self):
        r'''Calculate and return the activity coefficients of a liquid phase
        using an activity coefficient model.

        .. math::
            \gamma_i = \exp\left(\frac{\frac{\partial n_i G^E}{\partial n_i }}{RT}\right)

        Returns
        -------
        gammas : list[float]
            Activity coefficients, [-]

        Notes
        -----
        '''
        try:
            return self._gammas
        except:
            pass
        # Matches the gamma formulation perfectly
        GE = self.GE()
        dG_dxs = self.dGE_dxs()
        if self.scalar:
            dG_dns = dxs_to_dn_partials(dG_dxs, self.xs, GE)
            RT_inv = 1.0 / (R * self.T)
            gammas = [exp(i * RT_inv) for i in dG_dns]
        else:
            gammas = gibbs_excess_gammas(self.xs, dG_dxs, GE, self.T)
        self._gammas = gammas
        return gammas
Exemple #2
0
    def dnGE_dns(self):
        r'''Calculate and return the partial mole number derivative of excess
        Gibbs energy of a liquid phase using an activity coefficient model.

        .. math::
            \frac{\partial n G^E}{\partial n_i}

        Returns
        -------
        dnGE_dns : list[float]
            First partial mole number derivative of excess Gibbs entropy of the
            liquid phase, [J/(mol)]

        Notes
        -----
        '''
        return dxs_to_dn_partials(self.dGE_dxs(), self.xs, self.GE())
Exemple #3
0
    def dgammas_dT(self):
        r'''Calculate and return the temperature derivatives of activity
        coefficients of a liquid phase using an activity coefficient model.

        .. math::
            \frac{\partial \gamma_i}{\partial T} =
            \left(\frac{\frac{\partial^2 n G^E}{\partial T \partial n_i}}{RT} -
            \frac{{\frac{\partial n_i G^E}{\partial n_i }}}{RT^2}\right)
             \exp\left(\frac{\frac{\partial n_i G^E}{\partial n_i }}{RT}\right)


        Returns
        -------
        dgammas_dT : list[float]
            Temperature derivatives of activity coefficients, [1/K]

        Notes
        -----
        '''
        r'''
        from sympy import *
        R, T = symbols('R, T')
        f = symbols('f', cls=Function)
        diff(exp(f(T)/(R*T)), T)
        '''
        try:
            return self._dgammas_dT
        except AttributeError:
            pass
        d2nGE_dTdns = self.d2nGE_dTdns()

        dG_dxs = self.dGE_dxs()
        GE = self.GE()
        dG_dns = dxs_to_dn_partials(dG_dxs, self.xs, GE)

        T_inv = 1.0/self.T
        RT_inv = R_inv*T_inv
        self._dgammas_dT = dgammas_dT = []
        for i in self.cmps:
            x1 = dG_dns[i]*T_inv
            dgammas_dT.append(RT_inv*(d2nGE_dTdns[i] - x1)*exp(dG_dns[i]*RT_inv))
        return dgammas_dT
Exemple #4
0
    def dnSE_dns(self):
        r'''Calculate and return the partial mole number derivative of excess
        entropy of a liquid phase using an activity coefficient model.

        .. math::
            \frac{\partial n S^E}{\partial n_i}

        Returns
        -------
        dnSE_dns : list[float]
            First partial mole number derivative of excess entropy of the liquid
            phase, [J/(mol*K)]

        Notes
        -----
        '''
        dnSE_dns = dxs_to_dn_partials(self.dSE_dxs(), self.xs, self.SE())
        if not self.scalar and type(dnSE_dns) is list:
            dnSE_dns = array(dnSE_dns)
        return dnSE_dns