0% found this document useful (0 votes)
31 views

Project No. 03: Submitted By: Khalil Ahmad

This document contains a project submission for solving the Laplace equation to calculate temperature distribution in a 2D rectangular steel block. It presents the Laplace equation and boundary conditions considered. A Matlab program is provided that uses an explicit finite difference method to iteratively solve the Laplace equation given the boundary conditions of different fixed temperatures on the edges of the block until convergence within a specified tolerance is reached. On convergence, the program generates contour, contourf, and surface plots of the calculated temperature distribution.

Uploaded by

Khalil Ahmad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views

Project No. 03: Submitted By: Khalil Ahmad

This document contains a project submission for solving the Laplace equation to calculate temperature distribution in a 2D rectangular steel block. It presents the Laplace equation and boundary conditions considered. A Matlab program is provided that uses an explicit finite difference method to iteratively solve the Laplace equation given the boundary conditions of different fixed temperatures on the edges of the block until convergence within a specified tolerance is reached. On convergence, the program generates contour, contourf, and surface plots of the calculated temperature distribution.

Uploaded by

Khalil Ahmad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 5

Project No.

03

Project Title:

Submitted By:

Khalil Ahmad

Submitted To:

Dr. Khalid Pervaiz

Dated:

13-07-2014

Institute of space Technology Islamabad, Pakistan

Laplace Equation
Then the Laplace equation for two dimensional rectangular steel block is shown below
2u
2u

0
x2
y2
and its fde becomes

ij

i+1,j

i-1,j

+u

i,j+1

+u

i,j-1

+u

4
Consider the problem below we use Laplace equation to calculate temperature distribution

T = 50

T = 100

T=0

T = 25

Matlab Program:
function [x,y,T]= LaplaceExplicit(n,m,Dx,Dy)
clc
echo off;
n = 10;
m = 20;
nx = 30;
ny = 24;
Dx = 1;
Dy = 1;
%numgrid(n,m);
R = 5.0;

T = R*ones(n+1,m+1); % All T(i,j) = 1 includes all boundary conditions


x = [0:Dx:n*Dx];
y = [0:Dy:m*Dy];
% x and y vectors
for i = 1:n
% Boundary conditions at j = m+1 and j = 1
T(i,m+1) = 50;
% Top boundary temperature
T(i,1) = 25;
% Bottom Boundary temperature
end
for j = 1:m
T(n+1,j) = 0;
% Left Boundary temperature
T(1,j) = 100;
% Bottom Boundary temperature
end;
TN = T;
% TN = new iteration for solution
err = TN-T;
% Iterative procedure
epsilon = 1e-5;
% tolerance for convergence
imax = 1000;
% maximum number of iterations allowed
k = 1;
% initial index value for iteration
% Calculation loop
while k<= imax
for i = 2:n
for j = 2:m
TN(i,j)=(T(i-1,j)+T(i+1,j)+(T(i,j-1)+T(i,j+1)))/4;
err(i,j) = abs(TN(i,j)-T(i,j));
end;
end;
T = TN;
k = k + 1;
errmax = max(max(err));
if errmax < epsilon
[X,Y] = meshgrid(x,y);
figure(1);
contour(X,Y,T',20);xlabel('X-axis in meters');ylabel('Y-axis in
meters'),colorbar
title('Laplace equation solution - Dirichlet boundary conditions Explicit');
figure(2);
contourf(X,Y,T',20);xlabel('x in meters');ylabel('y in meters'),colorbar
title('Laplace equation solution - Dirichlet boundary conditions Explicit');
figure(3);
surfc(X,Y,T');
xlabel('X-axis in meters');ylabel('Y-axis in meters');zlabel('T(x,y) in deg
C');
title('Laplace equation solution - Dirichlet boundary conditions Explicit');
fprintf('Convergence achieved after %i iterations.\n',k);
fprintf('See the following figures:\n');
fprintf('==========================\n');
fprintf('Figure 1 - sketch of computational grid \n');
fprintf('Figure 2 - contour plot of temperature \n');
fprintf('Figure 3 - surface plot of temperature \n');

return
end;
end;
fprintf('\n No convergence after %i iterations.',k);

Matlab Plots:

You might also like