#Initialization of variables
import math
import numpy
from numpy import linalg
ndot=2400.0 #mol/s
Hr1= -2878 #Kj/mol
HvWater=44.0 #Kj/mol
HvButane=19.2 #Kj/mol
#Calculations and print '%s %.3f' %ing :
print (" All the values in the textbook are Approximated hence the values in this code differ from those of Textbook")
print ("Part 1")
E1= ndot/4
deltaH1=E1*Hr1
print '%s %.3E' %("enthalpy change (KJ/s) = ",deltaH1)
print ("part2")
Hr2=2*Hr1
E2=ndot/8
deltaH2=E2*Hr2
print '%s %.3E' %("Enthalpy change (kJ/s) = ",deltaH2)
print ("part 3")
Hr3=Hr1+5*HvWater+HvButane
deltaH3=E1*Hr3
print '%s %.3E' %("Enthalpy change (kJ/s) = ",deltaH3)
raw_input('press enter key to exit')
#Initialization of variables
import math
import numpy
from numpy import linalg
deltaHr= -420.8 #kj/mol
R=8.314
T=298.0 #K
#Calculations and printing :
print(" All the values in the textbook are Approximated hence the values in this code differ from those of Textbook")
print("From reaction, only gaseous are counted")
left=1+2
right=1+1
deltaUr=deltaHr-R*T*(right-left)/math.pow(10,3)
print '%s %.3f' %("deltaUr (KJ/mol) = ",deltaUr)
raw_input('press enter key to exit')
#Initialization of variables
import math
import numpy
from numpy import linalg
HCO2= -393.5 #KJ/mol
HH2O= -285.84 #KJ/mol
HC5H12= -173. #KJ/mol
#Calculations and printing :
print(" All the values in the textbook are Approximated hence the values in this code differ from those of Textbook")
Hr=5*HCO2+6*HH2O-HC5H12
print '%s %.3f' %(" \n Heat of the rxn (KJ/mol) = ",Hr)
raw_input('press enter key to exit')
#Initialization of variables
import math
import numpy
from numpy import linalg
Hethane= -1559.9 #Kj/mol
Hethene= -1411 #Kj/mol
Hhydrogen= -285.84 #Kj/mol
#Calculations and printing :
print(" All the values in the textbook are Approximated hence the values in this code differ from those of Textbook")
Hr=Hethane-Hethene-Hhydrogen
print '%s %.3f' %(" \n Heat of the rxn (KJ/mol) = ",Hr)
raw_input('press enter key to exit')
#Initialization of variables
import math
import numpy
from numpy import linalg
import scipy
from scipy import integrate
nNH3=100.0 #mol/s
nO2in=200.0 #mol/s
H1=8.470 #Kj/mol
H3=9.570 #Kj/mol
T1=25.0
T2=300.0
Hr= -904.7 #Kj/mol
#Calculations and printing :
print(" All the values in the textbook are Approximated hence the values in this code differ from those of Textbook")
def fun(T):
fun=29.50*math.pow(10,-3)+ T*0.8188*math.pow(10,-5) - math.pow(T,2) * 0.2925 *math.pow(10,-8) + math.pow(T,3) * 0.3652 * math.pow(10,-12)
return fun
H2, err=scipy.integrate.quad(fun,T1,T2) #scipy.integrate.quad is an inbuilt function which can calculate definite integrals
E=nNH3/4.
nO2out=nO2in-nNH3*5./4.
nNO=nNH3
nH2O=nNH3*6./4.
deltaH=E*Hr+(nO2out*H1+nNO*H2+nH2O*H3)
Qdot=deltaH
print '%s %.3f' %(" \n Heat Transferred (kW) = ",Qdot)
raw_input('press enter key to exit')
#Initialization of variables
import math
import numpy
from numpy import linalg
import scipy
from scipy import integrate
NinMethane=100.0 #mol
NinOxygen=100.0 #mol
NinNitrogen=376.0 #mol
NoutMethane=60.0 #mol
NoutOxygen=50.0 #mol
NoutNitrogen=376.0 #mol
NoutFormal=30.0 #mol
NoutCarbon=10.0 #mol
NoutWater=50.0 #mol
H1= -74.85 #Kj/mol
H2= 2.235 #Kj/mol
H3= 2.187 #Kj/mol
H5=3.758#Kj/mol
H6=3.655 #Kj/mol
H8= -393.5+4.75 #Kj/mol
H9= -241.83+4.27 #Kj/mol
T1=25.0 #C
T2=150.0 #C
#Calculations and printing :
print(" All the values in the textbook are Approximated hence the values in this code differ from those of Textbook")
def fun1(T):
fun1=34.31*math.pow(10,-3)+ T*5.469*math.pow(10,-5) + math.pow(T,2) * 0.3661 *math.pow(10,-8) - math.pow(T,3) * 11 * math.pow(10,-12)
return fun1
HoutMethane, err=scipy.integrate.quad(fun1,T1,T2)
H4= -74.85 + HoutMethane
def fun2(T):
fun2=34.28*math.pow(10,-3)+ T*4.268*math.pow(10,-5) - math.pow(T,3) * 8.694 * math.pow(10,-12)
return fun2
HoutFormal, err2=scipy.integrate.quad(fun2,T1,T2) #scipy.integrate.quadis an inbuilt function which can calculate definite integrals
H7= -115.90+ HoutFormal
deltaH=NoutWater*H9+NoutCarbon*H8+NoutFormal*H7+NoutNitrogen*H6+NoutOxygen*H5+NoutMethane*H4-NinNitrogen*H3-NinOxygen*H2-NinMethane*H1
Q=deltaH
print '%s %.3f' %(" \n Q (KJ) = ",Q)
raw_input('press enter key to exit')
#Initialization of variables
import math
import numpy
from numpy import linalg
basis=150.0 #mol/s
x=0.9
HinEthanol= -212.19
HinEthanone= -147.07
HoutEthanol= -216.81
HoutEthanone= -150.9
HoutHydrogen=6.595
NinEthanol=135.0
NinEthanone=15.0
Q=2440.0 #KW
#Calculations and printing :
print(" All the values in the textbook are Approximated hence the values in this code differ from those of Textbook")
print("Carbon Balance")
print("basis*x *2 + basis* (1-x) *2=2 n1+2 n2")
print("Hydrogen Balance")
print("basis * x *6 + basis * (1-x)*4 = 6 n1+4 n2+2 n3")
print("Energy Balance")
print("Q= HoutEthanol n1 HoutEthanone n2 + HoutHydrogen n3 -NinEthanol * HinEthanol -NinEthanone* HinEthanone")
A=([[1, 1, 0],[3, 2, 1],[216.81, 150.9, -6.595]])
b=([[150],[435],[28412]])
C=numpy.dot(linalg.inv(A),b)
n1=C[0,0]
print '%s %.3f' %(" \n n1 (mol Ethanol/s) = ",n1)
n2=C[1,0]
print '%s %.3f' %(" \n n2 (mol Ethanone/s) = ",n2)
n3=C[2,0]
print '%s %.3f' %(" \n n3 (mol Hydrogen/s) = ",n3)
print("The solutions in the Text are Wrong")
fraction=(NinEthanol-n1)/NinEthanol
print '%s %.3f' %("Fractional conversion of Ethanol = ",fraction)
raw_input('press enter key to exit')
#Initialization of variables
import math
import numpy
from numpy import linalg
print("from tables,")
HfAcid= -1294. #Kj/mol
HfBase= -469.1 #Kj/mol
HfSalt= -1974. #Kj/mol
HfWater= -285.8 #Kj/mol
#Calculations and printing :
print(" All the values in the textbook are Approximated hence the values in this code differ from those of Textbook")
print("part 1")
Hr=HfSalt+3*HfWater-HfAcid-3*HfBase
print '%s %.3f' %("Hr of the rxn (KJ/mol) = ",Hr)
print("part 2")
deltaH=Hr*5./3.
print '%s %.3f' %("deltaH (KJ) = ",deltaH)
raw_input('press enter key to exit')
import math
import numpy
from numpy import linalg
x=0.1
y=0.2
MAcid=98.1
MS=32.0
MSalt=142.0
MBase=40.0
MWater=18.0
MNa=46.0
basis=1000.0 #g
T2=35.0
T1=25.0
T3=40.0
#Calculations and printing :
print(" All the values in the textbook are Approximated hence the values in this code differ from those of Textbook")
print("Using S balance, ")
m2=basis*x*MS*MSalt/(MAcid*MS)
print '%s %.3f' %(" \n m2 (g Na2SO4) = ",m2)
print("Using Na balance, ")
m1=2*MNa*m2*MBase/(y*MNa*MSalt)
print '%s %.3f' %(" \n m1 (g NaOH) = ",m1)
print("Total mass balance, ")
m3=basis+m1-m2
print '%s %.3f' %(" \n m3 (g H2O) = ",m3)
print '%s %.3f' %(" \n Mass of product solution = ",m2+m3)
m=m2+m3
Water=m2*2/MSalt
print '%s %.3f' %(" \n Water Formed in the reaction (mol H2O) = ",Water)
print("H2SO4(aq):")
a1=basis*(1-x)/MWater
b1=basis*x/MAcid
rAcid=a1/b1
print '%s %.3f' %(" \n rAcid (mol Water/mol Acid) = ",rAcid)
print("NaOH(aq):")
a2=m1*(1-y)/MWater
b2=m1*y/MBase
rBase=a2/b2
print '%s %.3f' %(" \n rBase (mol Water/mol Base) = ",rBase)
print("Na2SO4(aq):")
a3=m3/MWater
b3=m2/MSalt
rSalt=a3/b3
print '%s %.3f' %(" \n rSalt (mol Water/mol Salt) =",rSalt)
E=b1
print '%s %.3f' %(" \n Extent of reaction (mol) = ",E)
nHAcid=basis*3.85*(T3-T1)/1000
nHSalt=m*4.184*(T2-T1)/1000
nHBase=0
HfSalt= -1384
HfAcid= -884.6
HfBase= -468.1
HfWater= -285.84
deltaHr=HfSalt+ 2*HfWater - HfAcid - 2*HfBase
print '%s %.3f' %(" \n Entahlpy change in the rxn (KJ/mol) = ",deltaHr)
Q=E*deltaHr + (nHSalt-nHAcid-nHBase)
print '%s %.3f' %(" \n Q of the rxn (KJ) = ",Q)
print("The answer in the Text is wrong.")
raw_input('press enter key to exit')
#Initialization of variables
import math
import numpy
from numpy import linalg
x=0.85
H1= 802 #KJ/mol
H2= 1428 #kJ/mol
M1=16.0
M2=30.0
#Calculations and printing :
print(" All the values in the textbook are Approximated hence the values in this code differ from those of Textbook")
y1=x*16
y2=(1-x)*30
xCH4=y1/(y1+y2)
HHVMethane=(H1+ 2*44.013)/M1
HHVEthane=(H2+ 3*44.013)/M2
HHV=xCH4*HHVMethane + (1-xCH4)*HHVEthane
print '%s %.3f' %(" \n HHV of Fuel (KJ/g) = ",HHV)
raw_input('press enter key to exit')