JOURNAL REVIEW: Finite-Difference Approximations To The Heat Equation (Focusing On Backward Time Centered Scheme)

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

JOURNAL REVIEW: Finite-Difference Approximations to the Heat

Equation (focusing on Backward Time Centered Scheme)

I. Introduction

The journal provides a practical overview of numerical solutions to the heat

equation using the finite difference method. The forward time, centered space (FTCS),

the backward time, centered space (BTCS), and Crank-Nicolson schemes are developed,

and applied to a simple problem involving the one-dimensional heat equation. The main

focus of the paper is to establish the different steps that are needed to solve for a one-

dimensional heat equation by numerical analysis and show how to obtain the solution of

a one-dimensional heat equation using MATLAB®.

Our journal review focuses where the heat equation was derived and evaluated

using the Backward Time Centered Space Scheme. In the journal, analytical

solution and the numerical approximation were compared by solving a sample problem.

It is observed that the Backward Time, Centered Space scheme produces a stable at

every time step which makes it a decent method in approximating values of a heat

equation.

The finite difference method is one of several techniques for obtaining numerical

solutions to the one dimensional heat 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.

Applying the finite-difference method to a differential equation involves

replacing all derivatives with difference formulas. In the heat equation there are

derivatives with respect to time, and derivatives with respect to space. Using different

combinations of mesh points in the difference formulas results in different schemes.

II. Backward Time Centered Space Scheme and Truncation

It is stated in the paper that the implementation of the BTCS scheme requires

solving a system of equations at each time step. In addition to the complication of

developing the code, the computational effort per time step for the BTCS scheme is

greater than the computational effort per time step of the FTCS (Forward Time Centered

Spaced Scheme). The BTCS scheme has one huge advantage over the FTCS scheme: it is

unconditional stable (for solutions to the heat equation). The BTCS scheme is just as

accurate as the FTCS scheme. Therefore, with some extra effort, the BTCS scheme yields

a computational model that is robust to choices of ∆t and ∆x. This advantage is not

always overwhelming, however, and the FTCS scheme is still useful for some problems.

III. BTCSS Solution of a one-dimensional heat equation using MATLAB®.

After starting the program, the needed variables are entered and then read by the

application. From the data the size of the matrix is defined and the initial and final

conditions are imposed. Following the defining of the size of the matrix, the coefficient

of the tridiagonal was computed and stored on the matrix. Then the matrix is solved
using the LU decomposition. Finally the error, graph, the time step, mesh spacing and

maximum time is displayed after the program is completed running.

function [errout,xo,to,Uo] = heatBTCS(nt,nx,K,L,tmax)


% heatBTCS Solve 1D heat equation with the BTCS scheme
%
% Synopsis: heatBTCS
% heatBTCS(nt)
% heatBTCS(nt,nx)
% heatBTCS(nt,nx,alpha)
% heatBTCS(nt,nx,alpha,L)
% heatBTCS(nt,nx,alpha,L,tmax)
% heatBTCS(nt,nx,alpha,L,tmax,errPlots)
% err = heatBTCS(...)
% [err,x,t,U] = heatBTCS(...)
%
% Input: nt = number of steps. Default: nt = 10;
% nx = number of mesh points in x direction. Default: nx=20
% K = diffusion coefficient. Default: alpha = 0.1
% L = length of the domain. Default: L = 1;
% tmax = maximum time for the simulation. Default: tmax = 0.5
% Default: errPlots = 1 (make the plots)
%
% Output: err = L2 norm of error evaluated at spatial nodes on last time step
% x = location of finite difference nodes
% t = values of time at which solution is obtained (time nodes)
% U = matrix of solutions: U(:,j) is U(x) at t = t(j)
ifnargin<1, nt = 10; end
ifnargin<2, nx = 20; end
ifnargin<3, K = 0.1; end% diffusivity
ifnargin<4, L = 1; end
ifnargin<5, tmax = 0.5; end

