Sei sulla pagina 1di 6

Two-Dimensional Heat equation Report

Elmukashfi Osman
23615701
23.DEC.2015

Abstract
This report represent a practical overview of numerical solutions to the heat
equation using the finite difference method. The forward time, centered space (FTCS)
is developed, and applied to a simple problem involving the two-dimensional heat
equation. Complete, working Mat-lab codes for each scheme are presented. The
results of running the codes on (two-dimensional) meshes, and with time steps is
demonstrated. These sample calculations show that the schemes realize theoretical
predictions of how their truncation errors depend on mesh spacing and time step.
The codes also allow the reader to experiment with the stability limit of the FTCS
scheme.

1. The Heat Equation


The two-dimensional heat equation in (X,Y)space is

2T 2T
T
2 2
t
y
x

Where is the thermal diffusivity.

2. Finite Difference Method


The finite difference method is one of several techniques for obtaining numerical solutions
to Equation. In all numerical solutions the continuous partial differential equation (PDE) is
replaced with a discrete approximation. In this context the word \discrete" means that the
numerical solution is known only at a finite number of points in the physical domain. The
number of those points can be selected by the user of the numerical method. In general,
increasing the number of points not only increases the resolution (i.e., detail), but also the
accuracy of the numerical solution.

3.

Heat equation scheme

The finite difference approximations developed in the preceding section are now assembled
into a discrete approximation to Equation (1). Both the time and space derivatives are replaced
by finite difference. Doing so requires specification both the time and spatial locations of the _
values in the finite difference formulas. Therefore, we need to introduce superscript m to
designate the time step of the discrete solution.
Ti ,nj1 Ti ,nj
t

Ti n1, j 2Ti ,nj Ti n1, j Ti ,nj 1 2Ti ,nj Ti ,nj 1


2
(

x
)
( y ) 2

Stable solutions with the FTCS scheme are only obtained if


t
t 1

2
2
(

x
)
(

y
)

4. Implementation
Matlab versions of the FTCS is presented and demonstrated in this section.
Case study

Since the problem is symmetrical, it is sufficient to consider only a quarter of the crosssection of the rod. The coordinate system will be placed in the center of the rod, so the axes
overlap the symmetry axes.

5. Results

Fig .1 Temperature

Fig .2 Contour lines

Fig .3 Error

6. Appendix (Matlab Code)


%2D Heat Equation code using FTCS scheme
clear; close all; clc
n = 10;
x = linspace(0,1,n);
dx = x(2)-x(1);
y = x;
dy = dx;
%
TU
% +-----------------------+
% |
|
% |
|
% |TLH
To
|TRH
% |
|
% |
|
% |
|
% +-----------------------+
%
TL
TOL = 1e-6;
T = zeros(n);
T(1,1:n) = 10; %TOP
T(n,1:n) = 10; %BOTTOM
T(1:n,1) = 10; %LEFT
T(1:n,n) = 1; %RIGHT
dt = 0.01*dx^2;
% k =1;
% err=1;
% iteration
for t=1:500
Err=0;
Told = T;
for i = 2:n-1
for j = 2:n-1
T(i,j) = dt*(Told(i+1,j)-2*Told(i,j)+Told(i-1,j))/dx^2 +
dt*(Told(i,j+1)-2*Told(i,j)+Told(i,j-1))/dy^2 + Told(i,j);
Err = Err+(abs(T(i,j)-Told(i,j)));
end
end
Er(t) = Err;
if t>1
err(t) = abs(Er(t)-Er(t-1));
end
end
%subplot(2,2,1);
%surf(x,y,T);
%shading interp;
%colorbar
view(2);
%subplot(2,2,2);
%contour(T);
subplot(2,2,4);
plot(log10(err));

Potrebbero piacerti anche