def Kweq_1981(T, rho_w): r'''Calculates equilibrium constant for OH- and H+ in water, according to [1]_. Second most recent formulation. .. math:: \log_{10} K_w= A + B/T + C/T^2 + D/T^3 + (E+F/T+G/T^2)\log_{10} \rho_w Parameters ---------- T : float Temperature of fluid [K] rho_w : float Density of water, [kg/m^3] Returns ------- Kweq : float Ionization constant of water, [-] Notes ----- Density is internally converted to units of g/cm^3. A = -4.098; B = -3245.2; C = 2.2362E5; D = -3.984E7; E = 13.957; F = -1262.3; G = 8.5641E5 Examples -------- >>> -1*log10(Kweq_1981(600, 700)) 11.274522047458206 References ---------- .. [1] Marshall, William L., and E. U. Franck. "Ion Product of Water Substance, 0-1000 degree C, 1010,000 Bars New International Formulation and Its Background." Journal of Physical and Chemical Reference Data 10, no. 2 (April 1, 1981): 295-304. doi:10.1063/1.555643. ''' rho_w = rho_w / 1000. A = -4.098 B = -3245.2 C = 2.2362E5 D = -3.984E7 E = 13.957 F = -1262.3 G = 8.5641E5 K_w = 10**(A + B / T + C / T**2 + D / T**3 + (E + F / T + G / T**2) * log10(rho_w)) return K_w
def Kweq_1981(T, rho_w): r'''Calculates equilibrium constant for OH- and H+ in water, according to [1]_. Second most recent formulation. .. math:: \log_{10} K_w= A + B/T + C/T^2 + D/T^3 + (E+F/T+G/T^2)\log_{10} \rho_w Parameters ---------- T : float Temperature of fluid [K] rho_w : float Density of water, [kg/m^3] Returns ------- Kweq : float Ionization constant of water, [-] Notes ----- Density is internally converted to units of g/cm^3. A = -4.098; B = -3245.2; C = 2.2362E5; D = -3.984E7; E = 13.957; F = -1262.3; G = 8.5641E5 Examples -------- >>> -1*log10(Kweq_1981(600, 700)) 11.274522047458206 References ---------- .. [1] Marshall, William L., and E. U. Franck. "Ion Product of Water Substance, 0-1000 degree C, 1010,000 Bars New International Formulation and Its Background." Journal of Physical and Chemical Reference Data 10, no. 2 (April 1, 1981): 295-304. doi:10.1063/1.555643. ''' rho_w = rho_w/1000. A = -4.098 B = -3245.2 C = 2.2362E5 D = -3.984E7 E = 13.957 F = -1262.3 G = 8.5641E5 return 10**(A + B/T + C/T**2 + D/T**3 + (E + F/T + G/T**2)*log10(rho_w))
def omega(CASRN, AvailableMethods=False, Method=None, IgnoreMethods=['LK', 'DEFINITION']): r'''This function handles the retrieval of a chemical's acentric factor, `omega`, or its calculation from correlations or directly through the definition of acentric factor if possible. Requires a known boiling point, critical temperature and pressure for use of the correlations. Requires accurate vapor pressure data for direct calculation. Will automatically select a method to use if no Method is provided; returns None if the data is not available and cannot be calculated. .. math:: \omega \equiv -\log_{10}\left[\lim_{T/T_c=0.7}(P^{sat}/P_c)\right]-1.0 Examples -------- >>> omega(CASRN='64-17-5') 0.635 Parameters ---------- CASRN : string CASRN [-] Returns ------- omega : float Acentric factor of compound methods : list, only returned if AvailableMethods == True List of methods which can be used to obtain omega with the given inputs Other Parameters ---------------- Method : string, optional The method name to use. Accepted methods are 'PSRK', 'PD', 'YAWS', 'LK', and 'DEFINITION'. All valid values are also held in the list omega_methods. AvailableMethods : bool, optional If True, function will determine which methods can be used to obtain omega for the desired chemical, and will return methods instead of omega IgnoreMethods : list, optional A list of methods to ignore in obtaining the full list of methods, useful for for performance reasons and ignoring inaccurate methods Notes ----- A total of five sources are available for this function. They are: * 'PSRK', a compillation of experimental and estimated data published in the Appendix of [15]_, the fourth revision of the PSRK model. * 'PD', an older compillation of data published in (Passut & Danner, 1973) [16]_. * 'YAWS', a large compillation of data from a variety of sources; no data points are sourced in the work of [17]_. * 'LK', a estimation method for hydrocarbons. * 'DEFINITION', based on the definition of omega as presented in [1]_, using vapor pressure data. References ---------- .. [1] Pitzer, K. S., D. Z. Lippmann, R. F. Curl, C. M. Huggins, and D. E. Petersen: The Volumetric and Thermodynamic Properties of Fluids. II. Compressibility Factor, Vapor Pressure and Entropy of Vaporization. J. Am. Chem. Soc., 77: 3433 (1955). .. [2] Horstmann, Sven, Anna Jabłoniec, Jörg Krafczyk, Kai Fischer, and Jürgen Gmehling. "PSRK Group Contribution Equation of State: Comprehensive Revision and Extension IV, Including Critical Constants and Α-Function Parameters for 1000 Components." Fluid Phase Equilibria 227, no. 2 (January 25, 2005): 157-64. doi:10.1016/j.fluid.2004.11.002. .. [3] Passut, Charles A., and Ronald P. Danner. "Acentric Factor. A Valuable Correlating Parameter for the Properties of Hydrocarbons." Industrial & Engineering Chemistry Process Design and Development 12, no. 3 (July 1, 1973): 365-68. doi:10.1021/i260047a026. .. [4] Yaws, Carl L. Thermophysical Properties of Chemicals and Hydrocarbons, Second Edition. Amsterdam Boston: Gulf Professional Publishing, 2014. ''' def list_methods(): ''' List methods available for calculating a chemical's acentric factor, omega ''' methods = [] if (CASRN in _crit_PSRKR4.index and not np.isnan(_crit_PSRKR4.at[CASRN, 'omega'])): methods.append('PSRK') if (CASRN in _crit_PassutDanner.index and not np.isnan(_crit_PassutDanner.at[CASRN, 'omega'])): methods.append('PD') if (CASRN in _crit_Yaws.index and not np.isnan(_crit_Yaws.at[CASRN, 'omega'])): methods.append('YAWS') Tcrit, Pcrit = Tc(CASRN), Pc(CASRN) if Tcrit and Pcrit: if Tb(CASRN): methods.append('LK') if VaporPressure(CASRN=CASRN).T_dependent_property(Tcrit * 0.7): # TODO: better integration methods.append('DEFINITION') if IgnoreMethods: for Method in IgnoreMethods: if Method in methods: methods.remove(Method) methods.append('NONE') return methods if AvailableMethods: return list_methods() if not Method: Method = list_methods()[0] # This is the calculate, given the method section if Method == 'PSRK': _omega = float(_crit_PSRKR4.at[CASRN, 'omega']) elif Method == 'PD': _omega = float(_crit_PassutDanner.at[CASRN, 'omega']) elif Method == 'YAWS': _omega = float(_crit_Yaws.at[CASRN, 'omega']) elif Method == 'LK': _omega = LK_omega(Tb(CASRN), Tc(CASRN), Pc(CASRN)) elif Method == 'DEFINITION': P = VaporPressure(CASRN=CASRN).T_dependent_property(Tc(CASRN) * 0.7) _omega = -log10(P / Pc(CASRN)) - 1.0 elif Method == 'NONE': _omega = None else: raise Exception('Failure in in function') return _omega
def StielPolar(Tc=None, Pc=None, omega=None, CASRN='', Method=None, AvailableMethods=False): r'''This function handles the calculation of a chemical's Stiel Polar factor, directly through the definition of Stiel-polar factor if possible. Requires Tc, Pc, acentric factor, and a vapor pressure datum at Tr=0.6. Will automatically select a method to use if no Method is provided; returns None if the data is not available and cannot be calculated. .. math:: x = \log P_r|_{T_r=0.6} + 1.70 \omega + 1.552 Parameters ---------- Tc : float Critical temperature of fluid [K] Pc : float Critical pressure of fluid [Pa] omega : float Acentric factor of the fluid [-] CASRN : string CASRN [-] Returns ------- factor : float Stiel polar factor of compound methods : list, only returned if AvailableMethods == True List of methods which can be used to obtain Stiel polar factor with the given inputs Other Parameters ---------------- Method : string, optional The method name to use. Only 'DEFINITION' is accepted so far. All valid values are also held in the list Stiel_polar_methods. AvailableMethods : bool, optional If True, function will determine which methods can be used to obtain Stiel-polar factor for the desired chemical, and will return methods instead of stiel-polar factor Notes ----- Only one source is available for this function. It is: * 'DEFINITION', based on the definition of Stiel Polar Factor presented in [1]_, using vapor pressure data. A few points have also been published in [2]_, which may be used for comparison. Currently this is only used for a surface tension correlation. Examples -------- >>> StielPolar(647.3, 22048321.0, 0.344, CASRN='7732-18-5') 0.024581140348734376 References ---------- .. [1] Halm, Roland L., and Leonard I. Stiel. "A Fourth Parameter for the Vapor Pressure and Entropy of Vaporization of Polar Fluids." AIChE Journal 13, no. 2 (1967): 351-355. doi:10.1002/aic.690130228. .. [2] D, Kukoljac Miloš, and Grozdanić Dušan K. "New Values of the Polarity Factor." Journal of the Serbian Chemical Society 65, no. 12 (January 1, 2000). http://www.shd.org.rs/JSCS/Vol65/No12-Pdf/JSCS12-07.pdf ''' def list_methods(): ''' List methods available for Stiel's polar factor ''' methods = [] if Tc and Pc and omega: methods.append('DEFINITION') methods.append('NONE') return methods if AvailableMethods: return list_methods() if not Method: Method = list_methods()[0] if Method == 'DEFINITION': P = VaporPressure(CASRN=CASRN).T_dependent_property(Tc * 0.6) if not P: factor = None else: Pr = P / Pc factor = log10(Pr) + 1.70 * omega + 1.552 elif Method == 'NONE': factor = None else: raise Exception('Failure in in function') return factor
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 omega(CASRN, AvailableMethods=False, Method=None, IgnoreMethods=['LK', 'DEFINITION']): r'''This function handles the retrieval of a chemical's acentric factor, `omega`, or its calculation from correlations or directly through the definition of acentric factor if possible. Requires a known boiling point, critical temperature and pressure for use of the correlations. Requires accurate vapor pressure data for direct calculation. Will automatically select a method to use if no Method is provided; returns None if the data is not available and cannot be calculated. .. math:: \omega \equiv -\log_{10}\left[\lim_{T/T_c=0.7}(P^{sat}/P_c)\right]-1.0 Examples -------- >>> omega(CASRN='64-17-5') 0.635 Parameters ---------- CASRN : string CASRN [-] Returns ------- omega : float Acentric factor of compound methods : list, only returned if AvailableMethods == True List of methods which can be used to obtain omega with the given inputs Other Parameters ---------------- Method : string, optional The method name to use. Accepted methods are 'PSRK', 'PD', 'YAWS', 'LK', and 'DEFINITION'. All valid values are also held in the list omega_methods. AvailableMethods : bool, optional If True, function will determine which methods can be used to obtain omega for the desired chemical, and will return methods instead of omega IgnoreMethods : list, optional A list of methods to ignore in obtaining the full list of methods, useful for for performance reasons and ignoring inaccurate methods Notes ----- A total of five sources are available for this function. They are: * 'PSRK', a compillation of experimental and estimated data published in the Appendix of [15]_, the fourth revision of the PSRK model. * 'PD', an older compillation of data published in (Passut & Danner, 1973) [16]_. * 'YAWS', a large compillation of data from a variety of sources; no data points are sourced in the work of [17]_. * 'LK', a estimation method for hydrocarbons. * 'DEFINITION', based on the definition of omega as presented in [1]_, using vapor pressure data. References ---------- .. [1] Pitzer, K. S., D. Z. Lippmann, R. F. Curl, C. M. Huggins, and D. E. Petersen: The Volumetric and Thermodynamic Properties of Fluids. II. Compressibility Factor, Vapor Pressure and Entropy of Vaporization. J. Am. Chem. Soc., 77: 3433 (1955). .. [2] Horstmann, Sven, Anna Jabłoniec, Jörg Krafczyk, Kai Fischer, and Jürgen Gmehling. "PSRK Group Contribution Equation of State: Comprehensive Revision and Extension IV, Including Critical Constants and Α-Function Parameters for 1000 Components." Fluid Phase Equilibria 227, no. 2 (January 25, 2005): 157-64. doi:10.1016/j.fluid.2004.11.002. .. [3] Passut, Charles A., and Ronald P. Danner. "Acentric Factor. A Valuable Correlating Parameter for the Properties of Hydrocarbons." Industrial & Engineering Chemistry Process Design and Development 12, no. 3 (July 1, 1973): 365-68. doi:10.1021/i260047a026. .. [4] Yaws, Carl L. Thermophysical Properties of Chemicals and Hydrocarbons, Second Edition. Amsterdam Boston: Gulf Professional Publishing, 2014. ''' def list_methods(): methods = [] if CASRN in _crit_PSRKR4.index and not np.isnan(_crit_PSRKR4.at[CASRN, 'omega']): methods.append('PSRK') if CASRN in _crit_PassutDanner.index and not np.isnan(_crit_PassutDanner.at[CASRN, 'omega']): methods.append('PD') if CASRN in _crit_Yaws.index and not np.isnan(_crit_Yaws.at[CASRN, 'omega']): methods.append('YAWS') Tcrit, Pcrit = Tc(CASRN), Pc(CASRN) if Tcrit and Pcrit: if Tb(CASRN): methods.append('LK') if VaporPressure(CASRN=CASRN).T_dependent_property(Tcrit*0.7): methods.append('DEFINITION') # TODO: better integration if IgnoreMethods: for Method in IgnoreMethods: if Method in methods: methods.remove(Method) methods.append('NONE') return methods if AvailableMethods: return list_methods() if not Method: Method = list_methods()[0] # This is the calculate, given the method section if Method == 'PSRK': _omega = float(_crit_PSRKR4.at[CASRN, 'omega']) elif Method == 'PD': _omega = float(_crit_PassutDanner.at[CASRN, 'omega']) elif Method == 'YAWS': _omega = float(_crit_Yaws.at[CASRN, 'omega']) elif Method == 'LK': _omega = LK_omega(Tb(CASRN), Tc(CASRN), Pc(CASRN)) elif Method == 'DEFINITION': P = VaporPressure(CASRN=CASRN).T_dependent_property(Tc(CASRN)*0.7) _omega = -log10(P/Pc(CASRN)) - 1.0 elif Method == 'NONE': _omega = None else: raise Exception('Failure in in function') return _omega
def StielPolar(Tc=None, Pc=None, omega=None, CASRN='', Method=None, AvailableMethods=False): r'''This function handles the calculation of a chemical's Stiel Polar factor, directly through the definition of Stiel-polar factor if possible. Requires Tc, Pc, acentric factor, and a vapor pressure datum at Tr=0.6. Will automatically select a method to use if no Method is provided; returns None if the data is not available and cannot be calculated. .. math:: x = \log P_r|_{T_r=0.6} + 1.70 \omega + 1.552 Parameters ---------- Tc : float Critical temperature of fluid [K] Pc : float Critical pressure of fluid [Pa] omega : float Acentric factor of the fluid [-] CASRN : string CASRN [-] Returns ------- factor : float Stiel polar factor of compound methods : list, only returned if AvailableMethods == True List of methods which can be used to obtain Stiel polar factor with the given inputs Other Parameters ---------------- Method : string, optional The method name to use. Only 'DEFINITION' is accepted so far. All valid values are also held in the list Stiel_polar_methods. AvailableMethods : bool, optional If True, function will determine which methods can be used to obtain Stiel-polar factor for the desired chemical, and will return methods instead of stiel-polar factor Notes ----- Only one source is available for this function. It is: * 'DEFINITION', based on the definition of Stiel Polar Factor presented in [1]_, using vapor pressure data. A few points have also been published in [2]_, which may be used for comparison. Currently this is only used for a surface tension correlation. Examples -------- >>> StielPolar(647.3, 22048321.0, 0.344, CASRN='7732-18-5') 0.024581140348734376 References ---------- .. [1] Halm, Roland L., and Leonard I. Stiel. "A Fourth Parameter for the Vapor Pressure and Entropy of Vaporization of Polar Fluids." AIChE Journal 13, no. 2 (1967): 351-355. doi:10.1002/aic.690130228. .. [2] D, Kukoljac Miloš, and Grozdanić Dušan K. "New Values of the Polarity Factor." Journal of the Serbian Chemical Society 65, no. 12 (January 1, 2000). http://www.shd.org.rs/JSCS/Vol65/No12-Pdf/JSCS12-07.pdf ''' def list_methods(): methods = [] if Tc and Pc and omega: methods.append('DEFINITION') methods.append('NONE') return methods if AvailableMethods: return list_methods() if not Method: Method = list_methods()[0] if Method == 'DEFINITION': P = VaporPressure(CASRN=CASRN).T_dependent_property(Tc*0.6) if not P: factor = None else: Pr = P/Pc factor = log10(Pr) + 1.70*omega + 1.552 elif Method == 'NONE': factor = None else: raise Exception('Failure in in function') return factor