Numerical Solution of a One Dimensional Heat Equation with Dirichlet Boundary Conditions

In this paper I present Numerical solutions of a one dimensional heat Equation together with initial condition and Dirichlet boundary conditions. Two methods are used to compute the numerical solutions, viz. Finite difference methods and Finite element methods. The finite element methods are implemented by Crank Nicolson method. The numerical solutions of a one dimensional heat Equation together with initial condition and Dirichlet boundary conditions using finite difference methods do not always converge to the exact solutions. It indicates the occurrence of numerical instability in finite difference methods. Finally the numerical solutions obtained by these two methods are compared with the analytic solutions graphically into two and three dimensions.


Introduction
Many physical problems in the real world such as heat equation, wave equation, Poisson equation and Laplace equation are modeled by partial differential equations. Some of these partial differential equations have exact solution in regular shape domain. But in general if the domain has irregular shape, computing exact solution of such equations is difficult. Due to this we use numerical methods to compute the solution of the modeled partial differential equations.
Finite difference and finite element methods are the two numerical methods that are applied to compute the solutions of partial differential equations by discretizing the domain in to finite number of regions. The solutions are computed at the grid points of the domain.
In literature [10] B-spline finite element methods are applied for numerical Simulation of one dimensional heat Equation. This motivates me to apply finite difference and finite element methods to heat equation with the given conditions and study the behavior of the solution for different values of . This paper includes the following sections. Section 2 Problem definition Section 3 Finite difference methods Section 4 Finite element methods Section 5 Exact solution Section 6 Comparison of solutions Section 7 Conclusions.

Finite Difference Methods
In this method the partial differential equation is approximated by the set of finite difference equations. When we solve equation (1) using finite difference methods, infinitely many points in the -plane is replaced by a finite set of points. Thus equation (1) is replaced by algebraic equations and the algebraic equations are solved at each point. More specifically, we follow the following steps: i. We discretize the domain[ , ] × [0, ].
ii. We discretize equation (1). In this process equation (1) is replaced by algebraic equations. iii. We discretize the boundary conditions and the initial conditions. iv. We solve the algebraic equations obtained in steps (ii) and (iii) at the points obtained in step (i). Using these steps, we obtain the following set of algebraic equations and boundary conditions ,+ = , The finite difference method for equation (1) together with equations (2) and (3) is stable if 0 < ; ≤ and unstable if ; > .

Finite Element Methods
The main idea of finite element methods is changing equation (1) in to weak form. The solution of the weak formulation of equation (1) approximates the exact or analytic solution of equation (1). The accuracy of the solutions depends on the number and size of the elements, and the types of functions that are considered within the elements. To implement the finite element method for equation (1) we follow the following steps: i. We find the weak formulation of equation (1). ii. We discretize the interval[ , ] and[0, ].
iii. We compute the stiffness matrix and mass matrix. iv. We apply the Crank -Nicolson method to solve the resulting system of first order differential equations. We use these steps as follows: The weak formulation of equation (1) Here Thus using (7) the finite element problem is to find ) ∈ G ) such that where G ) is a subspace of > ? [ , ] and depends on a positive parameter . Also dim G ) = − 1.  Here we take Thus using (8) and (9) the weak formulation becomes We may write as Crank -Nicolson or trapezoidal method is applied to compute (11) at the nodes. The method is given by (14)

Comparisons of Solutions
Here we compare the solutions using finite element methods, finite difference methods and exact method for( = 0.001 and different values of as shown in Figure 2 (a), (b) and (c). We also compare the numerical solution with the exact solution for ( = 0.001 and ( = 0.01 as shown in Figure 2 (d) and Figure 3.
As we see in Figure 3 the numerical solutions using finite element methods approximates the exact or analytic solutions but numerical solutions using finite difference method does not approximate the exact or analytic solutions. This is the effect of instability and not a truncation effect.Here ; = ?.?

Conclusions
The finite element methods approximate the exact solution of heat equation (1) together with (2) and (3). But the finite difference methodsdo not give approximate solutions for all(.The stepsize in the direction must be much smaller than the step size in the direction.Though these depend on the partial differential equation as well as the boundary conditions, if0 < ; ≤ for the heat equation, then the finite difference method is stable, that is it gives reasonable approximations to the exact solution. If ; > , the finite difference method is unstable. Therefore; finite element methods are best methods if we compare with finite difference methods to compute the solutions of equation (1) together with (2) and (3).