You are on page 1of 10

1. b.

Distributed Parameter systems:


Objective: To solve 1-Dimensional heat equation provided with initial and boundary
conditions by analytical method and finite difference method and to identify the heat flow in
a 2-Dimensional plane by finite element method.
Definition: A process model considering some process variables as a function of time and
spatial position is called Distributed parameter model.
Process variable=f (time, position)
A) To solve one dimensional heat equation using analytical method.
MATLAB CODING:
clc;
clear all;
k=4;
l=1;
a=2;
s=0;
for x=1:3
u(x,1)=(x.*(15-x))/4
end
for t=2:3
for x=1:4
for n=1:1000
s=s+(8*k*(1^2)/(pi^3))*((1/(((2*n)-1))^3)*(sin((((2*n)-1)*x*pi)/1))*(exp(-((((2*n)1)^2)*(pi^2)*(a^2)*t)/(1^2))));
end
u(x,t)=s;
end
end
z=u'
f=1:1:4
e=1:1:3
surf(f,e,z)
title('One dimensional heat equation-fourier analysis');
xlabel('X');
ylabel('time');
zlabel('Temperature');

One dimensional heat equation-fourier analysis

9
8
7
6
Temperature

5
4
3
2
1
0
-1
3

2.8

2.6

2.4

2.2

1.8

time

1.6

1.4

1.2

1.5

2.5

B) To solve one dimensional heat equation using finite difference method.


MATLAB CODING:
clc;
clear all;
k=0.2;
h=0.1;
T=2;
c=0.005;
r=((c*k)/(h^2));
n=5;
m=5;
x=0:h:0.5;
t=1:k:T;
i=inline('(x.*(15-x))/4')
u(1:n+1,1)=i(x);
bb=inline('t*0')
u(1,1:m+1)=bb(t)
be=inline('t.^0');
u(n+1,1:m+1)=be(t)
for j=2:m+1
u(2:n,j)=r*u(1:n-1,j-1)+(1-(2*r))*u(2:n,j-1)+r*u(3:n+1,j-1);
end
z=u'
surf(x,t,z);
title('One dimensional heat equation-finite difference method');
xlabel('X');

3.5

ylabel('time');
zlabel('Temperature');
One dimensional heat equation-finite difference method

1.5

Temperature

0.5

0
2

1.9

1.8

1.7

1.6

1.5

1.4

time

1.3

1.2

1.1

0.05

0.1

0.15

0.2

0.25

0.3

0.35

0.4

0.45

0.5

C) To solve two dimensional heat equation using analytical method.


MATLAB CODING:
clc;
clear all;
a=2;
b=3;
r=20;
s=50;
e=1:1:5
f=1:1:5
m=4;
n=4;
c=0.07;
d=0.07;
a=0.5;
b=0.5;
for j=1:m+1
for i=1:n+1
k(i,j,1)=(1/((2.*pi.*(c.^2).*(d.^2)).^0.5)).*(exp(-(((i-a).^2)/(2.*(c.^2)))+(((jb).^2)/(2.*(d.^2)))))
end
end
for t=1:1:5
for y=1:1:5
for x=1:1:5
c(x,y,t)= ((r*s)/(4*pi*t*((a*b)^0.5)))*(exp(-(((x^2)/(4*a*t))+((y^2)/(4*b*t)))));
end
end

end
p=1;
for ti=1:3
figure(p)
surf(f,e,c(:,:,ti))
p=p+1;
title('Two dimensional heat equation-analytical method');
xlabel('X');
ylabel('Y');
zlabel('Temperature');
end
Two dimensional heat equation-analytical method

60

Temperature

50
40
30
20
10
0
5
4
3
2
Y

2
X

Two dimensional heat equation-analytical method

50

Temperature

40
30
20
10
0
5
4
3
2
1

Two dimensional heat equation-analytical method

40

Temperature

30
20
10
0
5
4
3
2
Y

2
X

D) To solve two dimensional heat equation using finite difference method.


