# Variables
T_c = 370. ; #[K]
P_c = 41.58 * 10**5 ; #[N/m**2]
R = 8.314 ;
V1 = 0.001 ; #[m**3]
V2 = 0.04 ; #[m**3]
q = 10400. ; #[J]
# Calculations
a = 27./64 * (R **2)*(T_c)**2 / P_c ;
del_U = -0.96 * (1 / V2 - 1 / V1) ;
W = round(del_U - q,-1) ;
# Results
print " Work done for the expansion = %.f J/mol"%(W) ;
from scipy.optimize import fsolve
from scipy.integrate import quad
import math
# Variables
P_1 = 9.43 * 10**5 ; #[N/m**2]
P_2 = 18.9 * 10**5 ; #[N/m**2]
T_1 = 80 + 273 ; #[K]
T_2 = 120 + 273 ; #[K]
A = 1.935 ;
B = 36.915 * 10**-3 ;
C = -11.402 * 10**-6 ;
T_c = 425.2 ; # [K]
P_c = 37.9 * 10**5 ; #[N/m**2]
R = 8.314 ;
del_h_1 = 1368 ; #[J/mol]
del_h_3 = -2542 ; #[J/mol]
Ws = 2100. ; #[J/mol]
a = 0.42748 * R**2 * T_c**2.5 / P_c ;
b = 0.08664 * R * T_c / P_c ;
def f1(v):
return R * T_1 / (v - b) - a / (math.sqrt(T_1) * v *(v + b)) - P_1;
za= fsolve( f1,0.001)
def f2(v):
return R * T_2 / (v - b) - a / (math.sqrt(T_2) * v *(v + b)) - P_2;
zb= fsolve( f2,0.001)
v1 = zb
v2 = zb
def f3(v):
T = 353.15
return b*R*T/(v-b) + a/T**0.5 * (3./(2*b) * math.log(v/(v+b)) - 1./(v+b))
delta_h1 = quad(f3,za,zb)
def f(T):
return R * ( A * T + B/2 * T**2 + C/3 * T**3) ;
del_h_2 = f(T_2) - f(T_1) ;
del_h_total = del_h_1 + del_h_2 + del_h_3 ;
q = del_h_total - Ws ;
# Results
print "v1 = %.2e m**3/mol, v2 = %.2e m**3/mol"%(za,zb ) ;
print "The heat input = %.f J/mol"%(q);
# Note : answer is slightly different because of rounding error.
from sympy import log
from sympy.solvers import solve
from sympy import Symbol
#Variables
A = 2.104 ;
B = 2.98 * 10**-3 ;
R = 8.314 ;
Beta = 3.5 * 10**-5 ;
v = 7.1 * 10**-6 # m**3/mol
P2 = 10000*10**5 ; #[N/m**2]
P1 =1 ; #[N/m**2]
#Calculations
T2 = Symbol('T2')
q = solve(A*R*log(T2/1000)+B*R*(T2-1000)-(Beta*v*(P2-P1)),T2)
#Result
print "Heat input = ",q,"J/mol"
from scipy.integrate import quad
# Variables ( same as example 5.4)
R = 8.314
Tc = 425.2 # K
Pc = 37.9 # bar
w = 0.199
T1 = 353.15 # K
Tc = 425.2 # K
P1 = 9.47 # bar
Pc = 38. # bar
T2 = 393.15 # K
P2 = 18.9 # bar
R = 8.314
# calculations
T1r = T1/Tc
P1r = P1/Pc
T2r = T2/Tc
P2r = P2/Pc
def f(T):
return 1.935 + 36.915 * 10**-3 * T - 11.402 * 10**-6 * T**2
cpDt = R * quad(f,353,393)[0]
h2h1 = .536 * R*Tc +cpDt - .969*R*Tc
# Results
print "the heat capacity = %.f J/mol"%cpDt
print "h2 - h1 = %.f J/mol"%h2h1
# Note : answer is slightly differnt becuase of rounding off error. and this problem is same as 5.4
import math
from scipy.integrate import quad
# Variables
T_c = 126.2; #[K] , From appendix A.1
P_c = 33.8 * 10**5 ; #[N/m**2] , From appendix A.1
w = 0.039 ; # From appendix A.1
enth_dep_1 = -2.81 ; # From table C.1 Appendix C
A = 3.28 ; # From Appendix A.2
B = 0.593 * 10**-3 ; # From Appendix A.2
del_h_dep_l = -5.1 ;
del_h_dep_v = -0.1 ;
T1 = 151. #[K]
P1 = 100. * 10**5 ; #[N/m**2]
P2 = 1. * 10**5 ; #[N/m**2]
T2_r = 0.61 ; # From figure 5.4
# Calculations
T1_r = T1 / T_c ;
P1_r = round(P1 / P_c) ;
P2_r = P2 / P_c ;
T2 = round(T2_r * T_c) ; #[K]
def f(T):
#return A * T + B/2 * T**2
return A + B*T
ans = quad(f,151,T2)[0]
x = 1. / T_c *ans
y = enth_dep_1 - x ;
# Results
X = ( y - del_h_dep_l) / (del_h_dep_v - del_h_dep_l);
print "Quality = %.2f"%(X) ;
# Note: answer is different because of quad is giving different value -1.9 instead of -1.28.