#calculate the dHp value
#Initialization of variables
n1=10 #mol
n2=12 #mol
#calculations
dn=n1-n2
#results
print '%s %d %s' %("dHp = dEv-",dn,"*RT")
#calculate the Enthalpy
#Initialization of variables
Ht1=-22063 #cal
T=298.15 #K
#calculations
H=Ht1 +0.5293*T + 0.3398*10**-3 *T**2 - 2.039*10**-7 *T**3
#results
print '%s %d %s' %("Enthalpy =",H,"cal")
#calculate the Entropy
#Initialization of variables
Cp=0.797 #cal/deg/mol
#calculations
S=Cp/3.
#results
print '%s %.3f %s' %("Entropy =",S," eu/mol")
#calculate the Change in entropy
#Initialization of variables
T1=77.32 #K
P=1 #atm
T2=126 #K
Pc=33.5 #atm
#calculations
dS=27/32. *1.987*P/Pc *(T2/T1)**3
#results
print '%s %.2f %s' %("Change in entropy =",dS,"eu/mol")
#calculate the Change in entropy, enthalpy and free energy
#Initialization of variables
S1=57.47
S2=50.34
S3=49
H1=8.09
H2=21.06
H3=0
F1=12.39
F2=20.72
F3=0
#calculations
dS=S1-S2-0.5*S3
dH=H1-H2-0.5*H3
dF=F1-F2-0.5*F3
#results
print '%s %.2f %s' %("Change in entropy =",dS," eu")
print '%s %.2f %s' %("\n Change in enthalpy =",dH," kcal")
print '%s %.2f %s' %("\n Change in free energy =",dF,"kcal")
#calculate the change in free energy
#Initialization of variables
import math
P1=0.01
P2=0.1
P3=0.01
dF0=-54640 #cal
T=298.15 #K
R=1.987 #cal/deg
#calculations
Qp=P1/(P2*P3**0.5)
dF=dF0+R*T*math.log(Qp)
#results
print '%s %d %s' %("change in free energy =",dF,"cal")
#calculate the Equilibrium constant
#Initialization of variables
print "From table 13.4 "
logKfwater=40.04724
logKfH2=0
logKfO2=0
#calculations
logK=logKfwater-logKfH2-0.5*logKfO2
K=10**logK
#results
print '%s %.4e' %("Equilibrium constant = ",K)
#calculate the value of Kc
#Initialization of variables
Kp=1.1*10**40 #atm**-0.5
dn=-0.5
R=0.08206 #lt atm/deg mol
T=298.15 #K
#calculations
Kc=Kp*(R*T)**(-dn)
#results
print '%s %.1e %s' %("Kc =",Kc," (mol/lt)^-0.5")
#calculate the Density of equilibrium mixture
#Initialization of variables
import numpy
Kp=0.141 #atm
P=1 #atm
nu=2
R=0.08206 #lt atm/deg mol
T=298.15 #K
M=92.02 #g/mol
#calculations
p=([Kp+ 4*P,0, -Kp])
z=numpy.roots(p)
alpha=z[0]
wbyV=P*M/(R*T*(1+(nu-1)*alpha))
#results
print '%s %.2f %s' %("Density of the equilibrium mixture =",wbyV," g/lt")
#calculate the Final pressure after equilibrium
#Initialization of variables
x=0.5
P=0.468 #atm
#calculations
P1=x*P
P2=x*P
Kp=P1*P2
#results
print '%s %.4f %s' %("Final pressure after equilibrium =",Kp," atm^2")