Sei sulla pagina 1di 18

40499 and 40503

DEPARTMENT OF MATERIAL SCIENCE AND ENGINEERING.

AFRICAN UNIVERSITY OF SCIENCE AND TECHNOLOGY [AUST].

KINETICS
PROJECT ONE

GROUP;
[1] NWAZOJIE CHUKWUDALU CLARE 40499
[2] OSAWEMWENZE AMEN LILIAN 40503

PROFESSOR: PROF. ACHENIE


14TH DECEMBER, 2016.

1
40499 and 40503

Problem 1: Solve the ODE below for concentration ( C ) as a function of reactor volume (VR ).
Develop a MATLAB m-file. Plot concentration versus volume label the axes and provide a
graph title. Discuss the solution.

= 0 < VR 2000
( )
c(0) = 2;
Data : Q = 50; k = 0.198; v = 3.8
Solution
The ordinary differential equation (ODE) is solved for concentration as a function of reactor volume, the
equation is already represented in the form that is recognised by MATLAB, therefore the equation was
solved directly using ode45. The matlab code is shown below;

MATLAB CODE:
function [VR,c]=ODEproblem1(N)

Vrspan=[0 N]; %define the volume interval on which to solve the problem
c0=2; %define the initial condition
% Call on ode45 to solve the problem, RHS is a function that defines the
% right hand side of the ODE, The @ symbol tells me that the RHS is a
% function and not a variable

[VR,c]=ode45(@RHS,Vrspan,c0);

figure
plot (VR,c,'m'); grid on %plot concentration c versus Volume VR
xlabel ('VR'); %This is the x-axis
ylabel ('c');%This is the y-axis
title ('This is plot of Concentration, c versus Volume, VR');
end

function [myRHS]=RHS(VR,c) %VR is an independent variable, c is a dependent variable


k=0.198; Q=50; v=3.8;
myRHS=-k*c/(Q*(c+v));
end

2
40499 and 40503

This is plot of Concentration, c versus Volume, VR


2

1.8

1.6

1.4

1.2
c
1

0.8

0.6

0.4

0.2
0 200 400 600 800 1000 1200 1400 1600 1800 2000
VR
Figure 1: A plot of Concentration against reactor volume

Discussion 1:
The Fig. 1 shows the solution to the ordinary differential equation obtained from Matlab. The graph
shows that the initial condition was satisfied, the concentration was two (C=2) when the reactor volume
was zero (Vr = 0). The graph also shows that as the volume of the reactor increases, the concentration
decreases. At Vr = 1000, the concentration was 0.93 and at Vr = 2000, the concentration was 0.38. Since
the initial conditions are satisfied and the concentration tends to zero as the volume increases, the graph
can be said to be the solution of the equation. This shows that concentration has an inverse relationship
with the reactor volume.

Problem 2: Solve the following two-point BVP using Matlab. Provide the Matlab file as well as
a discussion of the solution.


+ = 0 < r <1
|r=0= 0 c(1) =1 = 5 K = 2

3
40499 and 40503

Solution 2:

Matlab does not recognize the form in which the equation is written since it is a second order equation,
therefore the equation will be written in the form matlab recognises by writing it in the form of first order
equation as shown below;

Reducing the second order equation to first order;


+ = .(1)

Let; c = b(1) ...................................................................... ............ (2)

= cl = b(2) ............................ First ODE equation

= cll = bl(2)........................................................................ (3)

Substituting equation (2) and (3) back into equation 1gives;



cll + cl =


bl(2) + c(2) =

( )
bl(2) = - b(2).Second ODE equation
( )

Solving for the boundary conditions;

cl(0) = 0 From First ODE equation c(2) = 0First BC

c(1) = 1 c(1) - 1 = 0Second BC

Matlab Code 2:

function [r,c] = BVPproblem2(N)

solinit=bvpinit(linspace(0.01,1,10),[1 0]); % bvpinit forms the initial guess for bvp4c

sol = bvp4c(@Odefun,@BCfun,solinit); % Calling on bvp4c to solve boundary value


problems for ordinary differential equations having the function'Odefun',boundary conditions 'BCfun' and
'solinit' solution with the mesh count and initial guess.

r = linspace(0.01,1); %values interval of r

4
40499 and 40503

c = deval(sol,r); %Evaluate the numerical solution of c using the


