Chapter 10 - The rates of reactions

Example E1 - Pg 222

In [1]:
#Calculate the overall rate constant and hence the overall rate law
#Initialization of variables
%matplotlib inline
import math
import numpy as np
from numpy import linalg
import matplotlib
from matplotlib import pyplot
def fun(x,n):
	for i in range(0,len(x)):
		x[i]=x[i]*math.pow(10,-n)
	return

I=([1., 2., 4., 6.])
r1=([1.070, 3.48, 13.9, 31.3])
r2=([4.35, 17.4, 69.6, 157])
r3=([10.69, 34.7, 138, 313])
Ar=([1., 5., 10.])
fun(r1,3)
fun(I,5)
fun(r2,3)
fun(r3,3)
fun(Ar,3)
#calculations
def fun1(x):
	for i in range(0,len(x)):
		x[i]=math.log10(x[i])
	return x

logI=fun1(I)
logr1=fun1(r1)
logr2=fun1(r2)
logr3=fun1(r3)
#The calculations are approximate.hence the value differs from textbook a bit.
x=logI
y=logr1
A = np.vstack([x, np.ones(len(x))]).T
m1, b1 = np.linalg.lstsq(A, y)[0]

y=logr2
A = np.vstack([x, np.ones(len(x))]).T
m2, b2 = np.linalg.lstsq(A, y)[0]

y=logr3
A = np.vstack([x, np.ones(len(x))]).T
m3, b3 = np.linalg.lstsq(A, y)[0]

logAr=fun1(Ar)
kdash=([b1, b2, b3])
pyplot.plot(logAr,kdash)
pyplot.xlabel('log(Ar)')
pyplot.ylabel('log(kdash)')
x=logAr
y=kdash

A = np.vstack([x, np.ones(len(x))]).T
m4, b4 = np.linalg.lstsq(A, y)[0]

logk=b4
k=math.pow(10,logk)
#results
print '%s %.1e %s' %("Overall rate law is r =",k," [I]^2 [Ar]")
pyplot.show()
print '%s' %('The answers in the textbook are rounded and hence a bit different from the code.')
Populating the interactive namespace from numpy and matplotlib
Overall rate law is r = 8.1e+09  [I]^2 [Ar]
The answers in the textbook are rounded and hence a bit different from the code.

Example E2 - Pg 224

In [8]:
#calcualte the rate constant for the given first order reaction
#Initialization of variables
import math
import numpy as np
import matplotlib
from matplotlib import pyplot
t=([0, 1000., 2000., 3000., 4000.])
p=[10.20, 5.72, 3.99, 2.78, 1.94]
def fun2(x):
	for i in range(0,len(x)):
		x[i]=math.log(x[i])
	return x
lnp=fun2(p)
x=t
y=lnp
#hence the value differs from textbook a bit.
A = np.vstack([x, np.ones(len(x))]).T
m1, b1 = np.linalg.lstsq(A, y)[0]
k= -m1
pyplot.plot(x,y)
pyplot.xlabel('time t/sec ')
pyplot.ylabel('ln(P/Torr)')
#Since first order reaction
#results
print '%s %.2e %s' %("rate constant =",k," s^-1")
pyplot.show()
rate constant = 4.04e-04  s^-1

Example E3 - Pg 230

In [19]:
#Calculate the Activation energy and Arrhenius factor
#Initialization of variables
import math
import numpy as np
from numpy import linalg
T=[700, 730, 760, 790, 810, 840, 910, 1000]
k=[0.011, 0.035, 0.105, 0.343, 0.789, 2.17, 20, 145]
#calculations
def fun1(x):
	for i in range(0,len(x)):
		x[i]=1000./(x[i])
	return x
x= fun1(T)
def fun2(x):
	for i in range(0,len(x)):
		x[i]=math.log(x[i])
	return x
y=fun2(k)
A = np.vstack([x, np.ones(len(x))]).T
m1, b1 = np.linalg.lstsq(A, y)[0]
print '%s' %('from graph')
Ea=-m1*8.3145/1000. *1000.
A=math.pow(math.e,(b1))
#results
print '%s %d %s' %("Activation energy =",Ea," kJ/mol")
print '%s %.2e %s' %("\n Arrhenius factor =",A,"L/ mol s")
from graph
Activation energy = 188  kJ/mol

 Arrhenius factor = 1.08e+12 L/ mol s

Example I1 - Pg 228

In [20]:
#calculate the net time required
#Initialization of variables
import math
t=28.4 #min
#calculations
n=math.log10(8.) / math.log10(2.)
time=n*t
#results
print '%s %.1f %s' %("Time required =",time,"min")
Time required = 85.2 min

Example I2 - Pg 230

In [21]:
#calculate the value of kdash
#Initialization of variables
import math
E=50*1000. #J/mol
T1=25+273. #K
T2=37+273. #K
#calculations
ln=E/8.3145 *(1./T1-1./T2)
factor=math.pow(math.e,(ln))
#results
print '%s %.2f %s' %("kdash =",factor,"k")
kdash = 2.18 k