示例#1
0
    def _Dew_P(self):
        def f(P):
            eq = self.__class__(self.T, P, self.mezcla)
            return sum([x / k for k, x in zip(eq.Ki, self.fraccion)]) - 1.

        P = fsolve(f, self.P.atm)
        return unidades.Pressure(P, "atm")
示例#2
0
 def __init__(self, T, P, mezcla, **kwargs):
     self.T = unidades.Temperature(T)
     self.P = unidades.Pressure(P, "atm")
     self.mezcla = mezcla
     self.componente = mezcla.componente
     self.fraccion = mezcla.fraccion
     self.kwargs = kwargs
示例#3
0
 def TB_H_exceso(self, T, P):
     """Método de cálculo de la entalpía de exceso mediante la ecuación de estado de Trebble-Bishnoi"""
     p = unidades.Pressure(P, "atm")
     U = self.TB_U_exceso(T, P)
     a, b, c, d, q1, q2 = self.TB_lib(T, P)
     t = 1 + 6 * c / b + c**2 / b**2 + 4 * d**2 / b**2
     if t >= 0:
         v = self.TB_V(T, P).m3g * self.peso_molecular
         return unidades.Enthalpy(
             p * v - R / T / self.peso_molecular + U.Jg, "Jg")
     else:
         Z = self.TB_Z(T, P)
         return unidades.Enthalpy(
             R / self.peso_molecular * T * (Z - 1) + U.Jg, "Jg")
示例#4
0
 def fug(self, rho, T, nfirni=None):
     if not nfirni:
         tau = self.Tc / T
         delta = rho / self.rhoc
         fir, firt, firtt, fird, firdd, firdt, firdtt, nfirni = self._phir(
             tau, delta)
     f = []
     FI = []
     for xi, dn in zip(self.xi, nfirni):
         f.append(
             unidades.Pressure(xi * rho / self.M * R_atml * T * exp(dn),
                               "atm"))
         FI.append(dn - log(self.Z))
     return f, FI
示例#5
0
 def TB_Fugacidad(self, T, P):
     """Método de cálculo de la fugacidad mediante la ecuación de estado de Trebble-Bishnoi"""
     a, b, c, d, q1, q2 = self.TB_lib(T, P)
     z = self.TB_Z(T, P)
     A = a * P / R_atml**2 / T**2
     B = b * P / R_atml / T
     u = 1 + c / b
     t = 1 + 6 * c / b + c**2 / b**2 + 4 * d**2 / b**2
     tita = abs(t)**0.5
     if t >= 0:
         lamda = log((2 * z + B * (u - tita)) / (2 * z + B * (u + tita)))
     else:
         lamda = 2 * arctan((2 * z + u * B) / B / tita) - pi
     fi = z - 1 - log(z - B) + A / B / tita * lamda
     return unidades.Pressure(P * exp(fi), "atm")
