Sei sulla pagina 1di 11

SIMULATION OF A PARTIAL DIFFERENTIAL EQUATION SYSTEM

Numerical Methods for Chemical Engineers (6KM06) Assignment-2

By Satish Kamath 0868860 (s130160) Chethana Gadiyar -0867843 (s134976)

INTRODUCTION A 2 step chemical reaction is taking place in a tubular reactor. The equations governing the change in concentration of the species in the reaction are:
2C CA CA vz D 2A k1C ACB t z z CB C 2C vz B D 2B k1C ACB k2CBCC t z z 2 Cc C CC vz c D k1C ACB k2CBCc t z z 2 CD C 2C D vz D D k2CBCC t z z 2

The Danckwerts boundary conditions are applied for the reactors inlet and outlet. The reaction is assumed at constant temperature with rate constants,k1, k2 =1. The initial conditions for the concentrations of species A,B,C,D are CA, CB=1 and CC, CD=0. The Axial velocity, vz=1m/s and Diffusion Coefficient, D=1.10-4 m2/s.

METHODS We attempt in solving 4 partial differential equations simultaneously. We have 1. Utilised MATLAB built in function, pdepe() to solve the partial differential equations . For the pdepe functions the spatial co-ordinate system is a dimensionless system (z/L). L=10m (assumed). 2. Discretized spatial domain by finite volume method (FVM) resulting in a set of ordinary differential equations and then solved it using ode15s.

RESULTS The result obtained from both the methods is given below:

CA vs time,distance in pdepe()

CA vs time,distance in FVM

CB vs time,distance in pdepe()3

CB vs time,distance in FVM

The CA and CB decreases with time and distance as it is consumed during the reaction. At time=5s, at the outlet of reactor, CA=0.32 mol/dm3, CB =0.0296 mol/dm3.

CC vs time,distance in pdepe()

CC vs time,distance in FVM

CD vs time,distance in pdepe()

CD vs time,distance in FVM

The CC and CD increases with time and distance as it is formed during the reaction. At time= 5s, at reactor outlet, CC =0.36 mol/dm3, CD = 0.31 mol/dm3. For a particular time instant, the reaction reaches an equilibrium at certain distance from inlet after which concentrations remain constant till the outlet of the reactor. The concentration terms reach a steady state at time=5s and there is no change in concentration with time after time=5s. The concentration changes only along length of the reactor.
5

CONCLUSIONS The spatial discretization and pdepe functions give the same results as we can observe from the solution plots. As we can observe that some values of concentration in pdepe() plots have a negative values. That is noise or fluctuation from the pde solver which is unavoidable.