output of bvp4c 'sol' and 'r'
plot(r,c(1,:)); grid on %Plot c versus r
xlabel('r'); % x-axis caption
ylabel('c'); % y-axis caption
title ('This is plot of "c" versus "r"');
end

function dbdr=Odefun(r,b) %odefun is a function handle that evaluates the


differential equations
dbdr=[b(2) (5*b(1))/(1+2*b(1))-((2/r)*b(2))];
end

function theBC=BCfun(ya,yb) %Handle to a function that evaluates the residual in


the boundary conditions
theBC=[ya(2) yb(1)-1];
end

This is plot of "c" versus "r"


1

0.95

0.9

c 0.85

0.8

0.75

0.7
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
r
Figure 2: Plot of C against r.

5
40499 and 40503

Discussion 2:
The Fig. 2 gives the plot for the two - point Boundary Value Problem (BVP) using Matlab. bvp4c was
called on to solve the equation, the resulting graph shows that the boundary conditions were satisfied. The

BVP = 0 on the left hand side of the graph is satisfied as this shows that the change of 'c' with

respect to 'r' is zero. At r = 0, c=0.74 and at r = 1, c = 1 this shows that 'c' increases as 'r' increases. The
two boundary conditions are satisfied therefore the graph is a solution and has a reasonable interpretation
to the two - point Boundary Value Problem (BVP).

Problem 3:
To solve a steady state problem that combines diffusion with convective transport and chemical reaction
which is shown in the equation below;

+ = 0 ...................................... (1)

0< =2
=1 =0 = 0.5 0 2

(a) For = where k = 1 for second order rate of reaction

Solution 3:
Matlab does not recognize the form in which equation (1) is written since it is a second order equation,
therefore the equation will be written in the form matlab recognises by writing it in the form of first order
equation as shown below;

0.5 + = 0 . . (2)

but = , = 1 , therefore;

= (3)

Substituting equation (3) into (2) gives;

0.5 = 0 (4)

Divide equation (4) through by 0.5

2 2 =0

6
40499 and 40503

=2 +2

Let;

CA = y(1)

= (2)..............................................................................(5)

Therefore;

= =2 +2

=2 (2) + 2 (1) ........................................................... (6)

Solving for the boundary conditions;

cl(2) = 0 From First ODE equation c(2) = 0First BC

c(0) = 1 c(1) - 1 = 0Second BC

Matlab will be used to solve the equations (5) and (6) which have been reduced into the form Matlab
understands.

Matlab Code 3:

function [z,c] = bvpproblem3(input)% This will solve the boundary value


%problem
disp (input)% it displays the input

solinit = bvpinit(linspace(0,2,10),[1 0]); % shows the linespacing and


%the initial guess for x and y

sol = bvp4c(@odefun,@odeBC,solinit);% The sol contains the result


z = linspace(0,2); % interval for z
c= deval(sol,z);%evaluates the numerical solution using the output of bvp4c

figure
plot(z,c(1,:)); grid on %plots first row of z and c
xlabel('z'); % x-axis label
ylabel('C'); % y-axis label
title('Graph of Concentration along the Length Z @ Uz = 0.5');
end

function dydz = odefun(z,y)


u = 0.5; % u will be varied at 0.5, 1, 1.5 and 2
dydz = [y(2) (2*(u)*y(2)+2*y(1)^2)];
7
40499 and 40503

end

function res = odeBC(Va,Vb)


res = [ Va(1)-1 Vb(2) ];
end

Graph of Concentration along the Length Z @ Uz = 0.5


Graph of Concentration along the Length Z @ Uz = 1
1 1

0.9
0.9

0.8
0.8

0.7
C C 0.7
0.6

0.6
0.5

0.5
0.4

0.4
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2 0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
z z

A B
Graph of Concentration along the Length Z @ Uz = 1.5 Graph of Concentration along the Length Z @ Uz = 2
1 1

0.95 0.95

0.9 0.9

0.85
0.85
0.8
0.8
C 0.75 C
0.75
0.7
0.7
0.65
0.65
0.6

0.55 0.6

0.5 0.55
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2 0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
z z

C D
Figure 3: Plot of Concentration against Z at (A) 0.5 (B) 1 (C) 1.5 (D) 2

The Fig. 3 shows the plot of concentration at various average velocity (Uz) which is for the convective
transport. Fig. 3a,3b,3c and 3d all satisfy the boundary condition of CA=1 at Z=0 at the right hand side of
the graph and = 0. The value of CA at Z=2 for varying values of Uz is shown below;

