Presentation is loading. Please wait.

Presentation is loading. Please wait.

A Selection of Physical Chemistry Problems Solved using Mathematica Housam BINOUS National Institute of Applied Sciences and Technology

Similar presentations


Presentation on theme: "A Selection of Physical Chemistry Problems Solved using Mathematica Housam BINOUS National Institute of Applied Sciences and Technology"— Presentation transcript:

1 A Selection of Physical Chemistry Problems Solved using Mathematica Housam BINOUS National Institute of Applied Sciences and Technology 1- Applied Thermodynamics 2- Chemical Kinetics

2 Azeotropes for Ternary Systems Case of Acetone - Chloroform - Methanol System Gas Constant and Total Pressure : Vapor Pressure Using Antoine Equation : R=1.987;P=760; A1= ;B1= ;C1= ; A2= ;B2= ;C2= ; A3= ;B3= ;C3= ; PS1=10^(A1-B1/(C1+T)); PS2=10^(A2-B2/(C2+T)); PS3=10^(A3-B3/(C3+T));

3 Liquid phase activity coefficients from Wilson model : l12= ;l21= ;l13= ; l31= ;l23= ;l32= ; V1=74.05;V2=80.67;V3=40.73; X3=1.-X1-X2; A12=V2/V1 Exp[-l12/(R*( T))]; A13=V3/V1 Exp[-l13/(R*( T))]; A32=V2/V3 Exp[-l32/(R*( T))]; A21=V1/V2 Exp[-l21/(R*( T))]; A31=V1/V3 Exp[-l31/(R*( T))]; A23=V3/V2 Exp[-l23/(R*( T))]; GAM1=Exp[-Log[X1+X2*A12+X3*A13]+1-(X1/(X1+X2*A12+X3*A13)+ X2*A21/(X1*A21+X2+X3*A23)+X3*A31/(X1*A31+X2*A32+X3))]; GAM2=Exp[-Log[X1*A21+X2+X3*A23]+1-(X1*A12/(X1+X2*A12+X3*A13)+ X2/(X1*A21+X2+X3*A23)+X3*A32/(X1*A31+X2*A32+X3))]; GAM3=Exp[-Log[X1*A31+X2*A32+X3]+1-(X1*A13/(X1+X2*A12+X3*A13)+ X2*A23/(X1*A21+X2+X3*A23)+X3/(X1*A31+X2*A32+X3))];

4 Modified Raoult’s law : Using the Mathematica’s function FindRoot to solve a system of nonlinear equations using different initial guesses : Y1=X1*PS1*GAM1/P; Y2=X2*PS2*GAM2/P; Y3=X3*PS3*GAM3/P; In[25]:=FindRoot[{Y1==X1,Y2==X2, P==X1*PS1*GAM1+X2*PS2*GAM2+X3*PS3*GAM3},{X1,0.3},{X2,0.4},{T,40}] Out[25]={X1-> ,X2-> ,T-> } In[26]:=FindRoot[{Y1==X1,Y2==X2, P==X1*PS1*GAM1+X2*PS2*GAM2+X3*PS3*GAM3},{X1,0},{X2,0.4},{T,57}] Out[26]={X1 -> ^-27, X2 -> , T -> } In[27]:=FindRoot[{Y1==X1,Y2==X2, P==X1*PS1*GAM1+X2*PS2*GAM2+X3*PS3*GAM3},{X1,0.3},{X2,0},{T,57}] Out[27]={X1 -> , X2 -> ^-31, T -> } In[28]:=FindRoot[{Y1==X1,Y2==X2, P==X1*PS1*GAM1+X2*PS2*GAM2+X3*PS3*GAM3},{X1,0.3},{X2,0.6},{T,63}] Out[28]={X1-> ,X2-> ,T-> }

5 Calculation of Binary Interaction Parameters for Wilson Model Case of Methanol-Water binary system Gas Constant and Total Pressure : Modified Raoult’s law with Wilson’s model: P=760;R=1.987; A12[T_]:=18.07/40.73 Exp[-d1/(R (T ))]; A21[T_]:=40.73/18.07 Exp[-d2/(R (T ))]; y[x_,T_]:=x 10^(Aa-Ba/(T+Ca)) Exp[-Log[x+A12[T] (1-x)] +(1-x) (A12[T]/(x+A12[T] (1-x))-A21[T]/(A21[T] x+1-x))]/P Aa= ;Ba= ;Ca= ;

