You are on page 1of 6

Mathematical Formulation

MATLAB specifies such parabolic PDE in the form

c(x, t, u, ux)ut = x-m (xmb(x,t.u,ux))+s(x,t,u,ux).............(1)


with boundary conditions

p(xl, t, u) + q(xl, t) b(xl, t, u, ux) =0. (2)


p(xr, t, u) + q(xr, t) b(xr, t, u, ux) =0,..(3)

where xl represents the left endpoint of the boundary and xr represents the right
endpoint
of the boundary, and initial condition

u(0, x) = f(x).
For given problem the equation can be written as :
1

= 2

( 2

)+o

On comparing with main equation 1:


c=1/D, m=2,s=0,b=du/dx,u=c,x=r
Boundary conditions given in the problem:0+1.(du/dx)=0

at xl

on comparing with equation 2 pl=0 and ql=1

ur-u +0.(du/dx)=0 at xr on comparing with equation 3 pr=( ur-u) and qr=0


initial condition at time t=0 all concentrations are equal to 0.

Algorithm
1.Functions parabolic and parabolic1 are defined to plot the concn vs position and
surface contours respectively.
2. The constants required to be inputted by the user are fed into required
variables using input function.
3. D stores diffusivity coefficient, k stores the bulk concentration stores the radius
of cylinder,T stores the end time.
4. Functions bcl, initial1 and eqn1 are defined to pass the values of boundary
conditions, initial conditions and the equation to the function function.
5. The values of concentration gets stored in a 2 dimensional array u which
evaluated by calling the functions bcl,initial1 and eqn1 using function handles.
6. The function plot and surf produces the graphs and xlabel and ylabel is for
naming the axis.
7 Potting concentration vs position at a particular time is done by varying the
dimension associated with time through a loop the variable of the loop being z.
8. For a particular z u values at all x is ploted with respect to x.
9. hold on function used to retrieve all the plots on the same graph each
corresponding to a particular time.

Code for generating concn vs position plot


function parabolic
global D
global k
D=input('Enter diffusivity constant');
k=input('Enter bulk concentation');
R=input('Enter radius of cylinder');
T=input('Enter the end time in minutes');
x = linspace(0,R,100);
t = linspace(0,T*60,100);
m=2;
%Solving the PDE
u = pdepe(m,@eqn1,@initial1,@bc1,x,t);
%Plotting the solution
for z=1:100
plot(x,u(z,:))
hold on;
xlabel('Distance');
ylabel('concn');
end
function [pl,ql,pr,qr] = bc1(xl,ul,xr,ur,t)
%BC1: MATLAB function M-file that specifies boundary conditions
%for a PDE in time and one space dimension.
global k
pl = 0;
ql = 1;
pr = ur-k;
qr = 0;
function[c,b,s] = eqn1(x,t,u,DuDx)
%EQN1: MATLAB function M-file that specifies
%a PDE in time and one space dimension.
global D
c = 1/D;
b = DuDx;
s = 0;

function u0 = initial1(x)
%INITIAL1: MATLAB function M-file that specifies the initial condition
%for a PDE in time and one space dimension.
u0=0;

Code for generating surface contour


function parabolic1
global D
global k
D=input('Enter diffusivity constant');
k=input('Enter bulk concentation');
R=input('Enter radius of cylinder');
T=input('Enter the maximum number of minutes');
x = linspace(0,R,100);
t = linspace(0,T*60,100);
m=2;
%Solve the PDE
u = pdepe(m,@eqn1,@initial1,@bc1,x,t);
%Plot solution
surf(x,t,u);
title('Surface plot of solution.');
xlabel('Distance r');
ylabel('Time t');
zlabel('conc u');
function [pl,ql,pr,qr] = bc1(xl,ul,xr,ur,t)
%BC1: MATLAB function M-file that specifies boundary conditions
%for a PDE in time and one space dimension.
global k
pl = 0;
ql = 1;
pr = ur-k;
qr = 0;
function[c,b,s] = eqn1(x,t,u,DuDx)
%EQN1: MATLAB function M-file that specifies
%a PDE in time and one space dimension.
global D
c = 1/D;
b = DuDx;
s = 0;
function u0 = initial1(x)
%INITIAL1: MATLAB function M-file that specifies the initial condition
%for a PDE in time and one space dimension.
u0=0;

SAMPLE OUTPUT

Enter diffusivity constant0.00002


Enter bulk concentation0.05
Enter radius of cylinder0.1
Enter the maximum number of minutes1.0

Graph of concn vs position at a fixed time.

Plot for surface contour such that concentration on z axis time on y axis and
distance on x axis.

With the progress of time the concentration at a given point increases.

You might also like