8
40499 and 40503

Table 1: Concentration at varying Uz


Uz Concentration (CA) at Z=2
0.5 0.39
1 0.46
1.5 0.51
2.0 0.56

The table 1 shows concentration values extracted from the graphs at z=2. The values shows that as the
average velocity Uz is being increased, the concentration at z=2 increases indicating that as the velocity
is increased, the concentration of the reactant that is unused is increasing therefore the product formed at
z=2 is decreasing with increasing average velocity (Uz). This means that when velocity is increased, there
is insufficient time for complete conversion of to take place at constant L=2 as diffusion takes place.
Graph of Concentration along the Length Z @ Uz = 1
1 Graph of Concentration along the Length Z @ Uz = 1
1

0.9 0.9

0.8
0.8
0.7

C 0.7 C 0.6

0.5
0.6

0.4

0.5
0.3

0.4 0.2
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2 0 0.5 1 1.5 2 2.5 3 3.5 4
z z

Graph of Concentration along the Length Z @ Uz = 1


1 Graph of Concentration along the Length Z @ Uz = 1
1
0.9
0.9
0.8
0.8
0.7
0.7
0.6
0.6
C 0.5 C 0.5

0.4 0.4

0.3 0.3

0.2 0.2

0.1 0.1

0 0
0 2 4 6 8 10 12 14 16 18 20 0 5 10 15 20 25 30 35 40
z z

Figure 4. Plot of C against z at varying L=Z at constant Uz=1 for second order reaction

9
40499 and 40503

The Fig. 4 shows that when the length L= Z is varied for a constant Uz = 1 the amount of unused reactant
decreases as concentration is decreasing at L= Z indicating that more product is formed therefore
increasing velocity with increase in the length of the reactor increase time for reaction to take place
thereby forming more product as concentration of reactant is tending towards zero which is seen when
L=4, C= 0.27, at L=20, C= 0.05 and at L=40, C= 0.03. The graph also shows that as diffusion propagates,
the concentration decreases. Therefore increasing the reactor length when Uz is varied will lead to
concentration decreasing and tending to zero as diffusion is taking place.

(b) For = where k = 1 for First order rate of reaction


0.5 + = 0 . . (2)

but = , = 1 , therefore;

= (3)

Substituting equation (3) into (2) gives;

0.5 = 0 (4)

Divide equation (4) through by 0.5

2 2 =0

=2 +2

Let;

CA = y(1)

= (2)..............................................................................(5)

Therefore;

= =2 +2

=2 (2) + 2 (1) ........................................................... (6)

Solving for the boundary conditions;

cl(2) = 0 From First ODE equation c(2) = 0First BC

c(0) = 1 c(1) - 1 = 0Second BC


10
40499 and 40503

Matlab Code:

function [z,c] = bvpproblem3b(input) % This will solve the boundary value


%problem
disp (input) % it displays the input

solinit = bvpinit(linspace(0,2,10),[1 0]); % shows the linespacing and


%the initial guess for x and y

sol = bvp4c(@odefun,@odeBC,solinit); % The sol contains the result


z = linspace(0,2); % interval for z
c= deval(sol,z); %evaluates the numerical solution using the output of bvp4c

figure
plot(z,c(1,:)); grid on %plots first row of z and c
xlabel('z'); % x-axis label
ylabel('C'); % y-axis label
title('Graph of Concentration along the Length Z @ Uz = 0.5');
end

function dydz = odefun(z,y)


u = 0.5; % u will be varied at 0.5, 1, 1.5 and 2
dydz = [y(2) (2*(u)*y(2)+2*y(1))];

end

function res = odeBC(Va,Vb)


res = [ Va(1)-1 Vb(2) ];
end
Graph of Concentration along the Length Z @ Uz = 1
Graph of Concentration along the Length Z @ Uz = 0.5 1
1
0.9
0.9

0.8
0.8

0.7
0.7

C 0.6
C 0.6

0.5
0.5

0.4 0.4

0.3 0.3

0.2 0.2
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2 0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
z z

A B

Figure5: Plot of Concentration against Z at (A) Uz=0.5 and (B) Uz = 1 for first order reaction

11
40499 and 40503

Graph of Concentration along the Length Z @ Uz = 2


