Transient Analysis
Here from all the contour plots its shown that SOR gets the least iterations to converge the result with the required tolerance.
close all
clear all
clc
nx=12;ny=nx;er=1e-4;error=9e9;c=1;
x=linspace(0,1,nx);y=linspace(0,1,ny);
z=fliplr(y);f=1.5;
t=ones([nx,ny]);
t(1,2:nx)=600;
t(1:ny-1,1)=400;
t(2:ny,nx)=800;
t(ny,1:nx)=900;
t1=t;r1=t;
for o = 1:3
while (error > er)
for i = 2:nx-1
for j = 2:ny-1
if (o==1)
t(i,j)=0.25*(t1(i,j-1)+t1(i,j+1)+t1(i-1,j)+t1(i+1,j));
elseif (o==2)
t(i,j)= 0.25*(t(i,j-1)+t1(i,j+1)+t(i-1,j)+t1(i+1,j));
else
t(i,j)=((1-f)*t1(i,j)+(f*0.25*(t(i,j-1)+t1(i,j+1)+t(i-1,j)+t1(i+1,j))));
end
end
end
error=max(max(t-t1));
t1=t;
[u1,v1]=meshgrid(x,z);
%plot
if (o==1)
figure(1);contourf(u1,v1,t)
xlabel(\'length along x axis\');
ylabel(\'length along y axis\');
title(sprintf(\'jacobi iteration no. = %d\',c))
pause(0.003)
elseif(o==2)
figure(2);contourf(u1,v1,t)
xlabel(\'length along x axis\');
ylabel(\'length along y axis\');
title(sprintf(\'gauss seidel iteration no. = %d\',c))
pause(0.003)
else
figure(3);contourf(u1,v1,t)
xlabel(\'length along x axis\');
ylabel(\'length along y axis\');
title(sprintf(\'SOR iteration no. = %d\',c))
pause(0.003)
end
c=c+1;
end
error=19;c=1;t=r1;t1=r1;
end