# Chapter 18 - Ion Exchange¶

## Page 1062 Example 18.1¶

In [23]:
%matplotlib inline
from matplotlib.pyplot import plot,title,xlabel,ylabel,show
from math import pi,exp

Cse=0.132#        #in kg/kg
Cs = [0.091, 0.097 ,0.105 ,0.113 ,0.125 ,0.128, 0.132]
C=[];C1=[];C2=[]
for cc in Cs:
C.append(cc/Cse)
for cc in C:C1.append(1-cc)
for cc in C:C2.append(1-cc**2)
t = [2, 4 ,10 ,20 ,40 ,60 ,120]

plot(t,C1,t,C2)
title('1-(Cs/Cs* vs t(min)')
xlabel("1-(Cs/Cs*)")
ylabel('t(min)')
show()
#From the plot π**2Dr/ri**2 = 0.043
#For a pellet of twice the radius, that is r = 2ri
Slope = -0.043/4
print"\n Slope = %.3f"%(Slope)

#Thus, when the radius = 2ri
def equation1(t):
x = 1-(6/(pi)**2)*exp(-Slope*t)
return x

#CS/CS*=[1 − exp(−κDR/tri**2)]**0.5
#κDR/ri**2 = 0.04
#For a pellet twice the size

def equation2(t):

x1 = (1-exp(-0.01*t))**0.5
return x1

print"\n t(min)               Cs(kg/kg)       "
print"\n                       equation(i)         equation(ii)  "
t = [4 ,20, 60]#               #t is in min
i=0
while i<=2:
print"\n %.3f                  %.3f                      %.3f        "%(t[(i)],Cse*equation1(t[(i)]),Cse*equation2(t[(i)]))
i=i+1


 Slope = -0.011

t(min)               Cs(kg/kg)

equation(i)         equation(ii)

4.000                  0.048                      0.026

20.000                  0.033                      0.056

60.000                  -0.021                      0.089


## Page 1072 Example 18.2¶

In [8]:
from sympy import symbols,solve

c_NaNO3 = 2.0#               #per cent by mass
print"\n Concentration of NaNO3 is %.3f kg/m**3"%((c_NaNO3/85)*(103/100))

#HNO3 (Molecular weight = 63 kg/kmol)
#Concentration = p per cent
#Concentration = (10p/63)(1030/1000)= 0.163p kg/m3
#In the solution: xNa+ = 0.242/(0.242 + 0.163p)
#For univalent ion exchange
#yNa+/(1 − yNa+ ) = KNa+H + [xNa+ /(1 − xNa+)]

yNa = 0.1
K_NaH = 2/1.3
p = symbols('p')
p1 = solve((0.1/0.9)*(0.163*p*(0.242+0.163*p))-1.5*(0.242*(0.242+0.163*p)))
print"\n p = %d percent"%(p1[1])

 Concentration of NaNO3 is 0.024 kg/m**3

p = 20 percent