6 Use Mathematica’s function FindMinimum to determine the binary interaction coefficients : Experimental data : {Methanol liquid mole fraction, Temperature, Methanol Vapor Mole fraction} from P. C. Wankat, Equilibruim Staged Separations, Prentice Hall 1988 mydata={{0,100,0},{0.02,96.4,0.134},{0.04,93.5,0.23}, {0.06,91.2,0.304},{0.08,89.3,0.365},{0.1,87.7,0.418}, {0.15,84.4,0.517},{0.2,81.7,0.579},{0.3,78,0.665},{0.4,75.3,0.729}, {0.5,73.1,0.779},{0.6,71.2,0.825},{0.7,69.3,0.87},{0.8,67.6,0.915}, {0.9,66,0.958},{0.95,65,0.979},{1,64.5,1}}; sumOfSquares[data_]:= Apply[Plus,Apply[Plus,Map[{(y[#[[1]],#[[2]]] - #[[3]])^2}&, data]]] param1=FindMinimum[sumOfSquares[mydata], {d1,0.1,90},{d2,.01,1000},MaxIterations->300] { ,{d1-> ,d2-> }}

7 Isobar Vapor-Liquid Equilibrium Calculations Case of Ethanol-Water System at 760 mmHg Vapor Pressure Using Antoine Equation : Activity coefficients using the Van Laar Model : A1= ;B1= ;C1= ; A2= ;B2= ;C2= ; PS2=10^(A1-B1/(C1+T)); PS1=10^(A2-B2/(C2+T)); G1[i_]:=Exp[A12 (A21 (1-x[i])/(A12 x[i]+A21 (1-x[i])))^2] G2[i_]:=Exp[A21 (A12 x[i]/(A12 x[i]+A21 (1-x[i])))^2] A12=1.6798;A21=0.9227;

8 Compute T and y for given x using a While loop and Mathematica’s function FindRoot : Create tables using Mathematica’s command Table : i=0;P=760;T=. While[i<101,{x[i]=i 0.01, T[i]=FindRoot[P== PS1 G1[i] x[i]+PS2 G2[i] (1-x[i]),{T,80}][[1,2]], y[i]=PS1 G1[i] x[i]/P/.T-> T[i],i++}] tb=Table[{x[i],y[i]},{i,0,100}]; tb2=Table[{x[i],T[i]},{i,0,100}]; tb3=Table[{y[i],T[i]},{i,0,100}];

9 Mathematica’s commands ListPlot and Show are used to plot Bubble point and dew point temperatures on the same figure : x,y T plt1=ListPlot[tb2,PlotStyle->RGBColor[1,0,0],PlotJoined-> True, PlotRange->All] plt2=ListPlot[tb3,PlotStyle->RGBColor[0,0,1],PlotJoined-> True, PlotRange->All]

10 Mathematica’s commands ListPlot, Line and Epilog are used to plot the VLE data and the y=x line : x y plt1=ListPlot[tb,PlotStyle->RGBColor[1,0,0],PlotJoined-> True, Epilog-> {RGBColor[0,1,0],Line[{{0,0},{1,1}}]}]

11 Isotherm Vapor-Liquid Equilibrium Calculations Case of Ethanol-Ethyl acetate System at 70°C Vapor Pressure Using Antoine Equation : Partial pressure using Raoult’s law : A1= ;B1= ;C1= ; A2= ;B2= ;C2= ; PS1=10^(A1-B1/(C1+T)); PS2=10^(A2-B2/(C2+T)); T=70; P1[x_]:=PS1 x;P2[x_]:=PS2 (1-x); plt3=Plot[{P1[x],P2[x]},{x,0,1}, PlotStyle->{RGBColor[1,0,1],RGBColor[0,1,0]}]

12 Liquid activity coefficients using the Margules Model : Expect positive deviation from ideality because activity coefficients are greater than 1 : x ii A12=0.8557;A21=0.7476; G3=Exp[(A12+2 (A21-A12) x) (1-x)^2] G4=Exp[(A21+2 (A12-A21) (1-x)) x^2] plt8=Plot[{G3,G4},{x,0,1}, PlotStyle->{RGBColor[0,0,1],RGBColor[0,0,1]}]

13 Partial pressure using Modified Raoult’s law : x PiPi P1[x_]:=G3 PS1 x;P2[x_]:=G4 PS2 (1-x); plt5=Plot[{P1[x],P2[x]},{x,0,1}, PlotStyle->{RGBColor[0,0,1],RGBColor[0,0,1]}] Show[plt3,plt5]

14 x,y P Plotting P versus x and y to get the isotherm VLE diagram : P[x_]:=G3 x PS1+G4 (1-x) PS2 plt10=Plot[P[x],{x,0,1},PlotStyle->RGBColor[1,0,1]] tbl=Table[{x G3 PS1/(G3 x PS1+G4 (1-x) PS2), G3 x PS1+G4 (1-x) PS2},{x,0,1,0.01}]; plt11=ListPlot[tbl,PlotStyle->RGBColor[1,0,1], PlotJoined->True] Show[plt10,plt11]

15 Wei-Prater mechanism 3-reactant triangle network : A1=A2=A3=A1 with rate constants k12, k21, k23, k32, k31, k13. Steady state solution obtained using Mathematica’s function Solve : Rate constants are not independent : k32=k23 (k12/k21) (k31/k13) k12=.5;k21=0.7;k13=.1;k31=.2;k23=.9;k32=k23 (k12/k21) (k31/k13) A1o=.7;A2o=0;A3o=.3;tf=10; sequil=Solve[{0==-(k12 +k13) A1+k21 A2+k31 A3, 0==k12 A1 -(k21 +k23)A2+k32 A3,A3==A1o+A2o+A3o-A1-A2}, {A1,A2,A3}]//Simplify {A1+A2+A3,A2/A1,k12/k21,A3/A1,k13/k31,A3/A2,k23/k32}/.sequil {{A1-> ,A2-> ,A3-> }} {{1., , ,0.5,0.5,0.7,0.7}}

16 transient solution obtained using Mathematica’s function NDSolve : Plotting the solution using Mathematica’s functions Plot and ParametricPlot : solWP=NDSolve[{A1'[t]==-(k12 +k13) A1[t]+k21 A2[t]+ k31 (A1o+A2o+A3o-A1[t]-A2[t]), A2'[t]==k12 A1[t] -(k21 +k23)A2[t]+ k32 (A1o+A2o+A3o-A1[t]-A2[t]), A1[0]==A1o,A2[0]==A2o},{A1[t],A2[t]},{t,0,tf}]; ({A1[t],A2[t],A1o+A2o+A3o-A1[t]-A2[t]})/.solWP/.t->tf {{ , , }} Plot[Evaluate[Table[{A1[t],A2[t],A1o+A2o+A3o-A1[t]-A2[t]}/.solWP]],{t,0,tf}, Frame->True,DefaultFont->{"Symbol-Bold",14}, FrameLabel->{"t","A1, A2, A3"},PlotRange->{{0,tf},{0,1}}, PlotStyle->{RGBColor[1,0,0],RGBColor[0,1,0],RGBColor[0,0,1]}]; ParametricPlot[Evaluate[Table[{A2[t],A1[t]}/.solWP]],{t,0,tf},Frame->True, DefaultFont->{"Symbol-Bold",14},FrameLabel->{"A2","A1"}, PlotRange->{{0,1},{0,1}}];

17 Transient solution of Wei-Prater problem :

18 Consecutive reactions : A1=A2=A3=A4=A5 with rate constants k12, k21, k23, k32, k31, k13... transient solution obtained using Mathematica’s function NDSolve : Plotting the transient solution using Mathematica’s functions Plot : k12=k23=k34=k45=1;k21=k32=k43=k54=.1;A1o=1;tf=10; sol5=NDSolve[{A1'[t]==-k12 A1[t]+k21 A2[t], A2'[t]==k12 A1[t] -(k21 +k23)A2[t]+k32 A3[t], A3'[t]==k23 A2[t] -(k32 +k34)A3[t]+k43 A4[t], A4'[t]==k34 A3[t] -(k43 +k45)A4[t]+k54 (A1o-A1[t]-A2[t]-A3[t]-A4[t]), A1[0]==A1o,A2[0]==0,A3[0]==0,A4[0]==0}, {A1[t],A2[t],A3[t],A4[t]},{t,0,tf}]; Plot[Evaluate[Table[{A1[t],A2[t],A3[t],A4[t],A1o-A1[t]-A2[t]-A3[t]-A4[t]} /.sol5]],{t,0,tf},Frame->True,DefaultFont->{"Symbol-Bold",14}, FrameLabel->{"t","A1, A2, A3, A4, A5"},PlotRange->{{0,tf},{0,1}}, PlotStyle->{RGBColor[1,0,0],RGBColor[0,1,0],RGBColor[0,0,1], RGBColor[1,1,0],RGBColor[0,1,1]}];

19 Steady state solution obtained using Mathematica’s function Solve : Plotting the steady state solution using Mathematica’s functions ListPlot : soleq=Solve[{0==-k12 A1+k21 A2, 0==k12 A1-(k21 +k23)A2+k32 A3, 0==k23 A2 -(k32 +k34)A3+k43 A4, 0==k34 A3 -(k43 +k45)A4+k54 (A1o-A1-A2-A3-A4)},{A1,A2,A3,A4}] A5=(A1o-A1-A2-A3-A4)/.soleq ListPlot[Flatten[{A1,A2,A3,A4,(A1o-A1-A2-A3-A4)}/.soleq], PlotStyle->{PointSize[0.015],RGBColor[1,0,0]}]

20 transient solution : Steady state solution :

21 Lotka-Volterra Mechanism Foxes and rabbits interactions : Governing equations :

22 NDSolve finds the solutions to the ODEs and Plot gives the figure with typical oscillationsfor the case A=3.7, k1=1.2, k2=1.5 and k3=1.2 : t x,y A =3.7;k1=1.2;k2=1.5;k3=1.2; LV=NDSolve[{X'[t]==k1 A X[t]-k2 X[t] Y[t],Y'[t]==k2 X[t] Y[t] - k3 Y[t],X[0]==.85,Y[0]==3.2},{X[t],Y[t]},{t,0,10}]; Plot[Evaluate[Table[{X[t],Y[t]}/.LV]],{t,0,10}, PlotStyle->{RGBColor[1,0,0],RGBColor[0,0,1]}]

23 Oregonator model of the BZ reaction Main chemical reactions taking places : Governing equations :

24 NDSolve finds the solutions to the ODEs for the case s=100, f=1.1, q=10 -6 and w=3.835 : Plotting the solution using Mathematica’s functions Plot and ParametricPlot : s=100;f=1.1;q=10^-6;w=3.835; sol1=NDSolve[{x'[t]==s (x[t]+y[t]-x[t] y[t]-q x[t]^2), y'[t]==1/s (-y[t]-x[t] y[t]+f z[t]), z'[t]==w (x[t]-z[t]), x[0]==1,y[0]==1,z[0]==1},{x,y,z},{t,0,5000}, WorkingPrecision->25,AccuracyGoal->10, PrecisionGoal->10,MaxSteps->Infinity] pl1=Plot[Evaluate[x[t]/.sol1],{t,0,1000},PlotRange->All, PlotStyle->RGBColor[0,0,1]] ParametricPlot[Evaluate[{z[t],y[t]}/.sol1],{t,500,1000}, PlotRange->{1,1.20},PlotStyle->RGBColor[0,1,0]]

25 The solution shows regular oscillations such as those observed in the Belousov-Zhabotinski experiments. Limit cycle are obtained and a lapse of time is necessary before oscillations are observed. u3u3 u2u2 u1u1 t

26 Lindermann-Hinshelwood Mechanism Quasi steady state approximation : If A large, reaction rate law is first order If A small, reaction rate law is second order Solve[{RA==k1 A^2-k2 A Ac, 0==k1 A^2-k2 A Ac-k3 Ac},{RA,Ac}]//Simplify

27 Continuous-Stirred Tank Reactor A in, B in A, B, C V d

28 t 10 3 C NDSolve and Plot are used to get the concentration profile of the product : k1=1;k2=10^-2;k0=d/V;V=10;d=0.6; sol=NDSolve[{ c'[t]==k1 a[t] b[t]-k2 c[t]-k0 c[t], a'[t]==-k1 a[t] b[t]+k2 c[t]+k0 (0.01-a[t]), b'[t]==-k1 a[t] b[t]+k2 c[t]+k0 (0.02-b[t]), a[0]==10^-2,b[0]==2 10^-2,c[0]==0},{a,b,c},{t,0,300}] Plot[Evaluate[1000 c[t]/.sol],{t,0,300},PlotRange->{0,8}, PlotStyle->RGBColor[1,0,0]]

29 Conclusion Mathematica’s algebraic, numerical and graphical capabilities can be put into advantage to solve several Physical Chemistry problems such as applied thermodynamics and chemical kinetics.

30 1/ 2/


Download ppt "A Selection of Physical Chemistry Problems Solved using Mathematica Housam BINOUS National Institute of Applied Sciences and Technology"

Similar presentations


Ads by Google