Challenge

Week 5 - Mid term project - Solving the steady and unsteady 2D heat conduction problem

AIM-: Solution of the 2D heat conduction equation by using the point iterative techniques using Jacobi, gauss seidel, and SOR methods with explicit and implicit.

clear all 
close all
clc

nx=10;
ny=nx;
x=linspace(0,1,nx);
dx=x(2)-x(1);
y=linspace(0,1,ny);
z=fliplr(y);
f=1.5;
iter=1;

t=ones([nx,ny])*298;

t(1,1:nx)=600;
t(ny,1:nx)=900;
t(2:ny-1,1)=400;
t(2:ny-1,nx)=800;

told=t;
r1=t;

error=19;
tol=1e-4;
for iterative_solver=1:3
    while(error>tol)
        for i=2:nx-1
        for j=2:ny-1
            if (iterative_solver==1)
                t(i,j)=jacobi_equ(t,told,i,j);
            elseif(iterative_solver==2)
                 t(i,j)=GS_equ(t,told,i,j);
            else
                 t(i,j)=Sor_equ(t,told,i,j,f);
            end 
            end 
            end 
        error=max(max(t-told));
            told=t;
            [u1,v1]=meshgrid(x,z);
            
            if(iterative_solver==1)
                figure(1);
                contourf(u1,v1,t);
                [C,h]=contourf(u1,v1,t);
                colorbar;
                colormap(jet);
                clabel(C,h);
                xlabel('x-axis');
                ylabel('y-axis');
                title_text=sprintf('jacobi iteration number=%d',iter);
                title(title_text);
                pause(0.003);
                
            elseif(iterative_solver==2)
                figure(2);
                contourf(u1,v1,t);
                [C,h]=contourf(u1,v1,t);
                colorbar;
                colormap(jet);
                clabel(C,h);
                xlabel('x-axis');
                ylabel('y-axis');
                title_text=sprintf('GS iteration number=%d',iter);
                title(title_text);
                pause(0.003);
                
            else  
               figure(3);
                contourf(u1,v1,t);
                [C,h]=contourf(u1,v1,t);
                colorbar;
                colormap(jet);
                clabel(C,h);
                xlabel('x-axis');
                ylabel('y-axis');
                title_text=sprintf('Sor iteration number=%d',iter);
                title(title_text);
                pause(0.003);
            end 
            iter=iter+1;
            end
    
    
    error=19;
    iter=1;
    t=r1;
    told=r1;
end 

RESULTS


Jacobi iteration -:

Gauss-seidel-:

Successive over-relaxation-:

CONCLUSION-:

as per the above result, we have concluded that Successive over-relaxation is a fast method among all methods. as we see all methods are discriminating on, a number of iteration and stability. In Jacobi method has a greater number of iteration other hand Successive over-relaxation is less iteration.

Transient method-:

MAIN PROGRAM (EXPLICIT FUNCTION)-:

clear all 
close all
clc

nx=10;
ny=nx;
x=linspace(0,1,nx);
dx=x(2)-x(1);
y=linspace(0,1,ny);
dy=y(2)-y(1);

c=1e-4;

nt=200;

dt=32;

k=(c*dt)/dx^2;

t=ones([nx,ny])*673;

t(1,1:nx)=600;
t(ny,1:nx)=900;
t(2:ny-1,1)=400;
t(2:ny-1,nx)=800;
told=t;

[xx,yy]=meshgrid(x,y);
tic
iter=1
for p=1:nt
    for i=2:nx-1
        for j=2:ny-1
            t(i,j)=k*(told(i-1,j)+told(i+1,j)+told(i,j+1))+(1-4*k)*told(i,j);
        end 
    end 
    
    error=max(abs(told-t));
    told=t;
    iter=iter+1;
end 

time=toc;
figure(1);
[C,h]=contourf(xx,yy,t);
colorbar;
colormap(jet);
clabel(C,h);
title(sprintf('2D unsteady state heat conduction (explicit method)\n computation time:%0.4f\ n CFL number:%0.4\n iterations=%d',time,k,iter));
xlabel('xx');
ylabel('yy');

RESULT-:

MAIN PROGRAM (IMPLICIT FUNCTION)-:

clear all 
close all
clc

nx=20;
ny=nx;

x=linspace(0,1,nx);
y=x;
z=fliplr(y);

dx=x(2)-x(1);
dy=dx;

t=ones([nx,ny])*298;

t(1,1:nx)=600;
t(ny,1:nx)=900;
t(2:ny-1,1)=400;
t(2:ny-1,nx)=800;

alpha=0.05;

dt=0.25;

told=t;
t_initial=t;

k1=alpha*(dt/dx^2);
k2=alpha*(dt/dy^2);

iterative_solver=1;

error=9e9;
tol=1e-4;
tic;

if iterative_solver==1
    iter=1;
    while error>tol
        for i=2:nx-1
            for j=2:ny-1
                term1=(1+2*k1+2*k2);
                t1=told(i-1,j);
                tr=told(i+1,j);
                tb=told(i,j-1);
                tu=told(i,j+1);
                t(i,j)=((told(i,j))+(k1*(t1+tr))+(k2*(tu+tb)))/term1;
            end 
        end 
        error_n=max(abs(told-t));
        error=max(error_n);
        told=t;
        iter=iter+1;
    end 
end
time=toc;
figure(1)
[C,h]=contourf(x,y,t);
colormap(jet);
colorbar;
clabel(C,h);
title_text=sprintf('JACOBI METHOD \n Iteration Number=%d\n computational time: %0.4f',iter,time);
title(title_text);

told=t_initial;
t=t_initial;
xlabel('xx');
ylabel('yy');

RESULT-:

CONCLUSION-:

1. As we see an implicit method and explicit method, as comper to both methods is much faster and accurate.

2. The computational time in both methods, an explicit method with iteration is faster than the implicit method and much accurate.

3. The order in steady-state to converge at the earliest is SOR>GS>JACOBI.

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.