Graph of Concentration along the Length Z @ Uz = 1.5 1
1

0.9 0.9

0.8 0.8

0.7
C 0.7
C

0.6

0.6
0.5

0.5
0.4

0.4
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2 0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
z z

C D
Figure5: Plot of Concentration against Z at (C) Uz=1.5 and (D) Uz = 2 for first order reaction

The Fig. 3 shows the plot of concentration at various average velocity (Uz) which is for the convective
transport. Fig. 5a,5b,5c and 5d all satisfy the boundary condition of CA=1 at Z=0 at the right hand side of

the graph and = 0. The value of CA at Z=2 for varying values of Uz is shown below;

Table 2: Concentration at varying Uz for first order reaction


Uz Concentration (CA) at Z=2
0.5 0.20
1 0.29
1.5 0.38
2.0 0.45

The table 1 shows concentration values extracted from the graphs at z=2. The values shows that as the
average velocity Uz is being increased, the concentration at z=2 increases indicating that as the velocity is
increased, the concentration of the reactant that is unused is increasing therefore the product formed at
z=2 is decreasing with increasing velocity. This means that when velocity (Uz) for convective transport is
increased, there is insufficient time for complete conversion to take place when the length of Z is 2.

3c) Comparing second and first order result

Table 3: Comparison of first and second order reaction


Uz First Order reaction = ) Second order reaction( = )
0.5 0.20 0.39
1.0 0.29 0.46
1.5 0.38 0.51
2.0 0.45 0.56
12
40499 and 40503

The table 3 shows the concentration at z=2 for varying Uz. The table shows that the concentrations for the
first order reaction at z=2 are lower than the concentrations for the second order reaction indicating that
more product is formed in the first order reaction than the second order reaction as the value of Uz is
increased because the concentration of the unused reactants are lower for the first order than in the second
order reaction. Since the concentration is lower for the first order reaction than the second order reaction
therefore the diffusion rate propagates faster and the rate of reaction to form a product is higher in the first
order than in the second order reaction. The convective transport is also higher in the first order reaction
than in the second order reaction since the final concentration at z=2 is lower in the first order reaction
than in the second order reaction.

Problem 4:
Solve the following PDE using the MATLAB function pdepe. Provide the Matlab
file as well as a discussion of the solution.

+ = - Da 0 < x <1; 0<t<tf

- | (0,t) - [1-c|(0,t)] = 0 |(1,t) = 0

c|( x,0)= 0 c|(0,0)=1

Data: Da = 2; Pe = 100; v = 2; tf = 2.5 . You may experiment with different values of t f

Rearranging the equation;

= - Da - ..1

= - Da - 2

Comparing 2 to the general equation;

C = x-m ( m
f)+s

C = 1; m = 0; f = ; s = - Da -

13
40499 and 40503

For the Boundary conditions, BC

BC No1: Left (l)

Having the general equation as

p + qf = 0

p+q =0

and the first BC we compare the coefficients of p and q