LIST OF SYMBOLS CA (mol/dm-3) Concetration of Species A CB (mol/ dm-3) Concentration of species B CC (mol/dm-3) Concetration of Species C CD (mol/dm-3) Concetration of Species D Vz (m/s) Axial Velocity D (m2/s) Diffusion Coefficient k1 ( s-1(mol/dm3)-1 Rate constant k2 (s-1(mol/dm3)-1 Rate constant z (m) Coordinate system in the direction of the length of the reactor L (m) Length of the Reactor T (s) - Time

APPENDIX 1. Pdepe function routine:


global D; global u0; global vz; global k1; global k2; global L; L=10; k1=1;k2=1; D=1e-4; u0=[1;1;0;0]; vz=1; x=linspace(0,1,200); t=linspace(0,5,200); sol=pdepe(0,@pdex2pde,@pdex2ic,@pdex2bc,x,t); sol1=sol(:,:,1); sol2=sol(:,:,2); sol3=sol(:,:,3); sol4=sol(:,:,4); display(sol1); figure surf(x,t,sol1) xlabel('length (z/L)'); ylabel('time (s)'); zlabel('Ca (mol/m^3)'); figure surf(x,t,sol2) xlabel('length (z/L)'); ylabel('time (s)'); zlabel('Cb (mol/m^3)'); figure surf(x,t,sol3) xlabel('length (z/L)'); ylabel('time (s)'); zlabel('Cc (mol/m^3)'); figure surf(x,t,sol4) xlabel('length (z/L)'); ylabel('time (s)'); zlabel('Cd (mol/m^3)');

The function defining the equations:


function [c,f,s]=pdex2pde(x,t,u,dudx) global D; global u0; global vz; global k1; 8

global k2; global L; c(1)=1; c(2)=1; c(3)=1; c(4)=1; f(1)=D*dudx(1)/L^2; f(2)=D*dudx(2)/L^2; f(3)=D*dudx(3)/L^2; f(4)=D*dudx(4)/L^2; s(1)=-vz*dudx(1)/L-k1*u(1)*u(2); s(2)=-vz*dudx(2)/L-k1*u(1)*u(2)-k2*u(2)*u(3); s(3)=-vz*dudx(3)/L+k1*u(1)*u(2)-k2*u(2)*u(3); s(4)=-vz*dudx(4)/L+k2*u(2)*u(3); end

The function defining initial condition:


function u = pdex2ic(x) global D; global u0; global vz; global k1; global k2; u(1)=1; u(2)=1; u(3)=0; u(4)=0; end

The function defining boundary conditions:


function [p1,q1,p2,q2] = pdex2bc(x1,u1,xr,ur,t) global D; global u0; global vz; global k1; global k2; global L; p1(1)=-vz*(u0(1)-u1(1)); q1(1)=-L; p1(2)=-vz*(u0(2)-u1(2)); q1(2)=-L; p1(3)=-vz*(u0(3)-u1(3)); q1(3)=-L; p1(4)=-vz*(u0(4)-u1(4)); q1(4)=-L; p2(1)=0; q2(1)=L/D; p2(2)=0; 9

q2(2)=L/D; p2(3)=0; q2(3)=L/D; p2(4)=0; q2(4)=L/D; end

2. The routine for spatial discretization:


Nz=100; L=10; k1=1;k2=1; D=10^-4; Nt=100; u0=[1;1;0;0]; vz=1; z=10; dz=z/Nz; e=ones(Nz,1); A=spdiags([e*(vz/2/dz+D/dz^2),e*(-2*D/dz^2),e*(-vz/2/dz+D/dz^2)],[1,0,1],Nz,Nz); b1=zeros(Nz,1);b2=zeros(Nz,1);b3=zeros(Nz,1);b4=zeros(Nz,1); for j=1:1 i=1; k=i+(j-1)*Nz; b1(k)=b1(k)+u0(1)*(2*vz/dz); b2(k)=b2(k)+u0(2)*(2*vz/dz); b3(k)=b3(k)+u0(3)*(2*vz/dz); b4(k)=b4(k)+u0(4)*(2*vz/dz); A(k,k)=-1.5*vz/dz-D/dz^2; if k-1>0 A(k,k-1)=0; end end for j=1:1 i=Nz; k=i+(j-1)*Nz; A(k,k)=A(k,k)-vz/2/dz+D/dz^2; if (k+1) < Nz A(k,k+1)=0; end end Ca0=[ones(Nz,1),ones(Nz,1),zeros(Nz,1),zeros(Nz,1)]; %display(Ca0); %display(A); time=linspace(0,5,Nt); options=odeset('RelTol',1e-6,'AbsTol',1e-10,'NormControl','on'); [t,sol]=ode15s(@conc1,time,Ca0,options,A,b1,b2,b3,b4,k1,k2,Nz); for i=1:Nt for j=1:4*Nz if j<=Nz solu1(i,j)=sol(i,j); end if j>Nz&&j<2*Nz+1 solu2(i,j-Nz)=sol(i,j); end 10

if j>2*Nz+1&&j<3*Nz+1 solu3(i,j-2*Nz)=sol(i,j); end if j>3*Nz+1&&j<4*Nz+1 solu4(i,j-3*Nz)=sol(i,j); end end end display(solu1); x=linspace(0,10,Nz); figure surf(x,time,solu1) figure surf(x,time,solu2) figure surf(x,time,solu3) figure surf(x,time,solu4);

The function defining the differential equations:


function dCdt = conc1(t,Cx,A,b1,b2,b3,b4,k1,k2,Nz) Cx=reshape(Cx,Nz,4); dCdt=[A*(Cx(:,1))-k1*(Cx(:,1)).*(Cx(:,2))+b1; A*(Cx(:,2))-k1*(Cx(:,1)).*(Cx(:,2))-k2*(Cx(:,2)).*(Cx(:,3))+b2; A*(Cx(:,3))+k1*(Cx(:,1)).*(Cx(:,2))-k2*(Cx(:,2)).*(Cx(:,3))+b3; A*Cx(:,4)+k2*Cx(:,2).*Cx(:,3)+b4]; end

11

Potrebbero piacerti anche