Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
was available for the fluid.
Analytical integrals are available for this expression.
Examples
--------
>>> Zabransky_quasi_polynomial(330, 591.79, -3.12743, 0.0857315, 13.7282, 1.28971, 6.42297, 4.10989)
165.4728226923247
References
----------
.. [1] Zabransky, M., V. Ruzicka Jr, V. Majer, and Eugene S. Domalski.
Heat Capacity of Liquids: Critical Review and Recommended Values.
2 Volume Set. Washington, D.C.: Amer Inst of Physics, 1996.
'''
Tr = T/Tc
return R*(a1*log(1-Tr) + a2/(1-Tr) + a3 + a4*Tr + a5*Tr**2 + a6*Tr**3)
dP_dT = R/x0 - da_alpha_dT/x1
dP_dV = -x3*x4 + x5*x7
d2P_dT2 = -d2a_alpha_dT2/x1
d2P_dV2 = -2.*a_alpha*x5*x5*x1**-3 + 2.*x7 + 2.*x3*x0**-3
d2P_dTdV = -R*x4 + da_alpha_dT*x5*x6
H_dep = x12*(T*da_alpha_dT - a_alpha) - x3 + x8
S_dep = -R*log((V*x3/(x0*x8))**2)/2. + da_alpha_dT*x12 # Consider Real part of the log only via log(x**2)/2 = Re(log(x))
Cv_dep = -T*d2a_alpha_dT2*x13*(-log(((x14 - x15 + x16)/(x14 + x15 - x16))**2)*0.5) # Consider Real part of the log only via log(x**2)/2 = Re(log(x))
else:
dP_dT = R/(V - b) - da_alpha_dT/(V**2 + V*delta + epsilon)
dP_dV = -R*T/(V - b)**2 - (-2*V - delta)*a_alpha/(V**2 + V*delta + epsilon)**2
d2P_dT2 = -d2a_alpha_dT2/(V**2 + V*delta + epsilon)
d2P_dV2 = 2*(R*T/(V - b)**3 - (2*V + delta)**2*a_alpha/(V**2 + V*delta + epsilon)**3 + a_alpha/(V**2 + V*delta + epsilon)**2)
d2P_dTdV = -R/(V - b)**2 + (2*V + delta)*da_alpha_dT/(V**2 + V*delta + epsilon)**2
H_dep = P*V - R*T + 2*(T*da_alpha_dT - a_alpha)*catanh((2*V + delta)/sqrt(delta**2 - 4*epsilon)).real/sqrt(delta**2 - 4*epsilon)
S_dep = -R*log(V) + R*log(P*V/(R*T)) + R*log(V - b) + 2*da_alpha_dT*catanh((2*V + delta)/sqrt(delta**2 - 4*epsilon)).real/sqrt(delta**2 - 4*epsilon)
Cv_dep = -T*(sqrt(1/(delta**2 - 4*epsilon))*log(V - delta**2*sqrt(1/(delta**2 - 4*epsilon))/2 + delta/2 + 2*epsilon*sqrt(1/(delta**2 - 4*epsilon))) - sqrt(1/(delta**2 - 4*epsilon))*log(V + delta**2*sqrt(1/(delta**2 - 4*epsilon))/2 + delta/2 - 2*epsilon*sqrt(1/(delta**2 - 4*epsilon))))*d2a_alpha_dT2
return [dP_dT, dP_dV, d2P_dT2, d2P_dV2, d2P_dTdV, H_dep, S_dep, Cv_dep]
7-13. doi:10.1016/j.fluid.2008.03.007.
.. [2] Walas, Stanley M. Phase Equilibria in Chemical Engineering.
Butterworth-Heinemann, 1985.
'''
if self.phase in ['l', 'l/g']:
if xs is None:
xs = self.zs
self.phis_l = self.fugacity_coefficients(self.Z_l, zs=xs)
self.fugacities_l = [phi*x*self.P for phi, x in zip(self.phis_l, xs)]
self.lnphis_l = [log(i) for i in self.phis_l]
if self.phase in ['g', 'l/g']:
if ys is None:
ys = self.zs
self.phis_g = self.fugacity_coefficients(self.Z_g, zs=ys)
self.fugacities_g = [phi*y*self.P for phi, y in zip(self.phis_g, ys)]
self.lnphis_g = [log(i) for i in self.phis_g]
Ammonia, from [1]_.
>>> Campbell_Thodos(T=405.45, Tb=239.82, Tc=405.45, Pc=111.7*101325, M=17.03, dipole=1.47)
7.347363635885525e-05
References
----------
.. [1] Campbell, Scott W., and George Thodos. "Prediction of Saturated
Liquid Densities and Critical Volumes for Polar and Nonpolar
Substances." Journal of Chemical & Engineering Data 30, no. 1
(January 1, 1985): 102-11. doi:10.1021/je00039a032.
'''
Tr = T/Tc
Tbr = Tb/Tc
Pc = Pc/101325.
s = Tbr * log(Pc)/(1-Tbr)
Lambda = Pc**(1/3.)/(M**0.5*Tc**(5/6.))
alpha = 0.3883 - 0.0179*s
beta = 0.00318*s - 0.0211 + 0.625*Lambda**(1.35)
if dipole:
theta = Pc*dipole**2/Tc**2
alpha -= 130540 * theta**2.41
beta += 9.74E6 * theta**3.38
if hydroxyl:
beta = 0.00318*s - 0.0211 + 0.625*Lambda**(1.35) + 5.90*theta**0.835
alpha = (0.69*Tbr - 0.3342 + 5.79E-10/Tbr**32.75)*Pc**0.145
Zra = alpha + beta*(1-Tr)
Vs = R*Tc/(Pc*101325)*Zra**(1+(1-Tr)**(2/7.))
return Vs
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]
Notes
-----
The object must be flashed before this routine can be used. It
depends on the properties T, P, zs, V_over_F, HeatCapacityGases,
EnthalpyVaporizations, VaporPressures, and xs.
References
----------
.. [1] Poling, Bruce E. The Properties of Gases and Liquids. 5th edition.
New York: McGraw-Hill Professional, 2000.
'''
S = 0
T = self.T
P = self.P
S -= R*sum([zi*log(zi) for zi in self.zs if zi > 0]) # ideal composition entropy composition; chemsep checked
# Both of the mixing and vapor pressure terms have negative signs
# Equation 6-4.4b in Poling for the vapor pressure component
# For liquids above their critical temperatures, Psat is equal to the system P (COCO).
if self.phase == 'g':
S -= R*log(P/101325.) # Gas-phase ideal pressure contribution (checked repeatedly)
for i in self.cmps:
S += self.HeatCapacityGases[i].T_dependent_property_integral_over_T(298.15, T)
elif self.phase == 'l':
Psats = self._Psats(T)
for i in self.cmps:
Sg298_to_T = self.HeatCapacityGases[i].T_dependent_property_integral_over_T(298.15, T)
Hvap = self.EnthalpyVaporizations[i](T)
if Hvap is None:
Hvap = 0 # Handle the case of a package predicting a transition past the Tc
Svap = -Hvap/T # Do the transition at the temperature of the liquid
S_P = -R*log(Psats[i]/101325.)
interpolation_property = lambda self, P: log(P)
'''log(P) interpolation transformation by default.'''
B0 = 0.1445 - 0.33/Tr - 0.1385/Tr**2 - 0.0121/Tr**3 - 0.000607/Tr**8
B1 = 0.0637 + 0.331/Tr**2 - 0.423/Tr**3 - 0.008/Tr**8
elif order == 1:
B0 = 33*Tc/(100*T**2) + 277*Tc**2/(1000*T**3) + 363*Tc**3/(10000*T**4) + 607*Tc**8/(125000*T**9)
B1 = -331*Tc**2/(500*T**3) + 1269*Tc**3/(1000*T**4) + 8*Tc**8/(125*T**9)
elif order == 2:
B0 = -3*Tc*(27500 + 34625*Tc/T + 6050*Tc**2/T**2 + 1821*Tc**7/T**7)/(125000*T**3)
B1 = 3*Tc**2*(331 - 846*Tc/T - 96*Tc**6/T**6)/(500*T**4)
elif order == 3:
B0 = 3*Tc*(8250 + 13850*Tc/T + 3025*Tc**2/T**2 + 1821*Tc**7/T**7)/(12500*T**4)
B1 = 3*Tc**2*(-662 + 2115*Tc/T + 480*Tc**6/T**6)/(250*T**5)
elif order == -1:
B0 = 289*T/2000. - 33*Tc*log(T)/100. + (969500*T**6*Tc**2 + 42350*T**5*Tc**3 + 607*Tc**8)/(7000000.*T**7)
B1 = 637*T/10000. - (23170*T**6*Tc**2 - 14805*T**5*Tc**3 - 80*Tc**8)/(70000.*T**7)
elif order == -2:
B0 = 289*T**2/4000. - 33*T*Tc*log(T)/100. + 33*T*Tc/100. + 277*Tc**2*log(T)/2000. - (254100*T**5*Tc**3 + 607*Tc**8)/(42000000.*T**6)
B1 = 637*T**2/20000. - 331*Tc**2*log(T)/1000. - (44415*T**5*Tc**3 + 40*Tc**8)/(210000.*T**6)
else:
raise Exception('Only orders -2, -1, 0, 1, 2 and 3 are supported.')
Br = (B0+omega*B1)
return Br*R*Tc/Pc
Industrial & Engineering Chemistry Fundamentals 22, no. 1 (February 1,
1983): 90-97. doi:10.1021/i100009a016.
.. [2] Reid, Robert C.; Prausnitz, John M.; Poling, Bruce E.
Properties of Gases and Liquids. McGraw-Hill Companies, 1987.
'''
Cs = [2.907741307E6, -3.312874033E6, 1.608101838E6, -4.331904871E5,
7.062481330E4, -7.116620750E3, 4.325174400E2, -1.445911210E1,
2.037119479E-1]
Tr = T/Tc
if Tr > 2:
Tr = 2
Vr = Vm/Vc
if Vr > 2:
Vr = 2
theta = 1 + (omega - 0.011)*(0.09057 - 0.86276*log(Tr) + (0.31664 - 0.46568/Tr)*(Vr-0.5))
psi = (1 + (omega-0.011)*(0.39490*(Vr-1.02355) - 0.93281*(Vr-0.75464)*log(Tr)))*0.288/Zc
f = Tc/190.4*theta
h = Vc/9.92E-5*psi
T0 = T/f
rho0 = 16.04/(Vm*1E6)*h # Vm must be in cm^3/mol here.
eta0 = 1E-7*sum([Cs[i]*T0**((i+1-4)/3.) for i in range(len(Cs))])
k1 = 1944*eta0
b1 = -0.25276920E0
b2 = 0.334328590E0
b3 = 1.12
b4 = 0.1680E3
k2 = (b1 + b2*(b3 - log(T0/b4))**2)/1000.*rho0
a1 = -7.19771
a2 = 85.67822
a3 = 12.47183