- |((0,t) - [1-c|(0,t)] = 0 ..BC 1

pl = - [1-c|(0,t)] and ql = -1

pl = -[1-c] and ql = -1

BC No2: Right (r)

Comparing the second BC with the general equation as above;

| (1,t) = 0.BC 2

pr = 0 and qr = Pe

pr = 0 and qr = 100

Initial Condition (IC);

c0= 0 .. IC

Matlab Code 4:

% this is an m-file to solve problem 4


function [x,t,sol] = PDEproblem4(tf)
m = 0;% the problem has a rectangular coordinate
x = 0:0.05:1;
t = 0:0.1:tf;
% calling on pdepe to solve the problem, the solution is contained in sol
sol = pdepe(m,@pdeFunc,@pdeIC,@pdeBC,x,t);
c = sol;

% Now plot the solutions on 3D


surf(x,t,c)
title('PDE plot solution @ tf=2.5')
xlabel('Distance x')
14
40499 and 40503

ylabel('Time t')
zlabel('c')

%Now plot the solution on 2D


figure
plot(x,c(end,:)); grid on %at t=2.5 as c=f(x)
title('Plot of solution @ tf=2.5') %tf will be varied for 1,2 and 4
xlabel('Distance x')
ylabel('c(x,tf)')

figure
plot(x,c(1,:)); grid on
title('Plot of solution @ tf=2.5') %tf will be varied for 1,2 and 4
xlabel('Distance x')
ylabel('c(x,tf)')

figure
plot(t,c(:,end)); grid on
title('Plot of solution @ x=1')
xlabel('Time t')
ylabel('c(1,tf)')

end

function [C,f,s]=pdeFunc(x,t,c,dcdx)
%This defines c(x,t,u,dudx), s(x,t,u,dudx), f(x,t,u,dudx)
C = 1;
f = (1/100)*dcdx;
s = -(2*c/(c+2))-(dcdx);
end

function [c0] = pdeIC(x)


% This defines the initial conditions
if (x>0)
c0 = 0;
else
c0 = 1;
end;
end

function [pl,ql,pr,qr]=pdeBC(xl,cl,xr,cr,t)
%This defines the boundary conditions:i.e. left BC & right BC
%[pl,ql,pr,pl]==[pLeft,qRight,pRight,pLeft]
%[xl,xr]=[0,1]
%[xl,cl,xr,t]==[xleft,cleft,xright,time]

pl = -(1-cl);
15
40499 and 40503

pr = 0;
ql = -1;
qr = 100;
end

PDE plot solution @ tf=2.5

Plot of solution @ tf=2.5


1

1.5
0.9

1
0.8

c
c(x,tf)
0.7 0.5

0.6
0
3
0.5 1
2
0.8
0.6
1 0.4
0.4 0.2
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 0
Time t 0
Distance x Distance x

A B
Plot of solution @ tf=0.5
Plot of solution @ tf=1
1
1

0.9
0.9
0.8
0.8
0.7

0.6 0.7

c(x,tf) c(x,tf)
0.5 0.6

0.4
0.5
0.3
0.4
0.2

0.1 0.3

0 0.2
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Distance x Distance x

C D
Figure 7: Plot of C against X at (A) tf = 2.5 (B) Surf tf =2.5 (C) tf = 0.5 (D) tf = 1

16
40499 and 40503

Plot of solution @ tf=2


1 Plot of solution @ tf=4
1

0.9
0.9

0.8 0.8

c(x,tf)
0.7 c(x,tf)
0.7

0.6 0.6

0.5 0.5

0.4 0.4
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Distance x Distance x

A B
Figure 8: Plot of C against X at (A) tf= 2 (B) tf = 4
Plot of solution @ x=1
0.5

0.45

0.4

0.35

0.3

c(1,tf)
0.25

0.2

0.15

0.1

0.05

0
0 0.5 1 1.5 2 2.5
Time t

Figure 9: Plot of C against T

17
40499 and 40503

Discussion 4:

The plot of the solution c versus x, distance is first obtained at final time, tf=2.5 and further varied at
times 0.5, 1, 2 and 4. The initial plot at tf= 2.5 gave a negative slope that indicates that the solution c
decreases as the distance, x increases. Subsequent plots such as @ tf=0.5, altered the regularity of the
previous plot at the maximum limit of x, solution of c remained constant with a value of zero until x
started decreasing and at point 0.8 of the x-axis, c gradually started to increase in a curve like manner
until at some point between 0.8 and 0.9 of c the slope disrupts a little and then continues. Plots of tf= 4
and tf=2 had no significant change compared with the initial plot of tf=2.5 and then plot of tf=1 had at the
maximum limit of x, c solution close to value 0.3 and then continued to increase almost uniformly
with decreasing values of x. It can now be deduced that at varying tf greater than 2 the plots remained
the same but at tf less than 2 the plots varied at different values of tf. Assuming the solution of c is
concentration of molecules in space and x is the distance the concentration moves, it now means that at a
lesser time such as 0.5, the concentration does not cover much distance but at a greater time interval the
concentration travels covering a greater distance.

In the last plot of c solution versus time, t which is a positive indicates that the latter remained at zero
until time of almost 0.5 where it increased continuously with time but at some point of time 1.25, the
solution of c remained constant with increasing time.

The plot of c solution versus time, t implies that concentration increased with time and got to a point the
concentration remained constant even with increase in time.

The initial conditions c(x,0) = 0 c(0,0)=1 and the boundary conditions ( , ) 1 ( , ) =


0 ( , ) = 0 are also satisfied and indicated on the graph. The graph can be said to be accurate since the
boundary conditions are satisfied and the concentration decreases at Tf=2.5 as the diffusion process
occurs.

18

Potrebbero piacerti anche