# Variables
basis = 1 #kmol n bumath.tane
P = 1.013*10**5 #N/m**2
R = 8.3143*10**3 #J/kmol K
T = 272.6 #K
# Calculations
V = basis*R*T/P
Ts = 373.1 #K
Vs = basis*R*Ts/P
# Results
print "Volume in case 1 = %.2f m**3"%(V)
print " Volume in case 2 = %.2f m**3"%(Vs)
# Variables
Vb = 30 #m**3/kmol
P = 1.013*10**5 #Pa
R = 8.3143*10**3 #J/kmol K
T = 373.1 #K
# Calculations
Z = P*Vb/(R*T)
# Results
print "Compressibility factor = %.3f"%(Z)
import math
# Variables
Pc = 22.12*10**6 #Pa
Tc = 647.3 #K
Vc = 0.05697 #m**3/Kmol
R = 8.3143*10**3
Tr = 0.7
# Calculations
Zc = Pc*Vc/(R*Tc)
T = Tr*Tc
Ps = 10**6 #Pa
w = -math.log10(Ps/Pc) -1
# Results
print "critical compressibility factor = %.3f"%(Zc)
print " Accentric factor = %.4f"%(w)
# Variables
basis = 1 #kmol ammonia
P = 10**6 #pa
a = 4.19
b = 0.0373
R = 8314.3
Tc = 405.5
Pc = 11.28*10**6
# Calculations
print ("case a")
print ("Umath.sing vandwerwaals equation, ")
print ("(P+a/v**2)*(V-b) = R*T, on solving by trail and error method,")
V = 3
print "Volume = %d m**3/kmol"%(V)
# Variables
basis = 1. #kmol ammonia
P = 10.**6 #pa
a = 4.19
b = 0.0373
R = 8314.3
Tc = 405.5
Pc = 11.28*10**6
# Calculations
print ("part b")
an = 27*R**2*Tc**2 /(64*Pc)
bn = R*Tc/(8*Pc)
V = 3
# Results
print "Since an and bn are same as a and b, V is the same = %d m**3/kmol"%(V)
# note : rounding off error.
# Variables
print ("part c")
print ("USing SRK equation, P = RT/(V-b) -alph*a/(V*(V+b))")
print ("By trail and error method,")
# Calculations
v2 = 2.98
# Results
print "volume = %.2f m**3/kmol"%(v2)
# Variables
Pc = 22.12*10**6 #Pa
Tc = 647.3 #K
Zc = 0.234
T = 973.1 #K
P = 25*10**6 #Pa
# Calculations
Tr = T/Tc
Pr = P/Pc
Z = 0.916
Zn = Z+0.05*(Zc-0.27)
# Results
print "Compresson factor = %.3f "%(Zn)
# Variables
w = 0.3448
Z0 = 0.898
Z1 = 0.08
# Calculations
Z = Z0 + Z1*w
# Results
print "Compression factor = %.3f "%(Z)