def EQ115(T, A, B, C=0, D=0, E=0): r'''DIPPR Equation #115. No major uses; has been used as an alternate liquid viscosity expression, and as a model for vapor pressure. Only parameters A and B are required. .. math:: Y = \exp\left(A + \frac{B}{T} + C\log T + D T^2 + \frac{E}{T^2}\right) Parameters ---------- T : float Temperature, [K] A-E : float Parameter for the equation; chemical and property specific [-] Returns ------- Y : float Property [constant-specific] Examples -------- No coefficients found for this expression. References ---------- .. [1] Design Institute for Physical Properties, 1996. DIPPR Project 801 DIPPR/AIChE ''' return exp(A+B/T+C*log(T)+D*T**2 + E/T**2)
def mul(self, T): r'''Computes liquid viscosity at a specified temperature of an organic compound using the Joback method as a function of chemical structure only. .. math:: \mu_{liq} = \text{MW} \exp\left( \frac{ \sum_i \mu_a - 597.82}{T} + \sum_i \mu_b - 11.202 \right) Parameters ---------- T : float Temperature, [K] Returns ------- mul : float Liquid viscosity, [Pa*s] Examples -------- >>> J = Joback('CC(=O)C') >>> J.mul(300) 0.0002940378347162687 ''' if self.calculated_mul_coeffs is None: self.calculated_mul_coeffs = Joback.mul_coeffs(self.counts) a, b = self.calculated_mul_coeffs return self.MW * exp(a / T + b)
def Edalat(T, Tc, Pc, omega): r'''Calculates vapor pressure of a fluid at arbitrary temperatures using a CSP relationship by [1]_. Requires a chemical's critical temperature, pressure, and acentric factor. Claimed to have a higher accuracy than the Lee-Kesler CSP relationship. The vapor pressure of a chemical at `T` is given by: .. math:: \ln(P^{sat}/P_c) = \frac{a\tau + b\tau^{1.5} + c\tau^3 + d\tau^6} {1-\tau} a = -6.1559 - 4.0855\omega b = 1.5737 - 1.0540\omega - 4.4365\times 10^{-3} d c = -0.8747 - 7.8874\omega d = \frac{1}{-0.4893 - 0.9912\omega + 3.1551\omega^2} \tau = 1 - \frac{T}{T_c} Parameters ---------- T : float Temperature of fluid [K] Tc : float Critical temperature of fluid [K] Pc : float Critical pressure of fluid [Pa] omega : float Acentric factor [-] Returns ------- Psat : float Vapor pressure, [Pa] Notes ----- [1]_ found an average error of 6.06% on 94 compounds and 1106 data points. Examples -------- >>> Edalat(347.2, 617.1, 36E5, 0.299) 13461.273080743307 References ---------- .. [1] Edalat, M., R. B. Bozar-Jomehri, and G. A. Mansoori. "Generalized Equation Predicts Vapor Pressure of Hydrocarbons." Oil and Gas Journal; 91:5 (February 1, 1993). ''' tau = 1. - T/Tc a = -6.1559 - 4.0855*omega c = -0.8747 - 7.8874*omega d = 1./(-0.4893 - 0.9912*omega + 3.1551*omega**2) b = 1.5737 - 1.0540*omega - 4.4365E-3*d lnPr = (a*tau + b*tau**1.5 + c*tau**3 + d*tau**6)/(1.-tau) return exp(lnPr)*Pc
def Edalat(T, Tc, Pc, omega): r'''Calculates vapor pressure of a fluid at arbitrary temperatures using a CSP relationship by [1]_. Requires a chemical's critical temperature, pressure, and acentric factor. Claimed to have a higher accuracy than the Lee-Kesler CSP relationship. The vapor pressure of a chemical at `T` is given by: .. math:: \ln(P^{sat}/P_c) = \frac{a\tau + b\tau^{1.5} + c\tau^3 + d\tau^6} {1-\tau} a = -6.1559 - 4.0855\omega b = 1.5737 - 1.0540\omega - 4.4365\times 10^{-3} d c = -0.8747 - 7.8874\omega d = \frac{1}{-0.4893 - 0.9912\omega + 3.1551\omega^2} \tau = 1 - \frac{T}{T_c} Parameters ---------- T : float Temperature of fluid [K] Tc : float Critical temperature of fluid [K] Pc : float Critical pressure of fluid [Pa] omega : float Acentric factor [-] Returns ------- Psat : float Vapor pressure, [Pa] Notes ----- [1]_ found an average error of 6.06% on 94 compounds and 1106 data points. Examples -------- >>> Edalat(347.2, 617.1, 36E5, 0.299) 13461.273080743307 References ---------- .. [1] Edalat, M., R. B. Bozar-Jomehri, and G. A. Mansoori. "Generalized Equation Predicts Vapor Pressure of Hydrocarbons." Oil and Gas Journal; 91:5 (February 1, 1993). ''' tau = 1. - T / Tc a = -6.1559 - 4.0855 * omega c = -0.8747 - 7.8874 * omega d = 1. / (-0.4893 - 0.9912 * omega + 3.1551 * omega**2) b = 1.5737 - 1.0540 * omega - 4.4365E-3 * d lnPr = (a * tau + b * tau**1.5 + c * tau**3 + d * tau**6) / (1. - tau) return exp(lnPr) * Pc
def mul(self, T): r'''Computes liquid viscosity at a specified temperature of an organic compound using the Joback method as a function of chemical structure only. .. math:: \mu_{liq} = \text{MW} \exp\left( \frac{ \sum_i \mu_a - 597.82}{T} + \sum_i \mu_b - 11.202 \right) Parameters ---------- T : float Temperature, [K] Returns ------- mul : float Liquid viscosity, [Pa*s] Examples -------- >>> J = Joback('CC(=O)C') >>> J.mul(300) 0.0002940378347162687 ''' if self.calculated_mul_coeffs is None: self.calculated_mul_coeffs = Joback.mul_coeffs(self.counts) a, b = self.calculated_mul_coeffs return self.MW*exp(a/T + b)
def EQ115(T, A, B, C=0, D=0, E=0): r'''DIPPR Equation #115. No major uses; has been used as an alternate liquid viscosity expression, and as a model for vapor pressure. Only parameters A and B are required. .. math:: Y = \exp\left(A + \frac{B}{T} + C\log T + D T^2 + \frac{E}{T^2}\right) Parameters ---------- T : float Temperature, [K] A-E : float Parameter for the equation; chemical and property specific [-] Returns ------- Y : float Property [constant-specific] Examples -------- No coefficients found for this expression. References ---------- .. [1] Design Institute for Physical Properties, 1996. DIPPR Project 801 DIPPR/AIChE ''' return exp(A + B / T + C * log(T) + D * T**2 + E / T**2)
def Laliberte_heat_capacity_i(T, w_w, a1, a2, a3, a4, a5, a6): r'''Calculate the heat capacity of a solute using the form proposed by [1]_ Parameters are needed, and a temperature, and water fraction. .. math:: Cp_i = a_1 e^\alpha + a_5(1-w_w)^{a_6} \alpha = a_2 t + a_3 \exp(0.01t) + a_4(1-w_w) Parameters ---------- T : float Temperature of fluid [K] w_w : float Weight fraction of water in the solution a1-a6 : floats Function fit parameters Returns ------- Cp_i : float Solute partial heat capacity, [J/kg/K] Notes ----- Units are Kelvin and J/kg/K. Temperature range check is TODO Examples -------- >>> d = _Laliberte_Heat_Capacity_ParametersDict['7647-14-5'] >>> Laliberte_heat_capacity_i(1.5+273.15, 1-0.00398447, d["A1"], d["A2"], d["A3"], d["A4"], d["A5"], d["A6"]) -2930.7353945880477 References ---------- .. [1] Laliberte, Marc. "A Model for Calculating the Heat Capacity of Aqueous Solutions, with Updated Density and Viscosity Data." Journal of Chemical & Engineering Data 54, no. 6 (June 11, 2009): 1725-60. doi:10.1021/je8008123 ''' t = T - 273.15 alpha = a2 * t + a3 * exp(0.01 * t) + a4 * (1 - w_w) Cp_i = a1 * exp(alpha) + a5 * (1 - w_w)**a6 Cp_i = Cp_i * 1000. return Cp_i
def Laliberte_heat_capacity_i(T, w_w, a1, a2, a3, a4, a5, a6): r'''Calculate the heat capacity of a solute using the form proposed by [1]_ Parameters are needed, and a temperature, and water fraction. .. math:: Cp_i = a_1 e^\alpha + a_5(1-w_w)^{a_6} \alpha = a_2 t + a_3 \exp(0.01t) + a_4(1-w_w) Parameters ---------- T : float Temperature of fluid [K] w_w : float Weight fraction of water in the solution a1-a6 : floats Function fit parameters Returns ------- Cp_i : float Solute partial heat capacity, [J/kg/K] Notes ----- Units are Kelvin and J/kg/K. Temperature range check is TODO Examples -------- >>> d = _Laliberte_Heat_Capacity_ParametersDict['7647-14-5'] >>> Laliberte_heat_capacity_i(1.5+273.15, 1-0.00398447, d["A1"], d["A2"], d["A3"], d["A4"], d["A5"], d["A6"]) -2930.7353945880477 References ---------- .. [1] Laliberte, Marc. "A Model for Calculating the Heat Capacity of Aqueous Solutions, with Updated Density and Viscosity Data." Journal of Chemical & Engineering Data 54, no. 6 (June 11, 2009): 1725-60. doi:10.1021/je8008123 ''' t = T - 273.15 alpha = a2*t + a3*exp(0.01*t) + a4*(1. - w_w) Cp_i = a1*exp(alpha) + a5*(1. - w_w)**a6 return Cp_i*1000.
def Lee_Kesler(T, Tc, Pc, omega): r'''Calculates vapor pressure of a fluid at arbitrary temperatures using a CSP relationship by [1]_; requires a chemical's critical temperature and acentric factor. The vapor pressure is given by: .. math:: \ln P^{sat}_r = f^{(0)} + \omega f^{(1)} f^{(0)} = 5.92714-\frac{6.09648}{T_r}-1.28862\ln T_r + 0.169347T_r^6 f^{(1)} = 15.2518-\frac{15.6875}{T_r} - 13.4721 \ln T_r + 0.43577T_r^6 Parameters ---------- T : float Temperature of fluid [K] Tc : float Critical temperature of fluid [K] Pc : float Critical pressure of fluid [Pa] omega : float Acentric factor [-] Returns ------- Psat : float Vapor pressure at T [Pa] Notes ----- This equation appears in [1]_ in expanded form. The reduced pressure form of the equation ensures predicted vapor pressure cannot surpass the critical pressure. Examples -------- Example from [2]_; ethylbenzene at 347.2 K. >>> Lee_Kesler(347.2, 617.1, 36E5, 0.299) 13078.694162949312 References ---------- .. [1] Lee, Byung Ik, and Michael G. Kesler. "A Generalized Thermodynamic Correlation Based on Three-Parameter Corresponding States." AIChE Journal 21, no. 3 (1975): 510-527. doi:10.1002/aic.690210313. .. [2] Reid, Robert C..; Prausnitz, John M.;; Poling, Bruce E. The Properties of Gases and Liquids. McGraw-Hill Companies, 1987. ''' Tr = T/Tc f0 = 5.92714 - 6.09648/Tr - 1.28862*log(Tr) + 0.169347*Tr**6 f1 = 15.2518 - 15.6875/Tr - 13.4721*log(Tr) + 0.43577*Tr**6 return exp(f0 + omega*f1)*Pc
def Lee_Kesler(T, Tc, Pc, omega): r'''Calculates vapor pressure of a fluid at arbitrary temperatures using a CSP relationship by [1]_; requires a chemical's critical temperature and acentric factor. The vapor pressure is given by: .. math:: \ln P^{sat}_r = f^{(0)} + \omega f^{(1)} f^{(0)} = 5.92714-\frac{6.09648}{T_r}-1.28862\ln T_r + 0.169347T_r^6 f^{(1)} = 15.2518-\frac{15.6875}{T_r} - 13.4721 \ln T_r + 0.43577T_r^6 Parameters ---------- T : float Temperature of fluid [K] Tc : float Critical temperature of fluid [K] Pc : float Critical pressure of fluid [Pa] omega : float Acentric factor [-] Returns ------- Psat : float Vapor pressure, [Pa] Notes ----- This equation appears in [1]_ in expanded form. It has been verified. The reduced pressure form of the equation ensures Examples -------- Example as in [2]_; Tr rounding source of tiny deviation >>> Lee_Kesler(347.2, 617.1, 36E5, 0.299) 13078.694162949312 References ---------- .. [1] Lee, Byung Ik, and Michael G. Kesler. "A Generalized Thermodynamic Correlation Based on Three-Parameter Corresponding States." AIChE Journal 21, no. 3 (1975): 510-527. doi:10.1002/aic.690210313. .. [2] Reid, Robert C..; Prausnitz, John M.;; Poling, Bruce E. The Properties of Gases and Liquids. McGraw-Hill Companies, 1987. ''' Tr = T / Tc f0 = 5.92714 - 6.09648 / Tr - 1.28862 * log(Tr) + 0.169347 * Tr**6 f1 = 15.2518 - 15.6875 / Tr - 13.4721 * log(Tr) + 0.43577 * Tr**6 P = exp(f0 + omega * f1) * Pc return P
def Wagner_original(T, Tc, Pc, a, b, c, d): r'''Calculates vapor pressure using the Wagner equation (3, 6 form). Requires critical temperature and pressure as well as four coefficients specific to each chemical. .. math:: \ln P^{sat}= \ln P_c + \frac{a\tau + b \tau^{1.5} + c\tau^3 + d\tau^6} {T_r} \tau = 1 - \frac{T}{T_c} Parameters ---------- T : float Temperature of fluid, [K] Tc : float Critical temperature, [K] Pc : float Critical pressure, [Pa] a, b, c, d : floats Parameters for wagner equation. Specific to each chemical. [-] Returns ------- Psat : float Vapor pressure at T [Pa] Notes ----- Warning: Pc is often treated as adjustable constant. Examples -------- Methane, coefficients from [2]_, at 100 K. >>> Wagner_original(100.0, 190.53, 4596420., a=-6.00435, b=1.1885, ... c=-0.834082, d=-1.22833) 34520.44601450496 References ---------- .. [1] Poling, Bruce E. The Properties of Gases and Liquids. 5th edition. New York: McGraw-Hill Professional, 2000. .. [2] McGarry, Jack. "Correlation and Prediction of the Vapor Pressures of Pure Liquids over Large Pressure Ranges." Industrial & Engineering Chemistry Process Design and Development 22, no. 2 (April 1, 1983): 313-22. doi:10.1021/i200021a023. ''' Tr = T / Tc tau = 1.0 - Tr return Pc * exp((a * tau + b * tau**1.5 + c * tau**3 + d * tau**6) / Tr)
def Wagner_original(T, Tc, Pc, a, b, c, d): r'''Calculates vapor pressure using the Wagner equation (3, 6 form). Requires critical temperature and pressure as well as four coefficients specific to each chemical. .. math:: \ln P^{sat}= \ln P_c + \frac{a\tau + b \tau^{1.5} + c\tau^3 + d\tau^6} {T_r} \tau = 1 - \frac{T}{T_c} Parameters ---------- T : float Temperature of fluid, [K] Tc : float Critical temperature, [K] Pc : float Critical pressure, [Pa] a, b, c, d : floats Parameters for wagner equation. Specific to each chemical. [-] Returns ------- Psat : float Vapor pressure at T [Pa] Notes ----- Warning: Pc is often treated as adjustable constant. Examples -------- Methane, coefficients from [2]_, at 100 K. >>> Wagner_original(100.0, 190.53, 4596420., a=-6.00435, b=1.1885, ... c=-0.834082, d=-1.22833) 34520.44601450496 References ---------- .. [1] Poling, Bruce E. The Properties of Gases and Liquids. 5th edition. New York: McGraw-Hill Professional, 2000. .. [2] McGarry, Jack. "Correlation and Prediction of the Vapor Pressures of Pure Liquids over Large Pressure Ranges." Industrial & Engineering Chemistry Process Design and Development 22, no. 2 (April 1, 1983): 313-22. doi:10.1021/i200021a023. ''' Tr = T/Tc tau = 1.0 - Tr return Pc*exp((a*tau + b*tau**1.5 + c*tau**3 + d*tau**6)/Tr)
def boiling_critical_relation(T, Tb, Tc, Pc): r'''Calculates vapor pressure of a fluid at arbitrary temperatures using a CSP relationship as in [1]_; requires a chemical's critical temperature and pressure as well as boiling point. The vapor pressure is given by: .. math:: \ln P^{sat}_r = h\left( 1 - \frac{1}{T_r}\right) h = T_{br} \frac{\ln(P_c/101325)}{1-T_{br}} Parameters ---------- T : float Temperature of fluid [K] Tb : float Boiling temperature of fluid [K] Tc : float Critical temperature of fluid [K] Pc : float Critical pressure of fluid [Pa] Returns ------- Psat : float Vapor pressure, [Pa] Notes ----- Units are Pa. Formulation makes intuitive sense; a logarithmic form of interpolation. Examples -------- Example as in [1]_ for ethylbenzene >>> boiling_critical_relation(347.2, 409.3, 617.1, 36E5) 15209.467273093938 References ---------- .. [1] Reid, Robert C..; Prausnitz, John M.;; Poling, Bruce E. The Properties of Gases and Liquids. McGraw-Hill Companies, 1987. ''' Tbr = Tb / Tc Tr = T / Tc h = Tbr * log(Pc / 101325.) / (1 - Tbr) P = exp(h * (1 - 1 / Tr)) * Pc return P
def Wagner(T, Tc, Pc, a, b, c, d): r'''Calculates vapor pressure using the Wagner equation (2.5, 5 form). Requires critical temperature and pressure as well as four coefficients specific to each chemical. .. math:: \ln P^{sat}= \ln P_c + \frac{a\tau + b \tau^{1.5} + c\tau^{2.5} + d\tau^5} {T_r} \tau = 1 - \frac{T}{T_c} Parameters ---------- T : float Temperature of fluid, [K] Tc : float Critical temperature, [K] Pc : float Critical pressure, [Pa] a, b, c, d : floats Parameters for wagner equation. Specific to each chemical. [-] Returns ------- Psat : float Vapor pressure at T [Pa] Notes ----- Warning: Pc is often treated as adjustable constant. Examples -------- Methane, coefficients from [2]_, at 100 K. >>> Wagner(100., 190.551, 4599200, -6.02242, 1.26652, -0.5707, -1.366) 34415.00476263708 References ---------- .. [1] Wagner, W. "New Vapour Pressure Measurements for Argon and Nitrogen and a New Method for Establishing Rational Vapour Pressure Equations." Cryogenics 13, no. 8 (August 1973): 470-82. doi:10.1016/0011-2275(73)90003-9 .. [2] Poling, Bruce E. The Properties of Gases and Liquids. 5th edition. New York: McGraw-Hill Professional, 2000. ''' Tr = T/Tc tau = 1.0 - T/Tc return Pc*exp((a*tau + b*tau**1.5 + c*tau**2.5 + d*tau**5)/Tr)
def Wagner(T, Tc, Pc, a, b, c, d): r'''Calculates vapor pressure using the Wagner equation (2.5, 5 form). Requires critical temperature and pressure as well as four coefficients specific to each chemical. .. math:: \ln P^{sat}= \ln P_c + \frac{a\tau + b \tau^{1.5} + c\tau^{2.5} + d\tau^5} {T_r} \tau = 1 - \frac{T}{T_c} Parameters ---------- T : float Temperature of fluid, [K] Tc : float Critical temperature, [K] Pc : float Critical pressure, [Pa] a, b, c, d : floats Parameters for wagner equation. Specific to each chemical. [-] Returns ------- Psat : float Vapor pressure at T [Pa] Notes ----- Warning: Pc is often treated as adjustable constant. Examples -------- Methane, coefficients from [2]_, at 100 K. >>> Wagner(100., 190.551, 4599200, -6.02242, 1.26652, -0.5707, -1.366) 34415.00476263708 References ---------- .. [1] Wagner, W. "New Vapour Pressure Measurements for Argon and Nitrogen and a New Method for Establishing Rational Vapour Pressure Equations." Cryogenics 13, no. 8 (August 1973): 470-82. doi:10.1016/0011-2275(73)90003-9 .. [2] Poling, Bruce E. The Properties of Gases and Liquids. 5th edition. New York: McGraw-Hill Professional, 2000. ''' Tr = T / Tc tau = 1.0 - T / Tc return Pc * exp((a * tau + b * tau**1.5 + c * tau**2.5 + d * tau**5) / Tr)
def solubility_eutectic(T, Tm, Hm, Cpl=0, Cps=0, gamma=1): r'''Returns the maximum solubility of a solute in a solvent. .. math:: \ln x_i^L \gamma_i^L = \frac{\Delta H_{m,i}}{RT}\left( 1 - \frac{T}{T_{m,i}}\right) - \frac{\Delta C_{p,i}(T_{m,i}-T)}{RT} + \frac{\Delta C_{p,i}}{R}\ln\frac{T_m}{T} \Delta C_{p,i} = C_{p,i}^L - C_{p,i}^S Parameters ---------- T : float Temperature of the system [K] Tm : float Melting temperature of the solute [K] Hm : float Heat of melting at the melting temperature of the solute [J/mol] Cpl : float, optional Molar heat capacity of the solute as a liquid [J/mol/K] Cpls: float, optional Molar heat capacity of the solute as a solid [J/mol/K] gamma : float, optional Activity coefficient of the solute as a liquid [-] Returns ------- x : float Mole fraction of solute at maximum solubility [-] Notes ----- gamma is of the solute in liquid phase Examples -------- From [1]_, matching example >>> solubility_eutectic(T=260., Tm=278.68, Hm=9952., Cpl=0, Cps=0, gamma=3.0176) 0.24340068761677464 References ---------- .. [1] Gmehling, Jurgen. Chemical Thermodynamics: For Process Simulation. Weinheim, Germany: Wiley-VCH, 2012. ''' dCp = Cpl - Cps x = exp(-Hm / R / T * (1 - T / Tm) + dCp * (Tm - T) / R / T - dCp / R * log(Tm / T)) / gamma return x
def boiling_critical_relation(T, Tb, Tc, Pc): r'''Calculates vapor pressure of a fluid at arbitrary temperatures using a CSP relationship as in [1]_; requires a chemical's critical temperature and pressure as well as boiling point. The vapor pressure is given by: .. math:: \ln P^{sat}_r = h\left( 1 - \frac{1}{T_r}\right) h = T_{br} \frac{\ln(P_c/101325)}{1-T_{br}} Parameters ---------- T : float Temperature of fluid [K] Tb : float Boiling temperature of fluid [K] Tc : float Critical temperature of fluid [K] Pc : float Critical pressure of fluid [Pa] Returns ------- Psat : float Vapor pressure at T [Pa] Notes ----- Units are Pa. Formulation makes intuitive sense; a logarithmic form of interpolation. Examples -------- Example as in [1]_ for ethylbenzene >>> boiling_critical_relation(347.2, 409.3, 617.1, 36E5) 15209.467273093938 References ---------- .. [1] Reid, Robert C..; Prausnitz, John M.;; Poling, Bruce E. The Properties of Gases and Liquids. McGraw-Hill Companies, 1987. ''' Tbr = Tb/Tc Tr = T/Tc h = Tbr*log(Pc/101325.)/(1 - Tbr) return exp(h*(1-1/Tr))*Pc
def solubility_eutectic(T, Tm, Hm, Cpl=0, Cps=0, gamma=1): r'''Returns the maximum solubility of a solute in a solvent. .. math:: \ln x_i^L \gamma_i^L = \frac{\Delta H_{m,i}}{RT}\left( 1 - \frac{T}{T_{m,i}}\right) - \frac{\Delta C_{p,i}(T_{m,i}-T)}{RT} + \frac{\Delta C_{p,i}}{R}\ln\frac{T_m}{T} \Delta C_{p,i} = C_{p,i}^L - C_{p,i}^S Parameters ---------- T : float Temperature of the system [K] Tm : float Melting temperature of the solute [K] Hm : float Heat of melting at the melting temperature of the solute [J/mol] Cpl : float, optional Molar heat capacity of the solute as a liquid [J/mol/K] Cpls: float, optional Molar heat capacity of the solute as a solid [J/mol/K] gamma : float, optional Activity coefficient of the solute as a liquid [-] Returns ------- x : float Mole fraction of solute at maximum solubility [-] Notes ----- gamma is of the solute in liquid phase Examples -------- From [1]_, matching example >>> solubility_eutectic(T=260., Tm=278.68, Hm=9952., Cpl=0, Cps=0, gamma=3.0176) 0.24340068761677464 References ---------- .. [1] Gmehling, Jurgen. Chemical Thermodynamics: For Process Simulation. Weinheim, Germany: Wiley-VCH, 2012. ''' dCp = Cpl-Cps x = exp(- Hm/R/T*(1-T/Tm) + dCp*(Tm-T)/R/T - dCp/R*log(Tm/T))/gamma return x
def Wagner(T, Tc, Pc, a, b, c, d): r'''Calculates vapor pressure using the Wagner equation 2.5, 5 form. Parameters are specific to a chemical, and form of Wagner equation. .. math:: \ln P^{sat}= \ln P_c + \frac{a\tau + b \tau^{1.5} + c\tau^{2.5} + d\tau^5} {T_r} Parameters ---------- T : float Temperature of fluid, [K] Tc : float Critical temperature, [K] Pc : float Critical pressure, [Pa] a, b, c, d : floats Parameters for wagner equation. Specific to a chemical. Trange : array_like Two temperatures, Tmin and Tmax, in which equation is appropriate. Returns ------- Psat: float Vapor pressure [Pa] Notes ----- Warning: Pc is often treated as adjustable constant. Examples -------- >>> Wagner(100., 190.551, 4599200, -6.02242, 1.26652, -0.5707, -1.366) # CH4 34415.00476263708 References ---------- .. [1] Wagner, W. "New Vapour Pressure Measurements for Argon and Nitrogen and a New Method for Establishing Rational Vapour Pressure Equations." Cryogenics 13, no. 8 (August 1973): 470-82. doi:10.1016/0011-2275(73)90003-9 ''' Tr = T / Tc tau = 1 - T / Tc return Pc * exp((a * tau + b * tau**1.5 + c * tau**2.5 + d * tau**5) / Tr)
def Laliberte_density_i(T, w_w, c0, c1, c2, c3, c4): r'''Calculate the density of a solute using the form proposed by Laliberte [1]_. Parameters are needed, and a temperature, and water fraction. Units are Kelvin and Pa*s. .. math:: \rho_{app,i} = \frac{(c_0[1-w_w]+c_1)\exp(10^{-6}[t+c_4]^2)} {(1-w_w) + c_2 + c_3 t} Parameters ---------- T : float Temperature of fluid [K] w_w : float Weight fraction of water in the solution c0-c4 : floats Function fit parameters Returns ------- rho_i : float Solute partial density, [kg/m^3] Notes ----- Temperature range check is TODO Examples -------- >>> d = _Laliberte_Density_ParametersDict['7647-14-5'] >>> Laliberte_density_i(273.15+0, 1-0.0037838838, d["C0"], d["C1"], d["C2"], d["C3"], d["C4"]) 3761.8917585699983 References ---------- .. [1] Laliberte, Marc. "A Model for Calculating the Heat Capacity of Aqueous Solutions, with Updated Density and Viscosity Data." Journal of Chemical & Engineering Data 54, no. 6 (June 11, 2009): 1725-60. doi:10.1021/je8008123 ''' t = T - 273.15 rho_i = ((c0 * (1 - w_w) + c1) * exp(1E-6 * (t + c4)**2)) / ((1 - w_w) + c2 + c3 * t) return rho_i
def Laliberte_viscosity_i(T, w_w, v1, v2, v3, v4, v5, v6): r'''Calculate the viscosity of a solute using the form proposed by [1]_ Parameters are needed, and a temperature. Units are Kelvin and Pa*s. .. math:: \mu_i = \frac{\exp\left( \frac{v_1(1-w_w)^{v_2}+v_3}{v_4 t +1}\right)} {v_5(1-w_w)^{v_6}+1} Parameters ---------- T : float Temperature of fluid [K] w_w : float Weight fraction of water in the solution v1-v6 : floats Function fit parameters Returns ------- mu_i : float Solute partial viscosity, Pa*s Notes ----- Temperature range check is outside of this function. Check is performed using NaCl at 5 degC from the first value in [1]_'s spreadsheet. Examples -------- >>> d = _Laliberte_Viscosity_ParametersDict['7647-14-5'] >>> Laliberte_viscosity_i(273.15+5, 1-0.005810, d["V1"], d["V2"], d["V3"], d["V4"], d["V5"], d["V6"] ) 0.004254025533308794 References ---------- .. [1] Laliberte, Marc. "A Model for Calculating the Heat Capacity of Aqueous Solutions, with Updated Density and Viscosity Data." Journal of Chemical & Engineering Data 54, no. 6 (June 11, 2009): 1725-60. doi:10.1021/je8008123 ''' t = T - 273.15 mu_i = exp( (v1 * (1 - w_w)**v2 + v3) / (v4 * t + 1)) / (v5 * (1 - w_w)**v6 + 1) mu_i = mu_i / 1000. return mu_i
def Laliberte_viscosity_i(T, w_w, v1, v2, v3, v4, v5, v6): r'''Calculate the viscosity of a solute using the form proposed by [1]_ Parameters are needed, and a temperature. Units are Kelvin and Pa*s. .. math:: \mu_i = \frac{\exp\left( \frac{v_1(1-w_w)^{v_2}+v_3}{v_4 t +1}\right)} {v_5(1-w_w)^{v_6}+1} Parameters ---------- T : float Temperature of fluid [K] w_w : float Weight fraction of water in the solution v1-v6 : floats Function fit parameters Returns ------- mu_i : float Solute partial viscosity, Pa*s Notes ----- Temperature range check is outside of this function. Check is performed using NaCl at 5 degC from the first value in [1]_'s spreadsheet. Examples -------- >>> d = _Laliberte_Viscosity_ParametersDict['7647-14-5'] >>> Laliberte_viscosity_i(273.15+5, 1-0.005810, d["V1"], d["V2"], d["V3"], d["V4"], d["V5"], d["V6"] ) 0.004254025533308794 References ---------- .. [1] Laliberte, Marc. "A Model for Calculating the Heat Capacity of Aqueous Solutions, with Updated Density and Viscosity Data." Journal of Chemical & Engineering Data 54, no. 6 (June 11, 2009): 1725-60. doi:10.1021/je8008123 ''' t = T-273.15 mu_i = exp((v1*(1-w_w)**v2 + v3)/(v4*t+1))/(v5*(1-w_w)**v6 + 1) return mu_i/1000.
def Laliberte_density_i(T, w_w, c0, c1, c2, c3, c4): r'''Calculate the density of a solute using the form proposed by Laliberte [1]_. Parameters are needed, and a temperature, and water fraction. Units are Kelvin and Pa*s. .. math:: \rho_{app,i} = \frac{(c_0[1-w_w]+c_1)\exp(10^{-6}[t+c_4]^2)} {(1-w_w) + c_2 + c_3 t} Parameters ---------- T : float Temperature of fluid [K] w_w : float Weight fraction of water in the solution c0-c4 : floats Function fit parameters Returns ------- rho_i : float Solute partial density, [kg/m^3] Notes ----- Temperature range check is TODO Examples -------- >>> d = _Laliberte_Density_ParametersDict['7647-14-5'] >>> Laliberte_density_i(273.15+0, 1-0.0037838838, d["C0"], d["C1"], d["C2"], d["C3"], d["C4"]) 3761.8917585699983 References ---------- .. [1] Laliberte, Marc. "A Model for Calculating the Heat Capacity of Aqueous Solutions, with Updated Density and Viscosity Data." Journal of Chemical & Engineering Data 54, no. 6 (June 11, 2009): 1725-60. doi:10.1021/je8008123 ''' t = T - 273.15 return ((c0*(1 - w_w)+c1)*exp(1E-6*(t + c4)**2))/((1 - w_w) + c2 + c3*t)
def EQ101(T, A, B, C, D, E): r'''DIPPR Equation # 101. Used in calculating vapor pressure, sublimation pressure, and liquid viscosity. All 5 parameters are required. E is often an integer. As the model is exponential, a sufficiently high temperature will cause an OverflowError. A negative temperature (or just low, if fit poorly) may cause a math domain error. .. math:: Y = \exp\left(A + \frac{B}{T} + C\cdot \ln T + D \cdot T^E\right) Parameters ---------- T : float Temperature, [K] A-E : float Parameter for the equation; chemical and property specific [-] Returns ------- Y : float Property [constant-specific] Notes ----- This function is not integrable for either dT or Y/T dT. Examples -------- Water vapor pressure; DIPPR coefficients normally listed in Pa. >>> EQ101(300, 73.649, -7258.2, -7.3037, 4.1653E-6, 2) 3537.44834545549 References ---------- .. [1] Design Institute for Physical Properties, 1996. DIPPR Project 801 DIPPR/AIChE ''' return exp(A + B/T + C*log(T) + D*T**E)
def EQ101(T, A, B, C, D, E): r'''DIPPR Equation # 101. Used in calculating vapor pressure, sublimation pressure, and liquid viscosity. All 5 parameters are required. E is often an integer. As the model is exponential, a sufficiently high temperature will cause an OverflowError. A negative temperature (or just low, if fit poorly) may cause a math domain error. .. math:: Y = \exp\left(A + \frac{B}{T} + C\cdot \ln T + D \cdot T^E\right) Parameters ---------- T : float Temperature, [K] A-E : float Parameter for the equation; chemical and property specific [-] Returns ------- Y : float Property [constant-specific] Notes ----- This function is not integrable for either dT or Y/T dT. Examples -------- Water vapor pressure; DIPPR coefficients normally listed in Pa. >>> EQ101(300, 73.649, -7258.2, -7.3037, 4.1653E-6, 2) 3537.44834545549 References ---------- .. [1] Design Institute for Physical Properties, 1996. DIPPR Project 801 DIPPR/AIChE ''' return exp(A + B / T + C * log(T) + D * T**E)
def Wagner_original(T, Tc, Pc, a, b, c, d): r'''Calculates vapor pressure using the original Wagner equation 3,6 form. Parameters are specific to a chemical, and form of Wagner equation. .. math:: \ln P^{sat}= \ln P_c + \frac{a\tau + b \tau^{1.5} + c\tau^3 + d\tau^6} {T_r} Parameters ---------- T : float Temperature of fluid, [K] Tc : float Critical temperature, [K] Pc : float Critical pressure, [Pa] a, b, c, d : floats Parameters for wagner equation. Specific to a chemical. Returns ------- Psat: float Vapor pressure [Pa] Notes ----- Warning: Pc is often treated as adjustable constant. Examples -------- >>> Wagner_original(100.0, 190.53, 4596420., -6.00435, 1.1885, -0.834082, -1.22833) # CH4 34520.44601450496 ''' Tr = T / Tc tau = 1.0 - Tr Psat = Pc * exp((a * tau + b * tau**1.5 + c * tau**3 + d * tau**6) / Tr) return Psat
def EQ127(T, A, B, C, D, E, F, G): r'''DIPPR Equation #127. Rarely used, and then only in calculating ideal-gas heat capacity. All 7 parameters are required. .. math:: Y = A+B\left[\frac{\left(\frac{C}{T}\right)^2\exp\left(\frac{C}{T} \right)}{\left(\exp\frac{C}{T}-1 \right)^2}\right] +D\left[\frac{\left(\frac{E}{T}\right)^2\exp\left(\frac{E}{T}\right)} {\left(\exp\frac{E}{T}-1 \right)^2}\right] +F\left[\frac{\left(\frac{G}{T}\right)^2\exp\left(\frac{G}{T}\right)} {\left(\exp\frac{G}{T}-1 \right)^2}\right] Parameters ---------- T : float Temperature, [K] A-G : float Parameter for the equation; chemical and property specific [-] Returns ------- Y : float Property [constant-specific] Examples -------- Ideal gas heat capacity of methanol; DIPPR coefficients normally in J/kmol/K >>> EQ127(20., 3.3258E4, 3.6199E4, 1.2057E3, 1.5373E7, 3.2122E3, -1.5318E7, 3.2122E3) 33258.0 References ---------- .. [1] Design Institute for Physical Properties, 1996. DIPPR Project 801 DIPPR/AIChE ''' return A+B*((C/T)**2*exp(C/T)/(exp(C/T) - 1)**2) + \ D*((E/T)**2*exp(E/T)/(exp(E/T)-1)**2) + \ F*((G/T)**2*exp(G/T)/(exp(G/T)-1)**2)
def collision_integral_Neufeld_Janzen_Aziz(Tstar, l=1, s=1): r'''Calculates Lennard-Jones collision integral for any of 16 values of (l,j) for the wide range of 0.3 < Tstar < 100. Values are accurate to 0.1 % of actual values, but the calculation of actual values is computationally intensive and so these simplifications are used, developed in [1]_. .. math:: \Omega_D = \frac{A}{T^{*B}} + \frac{C}{\exp(DT^*)} + \frac{E}{\exp(FT^{*})} + \frac{G}{\exp(HT^*)} + RT^{*B}\sin(ST^{*W}-P) Parameters ---------- Tstar : float Reduced temperature of the fluid [-] l : int term s : int term Returns ------- Omega : float Collision integral of A and B Notes ----- Acceptable pairs of (l,s) are (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (3, 3), (3, 4), (3, 5), and (4, 4). .. math:: T^* = \frac{k_b T}{\epsilon} Results are very similar to those of the more modern formulation, `collision_integral_Kim_Monroe`. Calculations begin to yield overflow errors in some values of (l, 2) after Tstar = 75, beginning with (1, 7). Also susceptible are (1, 5) and (1, 6). Examples -------- >>> collision_integral_Neufeld_Janzen_Aziz(100, 1, 1) 0.516717697672334 References ---------- .. [1] Neufeld, Philip D., A. R. Janzen, and R. A. Aziz. "Empirical Equations to Calculate 16 of the Transport Collision Integrals Omega(l, S)* for the Lennard-Jones (12-6) Potential." The Journal of Chemical Physics 57, no. 3 (August 1, 1972): 1100-1102. doi:10.1063/1.1678363 ''' if (l, s) not in Neufeld_collision: raise Exception('Input values of l and s are not supported') A, B, C, D, E, F, G, H, R, S, W, P = Neufeld_collision[(l, s)] omega = A/Tstar**B + C/exp(D*Tstar) + E/exp(F*Tstar) if (l, s) in [(1, 1), (1, 2), (3, 3)]: omega += G/exp(H*Tstar) if (l, s) not in [(1, 1), (1, 2)]: omega += R*Tstar**B*sin(S*Tstar**W-P) return omega
def EQ127(T, A, B, C, D, E, F, G, order=0): r'''DIPPR Equation #127. Rarely used, and then only in calculating ideal-gas heat capacity. All 7 parameters are required. .. math:: Y = A+B\left[\frac{\left(\frac{C}{T}\right)^2\exp\left(\frac{C}{T} \right)}{\left(\exp\frac{C}{T}-1 \right)^2}\right] +D\left[\frac{\left(\frac{E}{T}\right)^2\exp\left(\frac{E}{T}\right)} {\left(\exp\frac{E}{T}-1 \right)^2}\right] +F\left[\frac{\left(\frac{G}{T}\right)^2\exp\left(\frac{G}{T}\right)} {\left(\exp\frac{G}{T}-1 \right)^2}\right] Parameters ---------- T : float Temperature, [K] A-G : float Parameter for the equation; chemical and property specific [-] order : int, optional Order of the calculation. 0 for the calculation of the result itself; for 1, the first derivative of the property is returned, for -1, the indefinite integral of the property with respect to temperature is returned; and for -1j, the indefinite integral of the property divided by temperature with respect to temperature is returned. No other integrals or derivatives are implemented, and an exception will be raised if any other order is given. Returns ------- Y : float Property [constant-specific; if order == 1, property/K; if order == -1, property*K; if order == -1j, unchanged from default] Notes ----- The derivative with respect to T, integral with respect to T, and integral over T with respect to T are computed as follows. All expressions can be obtained with SymPy readily. .. math:: \frac{d Y}{dT} = - \frac{B C^{3} e^{\frac{C}{T}}}{T^{4} \left(e^{\frac{C}{T}} - 1\right)^{2}} + \frac{2 B C^{3} e^{\frac{2 C}{T}}}{T^{4} \left(e^{\frac{C}{T}} - 1\right)^{3}} - \frac{2 B C^{2} e^{\frac{C}{T}}}{T^{3} \left(e^{\frac{C}{T}} - 1\right)^{2}} - \frac{D E^{3} e^{\frac{E}{T}}}{T^{4} \left(e^{\frac{E}{T}} - 1\right)^{2}} + \frac{2 D E^{3} e^{\frac{2 E}{T}}}{T^{4} \left(e^{\frac{E}{T}} - 1\right)^{3}} - \frac{2 D E^{2} e^{\frac{E}{T}}}{T^{3} \left(e^{\frac{E}{T}} - 1\right)^{2}} - \frac{F G^{3} e^{\frac{G}{T}}}{T^{4} \left(e^{\frac{G}{T}} - 1\right)^{2}} + \frac{2 F G^{3} e^{\frac{2 G}{T}}}{T^{4} \left(e^{\frac{G}{T}} - 1\right)^{3}} - \frac{2 F G^{2} e^{\frac{G}{T}}}{T^{3} \left(e^{\frac{G}{T}} - 1\right)^{2}} .. math:: \int Y dT = A T + \frac{B C^{2}}{C e^{\frac{C}{T}} - C} + \frac{D E^{2}}{E e^{\frac{E}{T}} - E} + \frac{F G^{2}}{G e^{\frac{G}{T}} - G} .. math:: \int \frac{Y}{T} dT = A \log{\left (T \right )} + B C^{2} \left( \frac{1}{C T e^{\frac{C}{T}} - C T} + \frac{1}{C T} - \frac{1}{C^{2}} \log{\left (e^{\frac{C}{T}} - 1 \right )}\right) + D E^{2} \left( \frac{1}{E T e^{\frac{E}{T}} - E T} + \frac{1}{E T} - \frac{1}{E^{2}} \log{\left (e^{\frac{E}{T}} - 1 \right )}\right) + F G^{2} \left( \frac{1}{G T e^{\frac{G}{T}} - G T} + \frac{1}{G T} - \frac{1}{G^{2}} \log{\left (e^{\frac{G}{T}} - 1 \right )}\right) Examples -------- Ideal gas heat capacity of methanol; DIPPR coefficients normally in J/kmol/K >>> EQ127(20., 3.3258E4, 3.6199E4, 1.2057E3, 1.5373E7, 3.2122E3, -1.5318E7, 3.2122E3) 33258.0 References ---------- .. [1] Design Institute for Physical Properties, 1996. DIPPR Project 801 DIPPR/AIChE ''' if order == 0: return (A+B*((C/T)**2*exp(C/T)/(exp(C/T) - 1)**2) + D*((E/T)**2*exp(E/T)/(exp(E/T)-1)**2) + F*((G/T)**2*exp(G/T)/(exp(G/T)-1)**2)) elif order == 1: return (-B*C**3*exp(C/T)/(T**4*(exp(C/T) - 1)**2) + 2*B*C**3*exp(2*C/T)/(T**4*(exp(C/T) - 1)**3) - 2*B*C**2*exp(C/T)/(T**3*(exp(C/T) - 1)**2) - D*E**3*exp(E/T)/(T**4*(exp(E/T) - 1)**2) + 2*D*E**3*exp(2*E/T)/(T**4*(exp(E/T) - 1)**3) - 2*D*E**2*exp(E/T)/(T**3*(exp(E/T) - 1)**2) - F*G**3*exp(G/T)/(T**4*(exp(G/T) - 1)**2) + 2*F*G**3*exp(2*G/T)/(T**4*(exp(G/T) - 1)**3) - 2*F*G**2*exp(G/T)/(T**3*(exp(G/T) - 1)**2)) elif order == -1: return (A*T + B*C**2/(C*exp(C/T) - C) + D*E**2/(E*exp(E/T) - E) + F*G**2/(G*exp(G/T) - G)) elif order == -1j: return (A*log(T) + B*C**2*(1/(C*T*exp(C/T) - C*T) + 1/(C*T) - log(exp(C/T) - 1)/C**2) + D*E**2*(1/(E*T*exp(E/T) - E*T) + 1/(E*T) - log(exp(E/T) - 1)/E**2) + F*G**2*(1/(G*T*exp(G/T) - G*T) + 1/(G*T) - log(exp(G/T) - 1)/G**2)) else: raise Exception(order_not_found_msg)
def Ambrose_Walton(T, Tc, Pc, omega): r'''Calculates vapor pressure of a fluid at arbitrary temperatures using a CSP relationship by [1]_; requires a chemical's critical temperature and acentric factor. The vapor pressure is given by: .. math:: \ln P_r=f^{(0)}+\omega f^{(1)}+\omega^2f^{(2)} f^{(0)}=\frac{-5.97616\tau + 1.29874\tau^{1.5}- 0.60394\tau^{2.5} -1.06841\tau^5}{T_r} f^{(1)}=\frac{-5.03365\tau + 1.11505\tau^{1.5}- 5.41217\tau^{2.5} -7.46628\tau^5}{T_r} f^{(2)}=\frac{-0.64771\tau + 2.41539\tau^{1.5}- 4.26979\tau^{2.5} +3.25259\tau^5}{T_r} \tau = 1-T_{r} Parameters ---------- T : float Temperature of fluid [K] Tc : float Critical temperature of fluid [K] Pc : float Critical pressure of fluid [Pa] omega : float Acentric factor [-] Returns ------- Psat : float Vapor pressure at T [Pa] Notes ----- Somewhat more accurate than the :obj:`Lee_Kesler` formulation. Examples -------- Example from [2]_; ethylbenzene at 347.25 K. >>> Ambrose_Walton(347.25, 617.15, 36.09E5, 0.304) 13278.878504306222 References ---------- .. [1] Ambrose, D., and J. Walton. "Vapour Pressures up to Their Critical Temperatures of Normal Alkanes and 1-Alkanols." Pure and Applied Chemistry 61, no. 8 (1989): 1395-1403. doi:10.1351/pac198961081395. .. [2] Poling, Bruce E. The Properties of Gases and Liquids. 5th edition. New York: McGraw-Hill Professional, 2000. ''' Tr = T/Tc tau = 1 - T/Tc f0 = (-5.97616*tau + 1.29874*tau**1.5 - 0.60394*tau**2.5 - 1.06841*tau**5)/Tr f1 = (-5.03365*tau + 1.11505*tau**1.5 - 5.41217*tau**2.5 - 7.46628*tau**5)/Tr f2 = (-0.64771*tau + 2.41539*tau**1.5 - 4.26979*tau**2.5 + 3.25259*tau**5)/Tr return Pc*exp(f0 + omega*f1 + omega**2*f2)
def Sanjari(T, Tc, Pc, omega): r'''Calculates vapor pressure of a fluid at arbitrary temperatures using a CSP relationship by [1]_. Requires a chemical's critical temperature, pressure, and acentric factor. Although developed for refrigerants, this model should have some general predictive ability. The vapor pressure of a chemical at `T` is given by: .. math:: P^{sat} = P_c\exp(f^{(0)} + \omega f^{(1)} + \omega^2 f^{(2)}) f^{(0)} = a_1 + \frac{a_2}{T_r} + a_3\ln T_r + a_4 T_r^{1.9} f^{(1)} = a_5 + \frac{a_6}{T_r} + a_7\ln T_r + a_8 T_r^{1.9} f^{(2)} = a_9 + \frac{a_{10}}{T_r} + a_{11}\ln T_r + a_{12} T_r^{1.9} Parameters ---------- T : float Temperature of fluid [K] Tc : float Critical temperature of fluid [K] Pc : float Critical pressure of fluid [Pa] omega : float Acentric factor [-] Returns ------- Psat : float Vapor pressure, [Pa] Notes ----- a[1-12] are as follows: 6.83377, -5.76051, 0.90654, -1.16906, 5.32034, -28.1460, -58.0352, 23.57466, 18.19967, 16.33839, 65.6995, -35.9739. For a claimed fluid not included in the regression, R128, the claimed AARD was 0.428%. A re-calculation using 200 data points from 125.45 K to 343.90225 K evenly spaced by 1.09775 K as generated by NIST Webbook April 2016 produced an AARD of 0.644%. It is likely that the author's regression used more precision in its coefficients than was shown here. Nevertheless, the function is reproduced as shown in [1]_. For Tc=808 K, Pc=1100000 Pa, omega=1.1571, this function actually declines after 770 K. Examples -------- >>> Sanjari(347.2, 617.1, 36E5, 0.299) 13651.916109552498 References ---------- .. [1] Sanjari, Ehsan, Mehrdad Honarmand, Hamidreza Badihi, and Ali Ghaheri. "An Accurate Generalized Model for Predict Vapor Pressure of Refrigerants." International Journal of Refrigeration 36, no. 4 (June 2013): 1327-32. doi:10.1016/j.ijrefrig.2013.01.007. ''' Tr = T/Tc f0 = 6.83377 + -5.76051/Tr + 0.90654*log(Tr) + -1.16906*Tr**1.9 f1 = 5.32034 + -28.1460/Tr + -58.0352*log(Tr) + 23.57466*Tr**1.9 f2 = 18.19967 + 16.33839/Tr + 65.6995*log(Tr) + -35.9739*Tr**1.9 return Pc*exp(f0 + omega*f1 + omega**2*f2)
def Kweq_IAPWS(T, rho_w): r'''Calculates equilibrium constant for OH- and H+ in water, according to [1]_. This is the most recent formulation available. .. math:: Q = \rho \exp(\alpha_0 + \alpha_1 T^{-1} + \alpha_2 T^{-2} \rho^{2/3}) - \log_{10} K_w = -2n \left[ \log_{10}(1+Q) - \frac{Q}{Q+1} \rho (\beta_0 + \beta_1 T^{-1} + \beta_2 \rho) \right] -\log_{10} K_w^G + 2 \log_{10} \frac{18.015268}{1000} Parameters ---------- T : float Temperature of water [K] rho_w : float Density of water at temperature and pressure [kg/m^3] Returns ------- Kweq : float Ionization constant of water, [-] Notes ----- Formulation is in terms of density in g/cm^3; density is converted internally. n = 6; alpha0 = -0.864671; alpha1 = 8659.19; alpha2 = -22786.2; beta0 = 0.642044; beta1 = -56.8534; beta2 = -0.375754 Examples -------- Example from IAPWS check: >>> -1*log10(Kweq_IAPWS(600, 700)) 11.203153057603775 References ---------- .. [1] Bandura, Andrei V., and Serguei N. Lvov. "The Ionization Constant of Water over Wide Ranges of Temperature and Density." Journal of Physical and Chemical Reference Data 35, no. 1 (March 1, 2006): 15-30. doi:10.1063/1.1928231 ''' K_w_G = Kweq_IAPWS_gas(T) rho_w = rho_w / 1000. n = 6 alpha0 = -0.864671 alpha1 = 8659.19 alpha2 = -22786.2 beta0 = 0.642044 beta1 = -56.8534 beta2 = -0.375754 Q = rho_w * exp(alpha0 + alpha1 / T + alpha2 / T**2 * rho_w**(2 / 3.)) K_w = 10**(-1 * (-2 * n * (log10(1 + Q) - Q / (Q + 1) * rho_w * (beta0 + beta1 / T + beta2 * rho_w)) - log10(K_w_G) + 2 * log10(18.015268 / 1000))) return K_w
def Kweq_IAPWS(T, rho_w): r'''Calculates equilibrium constant for OH- and H+ in water, according to [1]_. This is the most recent formulation available. .. math:: Q = \rho \exp(\alpha_0 + \alpha_1 T^{-1} + \alpha_2 T^{-2} \rho^{2/3}) - \log_{10} K_w = -2n \left[ \log_{10}(1+Q) - \frac{Q}{Q+1} \rho (\beta_0 + \beta_1 T^{-1} + \beta_2 \rho) \right] -\log_{10} K_w^G + 2 \log_{10} \frac{18.015268}{1000} Parameters ---------- T : float Temperature of water [K] rho_w : float Density of water at temperature and pressure [kg/m^3] Returns ------- Kweq : float Ionization constant of water, [-] Notes ----- Formulation is in terms of density in g/cm^3; density is converted internally. n = 6; alpha0 = -0.864671; alpha1 = 8659.19; alpha2 = -22786.2; beta0 = 0.642044; beta1 = -56.8534; beta2 = -0.375754 Examples -------- Example from IAPWS check: >>> -1*log10(Kweq_IAPWS(600, 700)) 11.203153057603775 References ---------- .. [1] Bandura, Andrei V., and Serguei N. Lvov. "The Ionization Constant of Water over Wide Ranges of Temperature and Density." Journal of Physical and Chemical Reference Data 35, no. 1 (March 1, 2006): 15-30. doi:10.1063/1.1928231 ''' K_w_G = Kweq_IAPWS_gas(T) rho_w = rho_w/1000. n = 6 alpha0 = -0.864671 alpha1 = 8659.19 alpha2 = -22786.2 beta0 = 0.642044 beta1 = -56.8534 beta2 = -0.375754 Q = rho_w*exp(alpha0 + alpha1/T + alpha2/T**2*rho_w**(2/3.)) K_w = 10**(-1*(-2*n*(log10(1+Q)-Q/(Q+1) * rho_w *(beta0 + beta1/T + beta2*rho_w)) - log10(K_w_G) + 2*log10(18.015268/1000) )) return K_w
def EQ127(T, A, B, C, D, E, F, G, order=0): r'''DIPPR Equation #127. Rarely used, and then only in calculating ideal-gas heat capacity. All 7 parameters are required. .. math:: Y = A+B\left[\frac{\left(\frac{C}{T}\right)^2\exp\left(\frac{C}{T} \right)}{\left(\exp\frac{C}{T}-1 \right)^2}\right] +D\left[\frac{\left(\frac{E}{T}\right)^2\exp\left(\frac{E}{T}\right)} {\left(\exp\frac{E}{T}-1 \right)^2}\right] +F\left[\frac{\left(\frac{G}{T}\right)^2\exp\left(\frac{G}{T}\right)} {\left(\exp\frac{G}{T}-1 \right)^2}\right] Parameters ---------- T : float Temperature, [K] A-G : float Parameter for the equation; chemical and property specific [-] order : int, optional Order of the calculation. 0 for the calculation of the result itself; for 1, the first derivative of the property is returned, for -1, the indefinite integral of the property with respect to temperature is returned; and for -1j, the indefinite integral of the property divided by temperature with respect to temperature is returned. No other integrals or derivatives are implemented, and an exception will be raised if any other order is given. Returns ------- Y : float Property [constant-specific; if order == 1, property/K; if order == -1, property*K; if order == -1j, unchanged from default] Notes ----- The derivative with respect to T, integral with respect to T, and integral over T with respect to T are computed as follows. All expressions can be obtained with SymPy readily. .. math:: \frac{d Y}{dT} = - \frac{B C^{3} e^{\frac{C}{T}}}{T^{4} \left(e^{\frac{C}{T}} - 1\right)^{2}} + \frac{2 B C^{3} e^{\frac{2 C}{T}}}{T^{4} \left(e^{\frac{C}{T}} - 1\right)^{3}} - \frac{2 B C^{2} e^{\frac{C}{T}}}{T^{3} \left(e^{\frac{C}{T}} - 1\right)^{2}} - \frac{D E^{3} e^{\frac{E}{T}}}{T^{4} \left(e^{\frac{E}{T}} - 1\right)^{2}} + \frac{2 D E^{3} e^{\frac{2 E}{T}}}{T^{4} \left(e^{\frac{E}{T}} - 1\right)^{3}} - \frac{2 D E^{2} e^{\frac{E}{T}}}{T^{3} \left(e^{\frac{E}{T}} - 1\right)^{2}} - \frac{F G^{3} e^{\frac{G}{T}}}{T^{4} \left(e^{\frac{G}{T}} - 1\right)^{2}} + \frac{2 F G^{3} e^{\frac{2 G}{T}}}{T^{4} \left(e^{\frac{G}{T}} - 1\right)^{3}} - \frac{2 F G^{2} e^{\frac{G}{T}}}{T^{3} \left(e^{\frac{G}{T}} - 1\right)^{2}} .. math:: \int Y dT = A T + \frac{B C^{2}}{C e^{\frac{C}{T}} - C} + \frac{D E^{2}}{E e^{\frac{E}{T}} - E} + \frac{F G^{2}}{G e^{\frac{G}{T}} - G} .. math:: \int \frac{Y}{T} dT = A \log{\left (T \right )} + B C^{2} \left( \frac{1}{C T e^{\frac{C}{T}} - C T} + \frac{1}{C T} - \frac{1}{C^{2}} \log{\left (e^{\frac{C}{T}} - 1 \right )}\right) + D E^{2} \left( \frac{1}{E T e^{\frac{E}{T}} - E T} + \frac{1}{E T} - \frac{1}{E^{2}} \log{\left (e^{\frac{E}{T}} - 1 \right )}\right) + F G^{2} \left( \frac{1}{G T e^{\frac{G}{T}} - G T} + \frac{1}{G T} - \frac{1}{G^{2}} \log{\left (e^{\frac{G}{T}} - 1 \right )}\right) Examples -------- Ideal gas heat capacity of methanol; DIPPR coefficients normally in J/kmol/K >>> EQ127(20., 3.3258E4, 3.6199E4, 1.2057E3, 1.5373E7, 3.2122E3, -1.5318E7, 3.2122E3) 33258.0 References ---------- .. [1] Design Institute for Physical Properties, 1996. DIPPR Project 801 DIPPR/AIChE ''' if order == 0: return (A + B * ((C / T)**2 * exp(C / T) / (exp(C / T) - 1)**2) + D * ((E / T)**2 * exp(E / T) / (exp(E / T) - 1)**2) + F * ((G / T)**2 * exp(G / T) / (exp(G / T) - 1)**2)) elif order == 1: return (-B * C**3 * exp(C / T) / (T**4 * (exp(C / T) - 1)**2) + 2 * B * C**3 * exp(2 * C / T) / (T**4 * (exp(C / T) - 1)**3) - 2 * B * C**2 * exp(C / T) / (T**3 * (exp(C / T) - 1)**2) - D * E**3 * exp(E / T) / (T**4 * (exp(E / T) - 1)**2) + 2 * D * E**3 * exp(2 * E / T) / (T**4 * (exp(E / T) - 1)**3) - 2 * D * E**2 * exp(E / T) / (T**3 * (exp(E / T) - 1)**2) - F * G**3 * exp(G / T) / (T**4 * (exp(G / T) - 1)**2) + 2 * F * G**3 * exp(2 * G / T) / (T**4 * (exp(G / T) - 1)**3) - 2 * F * G**2 * exp(G / T) / (T**3 * (exp(G / T) - 1)**2)) elif order == -1: return (A * T + B * C**2 / (C * exp(C / T) - C) + D * E**2 / (E * exp(E / T) - E) + F * G**2 / (G * exp(G / T) - G)) elif order == -1j: return (A * log(T) + B * C**2 * (1 / (C * T * exp(C / T) - C * T) + 1 / (C * T) - log(exp(C / T) - 1) / C**2) + D * E**2 * (1 / (E * T * exp(E / T) - E * T) + 1 / (E * T) - log(exp(E / T) - 1) / E**2) + F * G**2 * (1 / (G * T * exp(G / T) - G * T) + 1 / (G * T) - log(exp(G / T) - 1) / G**2)) else: raise Exception(order_not_found_msg)
def Wilson(xs, params): r'''Calculates the activity coefficients of each species in a mixture using the Wilson method, given their mole fractions, and dimensionless interaction parameters. Those are normally correlated with temperature, and need to be calculated separately. .. math:: \ln \gamma_i = 1 - \ln \left(\sum_j^N \Lambda_{ij} x_j\right) -\sum_j^N \frac{\Lambda_{ji}x_j}{\displaystyle\sum_k^N \Lambda_{jk}x_k} Parameters ---------- xs : list[float] Liquid mole fractions of each species, [-] params : list[list[float]] Dimensionless interaction parameters of each compound with each other, [-] Returns ------- gammas : list[float] Activity coefficient for each species in the liquid mixture, [-] Notes ----- This model needs N^2 parameters. The original model correlated the interaction parameters using the standard pure-component molar volumes of each species at 25°C, in the following form: .. math:: \Lambda_{ij} = \frac{V_j}{V_i} \exp\left(\frac{-\lambda_{i,j}}{RT}\right) However, that form has less flexibility and offered no advantage over using only regressed parameters. Most correlations for the interaction parameters include some of the terms shown in the following form: .. math:: \ln \Lambda_{ij} =a_{ij}+\frac{b_{ij}}{T}+c_{ij}\ln T + d_{ij}T + \frac{e_{ij}}{T^2} + h_{ij}{T^2} The Wilson model is not applicable to liquid-liquid systems. Examples -------- Ethanol-water example, at 343.15 K and 1 MPa: >>> Wilson([0.252, 0.748], [[1, 0.154], [0.888, 1]]) [1.8814926087178843, 1.1655774931125487] References ---------- .. [1] Wilson, Grant M. "Vapor-Liquid Equilibrium. XI. A New Expression for the Excess Free Energy of Mixing." Journal of the American Chemical Society 86, no. 2 (January 1, 1964): 127-130. doi:10.1021/ja01056a002. .. [2] Gmehling, Jurgen, Barbel Kolbe, Michael Kleiber, and Jurgen Rarey. Chemical Thermodynamics for Process Simulation. 1st edition. Weinheim: Wiley-VCH, 2012. ''' gammas = [] cmps = range(len(xs)) for i in cmps: tot1 = log(sum([params[i][j]*xs[j] for j in cmps])) tot2 = 0. for j in cmps: tot2 += params[j][i]*xs[j]/sum([params[j][k]*xs[k] for k in cmps]) gamma = exp(1. - tot1 - tot2) gammas.append(gamma) return gammas
def Poyntings(self, T, P, Psats): Vmls = [VolumeLiquid(T=T, P=P) for VolumeLiquid in self.VolumeLiquids] return [ exp(Vml * (P - Psat) / (R * T)) for Psat, Vml in zip(Psats, Vmls) ]
def collision_integral_Neufeld_Janzen_Aziz(Tstar, l=1, s=1): r'''Calculates Lennard-Jones collision integral for any of 16 values of (l,j) for the wide range of 0.3 < Tstar < 100. Values are accurate to 0.1 % of actual values, but the calculation of actual values is computationally intensive and so these simplifications are used, developed in [1]_. .. math:: \Omega_D = \frac{A}{T^{*B}} + \frac{C}{\exp(DT^*)} + \frac{E}{\exp(FT^{*})} + \frac{G}{\exp(HT^*)} + RT^{*B}\sin(ST^{*W}-P) Parameters ---------- Tstar : float Reduced temperature of the fluid [-] l : int term s : int term Returns ------- Omega : float Collision integral of A and B Notes ----- Acceptable pairs of (l,s) are (1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (3, 3), (3, 4), (3, 5), and (4, 4). .. math:: T^* = \frac{k_b T}{\epsilon} Results are very similar to those of the more modern formulation, `collision_integral_Kim_Monroe`. Calculations begin to yield overflow errors in some values of (l, 2) after Tstar = 75, beginning with (1, 7). Also susceptible are (1, 5) and (1, 6). Examples -------- >>> collision_integral_Neufeld_Janzen_Aziz(100, 1, 1) 0.516717697672334 References ---------- .. [1] Neufeld, Philip D., A. R. Janzen, and R. A. Aziz. "Empirical Equations to Calculate 16 of the Transport Collision Integrals Omega(l, S)* for the Lennard-Jones (12-6) Potential." The Journal of Chemical Physics 57, no. 3 (August 1, 1972): 1100-1102. doi:10.1063/1.1678363 ''' if (l, s) not in Neufeld_collision: raise Exception('Input values of l and s are not supported') A, B, C, D, E, F, G, H, R, S, W, P = Neufeld_collision[(l, s)] omega = A / Tstar**B + C / exp(D * Tstar) + E / exp(F * Tstar) if (l, s) in [(1, 1), (1, 2), (3, 3)]: omega += G / exp(H * Tstar) if (l, s) not in [(1, 1), (1, 2)]: omega += R * Tstar**B * sin(S * Tstar**W - P) return omega
def UNIQUAC(xs, rs, qs, taus): r'''Calculates the activity coefficients of each species in a mixture using the Universal quasi-chemical (UNIQUAC) equation, given their mole fractions, `rs`, `qs`, and dimensionless interaction parameters. The interaction parameters are normally correlated with temperature, and need to be calculated separately. .. math:: \ln \gamma_i = \ln \frac{\Phi_i}{x_i} + \frac{z}{2} q_i \ln \frac{\theta_i}{\Phi_i}+ l_i - \frac{\Phi_i}{x_i}\sum_j^N x_j l_j - q_i \ln\left( \sum_j^N \theta_j \tau_{ji}\right)+ q_i - q_i\sum_j^N \frac{\theta_j \tau_{ij}}{\sum_k^N \theta_k \tau_{kj}} \theta_i = \frac{x_i q_i}{\displaystyle\sum_{j=1}^{n} x_j q_j} \Phi_i = \frac{x_i r_i}{\displaystyle\sum_{j=1}^{n} x_j r_j} l_i = \frac{z}{2}(r_i - q_i) - (r_i - 1) Parameters ---------- xs : list[float] Liquid mole fractions of each species, [-] rs : list[float] Van der Waals volume parameters for each species, [-] qs : list[float] Surface area parameters for each species, [-] taus : list[list[float]] Dimensionless interaction parameters of each compound with each other, [-] Returns ------- gammas : list[float] Activity coefficient for each species in the liquid mixture, [-] Notes ----- This model needs N^2 parameters. The original expression for the interaction parameters is as follows: .. math:: \tau_{ji} = \exp\left(\frac{-\Delta u_{ij}}{RT}\right) However, it is seldom used. Most correlations for the interaction parameters include some of the terms shown in the following form: .. math:: \ln \tau{ij} =a_{ij}+\frac{b_{ij}}{T}+c_{ij}\ln T + d_{ij}T + \frac{e_{ij}}{T^2} This model is recast in a slightly more computationally efficient way in [2]_, as shown below: .. math:: \ln \gamma_i = \ln \gamma_i^{res} + \ln \gamma_i^{comb} \ln \gamma_i^{res} = q_i \left(1 - \ln\frac{\sum_j^N q_j x_j \tau_{ji}} {\sum_j^N q_j x_j}- \sum_j \frac{q_k x_j \tau_{ij}}{\sum_k q_k x_k \tau_{kj}}\right) \ln \gamma_i^{comb} = (1 - V_i + \ln V_i) - \frac{z}{2}q_i\left(1 - \frac{V_i}{F_i} + \ln \frac{V_i}{F_i}\right) V_i = \frac{r_i}{\sum_j^N r_j x_j} F_i = \frac{q_i}{\sum_j q_j x_j} Examples -------- Ethanol-water example, at 343.15 K and 1 MPa: >>> UNIQUAC(xs=[0.252, 0.748], rs=[2.1055, 0.9200], qs=[1.972, 1.400], ... taus=[[1.0, 1.0919744384510301], [0.37452902779205477, 1.0]]) [2.35875137797083, 1.2442093415968987] References ---------- .. [1] Abrams, Denis S., and John M. Prausnitz. "Statistical Thermodynamics of Liquid Mixtures: A New Expression for the Excess Gibbs Energy of Partly or Completely Miscible Systems." AIChE Journal 21, no. 1 (January 1, 1975): 116-28. doi:10.1002/aic.690210115. .. [2] Gmehling, Jurgen, Barbel Kolbe, Michael Kleiber, and Jurgen Rarey. Chemical Thermodynamics for Process Simulation. 1st edition. Weinheim: Wiley-VCH, 2012. .. [3] Maurer, G., and J. M. Prausnitz. "On the Derivation and Extension of the Uniquac Equation." Fluid Phase Equilibria 2, no. 2 (January 1, 1978): 91-99. doi:10.1016/0378-3812(78)85002-X. ''' cmps = range(len(xs)) rsxs = sum([rs[i] * xs[i] for i in cmps]) phis = [rs[i] * xs[i] / rsxs for i in cmps] qsxs = sum([qs[i] * xs[i] for i in cmps]) vs = [qs[i] * xs[i] / qsxs for i in cmps] Ss = [sum([vs[j] * taus[j][i] for j in cmps]) for i in cmps] loggammacs = [ log(phis[i] / xs[i]) + 1 - phis[i] / xs[i] - 5 * qs[i] * (log(phis[i] / vs[i]) + 1 - phis[i] / vs[i]) for i in cmps ] loggammars = [ qs[i] * (1 - log(Ss[i]) - sum([taus[i][j] * vs[j] / Ss[j] for j in cmps])) for i in cmps ] return [exp(loggammacs[i] + loggammars[i]) for i in cmps]
def Wilson(xs, params): r'''Calculates the activity coefficients of each species in a mixture using the Wilson method, given their mole fractions, and dimensionless interaction parameters. Those are normally correlated with temperature, and need to be calculated separately. .. math:: \ln \gamma_i = 1 - \ln \left(\sum_j^N \Lambda_{ij} x_j\right) -\sum_j^N \frac{\Lambda_{ji}x_j}{\displaystyle\sum_k^N \Lambda_{jk}x_k} Parameters ---------- xs : list[float] Liquid mole fractions of each species, [-] params : list[list[float]] Dimensionless interaction parameters of each compound with each other, [-] Returns ------- gammas : list[float] Activity coefficient for each species in the liquid mixture, [-] Notes ----- This model needs N^2 parameters. The original model correlated the interaction parameters using the standard pure-component molar volumes of each species at 25°C, in the following form: .. math:: \Lambda_{ij} = \frac{V_j}{V_i} \exp\left(\frac{-\lambda_{i,j}}{RT} \right) However, that form has less flexibility and offered no advantage over using only regressed parameters. Most correlations for the interaction parameters include some of the terms shown in the following form: .. math:: \ln \Lambda_{ij} =a_{ij}+\frac{b_{ij}}{T}+c_{ij}\ln T + d_{ij}T + \frac{e_{ij}}{T^2} + h_{ij}{T^2} The Wilson model is not applicable to liquid-liquid systems. Examples -------- Ethanol-water example, at 343.15 K and 1 MPa: >>> Wilson([0.252, 0.748], [[1, 0.154], [0.888, 1]]) [1.8814926087178843, 1.1655774931125487] References ---------- .. [1] Wilson, Grant M. "Vapor-Liquid Equilibrium. XI. A New Expression for the Excess Free Energy of Mixing." Journal of the American Chemical Society 86, no. 2 (January 1, 1964): 127-130. doi:10.1021/ja01056a002. .. [2] Gmehling, Jurgen, Barbel Kolbe, Michael Kleiber, and Jurgen Rarey. Chemical Thermodynamics for Process Simulation. 1st edition. Weinheim: Wiley-VCH, 2012. ''' gammas = [] cmps = range(len(xs)) for i in cmps: tot1 = log(sum([params[i][j] * xs[j] for j in cmps])) tot2 = 0. for j in cmps: tot2 += params[j][i] * xs[j] / sum( [params[j][k] * xs[k] for k in cmps]) gamma = exp(1. - tot1 - tot2) gammas.append(gamma) return gammas
def NRTL(xs, taus, alphas): r'''Calculates the activity coefficients of each species in a mixture using the Non-Random Two-Liquid (NRTL) method, given their mole fractions, dimensionless interaction parameters, and nonrandomness constants. Those are normally correlated with temperature in some form, and need to be calculated separately. .. math:: \ln(\gamma_i)=\frac{\displaystyle\sum_{j=1}^{n}{x_{j}\tau_{ji}G_{ji}}} {\displaystyle\sum_{k=1}^{n}{x_{k}G_{ki}}}+\sum_{j=1}^{n} {\frac{x_{j}G_{ij}}{\displaystyle\sum_{k=1}^{n}{x_{k}G_{kj}}}} {\left ({\tau_{ij}-\frac{\displaystyle\sum_{m=1}^{n}{x_{m}\tau_{mj} G_{mj}}}{\displaystyle\sum_{k=1}^{n}{x_{k}G_{kj}}}}\right )} G_{ij}=\text{exp}\left ({-\alpha_{ij}\tau_{ij}}\right ) Parameters ---------- xs : list[float] Liquid mole fractions of each species, [-] taus : list[list[float]] Dimensionless interaction parameters of each compound with each other, [-] alphas : list[list[float]] Nonrandomness constants of each compound interacting with each other, [-] Returns ------- gammas : list[float] Activity coefficient for each species in the liquid mixture, [-] Notes ----- This model needs N^2 parameters. One common temperature dependence of the nonrandomness constants is: .. math:: \alpha_{ij}=c_{ij}+d_{ij}T Most correlations for the interaction parameters include some of the terms shown in the following form: .. math:: \tau_{ij}=A_{ij}+\frac{B_{ij}}{T}+\frac{C_{ij}}{T^{2}}+D_{ij} \ln{\left ({T}\right )}+E_{ij}T^{F_{ij}} Examples -------- Ethanol-water example, at 343.15 K and 1 MPa: >>> NRTL(xs=[0.252, 0.748], taus=[[0, -0.178], [1.963, 0]], ... alphas=[[0, 0.2974],[.2974, 0]]) [1.9363183763514304, 1.1537609663170014] References ---------- .. [1] Renon, Henri, and J. M. Prausnitz. "Local Compositions in Thermodynamic Excess Functions for Liquid Mixtures." AIChE Journal 14, no. 1 (1968): 135-144. doi:10.1002/aic.690140124. .. [2] Gmehling, Jurgen, Barbel Kolbe, Michael Kleiber, and Jurgen Rarey. Chemical Thermodynamics for Process Simulation. 1st edition. Weinheim: Wiley-VCH, 2012. ''' gammas = [] cmps = range(len(xs)) Gs = [[exp(-alphas[i][j] * taus[i][j]) for j in cmps] for i in cmps] for i in cmps: tn1, td1, total2 = 0., 0., 0. for j in cmps: # Term 1, numerator and denominator tn1 += xs[j] * taus[j][i] * Gs[j][i] td1 += xs[j] * Gs[j][i] # Term 2 tn2 = xs[j] * Gs[i][j] td2 = td3 = sum([xs[k] * Gs[k][j] for k in cmps]) tn3 = sum([xs[m] * taus[m][j] * Gs[m][j] for m in cmps]) total2 += tn2 / td2 * (taus[i][j] - tn3 / td3) gamma = exp(tn1 / td1 + total2) gammas.append(gamma) return gammas
class VaporPressure(TDependentProperty): '''Class for dealing with vapor pressure as a function of temperature. Consists of four coefficient-based methods and four data sources, one source of tabular information, four corresponding-states estimators, and the external library CoolProp. Parameters ---------- Tb : float, optional Boiling point, [K] Tc : float, optional Critical temperature, [K] Pc : float, optional Critical pressure, [Pa] omega : float, optional Acentric factor, [-] CASRN : str, optional The CAS number of the chemical eos : object, optional Equation of State object after :obj:`thermo.eos.GCEOS` Notes ----- To iterate over all methods, use the list stored in :obj:`vapor_pressure_methods`. **WAGNER_MCGARRY**: The Wagner 3,6 original model equation documented in :obj:`Wagner_original`, with data for 245 chemicals, from [1]_, **WAGNER_POLING**: The Wagner 2.5, 5 model equation documented in :obj:`Wagner` in [2]_, with data for 104 chemicals. **ANTOINE_EXTENDED_POLING**: The TRC extended Antoine model equation documented in :obj:`TRC_Antoine_extended` with data for 97 chemicals in [2]_. **ANTOINE_POLING**: Standard Antoine equation, as documented in the function :obj:`Antoine` and with data for 325 fluids from [2]_. Coefficients were altered to be in units of Pa and Celcius. **COOLPROP**: CoolProp external library; with select fluids from its library. Range is limited to that of the equations of state it uses, as described in [3]_. Very slow. **BOILING_CRITICAL**: Fundamental relationship in thermodynamics making several approximations; see :obj:`boiling_critical_relation` for details. Least accurate method in most circumstances. **LEE_KESLER_PSAT**: CSP method documented in :obj:`Lee_Kesler`. Widely used. **AMBROSE_WALTON**: CSP method documented in :obj:`Ambrose_Walton`. **SANJARI**: CSP method documented in :obj:`Sanjari`. **VDI_TABULAR**: Tabular data in [4]_ along the saturation curve; interpolation is as set by the user or the default. **EOS**: Equation of state provided by user. See Also -------- Wagner_original Wagner TRC_Antoine_extended Antoine boiling_critical_relation Lee_Kesler Ambrose_Walton Sanjari References ---------- .. [1] McGarry, Jack. "Correlation and Prediction of the Vapor Pressures of Pure Liquids over Large Pressure Ranges." Industrial & Engineering Chemistry Process Design and Development 22, no. 2 (April 1, 1983): 313-22. doi:10.1021/i200021a023. .. [2] Poling, Bruce E. The Properties of Gases and Liquids. 5th edition. New York: McGraw-Hill Professional, 2000. .. [3] Bell, Ian H., Jorrit Wronski, Sylvain Quoilin, and Vincent Lemort. "Pure and Pseudo-Pure Fluid Thermophysical Property Evaluation and the Open-Source Thermophysical Property Library CoolProp." Industrial & Engineering Chemistry Research 53, no. 6 (February 12, 2014): 2498-2508. doi:10.1021/ie4033999. http://www.coolprop.org/ .. [4] Gesellschaft, V. D. I., ed. VDI Heat Atlas. 2nd edition. Berlin; New York:: Springer, 2010. ''' name = 'Vapor pressure' units = 'Pa' interpolation_T = lambda self, T: 1. / T '''1/T interpolation transformation by default.''' interpolation_property = lambda self, P: log(P) '''log(P) interpolation transformation by default.''' interpolation_property_inv = lambda self, P: exp(P) '''exp(P) interpolation transformation by default; reverses :obj:`interpolation_property_inv`.''' tabular_extrapolation_permitted = False '''Disallow tabular extrapolation by default; CSP methods prefered normally.''' property_min = 0 '''Mimimum valid value of vapor pressure.''' property_max = 1E10 '''Maximum valid value of vapor pressure. Set slightly above the critical point estimated for Iridium; Mercury's 160 MPa critical point is the highest known.''' ranked_methods = [ WAGNER_MCGARRY, WAGNER_POLING, ANTOINE_EXTENDED_POLING, COOLPROP, ANTOINE_POLING, VDI_TABULAR, AMBROSE_WALTON, LEE_KESLER_PSAT, BOILING_CRITICAL, EOS, SANJARI ] '''Default rankings of the available methods.''' def __init__(self, Tb=None, Tc=None, Pc=None, omega=None, CASRN='', eos=None): self.CASRN = CASRN self.Tb = Tb self.Tc = Tc self.Pc = Pc self.omega = omega self.eos = eos self.Tmin = None '''Minimum temperature at which no method can calculate vapor pressure under.''' self.Tmax = None '''Maximum temperature at which no method can calculate vapor pressure above; by definition the critical point.''' self.method = None '''The method was which was last used successfully to calculate a property; set only after the first property calculation.''' self.tabular_data = {} '''tabular_data, dict: Stored (Ts, properties) for any tabular data; indexed by provided or autogenerated name.''' self.tabular_data_interpolators = {} '''tabular_data_interpolators, dict: Stored (extrapolator, spline) tuples which are interp1d instances for each set of tabular data; indexed by tuple of (name, interpolation_T, interpolation_property, interpolation_property_inv) to ensure that if an interpolation transform is altered, the old interpolator which had been created is no longer used.''' self.sorted_valid_methods = [] '''sorted_valid_methods, list: Stored methods which were found valid at a specific temperature; set by `T_dependent_property`.''' self.user_methods = [] '''user_methods, list: Stored methods which were specified by the user in a ranked order of preference; set by `T_dependent_property`.''' self.all_methods = set() '''Set of all methods available for a given CASRN and properties; filled by :obj:`load_all_methods`.''' self.load_all_methods() def load_all_methods(self): r'''Method which picks out coefficients for the specified chemical from the various dictionaries and DataFrames storing it. All data is stored as attributes. This method also sets :obj:`Tmin`, :obj:`Tmax`, and :obj:`all_methods` as a set of methods for which the data exists for. Called on initialization only. See the source code for the variables at which the coefficients are stored. The coefficients can safely be altered once the class is initialized. This method can be called again to reset the parameters. ''' methods = [] Tmins, Tmaxs = [], [] if self.CASRN in WagnerMcGarry.index: methods.append(WAGNER_MCGARRY) _, A, B, C, D, self.WAGNER_MCGARRY_Pc, self.WAGNER_MCGARRY_Tc, self.WAGNER_MCGARRY_Tmin = _WagnerMcGarry_values[ WagnerMcGarry.index.get_loc(self.CASRN)].tolist() self.WAGNER_MCGARRY_coefs = [A, B, C, D] Tmins.append(self.WAGNER_MCGARRY_Tmin) Tmaxs.append(self.WAGNER_MCGARRY_Tc) if self.CASRN in WagnerPoling.index: methods.append(WAGNER_POLING) _, A, B, C, D, self.WAGNER_POLING_Tc, self.WAGNER_POLING_Pc, Tmin, self.WAGNER_POLING_Tmax = _WagnerPoling_values[ WagnerPoling.index.get_loc(self.CASRN)].tolist() # Some Tmin values are missing; Arbitrary choice of 0.1 lower limit self.WAGNER_POLING_Tmin = Tmin if not np.isnan( Tmin) else self.WAGNER_POLING_Tmax * 0.1 self.WAGNER_POLING_coefs = [A, B, C, D] Tmins.append(Tmin) Tmaxs.append(self.WAGNER_POLING_Tmax) if self.CASRN in AntoineExtended.index: methods.append(ANTOINE_EXTENDED_POLING) _, A, B, C, Tc, to, n, E, F, self.ANTOINE_EXTENDED_POLING_Tmin, self.ANTOINE_EXTENDED_POLING_Tmax = _AntoineExtended_values[ AntoineExtended.index.get_loc(self.CASRN)].tolist() self.ANTOINE_EXTENDED_POLING_coefs = [Tc, to, A, B, C, n, E, F] Tmins.append(self.ANTOINE_EXTENDED_POLING_Tmin) Tmaxs.append(self.ANTOINE_EXTENDED_POLING_Tmax) if self.CASRN in AntoinePoling.index: methods.append(ANTOINE_POLING) _, A, B, C, self.ANTOINE_POLING_Tmin, self.ANTOINE_POLING_Tmax = _AntoinePoling_values[ AntoinePoling.index.get_loc(self.CASRN)].tolist() self.ANTOINE_POLING_coefs = [A, B, C] Tmins.append(self.ANTOINE_POLING_Tmin) Tmaxs.append(self.ANTOINE_POLING_Tmax) if has_CoolProp and self.CASRN in coolprop_dict: methods.append(COOLPROP) self.CP_f = coolprop_fluids[self.CASRN] Tmins.append(self.CP_f.Tmin) Tmaxs.append(self.CP_f.Tc) if self.CASRN in _VDISaturationDict: methods.append(VDI_TABULAR) Ts, props = VDI_tabular_data(self.CASRN, 'P') self.VDI_Tmin = Ts[0] self.VDI_Tmax = Ts[-1] self.tabular_data[VDI_TABULAR] = (Ts, props) Tmins.append(self.VDI_Tmin) Tmaxs.append(self.VDI_Tmax) if all((self.Tb, self.Tc, self.Pc)): methods.append(BOILING_CRITICAL) Tmins.append(0.01) Tmaxs.append(self.Tc) if all((self.Tc, self.Pc, self.omega)): methods.append(LEE_KESLER_PSAT) methods.append(AMBROSE_WALTON) methods.append(SANJARI) if self.eos: methods.append(EOS) Tmins.append(0.01) Tmaxs.append(self.Tc) self.all_methods = set(methods) if Tmins and Tmaxs: self.Tmin = min(Tmins) self.Tmax = max(Tmaxs) def calculate(self, T, method): r'''Method to calculate vapor pressure of a fluid at temperature `T` with a given method. This method has no exception handling; see `T_dependent_property` for that. Parameters ---------- T : float Temperature at calculate vapor pressure, [K] method : str Name of the method to use Returns ------- Psat : float Vapor pressure at T, [pa] ''' if method == WAGNER_MCGARRY: A, B, C, D = self.WAGNER_MCGARRY_coefs Psat = Wagner_original(T, self.WAGNER_MCGARRY_Tc, self.WAGNER_MCGARRY_Pc, A, B, C, D) elif method == WAGNER_POLING: A, B, C, D = self.WAGNER_POLING_coefs Psat = Wagner(T, self.WAGNER_POLING_Tc, self.WAGNER_POLING_Pc, A, B, C, D) elif method == ANTOINE_EXTENDED_POLING: Tc, to, A, B, C, n, E, F = self.ANTOINE_EXTENDED_POLING_coefs Psat = TRC_Antoine_extended(T, Tc, to, A, B, C, n, E, F) elif method == ANTOINE_POLING: A, B, C = self.ANTOINE_POLING_coefs Psat = Antoine(T, A, B, C, Base=10.0) elif method == COOLPROP: Psat = PropsSI('P', 'T', T, 'Q', 0, self.CASRN) elif method == BOILING_CRITICAL: Psat = boiling_critical_relation(T, self.Tb, self.Tc, self.Pc) elif method == LEE_KESLER_PSAT: Psat = Lee_Kesler(T, self.Tc, self.Pc, self.omega) elif method == AMBROSE_WALTON: Psat = Ambrose_Walton(T, self.Tc, self.Pc, self.omega) elif method == SANJARI: Psat = Sanjari(T, self.Tc, self.Pc, self.omega) elif method == EOS: Psat = self.eos[0].Psat(T) elif method in self.tabular_data: Psat = self.interpolate(T, method) return Psat def test_method_validity(self, T, method): r'''Method to check the validity of a method. Follows the given ranges for all coefficient-based methods. For CSP methods, the models are considered valid from 0 K to the critical point. For tabular data, extrapolation outside of the range is used if :obj:`tabular_extrapolation_permitted` is set; if it is, the extrapolation is considered valid for all temperatures. It is not guaranteed that a method will work or give an accurate prediction simply because this method considers the method valid. Parameters ---------- T : float Temperature at which to test the method, [K] method : str Name of the method to test Returns ------- validity : bool Whether or not a method is valid ''' if method == WAGNER_MCGARRY: if T < self.WAGNER_MCGARRY_Tmin or T > self.WAGNER_MCGARRY_Tc: return False elif method == WAGNER_POLING: if T < self.WAGNER_POLING_Tmin or T > self.WAGNER_POLING_Tmax: return False elif method == ANTOINE_EXTENDED_POLING: if T < self.ANTOINE_EXTENDED_POLING_Tmin or T > self.ANTOINE_EXTENDED_POLING_Tmax: return False elif method == ANTOINE_POLING: if T < self.ANTOINE_POLING_Tmin or T > self.ANTOINE_POLING_Tmax: return False elif method == COOLPROP: if T < self.CP_f.Tmin or T < self.CP_f.Tt or T > self.CP_f.Tmax or T > self.CP_f.Tc: return False elif method in [ BOILING_CRITICAL, LEE_KESLER_PSAT, AMBROSE_WALTON, SANJARI, EOS ]: if T > self.Tc or T < 0: return False # No lower limit elif method in self.tabular_data: # if tabular_extrapolation_permitted, good to go without checking if not self.tabular_extrapolation_permitted: Ts, properties = self.tabular_data[method] if T < Ts[0] or T > Ts[-1]: return False else: raise Exception('Method not valid') return True
def Sanjari(T, Tc, Pc, omega): r'''Calculates vapor pressure of a fluid at arbitrary temperatures using a CSP relationship by [1]_. Requires a chemical's critical temperature, pressure, and acentric factor. Although developed for refrigerants, should have some generality. The vapor pressure is given by: .. math:: P^{sat} = P_c\exp(f^{(0)} + \omega f^{(1)} + \omega^2 f^{(2)}) f^{(0)} = a_1 + \frac{a_2}{T_r} + a_3\ln T_r + a_4 T_r^{1.9} f^{(1)} = a_5 + \frac{a_6}{T_r} + a_7\ln T_r + a_8 T_r^{1.9} f^{(2)} = a_9 + \frac{a_{10}}{T_r} + a_{11}\ln T_r + a_{12} T_r^{1.9} Parameters ---------- T : float Temperature of fluid [K] Tc : float Critical temperature of fluid [K] Pc : float Critical pressure of fluid [Pa] omega : float Acentric factor [-] Returns ------- Psat : float Vapor pressure, [Pa] Notes ----- a 1-12 are as follows: 6.83377, -5.76051, 0.90654, -1.16906, 5.32034, -28.1460, -58.0352, 23.57466, 18.19967, 16.33839, 65.6995, -35.9739. For a claimed fluid not included in the regression, R128, the claimed AARD was 0.428%. A re-calculation using 200 data points from 125.45 K to 343.90225 K evenly spaced by 1.09775 K as generated by NIST Webbook April 2016 produced an AARD of 0.644%. It is likely that the author's regression used more precision in its coefficients than was shown here. Nevertheless, the function is reproduced as shown in [1]_. For Tc=808 K, Pc=1100000 Pa, omega=1.1571, this function actually declines after 770 K. Examples -------- >>> Sanjari(347.2, 617.1, 36E5, 0.299) 13651.916109552498 References ---------- .. [1] Sanjari, Ehsan, Mehrdad Honarmand, Hamidreza Badihi, and Ali Ghaheri. "An Accurate Generalized Model for Predict Vapor Pressure of Refrigerants." International Journal of Refrigeration 36, no. 4 (June 2013): 1327-32. doi:10.1016/j.ijrefrig.2013.01.007. ''' Tr = T / Tc f0 = 6.83377 + -5.76051 / Tr + 0.90654 * log(Tr) + -1.16906 * Tr**1.9 f1 = 5.32034 + -28.1460 / Tr + -58.0352 * log(Tr) + 23.57466 * Tr**1.9 f2 = 18.19967 + 16.33839 / Tr + 65.6995 * log(Tr) + -35.9739 * Tr**1.9 P = Pc * exp(f0 + omega * f1 + omega**2 * f2) return P
def UNIQUAC(xs, rs, qs, taus): r'''Calculates the activity coefficients of each species in a mixture using the Universal quasi-chemical (UNIQUAC) equation, given their mole fractions, `rs`, `qs`, and dimensionless interaction parameters. The interaction parameters are normally correlated with temperature, and need to be calculated separately. .. math:: \ln \gamma_i = \ln \frac{\Phi_i}{x_i} + \frac{z}{2} q_i \ln \frac{\theta_i}{\Phi_i}+ l_i - \frac{\Phi_i}{x_i}\sum_j^N x_j l_j - q_i \ln\left( \sum_j^N \theta_j \tau_{ji}\right)+ q_i - q_i\sum_j^N \frac{\theta_j \tau_{ij}}{\sum_k^N \theta_k \tau_{kj}} \theta_i = \frac{x_i q_i}{\displaystyle\sum_{j=1}^{n} x_j q_j} \Phi_i = \frac{x_i r_i}{\displaystyle\sum_{j=1}^{n} x_j r_j} l_i = \frac{z}{2}(r_i - q_i) - (r_i - 1) Parameters ---------- xs : list[float] Liquid mole fractions of each species, [-] rs : list[float] Van der Waals volume parameters for each species, [-] qs : list[float] Surface area parameters for each species, [-] taus : list[list[float]] Dimensionless interaction parameters of each compound with each other, [-] Returns ------- gammas : list[float] Activity coefficient for each species in the liquid mixture, [-] Notes ----- This model needs N^2 parameters. The original expression for the interaction parameters is as follows: .. math:: \tau_{ji} = \exp\left(\frac{-\Delta u_{ij}}{RT}\right) However, it is seldom used. Most correlations for the interaction parameters include some of the terms shown in the following form: .. math:: \ln \tau{ij} =a_{ij}+\frac{b_{ij}}{T}+c_{ij}\ln T + d_{ij}T + \frac{e_{ij}}{T^2} This model is recast in a slightly more computationally efficient way in [2]_, as shown below: .. math:: \ln \gamma_i = \ln \gamma_i^{res} + \ln \gamma_i^{comb} \ln \gamma_i^{res} = q_i \left(1 - \ln\frac{\sum_j^N q_j x_j \tau_{ji}} {\sum_j^N q_j x_j}- \sum_j \frac{q_k x_j \tau_{ij}}{\sum_k q_k x_k \tau_{kj}}\right) \ln \gamma_i^{comb} = (1 - V_i + \ln V_i) - \frac{z}{2}q_i\left(1 - \frac{V_i}{F_i} + \ln \frac{V_i}{F_i}\right) V_i = \frac{r_i}{\sum_j^N r_j x_j} F_i = \frac{q_i}{\sum_j q_j x_j} Examples -------- Ethanol-water example, at 343.15 K and 1 MPa: >>> UNIQUAC(xs=[0.252, 0.748], rs=[2.1055, 0.9200], qs=[1.972, 1.400], ... taus=[[1.0, 1.0919744384510301], [0.37452902779205477, 1.0]]) [2.35875137797083, 1.2442093415968987] References ---------- .. [1] Abrams, Denis S., and John M. Prausnitz. "Statistical Thermodynamics of Liquid Mixtures: A New Expression for the Excess Gibbs Energy of Partly or Completely Miscible Systems." AIChE Journal 21, no. 1 (January 1, 1975): 116-28. doi:10.1002/aic.690210115. .. [2] Gmehling, Jurgen, Barbel Kolbe, Michael Kleiber, and Jurgen Rarey. Chemical Thermodynamics for Process Simulation. 1st edition. Weinheim: Wiley-VCH, 2012. .. [3] Maurer, G., and J. M. Prausnitz. "On the Derivation and Extension of the Uniquac Equation." Fluid Phase Equilibria 2, no. 2 (January 1, 1978): 91-99. doi:10.1016/0378-3812(78)85002-X. ''' cmps = range(len(xs)) rsxs = sum([rs[i]*xs[i] for i in cmps]) phis = [rs[i]*xs[i]/rsxs for i in cmps] qsxs = sum([qs[i]*xs[i] for i in cmps]) vs = [qs[i]*xs[i]/qsxs for i in cmps] Ss = [sum([vs[j]*taus[j][i] for j in cmps]) for i in cmps] loggammacs = [log(phis[i]/xs[i]) + 1 - phis[i]/xs[i] - 5*qs[i]*(log(phis[i]/vs[i]) + 1 - phis[i]/vs[i]) for i in cmps] loggammars = [qs[i]*(1 - log(Ss[i]) - sum([taus[i][j]*vs[j]/Ss[j] for j in cmps])) for i in cmps] return [exp(loggammacs[i] + loggammars[i]) for i in cmps]
def NRTL(xs, taus, alphas): r'''Calculates the activity coefficients of each species in a mixture using the Non-Random Two-Liquid (NRTL) method, given their mole fractions, dimensionless interaction parameters, and nonrandomness constants. Those are normally correlated with temperature in some form, and need to be calculated separately. .. math:: \ln(\gamma_i)=\frac{\displaystyle\sum_{j=1}^{n}{x_{j}\tau_{ji}G_{ji}}} {\displaystyle\sum_{k=1}^{n}{x_{k}G_{ki}}}+\sum_{j=1}^{n} {\frac{x_{j}G_{ij}}{\displaystyle\sum_{k=1}^{n}{x_{k}G_{kj}}}} {\left ({\tau_{ij}-\frac{\displaystyle\sum_{m=1}^{n}{x_{m}\tau_{mj} G_{mj}}}{\displaystyle\sum_{k=1}^{n}{x_{k}G_{kj}}}}\right )} G_{ij}=\text{exp}\left ({-\alpha_{ij}\tau_{ij}}\right ) Parameters ---------- xs : list[float] Liquid mole fractions of each species, [-] taus : list[list[float]] Dimensionless interaction parameters of each compound with each other, [-] alphas : list[list[float]] Nonrandomness constants of each compound interacting with each other, [-] Returns ------- gammas : list[float] Activity coefficient for each species in the liquid mixture, [-] Notes ----- This model needs N^2 parameters. One common temperature dependence of the nonrandomness constants is: .. math:: \alpha_{ij}=c_{ij}+d_{ij}T Most correlations for the interaction parameters include some of the terms shown in the following form: .. math:: \tau_{ij}=A_{ij}+\frac{B_{ij}}{T}+\frac{C_{ij}}{T^{2}}+D_{ij} \ln{\left ({T}\right )}+E_{ij}T^{F_{ij}} Examples -------- Ethanol-water example, at 343.15 K and 1 MPa: >>> NRTL(xs=[0.252, 0.748], taus=[[0, -0.178], [1.963, 0]], ... alphas=[[0, 0.2974],[.2974, 0]]) [1.9363183763514304, 1.1537609663170014] References ---------- .. [1] Renon, Henri, and J. M. Prausnitz. "Local Compositions in Thermodynamic Excess Functions for Liquid Mixtures." AIChE Journal 14, no. 1 (1968): 135-144. doi:10.1002/aic.690140124. .. [2] Gmehling, Jurgen, Barbel Kolbe, Michael Kleiber, and Jurgen Rarey. Chemical Thermodynamics for Process Simulation. 1st edition. Weinheim: Wiley-VCH, 2012. ''' gammas = [] cmps = range(len(xs)) Gs = [[exp(-alphas[i][j]*taus[i][j]) for j in cmps] for i in cmps] for i in cmps: tn1, td1, total2 = 0., 0., 0. for j in cmps: # Term 1, numerator and denominator tn1 += xs[j]*taus[j][i]*Gs[j][i] td1 += xs[j]*Gs[j][i] # Term 2 tn2 = xs[j]*Gs[i][j] td2 = td3 = sum([xs[k]*Gs[k][j] for k in cmps]) tn3 = sum([xs[m]*taus[m][j]*Gs[m][j] for m in cmps]) total2 += tn2/td2*(taus[i][j] - tn3/td3) gamma = exp(tn1/td1 + total2) gammas.append(gamma) return gammas
def Ambrose_Walton(T, Tc, Pc, omega): r'''Calculates vapor pressure of a fluid at arbitrary temperatures using a CSP relationship by [1]_; requires a chemical's critical temperature and acentric factor. The vapor pressure is given by: .. math:: \ln P_r=f^{(0)}+\omega f^{(1)}+\omega^2f^{(2)} \tau = 1-T_{r} f^{(0)}=\frac{-5.97616\tau + 1.29874\tau^{1.5}- 0.60394\tau^{2.5} -1.06841\tau^5}{T_r} f^{(1)}=\frac{-5.03365\tau + 1.11505\tau^{1.5}- 5.41217\tau^{2.5} -7.46628\tau^5}{T_r} f^{(2)}=\frac{-0.64771\tau + 2.41539\tau^{1.5}- 4.26979\tau^{2.5} +3.25259\tau^5}{T_r} Parameters ---------- T : float Temperature of fluid [K] Tc : float Critical temperature of fluid [K] Pc : float Critical pressure of fluid [Pa] omega : float Acentric factor [-] Returns ------- Psat : float Vapor pressure, [Pa] Notes ----- Examples -------- >>> Ambrose_Walton(347.2, 617.1, 36E5, 0.299) 13558.913459865389 References ---------- .. [1] Ambrose, D., and J. Walton. "Vapour Pressures up to Their Critical Temperatures of Normal Alkanes and 1-Alkanols." Pure and Applied Chemistry 61, no. 8 (1989): 1395-1403. doi:10.1351/pac198961081395. .. [2] Reid, Robert C..; Prausnitz, John M.; Poling, Bruce E. The Properties of Gases and Liquids. McGraw-Hill Companies, 1987. ''' Tr = T / Tc tau = 1 - T / Tc f0 = (-5.97616 * tau + 1.29874 * tau**1.5 - 0.60394 * tau**2.5 - 1.06841 * tau**5) / Tr f1 = (-5.03365 * tau + 1.11505 * tau**1.5 - 5.41217 * tau**2.5 - 7.46628 * tau**5) / Tr f2 = (-0.64771 * tau + 2.41539 * tau**1.5 - 4.26979 * tau**2.5 + 3.25259 * tau**5) / Tr Psat = Pc * exp(f0 + omega * f1 + omega**2 * f2) return Psat
def Ambrose_Walton(T, Tc, Pc, omega): r'''Calculates vapor pressure of a fluid at arbitrary temperatures using a CSP relationship by [1]_; requires a chemical's critical temperature and acentric factor. The vapor pressure is given by: .. math:: \ln P_r=f^{(0)}+\omega f^{(1)}+\omega^2f^{(2)} f^{(0)}=\frac{-5.97616\tau + 1.29874\tau^{1.5}- 0.60394\tau^{2.5} -1.06841\tau^5}{T_r} f^{(1)}=\frac{-5.03365\tau + 1.11505\tau^{1.5}- 5.41217\tau^{2.5} -7.46628\tau^5}{T_r} f^{(2)}=\frac{-0.64771\tau + 2.41539\tau^{1.5}- 4.26979\tau^{2.5} +3.25259\tau^5}{T_r} \tau = 1-T_{r} Parameters ---------- T : float Temperature of fluid [K] Tc : float Critical temperature of fluid [K] Pc : float Critical pressure of fluid [Pa] omega : float Acentric factor [-] Returns ------- Psat : float Vapor pressure at T [Pa] Notes ----- Somewhat more accurate than the :obj:`Lee_Kesler` formulation. Examples -------- Example from [2]_; ethylbenzene at 347.25 K. >>> Ambrose_Walton(347.25, 617.15, 36.09E5, 0.304) 13278.878504306222 References ---------- .. [1] Ambrose, D., and J. Walton. "Vapour Pressures up to Their Critical Temperatures of Normal Alkanes and 1-Alkanols." Pure and Applied Chemistry 61, no. 8 (1989): 1395-1403. doi:10.1351/pac198961081395. .. [2] Poling, Bruce E. The Properties of Gases and Liquids. 5th edition. New York: McGraw-Hill Professional, 2000. ''' Tr = T / Tc tau = 1 - T / Tc f0 = (-5.97616 * tau + 1.29874 * tau**1.5 - 0.60394 * tau**2.5 - 1.06841 * tau**5) / Tr f1 = (-5.03365 * tau + 1.11505 * tau**1.5 - 5.41217 * tau**2.5 - 7.46628 * tau**5) / Tr f2 = (-0.64771 * tau + 2.41539 * tau**1.5 - 4.26979 * tau**2.5 + 3.25259 * tau**5) / Tr return Pc * exp(f0 + omega * f1 + omega**2 * f2)
def Poyntings(self, T, P, Psats): Vmls = [VolumeLiquid(T=T, P=P) for VolumeLiquid in self.VolumeLiquids] return [exp(Vml*(P-Psat)/(R*T)) for Psat, Vml in zip(Psats, Vmls)]
def Zuo_Stenby(T, Tc, Pc, omega): r'''Calculates air-water surface tension using the reference fluids methods of [1]_. .. math:: \sigma^{(1)} = 40.520(1-T_r)^{1.287} \sigma^{(2)} = 52.095(1-T_r)^{1.21548} \sigma_r = \sigma_r^{(1)}+ \frac{\omega - \omega^{(1)}} {\omega^{(2)}-\omega^{(1)}} (\sigma_r^{(2)}-\sigma_r^{(1)}) \sigma = T_c^{1/3}P_c^{2/3}[\exp{(\sigma_r)} -1] Parameters ---------- T : float Temperature of fluid [K] Tc : float Critical temperature of fluid [K] Pc : float Critical pressure of fluid [Pa] omega : float Acentric factor for fluid, [-] Returns ------- sigma : float Liquid surface tension, N/m Notes ----- Presently untested. Have not personally checked the sources. I strongly believe it is broken. The reference values for methane and n-octane are from the DIPPR database. Examples -------- Chlorobenzene >>> Zuo_Stenby(293., 633.0, 4530000.0, 0.249) 0.03345569011871088 References ---------- .. [1] Zuo, You-Xiang, and Erling H. Stenby. "Corresponding-States and Parachor Models for the Calculation of Interfacial Tensions." The Canadian Journal of Chemical Engineering 75, no. 6 (December 1, 1997): 1130-37. doi:10.1002/cjce.5450750617 ''' Tc_1, Pc_1, omega_1 = 190.56, 4599000.0 / 1E5, 0.012 Tc_2, Pc_2, omega_2 = 568.7, 2490000.0 / 1E5, 0.4 Pc = Pc / 1E5 def ST_r(ST, Tc, Pc): return log(1 + ST / (Tc**(1 / 3.0) * Pc**(2 / 3.0))) ST_1 = 40.520 * (1 - T / Tc)**1.287 # Methane ST_2 = 52.095 * (1 - T / Tc)**1.21548 # n-octane ST_r_1, ST_r_2 = ST_r(ST_1, Tc_1, Pc_1), ST_r(ST_2, Tc_2, Pc_2) sigma_r = ST_r_1 + (omega - omega_1) / (omega_2 - omega_1) * (ST_r_2 - ST_r_1) sigma = Tc**(1 / 3.0) * Pc**(2 / 3.0) * (exp(sigma_r) - 1) sigma = sigma / 1000 # N/m, please return sigma