MATLAB CODING:
clc;
clear all;
h=1;
m=4;
n=4;
k=1;
x=0:h:4
y=0:k:4
t=1;
c=0.07;
d=0.07;
a=0.5;
b=0.5;
for j=1:m+1
for i=1:n+1
k(i,j,1)=(1/((2.*pi.*(c.^2).*(d.^2)).^0.5)).*(exp(-(((i-a).^2)/(2.*(c.^2)))+(((jb).^2)/(2.*(d.^2)))))
end
end
for t=2:1:5
x0=inline('3.*x')
u(1:n+1,1,t)=x0(x);
y0=inline('y.*0')
u(1,1:m+1,t)=y0(x);
ly=inline('(12+y)')
u(n+1,1:m+1,t)=ly(x);
xl=inline('x.^2')
u(1:n+1,m+1,t)=xl(x);
%sfpf
u(3,3,t)=0.25*(u(1,3,t-1)+u(3,1,t-1)+u(5,3,t-1)+u(3,5,t-1))
%dfpf
u(2,2,t)=0.25*(u(1,1,t-1)+u(1,3,t-1)+u(3,1,t-1)+u(3,3,t-1))
u(2,4,t)=0.25*(u(1,3,t-1)+u(3,3,t-1)+u(1,5,t-1)+u(3,5,t-1))
u(4,2,t)=0.25*(u(3,1,t-1)+u(3,3,t-1)+u(5,1,t-1)+u(5,3,t-1))
u(4,4,t)=0.25*(u(3,3,t-1)+u(3,5,t-1)+u(5,3,t-1)+u(5,5,t-1))
%sfpf
u(2,3,t)=0.25*(u(1,3,t-1)+u(2,2,t-1)+u(2,4,t-1)+u(3,3,t-1))
u(3,2,t)=0.25*(u(3,1,t-1)+u(2,2,t-1)+u(3,3,t-1)+u(4,2,t-1))
u(3,4,t)=0.25*(u(3,3,t-1)+u(2,4,t-1)+u(3,5,t-1)+u(4,4,t-1))
u(4,3,t)=0.25*(u(4,2,t-1)+u(3,3,t-1)+u(4,4,t-1)+u(5,3,t-1))
%second iteration: order from u11,u12....
for i=1:10
u(2,2,t)=0.25*(u(2,1,t-1)+u(1,2,t-1)+u(2,3,t-1)+u(3,2,t-1))
u(2,3,t)=0.25*(u(1,3,t-1)+u(2,2,t-1)+u(2,4,t-1)+u(3,3,t-1))
u(2,4,t)=0.25*(u(1,4,t-1)+u(2,3,t-1)+u(3,4,t-1)+u(2,5,t-1))
u(3,2,t)=0.25*(u(3,1,t-1)+u(2,2,t-1)+u(3,3,t-1)+u(4,2,t-1))
u(3,3,t)=0.25*(u(3,2,t-1)+u(2,3,t-1)+u(3,4,t-1)+u(4,3,t-1))
u(3,4,t)=0.25*(u(3,3,t-1)+u(2,4,t-1)+u(3,5,t-1)+u(4,4,t-1))
u(4,2,t)=0.25*(u(3,2,t-1)+u(4,1,t-1)+u(5,2,t-1)+u(4,3,t-1))
u(4,3,t)=0.25*(u(4,2,t-1)+u(3,3,t-1)+u(4,4,t-1)+u(5,3,t-1))
u(4,4,t)=0.25*(u(4,3,t-1)+u(3,4,t-1)+u(5,4,t-1)+u(4,5,t-1))

end
figure(t)
surf(x,y,u(:,:,t))
end
title('Two dimensional heat equation-finite difference method');
xlabel('X');
ylabel('Y');
zlabel('Temperature');
Two dimensional heat equation-finite difference method

20

Temperature

15
10
5
0
4
3
2
1
Y

1
X

Two dimensional heat equation-finite difference method

20

Temperature

15
10
5
0
4
3
2
1
0

Two dimensional heat equation-finite difference method

20

Temperature

15
10
5
0
4
3
2
1
Y

1
X

Two dimensional heat equation-finite difference method

20

Temperature

15
10
5
0
4
3
2
1
Y

E) To solve two dimensional heat equation using finite element method:


By typing pdetool in command window we will obtain PDE Toolbox window.
By selecting Heat transfer mode we can obtain heat transfer through a plane.
By selecting Rectangle mode, we obtain a rectangle and boundary values are fed
after changing the rectangle to Boundary mode (BoundaryBoundary mode).
By selecting MeshMesh mode option we obtain the meshes (having many
triangles). The number of meshes can be increased by selecting Refine Mesh option.
By clicking PlotPlot solution we obtain the heat transfer through the plane.

Inference:
In analytical method, accurate and absolute results are obtained. If the model is complex and if it is
very difficult to obtain the model of the system, then numerical method is preferred where
approximate results are sufficient.

You might also like