示例#6
0
    def calculo(self):
        T = self.kwargs["T"]
        rho = self.kwargs["rho"]
        P = self.kwargs["P"]
        v = self.kwargs["v"]
        h = self.kwargs["h"]
        s = self.kwargs["s"]
        u = self.kwargs["u"]
        x = self.kwargs["x"]

        self.comp = []
        for i in self.kwargs["componente"]:
            c = self.componentes[i](eq="GERG", **self.kwargs)
            self.comp.append(c)
        self.id = self.kwargs["componente"]
        self.xi = self.kwargs["fraccion"]

        # Critic properties for mixture,
        # eq. 7.9, 7.10 pag.125, Tabla 7.10 pag 136
        bt = self.Prop_c["beta_t"]
        bv = self.Prop_c["beta_v"]
        gt = self.Prop_c["gamma_t"]
        gv = self.Prop_c["gamma_v"]
        c_T = zeros((len(self.comp), len(self.comp)))
        c_rho = zeros((len(self.comp), len(self.comp)))
        for i, cmpi in enumerate(self.comp):
            for j, cmpj in enumerate(self.comp):
                c_T[i, j] = 2 * bt[i][j] * gt[i][j] * (cmpi.Tc * cmpj.Tc)**0.5
                c_rho[i, j] = 2*bv[i][j]*gv[i][j]/8. * \
                    (1./cmpi.rhoc**(1./3)+1./cmpj.rhoc**(1./3))**3

        f_T = zeros((len(self.comp), len(self.comp)))
        f_rho = zeros((len(self.comp), len(self.comp)))
        dFT_ik = zeros((len(self.comp), len(self.comp)))
        dFT_ki = zeros((len(self.comp), len(self.comp)))
        dFrho_ik = zeros((len(self.comp), len(self.comp)))
        dFrho_ki = zeros((len(self.comp), len(self.comp)))
        for i, x_i in enumerate(self.xi):
            for j, x_j in enumerate(self.xi):
                f_T[i, j] = x_i * x_j * (x_i + x_j) / (bt[i][j]**2 * x_i + x_j)
                f_rho[i,
                      j] = x_i * x_j * (x_i + x_j) / (bv[i][j]**2 * x_i + x_j)
                dFT_ik[i, j] = x_j*(x_j+x_i)/(bt[i][j]**2*x_i+x_j) + \
                    x_j*x_i/(bt[i][j]**2*x_i+x_j) * \
                    (1-bt[i][j]**2*(x_j+x_i)/(bt[i][j]**2*x_i+x_j))
                dFrho_ik[i, j] = x_j*(x_j+x_i)/(bv[i][j]**2*x_i+x_j) + \
                    x_j*x_i/(bv[i][j]**2*x_i+x_j) * \
                    (1-bv[i][j]**2*(x_j+x_i)/(bv[i][j]**2*x_i+x_j))
                dFT_ki[j, i] = x_j*(x_j+x_i)/(bt[i][j]**2*x_j+x_i)+x_j*x_i / \
                    (bt[i][j]**2*x_j+x_i)*(1-(x_j+x_i)/(bt[i][j]**2*x_j+x_i))
                dFrho_ki[j, i] = x_j*(x_j+x_i)/(bv[i][j]**2*x_j+x_i)+x_j*x_i /\
                    (bv[i][j]**2*x_j+x_i)*(1-(x_j+x_i)/(bv[i][j]**2*x_j+x_i))

        sumai_v = sumaij_v = sumai_T = sumaij_T = m = 0
        for i, componentei in enumerate(self.comp):
            sumai_v += self.xi[i]**2 / componentei.rhoc
            sumai_T += self.xi[i]**2 * componentei.Tc
            m += self.xi[i] * componentei.M
            for j, componentej in enumerate(self.comp):
                if j > i:
                    sumaij_v += c_rho[i, j] * f_rho[i, j]
                    sumaij_T += c_T[i, j] * f_T[i, j]

        self.rhoc = unidades.Density(1. / (sumai_v + sumaij_v))
        self.Tc = unidades.Temperature(sumai_T + sumaij_T)
        self.M = m  # g/mol
        self.R = unidades.SpecificHeat(R / self.M, "kJkgK")

        Tcxi = rhocxi = []
        for i, componentei in enumerate(self.comp):
            sumav1 = sumat1 = 0
            for k in range(i):
                sumav1 += c_rho[k, i] * dFrho_ki[k, i]
                sumat1 += c_T[k, i] * dFT_ki[k, i]
            sumav2 = sumat2 = 0
            for k in range(i + 1, len(self.xi)):
                sumav2 += c_rho[i, k] * dFrho_ik[i, k]
                sumat2 += c_T[i, k] * dFT_ik[i, k]

            Tcxi.append(2 * self.xi[i] * componentei.Tc + sumat1 + sumat2)
            rhocxi.append(2 * self.xi[i] / componentei.rhoc + sumav1 + sumav2)
        self.Tcxi = Tcxi
        self.rhocxi = rhocxi

        if v and not rho:
            rho = 1. / v

        if T and x is not None:
            pass
        else:
            if T and P:
                rhoo = 2.
                rho = fsolve(lambda rho: self._solve(rho, T)["P"] - P * 1e6,
                             rhoo)
            elif T and rho:
                pass
            elif T and h is not None:
                rho = fsolve(lambda rho: self._solve(rho, T)["h"] - h, 200)
            elif T and s is not None:
                rho = fsolve(lambda rho: self._solve(rho, T)["s"] - s, 200)
            elif T and u is not None:
                rho = fsolve(lambda rho: self._solve(rho, T)["u"] - u, 200)
            elif P and rho:
                T = fsolve(lambda T: self._solve(rho, T)["P"] - P * 1e6, 600)
            elif P and h is not None:
                rho, T = fsolve(
                    lambda par: (self._solve(par[0], par[1])["P"] - P * 1e6,
                                 self._solve(par[0], par[1])["h"] - h),
                    [200, 600])
            elif P and s is not None:
                rho, T = fsolve(
                    lambda par: (self._solve(par[0], par[1])["P"] - P * 1e6,
                                 self._solve(par[0], par[1])["s"] - s),
                    [200, 600])
            elif P and u is not None:
                rho, T = fsolve(
                    lambda par: (self._solve(par[0], par[1])["P"] - P * 1e6,
                                 self._solve(par[0], par[1])["u"] - u),
                    [200, 600])
            elif rho and h is not None:
                T = fsolve(lambda T: self._solve(rho, T)["h"] - h, 600)
            elif rho and s is not None:
                T = fsolve(lambda T: self._solve(rho, T)["s"] - s, 600)
            elif rho and u is not None:
                T = fsolve(lambda T: self._solve(rho, T)["u"] - u, 600)
            elif h is not None and s is not None:
                rho, T = fsolve(
                    lambda par: (self._solve(par[0], par[1])["h"] - h,
                                 self._solve(par[0], par[1])["s"] - s),
                    [200, 600])
            elif h is not None and u is not None:
                rho, T = fsolve(
                    lambda par: (self._solve(par[0], par[1])["h"] - h,
                                 self._solve(par[0], par[1])["u"] - u),
                    [200, 600])
            elif s is not None and u is not None:
                rho, T = fsolve(
                    lambda par: (self._solve(par[0], par[1])["s"] - s,
                                 self._solve(par[0], par[1])["u"] - u),
                    [200, 600])
            else:
                raise IOError

        fio, fiot, fiott, fiod, fiodd, fiodt, fir, firt, firtt, fird, firdd,\
            firdt, firdtt, nfioni, nfirni = self._eq(rho, T)

        # Tabla 7.1 pag 127
        tau = self.Tc / T
        delta = rho / self.rhoc

        self.T = unidades.Temperature(T)
        self.rho = unidades.Density(rho)
        self.v = unidades.SpecificVolume(1. / rho)
        self.P = unidades.Pressure((1 + delta * fird) * self.R.JkgK * T * rho)
        self.Z = 1 + delta * fird
        self.s = unidades.SpecificHeat(self.R.kJkgK *
                                       (tau * (fiot + firt) - fio - fir))
        self.u = unidades.Enthalpy(self.R * T * tau * (fiot + firt))
        self.h = unidades.Enthalpy(self.R * T * (1 + tau *
                                                 (fiot + firt) + delta * fird))
        self.cp = unidades.SpecificHeat(
            self.R * (-tau**2 * (fiott + firtt) +
                      (1 + delta * fird - delta * tau * firdt)**2 /
                      (1 + 2 * delta * fird + delta**2 * firdd)))
        self.cv = unidades.SpecificHeat(-self.R * tau**2 * (fiott + firtt))
        self.g = unidades.Enthalpy(self.R * T * (1 + fio + fir + delta * fird))
        self.w = unidades.Speed(
            (self.R * T *
             (1 + 2 * delta * fird + delta**2 * firdd -
              (1 + delta * fird - delta * tau * firdt)**2 / tau**2 /
              (fiott + firtt)))**0.5)

        f, FI = self.fug(rho, T, nfirni)
        Ki, xi, yi, Q = self.flash()
        self.x = unidades.Dimensionless(Q)
        self.xl = xi
        self.xv = yi
        if self.kwargs["mezcla"]:
            self.Pc = self.kwargs["mezcla"].Pc
        self.Liquido = Fluid()
        self.Gas = Fluid()