% --- Compute mesh spacing and time step


dx = L/(nx-1);
dt = tmax/(nt-1);
% --- Create arrays to save data for export
x = linspace(0,L,nx)';
t = linspace(0,tmax,nt);
U = zeros(nx,nt);
% --- Set IC and BC
U(:,1) = sin(pi*x/L); % implies u0 = 0; uL = 0;
u0 = 0; uL = 0;
% --- Coefficients of the tridiagonal system
a = (-K/dx^2)*ones(nx,1); % subdiagonal a: coefficients of phi(i-1)
c = a; % superdiagonal c: coefficients of phi(i+1)
b = (1/dt)*ones(nx,1) - 2*a; % diagonal b: coefficients of phi(i)
b(1) = 1; c(1) = 0; % Fix coefficients of boundary nodes
b(end) = 1; a(end) = 0;
% Get LU factorization of coefficient matrix
n = length(a);
e = zeros(n,1); f = e;
e(1) = b(1);
f(1) = c(1)/b(1);
for i=2:n
e(i) = b(i) - a(i)*f(i-1);
f(i) = c(i)/e(i);
end
% --- Loop over time steps
for m=2:nt
d = U(:,m-1)/dt; % update right hand side
d(1) = u0; d(end) = uL; % overwrite BC values
% Output: v = solution vector
n = length(d);
ifnargin<5,
v = zeros(n,1); end
% --- Forward substitution to solve L*w = d
v(1) = d(1)/e(1);
for i=2:n
v(i) = (d(i) - a(i)*v(i-1))/e(i);
end
% --- Backward substitution to solve U*v = w
for i=n-1:-1:1
v(i) = v(i) - f(i)*v(i+1);
end
U(:,m) = v; % solve the system
end
% --- Compare with exact solution at end of simulation
ue = sin(pi*x/L)*exp(-t(nt)*K*(pi/L)^2);
err = norm(U(:,nt)-ue);
errout=norm(U(:,nt)-ue);
plot(x,U(:,1),'-',x,U(:,10),'*')
disp(sprintf('The error is %g',err))
disp(sprintf('the mesh space are: %g',dx))
disp(sprintf('the time step is: %g',dt))
disp(sprintf('the maximum time is: %g',tmax))

Using this m-file to solve for the heat equation with boundary conditions

u (0, t )  u ( L, t )  0 and initial condition f 0 ( x)  sin( x / L) , The value of K=0.1,length of

L=1, with a number of mesh points equal to 20 and number of time step equal to 10. It

also shows the error at t=0.50, the step size at time space (dt) and the mesh spacing

(dx).

Figure 1 shows the error , mesh space, time


spacing and maximum time for the heat equation
having the value of K=0.1,length of L=1, with a
number of mesh points equal to 20 and number of time
step equal to 10
Output of the program

It can be seen in the truncation Error Measurements that the BTCS scheme can

obtain solutions for much larger temperature changes than the FTCS scheme because

the BTCS scheme is unconditionally stable.

It can be seen that by using the Backward Time Centered Space scheme is a

reliable method to use for approximating the value of heat equations because it

produces a stable graph at each time step. This occurrence is due to the fact that the

backward finite difference used in approximating the time. By doing this the current

value of the approximation only depends on the previous values on the previous time

steps.

References:

Recktenwald∗, G. W. (n.d.). Equations, Finite-Difference Approximations to the Heat. Retrieved


from http://www.dima.uniroma1.it/users/lsa_adn/MATERIALE/FDheat.pdf
Seshaiyer, P. (2012). Finite-Difference Method for the 1D Heat Equation. Retrieved from
http://math.gmu.edu/~pseshaiy/F12/m679/m679_F12_notes_hw1.pdf
Hancock, Matthew J. "The 1-D Heat Equation." 18.303 Linear Partial Differential Equations
(2006): 1-44.

You might also like