示例#7
0
                fiv = r_[yi] * r_[self.titaiv] * self.P
                fil = r_[xi] * r_[self.titail] * self.P
                # criterio de convergencia Eq 21
                if sum((fil / fiv - 1)**2) < 1e-15 and (Q - Qo)**2 < 1e-15:
                    break
                else:
                    Ki = r_[self.titail] / r_[self.titaiv]
        return Ki, xi, yi, Q

id_GERG = [i.id for i in GERG.componentes]

if __name__ == "__main__":
    #    import doctest
    #    doctest.testmod()
    T = unidades.Temperature(205, "F")
    P = unidades.Pressure(315, "psi")
    aire = GERG(T=T,
                P=P,
                componente=[0, 3, 4, 5, 7, 9],
                fraccion=[0.26, 0.09, 0.25, 0.17, 0.11, 0.12])
#    print "%0.1f %0.4f %0.3f %0.3f %0.5f %0.4f %0.2f" % (aire.T, aire.rho, aire.h.kJkg, aire.s.kJkgK, aire.cv.kJkgK, aire.cp.kJkgK, aire.w), aire.P.MPa

#    aire=GERG([0], [1.], P=0.1, T=300)
#    print "%0.1f %0.4f %0.3f %0.3f %0.5f %0.4f %0.2f" % (aire.T, aire.rho, aire.h.kJkg, aire.s.kJkgK, aire.cv.kJkgK, aire.cp.kJkgK, aire.w), aire.P.MPa

#    aire=GERG([1], [1.], P=0.1, T=300)
#    print "%0.1f %0.4f %0.3f %0.3f %0.5f %0.4f %0.2f" % (aire.T, aire.rho, aire.h.kJkg, aire.s.kJkgK, aire.cv.kJkgK, aire.cp.kJkgK, aire.w), aire.P.MPa

#    aire=GERG([15], [1.], P=0.1, T=500)
#    print "%0.1f %0.4f %0.3f %0.3f %0.5f %0.4f %0.2f" % (aire.T, aire.rho, aire.h.kJkg, aire.s.kJkgK, aire.cv.kJkgK, aire.cp.kJkgK, aire.w), aire.P.MPa